diff --git a/webapp/templates/jury/analysis/contest_overview.html.twig b/webapp/templates/jury/analysis/contest_overview.html.twig index 0e63c63a33..cf1f357c15 100644 --- a/webapp/templates/jury/analysis/contest_overview.html.twig +++ b/webapp/templates/jury/analysis/contest_overview.html.twig @@ -381,7 +381,7 @@ var submissions = [ var contest_duration_minutes = Math.ceil(({{ current_contest.endtime }} - {{ current_contest.starttime }}) / 60); submission_stats.forEach(stat => { - stat.values = Array.from({ length: contest_duration_minutes }, (_, i) => [i, 0]); + stat.values = Array.from({ length: contest_duration_minutes + 1 }, (_, i) => [i, 0]); }); const statMap = submission_stats.reduce((map, stat) => { @@ -397,7 +397,7 @@ submissions.forEach(submission => { } }); -for (let minute = 0; minute < contest_duration_minutes; minute++) { +for (let minute = 0; minute <= contest_duration_minutes; minute++) { let this_minute_submission_nums = 0; submission_stats.forEach(stat => { this_minute_submission_nums += stat.values[minute][1]; @@ -405,6 +405,22 @@ for (let minute = 0; minute < contest_duration_minutes; minute++) { max_submissions_per_minute = Math.max(max_submissions_per_minute, this_minute_submission_nums); } +function generate_values(start_point, end_point, number_of_points) { + var values = [start_point]; // Initialize the array with the start point + var step = (end_point - start_point) / (number_of_points + 1); // Calculate the step size + for (var i = 1; i <= number_of_points; i++) { + values.push(Math.round(start_point + i * step)); // Generate evenly spaced values and round them to integers + } + values.push(end_point); // Add the end point to the array + return values; +} + +var start_point = 0; // Starting value of the range +var end_point = contest_duration_minutes; // Ending value of the range +var number_of_points = 9; // Number of intermediate points to generate + +var tickValues = generate_values(start_point, end_point, number_of_points); + nv.addGraph(function() { var chart = nv.models.multiBarChart() // .margin({left: 100}) //Adjust chart margins to give the x-axis some breathing room. @@ -417,11 +433,13 @@ nv.addGraph(function() { .y(function(d) { return d[1] }) //...in case your data is formatted differently. .showYAxis(true) //Show the y-axis .showXAxis(true) //Show the x-axis + .reduceXTicks(false) ; chart.xAxis //Chart x-axis settings .axisLabel('Contest Time(minutes)') + .ticks(tickValues.length) + .tickValues(tickValues) .tickFormat(d3.format('d')); - chart.yAxis //Chart y-axis settings .axisLabel('Total Submissions') .tickFormat(d3.format('d'));