diff --git a/src/helpers/figures/charts/bar_chart.ts b/src/helpers/figures/charts/bar_chart.ts index f5abcbe96e..c3da5ddf76 100644 --- a/src/helpers/figures/charts/bar_chart.ts +++ b/src/helpers/figures/charts/bar_chart.ts @@ -185,8 +185,6 @@ export class BarChart extends AbstractChart { } getDefinitionForExcel(): ExcelChartDefinition | undefined { - // Excel does not support aggregating labels - if (this.aggregated) return undefined; const dataSets: ExcelChartDataset[] = this.dataSets .map((ds: DataSet) => toExcelDataset(this.getters, ds)) .filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference); diff --git a/src/helpers/figures/charts/line_chart.ts b/src/helpers/figures/charts/line_chart.ts index 037e711941..f95f477997 100644 --- a/src/helpers/figures/charts/line_chart.ts +++ b/src/helpers/figures/charts/line_chart.ts @@ -193,8 +193,6 @@ export class LineChart extends AbstractChart { } getDefinitionForExcel(): ExcelChartDefinition | undefined { - // Excel does not support aggregating labels - if (this.aggregated) return undefined; const dataSets: ExcelChartDataset[] = this.dataSets .map((ds: DataSet) => toExcelDataset(this.getters, ds)) .filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference); diff --git a/src/helpers/figures/charts/pie_chart.ts b/src/helpers/figures/charts/pie_chart.ts index 0894754ae3..2ca816b6e3 100644 --- a/src/helpers/figures/charts/pie_chart.ts +++ b/src/helpers/figures/charts/pie_chart.ts @@ -161,8 +161,6 @@ export class PieChart extends AbstractChart { } getDefinitionForExcel(): ExcelChartDefinition | undefined { - // Excel does not support aggregating labels - if (this.aggregated) return undefined; const dataSets: ExcelChartDataset[] = this.dataSets .map((ds: DataSet) => toExcelDataset(this.getters, ds)) .filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference); diff --git a/tests/xlsx/xlsx_export.test.ts b/tests/xlsx/xlsx_export.test.ts index da91457478..ae1c963178 100644 --- a/tests/xlsx/xlsx_export.test.ts +++ b/tests/xlsx/xlsx_export.test.ts @@ -4,7 +4,7 @@ import { RAND, RANDARRAY, RANDBETWEEN } from "../../src/functions/module_math"; import { buildSheetLink, toXC } from "../../src/helpers"; import { DEFAULT_TABLE_CONFIG } from "../../src/helpers/table_presets"; import { Model } from "../../src/model"; -import { CustomizedDataSet, Dimension, ExcelChartType } from "../../src/types"; +import { CustomizedDataSet, Dimension } from "../../src/types"; import { XLSXExportXMLFile, XMLString } from "../../src/types/xlsx"; import { hexaToInt } from "../../src/xlsx/conversion"; import { adaptFormulaToExcel } from "../../src/xlsx/functions/cells"; @@ -1274,43 +1274,14 @@ describe("Test XLSX export", () => { expect(await exportPrettifiedXlsx(model)).toMatchSnapshot(); }); - test.each(["bar", "line", "pie", "scatter", "radar"] as const)( - "%s chart that aggregate labels is exported as image", - async (type: ExcelChartType) => { - const model = new Model({ - sheets: [ - { - ...chartData.sheets, - cells: { - ...chartData.sheets[0].cells, - A6: "P1", - A7: "P2", - A8: "P3", - A9: "P4", - B6: "17", - B7: "26", - B8: "13", - B9: "31", - C6: "31", - C7: "18", - C8: "9", - C9: "27", - }, - }, - ], - }); - createChart( - model, - { - dataSets: [{ dataRange: "Sheet1!B1:B9" }], - labelRange: "Sheet1!A2:A9", - aggregated: true, - type, - }, - "1" - ); - expect(getExportedExcelData(model).sheets[0].charts.length).toBe(0); - expect(getExportedExcelData(model).sheets[0].images.length).toBe(1); + test.each(["bar", "line", "pie"] as const)( + "%s chart that aggregate labels is exported as normal chart, ignoring the aggregation", + async (type: "bar" | "line" | "pie") => { + const model = new Model(); + createChart(model, { aggregated: true, type }, "1"); + const exportedData = getExportedExcelData(model); + expect(exportedData.sheets[0].charts.length).toBe(1); + expect(exportedData.sheets[0].images.length).toBe(0); } );