Skip to content

Commit

Permalink
Improve y-axis of the submission graph format.
Browse files Browse the repository at this point in the history
Found when looking at #2191

This changes the following things:
- Reduce amount of ticks for submissions with high runtimes
- Use integer ticks when higher precision only clutters the y-axis
- Add `s` to the labels to clearly indicate the unit
  • Loading branch information
meisterT committed Nov 23, 2023
1 parent f866ca5 commit d0ae5c5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion webapp/templates/jury/partials/submission_graph.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@
tickStep = 0.2;
} else if (maxY <= 5) {
tickStep = 0.5;
} else {
tickStep = Math.floor(maxY/5);
}
maxY += tickStep;
maxY = Math.floor(maxY/tickStep) * tickStep;
var chart = nv.models.multiBarChart()
.x(function (d) {
return d.label
Expand All @@ -58,7 +61,12 @@
}
chart.yAxis
.tickValues(tickValues)
.axisLabel('Runtime (in s)');
.axisLabel('Runtime');
if (tickStep >= 1) {
chart.yAxis.tickFormat(function(d) { return d3.format(',f')(d) + 's' });
} else {
chart.yAxis.tickFormat(function(d) { return d3.format(',.1f')(d) + 's' });
}
return chart;
}
Expand Down

0 comments on commit d0ae5c5

Please sign in to comment.