From 9bb758003605cad2b3beb9fef59c4139c0a4e747 Mon Sep 17 00:00:00 2001 From: Sanne de Vries Date: Fri, 3 Apr 2026 13:23:17 +0200 Subject: [PATCH] Show dashed comparison line for the current incomplete interval in top graph - The main line already shows a dashed segment for the current incomplete interval, but the comparison line didn't. This made it look like there was a drop in the previous period when there wasn't. --- assets/js/dashboard/stats/graph/graph-util.js | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/assets/js/dashboard/stats/graph/graph-util.js b/assets/js/dashboard/stats/graph/graph-util.js index 948a3edf82f8..ef66a153227c 100644 --- a/assets/js/dashboard/stats/graph/graph-util.js +++ b/assets/js/dashboard/stats/graph/graph-util.js @@ -25,12 +25,16 @@ function plottable(dataArray) { }) } -const buildComparisonDataset = function (comparisonPlot) { +const buildComparisonDataset = function (comparisonPlot, presentIndex) { if (!comparisonPlot) return [] + const data = presentIndex + ? comparisonPlot.slice(0, presentIndex) + : comparisonPlot + return [ { - data: plottable(comparisonPlot), + data: plottable(data), borderColor: 'rgba(99, 102, 241, 0.3)', pointBackgroundColor: 'rgba(99, 102, 241, 0.2)', pointHoverBackgroundColor: 'rgba(99, 102, 241, 0.5)', @@ -38,6 +42,21 @@ const buildComparisonDataset = function (comparisonPlot) { } ] } + +const buildDashedComparisonDataset = function (comparisonPlot, presentIndex) { + if (!comparisonPlot || !presentIndex) return [] + const dashedPart = comparisonPlot.slice(presentIndex - 1, presentIndex + 1) + const dashedPlot = new Array(presentIndex - 1).concat(dashedPart) + return [ + { + data: plottable(dashedPlot), + borderDash: [3, 3], + borderColor: 'rgba(99, 102, 241, 0.3)', + pointHoverBackgroundColor: 'rgba(99, 102, 241, 0.5)', + yAxisID: 'yComparison' + } + ] +} const buildDashedDataset = function (plot, presentIndex) { if (!presentIndex) return [] const dashedPart = plot.slice(presentIndex - 1, presentIndex + 1) @@ -90,7 +109,8 @@ export const buildDataSet = ( const dataset = [ ...buildMainPlotDataset(plot, present_index), ...buildDashedDataset(plot, present_index), - ...buildComparisonDataset(comparisonPlot) + ...buildComparisonDataset(comparisonPlot, present_index), + ...buildDashedComparisonDataset(comparisonPlot, present_index) ] return dataset.map((item) => Object.assign(item, defaultOptions))