Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/helpers/figures/charts/bar_chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,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);
Expand Down
2 changes: 0 additions & 2 deletions src/helpers/figures/charts/line_chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/helpers/figures/charts/pie_chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,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);
Expand Down
47 changes: 9 additions & 38 deletions tests/xlsx/xlsx_export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
}
);

Expand Down