Skip to content

Commit

Permalink
parametrizes the default zoom stage of the plot
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alpae committed Mar 27, 2020
1 parent 809c24c commit 86478fc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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} `);
}
Expand Down

0 comments on commit 86478fc

Please sign in to comment.