Skip to content

Commit 625c6bc

Browse files
committed
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.
1 parent 24a5ea0 commit 625c6bc

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,36 @@ 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 ? comparisonPlot.slice(0, presentIndex) : comparisonPlot
32+
3133
return [
3234
{
33-
data: plottable(comparisonPlot),
35+
data: plottable(data),
3436
borderColor: 'rgba(99, 102, 241, 0.3)',
3537
pointBackgroundColor: 'rgba(99, 102, 241, 0.2)',
3638
pointHoverBackgroundColor: 'rgba(99, 102, 241, 0.5)',
3739
yAxisID: 'yComparison'
3840
}
3941
]
4042
}
43+
44+
const buildDashedComparisonDataset = function (comparisonPlot, presentIndex) {
45+
if (!comparisonPlot || !presentIndex) return []
46+
const dashedPart = comparisonPlot.slice(presentIndex - 1, presentIndex + 1)
47+
const dashedPlot = new Array(presentIndex - 1).concat(dashedPart)
48+
return [
49+
{
50+
data: plottable(dashedPlot),
51+
borderDash: [3, 3],
52+
borderColor: 'rgba(99, 102, 241, 0.3)',
53+
pointHoverBackgroundColor: 'rgba(99, 102, 241, 0.5)',
54+
yAxisID: 'yComparison'
55+
}
56+
]
57+
}
4158
const buildDashedDataset = function (plot, presentIndex) {
4259
if (!presentIndex) return []
4360
const dashedPart = plot.slice(presentIndex - 1, presentIndex + 1)
@@ -90,7 +107,8 @@ export const buildDataSet = (
90107
const dataset = [
91108
...buildMainPlotDataset(plot, present_index),
92109
...buildDashedDataset(plot, present_index),
93-
...buildComparisonDataset(comparisonPlot)
110+
...buildComparisonDataset(comparisonPlot, present_index),
111+
...buildDashedComparisonDataset(comparisonPlot, present_index)
94112
]
95113

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

0 commit comments

Comments
 (0)