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 DOMjudge#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 28bbd88
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions webapp/templates/jury/partials/submission_graph.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
'output-limit': 'black',
} %}
function create_chart(data, maxY) {
var tickStep = 1;
var tickStep = Math.floor(maxY/5);
if (maxY <= 2) {
tickStep = 0.2;
} else if (maxY <= 5) {
tickStep = 0.5;
}
maxY += tickStep;
maxY = Math.floor(maxY/tickStep) * tickStep;
var chart = nv.models.multiBarChart()
.x(function (d) {
return d.label
Expand All @@ -58,7 +59,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 28bbd88

Please sign in to comment.