diff --git a/app/client/components/ChartView.ts b/app/client/components/ChartView.ts index 58d070d6..8c67fc87 100644 --- a/app/client/components/ChartView.ts +++ b/app/client/components/ChartView.ts @@ -802,7 +802,7 @@ function basicPlot(series: Series[], options: ChartOptions, dataOptions: Data): // up on hover is different than the value on the y-axis. It seems that one is the sum of all // values with same x-axis value, while the other is the last of them. To fix this, we force // unique values for the x-axis. - series = uniqXValues(series); + uniqXValues(series); } return { diff --git a/app/client/lib/chartUtil.ts b/app/client/lib/chartUtil.ts index cf76f177..a98ba2c5 100644 --- a/app/client/lib/chartUtil.ts +++ b/app/client/lib/chartUtil.ts @@ -23,15 +23,14 @@ export function sortByXValues(series: Array<{values: Datum[]}>): void { } } -// creates new version of series that has a duplicate free version of the values in the first one. -export function uniqXValues(series: Array): Array { - if (!series[0]) { return []; } +// Makes series so that the values of series[0] are duplicate free. +export function uniqXValues(series: Array) { + if (!series[0]) { return; } const n = series[0].values.length; const indexToKeep = new Set(uniqBy(range(n), (i) => series[0].values[i])); - return series.map((line: T) => ({ - ...line, - values: line.values.filter((_val, i) => indexToKeep.has(i)) - })); + series.forEach((line: T) => { + line.values = line.values.filter((_val, i) => indexToKeep.has(i)); + }); } // Creates new version of series that split any entry whose value in the first series is a list into