Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a 'hide-legend' graph option #807

Merged
merged 2 commits into from
May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions asv/www/graphdisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ $(document).ready(function() {
var select_reference = false;
/* The reference value */
var reference = 1.0;
/* Whether to show the legend */
var show_legend = true;
/* Is even commit spacing being used? */
var even_spacing = false;
var even_spacing_revisions = [];
Expand Down Expand Up @@ -257,6 +259,11 @@ $(document).ready(function() {
$('#even-spacing').removeClass('active');
update_state_url({'x-axis-scale': date_scale ? ['date'] : []});
});

$('#show-legend').on('click', function(evt) {
show_legend = !show_legend;
update_state_url({'show-legend': show_legend ? [] : [false]});
});

tooltip = $("<div></div>");
tooltip.appendTo("body");
Expand Down Expand Up @@ -1178,6 +1185,7 @@ $(document).ready(function() {
mode: "x"
},
legend: {
show: show_legend,
position: "nw",
labelFormatter: function(label, series) {
// Ensure HTML escaping
Expand Down Expand Up @@ -1384,6 +1392,22 @@ $(document).ready(function() {
}
delete params['x-axis-scale'];
}

var show_legend_button = $('#show-legend')
if (params['show-legend']) {
if (params['show-legend'][0] === 'false') {
show_legend = false;
show_legend_button.removeClass('active');
}
else {
show_legend_button.addClass('active');
show_legend = true;
}
delete params['show-legend'];
}
else {
show_legend_button.addClass('active');
}

if (Object.keys(params).length > 0) {
state_selection = params;
Expand Down
5 changes: 5 additions & 0 deletions asv/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@
title="Space commits by commit date along the x-axis">
date scale
</a>
<a id="show-legend" class="btn btn-default btn-xs" role="button"
data-toggle="tooltip" data-placement="right"
title="Show legend in the graph">
legend
</a>
</div>
</div>
</div>
Expand Down