Skip to content

Commit 49e6f84

Browse files
committed
[FIX] LineChart: Do not store window.Chart at top level
If for some reason the spreadsheet dependencies were not loaded before the library itself, we would store an undefined reference in `Chart` which ultimately leads to a traceback when trying to generate a `LineChart` closes #2817 Task: 3476486 Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
1 parent 8f9cbdd commit 49e6f84

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/helpers/figures/charts/line_chart.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ import {
5656
getFillingMode,
5757
} from "./chart_ui_common";
5858

59-
// @ts-ignore
60-
const Chart: typeof ChartType = window.Chart;
61-
6259
export class LineChart extends AbstractChart {
6360
readonly dataSets: DataSet[];
6461
readonly labelRange?: Range | undefined;
@@ -295,7 +292,9 @@ function getLineConfiguration(
295292
generateLabels(chart) {
296293
// color the legend labels with the dataset color, without any transparency
297294
const { data } = chart;
298-
const labels = Chart.defaults.plugins.legend.labels.generateLabels!(chart);
295+
/** @ts-ignore */
296+
const labels = (window.Chart as typeof ChartType).defaults.plugins.legend.labels
297+
.generateLabels!(chart);
299298
for (const [index, label] of labels.entries()) {
300299
label.fillStyle = data.datasets![index].borderColor as string;
301300
}

0 commit comments

Comments
 (0)