diff --git a/src/components/side_panel/chart/bar_chart/bar_chart_config_panel.ts b/src/components/side_panel/chart/bar_chart/bar_chart_config_panel.ts index 9d3b4e4c9c..e6170577f9 100644 --- a/src/components/side_panel/chart/bar_chart/bar_chart_config_panel.ts +++ b/src/components/side_panel/chart/bar_chart/bar_chart_config_panel.ts @@ -1,8 +1,16 @@ +import { BarChartDefinition } from "../../../../types/chart"; import { GenericChartConfigPanel } from "../building_blocks/generic_side_panel/config_panel"; export class BarConfigPanel extends GenericChartConfigPanel { static template = "o-spreadsheet-BarConfigPanel"; + get stackedLabel(): string { + const definition = this.props.definition as BarChartDefinition; + return definition.horizontal + ? this.chartTerms.StackedBarChart + : this.chartTerms.StackedColumnChart; + } + onUpdateStacked(stacked: boolean) { this.props.updateChart(this.props.figureId, { stacked, diff --git a/src/components/side_panel/chart/bar_chart/bar_chart_config_panel.xml b/src/components/side_panel/chart/bar_chart/bar_chart_config_panel.xml index cd38d289d7..c4da08c1e9 100644 --- a/src/components/side_panel/chart/bar_chart/bar_chart_config_panel.xml +++ b/src/components/side_panel/chart/bar_chart/bar_chart_config_panel.xml @@ -4,7 +4,7 @@
diff --git a/src/components/side_panel/chart/line_chart/line_chart_config_panel.ts b/src/components/side_panel/chart/line_chart/line_chart_config_panel.ts index 496be6f4a9..15af571317 100644 --- a/src/components/side_panel/chart/line_chart/line_chart_config_panel.ts +++ b/src/components/side_panel/chart/line_chart/line_chart_config_panel.ts @@ -16,7 +16,9 @@ export class LineConfigPanel extends GenericChartConfigPanel { get stackedLabel(): string { const definition = this.props.definition as LineChartDefinition; - return definition.fillArea ? this.chartTerms.StackedAreaChart : this.chartTerms.StackedBarChart; + return definition.fillArea + ? this.chartTerms.StackedAreaChart + : this.chartTerms.StackedLineChart; } getLabelRangeOptions() { diff --git a/src/components/translations_terms.ts b/src/components/translations_terms.ts index e456f0fa22..ff70ae210c 100644 --- a/src/components/translations_terms.ts +++ b/src/components/translations_terms.ts @@ -60,6 +60,7 @@ export const ChartTerms = { StackedBarChart: _t("Stacked bar chart"), StackedLineChart: _t("Stacked line chart"), StackedAreaChart: _t("Stacked area chart"), + StackedColumnChart: _t("Stacked column chart"), CumulativeData: _t("Cumulative data"), TreatLabelsAsText: _t("Treat labels as text"), AggregatedChart: _t("Aggregate"), diff --git a/tests/figures/chart/charts_component.test.ts b/tests/figures/chart/charts_component.test.ts index 5dc705b81c..12f7dc32ac 100644 --- a/tests/figures/chart/charts_component.test.ts +++ b/tests/figures/chart/charts_component.test.ts @@ -2075,4 +2075,22 @@ describe("Change chart type", () => { }); expect(select.value).toBe("stacked_line"); }); + + test("Changing chart type updates the stacked checkbox label accordingly", async () => { + createChart(model, { type: "line" }, chartId); + await mountChartSidePanel(chartId); + + expect(fixture.querySelector("label.o-checkbox")!.textContent).toBe("Stacked line chart"); + + updateChart(model, chartId, { fillArea: true }, sheetId); + await nextTick(); + expect(fixture.querySelector("label.o-checkbox")!.textContent).toBe("Stacked area chart"); + + await changeChartType("bar"); + expect(fixture.querySelector("label.o-checkbox")!.textContent).toBe("Stacked bar chart"); + + updateChart(model, chartId, { horizontal: false }, sheetId); + await nextTick(); + expect(fixture.querySelector("label.o-checkbox")!.textContent).toBe("Stacked column chart"); + }); });