From 86478fcf28409854afd9a872cb07acaf1aa2f9f5 Mon Sep 17 00:00:00 2001 From: Adrian Altenhoff Date: Fri, 27 Mar 2020 11:27:19 +0100 Subject: [PATCH] parametrizes the default zoom stage of the plot benchmarkPlot_scatter div accepts an additional attribute 'default-zoom' that allows to set the initial zoom state. Accepted value are either 'on' or 'true'. If not specified, the default is to not zoom the plot. --- src/app.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app.js b/src/app.js index 8c04031..7ea4efc 100644 --- a/src/app.js +++ b/src/app.js @@ -187,12 +187,16 @@ function join_all_json(result, divid, metric_x, metric_y,metrics_names, better){ var e = document.getElementById(divid + "_dropdown_list"); let classification_type = e.options[e.selectedIndex].id; + // load default zoom state from div attribute 'default-zoom' + let default_zoom = document.getElementById(divid).getAttribute('default-zoom'); + default_zoom = (default_zoom && (default_zoom === 'on' || default_zoom === 'true')); + //add button wich allows to toogle between reset view & out d3.select('#' + divid + '_buttons_container').append("button") .attr("class","toggle_axis_button") .attr("id",divid + "axis_button") - .attr("name", "optimal view") - .text("optimal view") + .attr("name", default_zoom ? "reset view" : "optimal view") + .text(default_zoom ? "reset view" : "optimal view") .on('click', function(d) { if (this.name == "optimal view"){ d3.select(this).text("reset view"); @@ -212,7 +216,7 @@ function join_all_json(result, divid, metric_x, metric_y,metrics_names, better){ }) - createChart(full_json,divid, classification_type, metric_x, metric_y,metrics_names, better, 0); + createChart(full_json,divid, classification_type, metric_x, metric_y,metrics_names, better, (default_zoom ? "auto" : 0)); } catch(err){ console.log(`Invalid Url Error: ${err.stack} `); }