Skip to content

Commit 7a31d44

Browse files
authored
Show dashed comparison line for the current incomplete interval in top graph (#6222)
- 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.
1 parent 24a5ea0 commit 7a31d44

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

assets/js/dashboard/stats/graph/graph-util.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,38 @@ function plottable(dataArray) {
2525
})
2626
}
2727

28-
const buildComparisonDataset = function (comparisonPlot) {
28+
const buildComparisonDataset = function (comparisonPlot, presentIndex) {
2929
if (!comparisonPlot) return []
3030

31+
const data = presentIndex
32+
? comparisonPlot.slice(0, presentIndex)
33+
: comparisonPlot
34+
3135
return [
3236
{
33-
data: plottable(comparisonPlot),
37+
data: plottable(data),
3438
borderColor: 'rgba(99, 102, 241, 0.3)',
3539
pointBackgroundColor: 'rgba(99, 102, 241, 0.2)',
3640
pointHoverBackgroundColor: 'rgba(99, 102, 241, 0.5)',
3741
yAxisID: 'yComparison'
3842
}
3943
]
4044
}
45+
46+
const buildDashedComparisonDataset = function (comparisonPlot, presentIndex) {
47+
if (!comparisonPlot || !presentIndex) return []
48+
const dashedPart = comparisonPlot.slice(presentIndex - 1, presentIndex + 1)
49+
const dashedPlot = new Array(presentIndex - 1).concat(dashedPart)
50+
return [
51+
{
52+
data: plottable(dashedPlot),
53+
borderDash: [3, 3],
54+
borderColor: 'rgba(99, 102, 241, 0.3)',
55+
pointHoverBackgroundColor: 'rgba(99, 102, 241, 0.5)',
56+
yAxisID: 'yComparison'
57+
}
58+
]
59+
}
4160
const buildDashedDataset = function (plot, presentIndex) {
4261
if (!presentIndex) return []
4362
const dashedPart = plot.slice(presentIndex - 1, presentIndex + 1)
@@ -90,7 +109,8 @@ export const buildDataSet = (
90109
const dataset = [
91110
...buildMainPlotDataset(plot, present_index),
92111
...buildDashedDataset(plot, present_index),
93-
...buildComparisonDataset(comparisonPlot)
112+
...buildComparisonDataset(comparisonPlot, present_index),
113+
...buildDashedComparisonDataset(comparisonPlot, present_index)
94114
]
95115

96116
return dataset.map((item) => Object.assign(item, defaultOptions))

0 commit comments

Comments
 (0)