diff --git a/src/helpers/figures/charts/chart_ui_common.ts b/src/helpers/figures/charts/chart_ui_common.ts index a6a1b39149..bc9c18c673 100644 --- a/src/helpers/figures/charts/chart_ui_common.ts +++ b/src/helpers/figures/charts/chart_ui_common.ts @@ -157,7 +157,7 @@ export function getDefaultChartJsRuntime( const xLabel = tooltipItem.dataset?.label || tooltipItem.label; // tooltipItem.parsed can be an object or a number for pie charts let yLabel = horizontalChart ? tooltipItem.parsed.x : tooltipItem.parsed.y; - if (!yLabel) { + if (yLabel === undefined || yLabel === null) { yLabel = tooltipItem.parsed; } const toolTipFormat = !format && Math.abs(yLabel) >= 1000 ? "#,##" : format; diff --git a/tests/figures/chart/chart_plugin.test.ts b/tests/figures/chart/chart_plugin.test.ts index 078a0ea882..58b2b7a3fa 100644 --- a/tests/figures/chart/chart_plugin.test.ts +++ b/tests/figures/chart/chart_plugin.test.ts @@ -1977,6 +1977,7 @@ describe("Chart design configuration", () => { expect(label).toEqual("6,000"); }); +<<<<<<< 18.0 test.each(["line", "scatter", "combo", "bar"] as const)( "%s chart with no title and no legend have the correct padding", (chartType) => { @@ -2050,6 +2051,18 @@ describe("Chart design configuration", () => { left: 20, right: 20, }); +||||||| 890f74235c9acf20fad16c1bfe054bf329a06ada +======= + test.each(["bar", "line"])( + "Basic chart tooltip label, zero-values are properly displayed", + (chartType) => { + setCellContent(model, "A2", "0"); + createChart(model, { ...defaultChart, type: chartType as "bar" | "line" }, "42"); + const runtime = model.getters.getChartRuntime("42") as BarChartRuntime; + const label = getTooltipLabel(runtime, 0, 0); + + expect(label).toEqual("0"); +>>>>>>> 5d9984709ef8d5f57803fbf1a49c56233990ee1c } ); });