@rowsncolumns/toolkit 24.5.11 → 24.5.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/charts.js +19 -2
- package/dist/cjs/exporter/ods/ods-export.js +17 -4
- package/dist/cjs/exporter/xlsx/chart-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/chart-builder.js +47 -25
- package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/charts.js +23 -2
- package/dist/esm/exporter/ods/ods-export.js +14 -1
- package/dist/esm/exporter/xlsx/chart-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/chart-builder.js +34 -19
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charts.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/charts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EAGT,aAAa,EACb,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAEhB,UAAU,EACV,UAAU,EACX,MAAM,2BAA2B,CAAC;AAKnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGrE;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,GAAG,SAAS,CAAC;AAkDnF,wBAAsB,YAAY,CAChC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,kBAAkB,EAC7B,SAAS,EAAE,GAAG,EACd,eAAe,CAAC,EAAE,eAAe,EACjC,cAAc,CAAC,EAAE,cAAc,GAC9B,OAAO,CAAC,aAAa,G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AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAYrD,CAAC;AAkEF;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,gBAAgB,EAAE,EAC3B,YAAY,EAAE,MAAM,GACnB,IAAI,CAuDN;AAID;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,GAAG,GAClB,sBAAsB,GAAG,SAAS,CAsBpC;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAoBpD;AA0BD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,GAAG,GAER,KAAK,GACL,QAAQ,GACR,MAAM,GACN,KAAK,GACL,UAAU,GACV,MAAM,GACN,OAAO,GACP,OAAO,GACP,SAAS,GACT,QAAQ,GACR,SAAS,GACT,UAAU,GACV,WAAW,GACX,SAAS,GACT,WAAW,GACX,QAAQ,CAsFX;AAED;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,GAAG,GAEX,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,SAAS,GACT,SAAS,GACT,YAAY,GACZ,SAAS,CASZ;AAoED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,GAAG,GACZ,MAAM,GAAG,SAAS,CA+CpB;
|
|
1
|
+
{"version":3,"file":"charts.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/charts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EAGT,aAAa,EACb,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAEhB,UAAU,EACV,UAAU,EACX,MAAM,2BAA2B,CAAC;AAKnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGrE;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,KAAK,MA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c,GAC9B,SAAS,EAAE,CAqMb;AA+uBD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,GAAG,EACb,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,cAAc,GAC9B,SAAS,EAAE,CA8Hb;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,cAAc,GAC9B,SAAS,EAAE,CAiBb;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,EACf,eAAe,CAAC,EAAE,eAAe,GAChC,sBAAsB,GAAG,IAAI,CAiK/B;AA+RD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,GAAG;;;;EAe/C;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,GAAG,GAC7C;IACE,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;IACzB,SAAS,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACD,SAAS,CAiCZ"}
|
|
@@ -1448,6 +1448,23 @@ function isSecondaryGroupContainer(container, secondaryIds) {
|
|
|
1448
1448
|
* model expects (one entry per parsed selection, with the data sheet's
|
|
1449
1449
|
* sheetId — not the chart's host sheet).
|
|
1450
1450
|
*/
|
|
1451
|
+
/**
|
|
1452
|
+
* A series name linked to a header cell (`<c:tx><c:strRef><c:f>`) → the
|
|
1453
|
+
* spec's `dataLabelSource`, so the renderers read the cell's current text
|
|
1454
|
+
* and the link survives inserted rows / columns and a sheet rename (#1100).
|
|
1455
|
+
* A reference that names no known sheet (or several cells) is dropped and
|
|
1456
|
+
* the cached title stays the literal name.
|
|
1457
|
+
*/
|
|
1458
|
+
function seriesLabelSource(nameRef, hostSheetId, resolveSheetId) {
|
|
1459
|
+
if (!nameRef)
|
|
1460
|
+
return {};
|
|
1461
|
+
var _a = __read(resolveSourcesFromRef(nameRef, hostSheetId, resolveSheetId), 1), source = _a[0];
|
|
1462
|
+
if (!source)
|
|
1463
|
+
return {};
|
|
1464
|
+
return {
|
|
1465
|
+
dataLabelSource: __assign(__assign({}, source), { endRowIndex: source.startRowIndex, endColumnIndex: source.startColumnIndex }),
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1451
1468
|
function resolveSourcesFromRef(ref, hostSheetId, resolveSheetId) {
|
|
1452
1469
|
var selections = generateSelectionsFromFormula("=".concat(ref));
|
|
1453
1470
|
return selections.map(function (sel) { return (__assign(__assign({}, sel.range), { sheetId: pickSheetId(sel.sheetName, hostSheetId, resolveSheetId) })); });
|
|
@@ -1599,7 +1616,7 @@ export function extractChartSeries(plotArea, chartType, sheetId, resolveSheetId)
|
|
|
1599
1616
|
? resolveSourcesFromRef(serCatRef, sheetId, resolveSheetId)
|
|
1600
1617
|
: [];
|
|
1601
1618
|
orders.push(seriesOrderOf(ser));
|
|
1602
|
-
series.push(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ dataLabel: seriesTitle || "Series ".concat(seriesIndex + 1) }, (nameRef
|
|
1619
|
+
series.push(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ dataLabel: seriesTitle || "Series ".concat(seriesIndex + 1) }, seriesLabelSource(nameRef, sheetId, resolveSheetId)), (categorySources.length ? { categorySources: categorySources } : {})), { color: colorInfo.color }), (colorInfo.noFill ? { noFill: true } : {})), { negativeColor: colorInfo.negativeColor, invertIfNegative: colorInfo.invertIfNegative }), (colorInfo.gradient ? { gradient: colorInfo.gradient } : {})), (container.isXY ? {} : { seriesChartType: seriesChartType })), (useSecondaryAxis ? { useSecondaryAxis: true } : {})), { sources: sources }), (inlineValues && inlineValues.length ? { inlineValues: inlineValues } : {})), (trendlines && trendlines.length ? { trendlines: trendlines } : {})), (errorBars ? { errorBars: errorBars } : {})), (marker ? { marker: marker } : {})), (dataPointColors && dataPointColors.length
|
|
1603
1620
|
? { dataPointColors: dataPointColors }
|
|
1604
1621
|
: {})), (seriesDataLabels ? { dataLabels: seriesDataLabels } : {})));
|
|
1605
1622
|
seriesIndex++;
|
|
@@ -1664,7 +1681,7 @@ export function extractChartSeries(plotArea, chartType, sheetId, resolveSheetId)
|
|
|
1664
1681
|
? resolveSourcesFromRef(serCatRef, sheetId, resolveSheetId)
|
|
1665
1682
|
: [];
|
|
1666
1683
|
orders.push(seriesOrderOf(ser));
|
|
1667
|
-
series.push(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ dataLabel: seriesTitle || "Series ".concat(index + 1) }, (nameRef
|
|
1684
|
+
series.push(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ dataLabel: seriesTitle || "Series ".concat(index + 1) }, seriesLabelSource(nameRef, sheetId, resolveSheetId)), (categorySources.length ? { categorySources: categorySources } : {})), { color: colorInfo.color }), (colorInfo.noFill ? { noFill: true } : {})), { negativeColor: colorInfo.negativeColor, invertIfNegative: colorInfo.invertIfNegative }), (colorInfo.gradient ? { gradient: colorInfo.gradient } : {})), { sources: sources }), (inlineValues && inlineValues.length ? { inlineValues: inlineValues } : {})), (marker ? { marker: marker } : {})), (dataPointColors && dataPointColors.length
|
|
1668
1685
|
? { dataPointColors: dataPointColors }
|
|
1669
1686
|
: {})), (seriesDataLabels ? { dataLabels: seriesDataLabels } : {})));
|
|
1670
1687
|
});
|
|
@@ -3672,16 +3672,17 @@ var buildChartObjectXml = function (chart, sheetNameById) {
|
|
|
3672
3672
|
var hasSeriesLabels = false;
|
|
3673
3673
|
var seriesXml = seriesRanges
|
|
3674
3674
|
.map(function (range, index) {
|
|
3675
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3676
|
-
var labelAddress =
|
|
3677
|
-
|
|
3675
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3676
|
+
var labelAddress = buildChartLabelAddressFromCell((_b = (_a = series[index]) === null || _a === void 0 ? void 0 : _a.dataLabelSource) !== null && _b !== void 0 ? _b : undefined, sheetNameById) ||
|
|
3677
|
+
buildChartLabelAddress((_c = series[index]) === null || _c === void 0 ? void 0 : _c.dataLabel, sheetNameById, (_d = chart.position) === null || _d === void 0 ? void 0 : _d.sheetId) ||
|
|
3678
|
+
buildChartLabelAddressFromRange((_f = (_e = series[index]) === null || _e === void 0 ? void 0 : _e.sources) === null || _f === void 0 ? void 0 : _f[0], sheetNameById);
|
|
3678
3679
|
var labelAttr = labelAddress
|
|
3679
3680
|
? " chart:label-cell-address=\"".concat(escapeXmlAddress(labelAddress), "\"")
|
|
3680
3681
|
: "";
|
|
3681
3682
|
if (labelAddress) {
|
|
3682
3683
|
hasSeriesLabels = true;
|
|
3683
3684
|
}
|
|
3684
|
-
var count = getRangePointCount((
|
|
3685
|
+
var count = getRangePointCount((_h = (_g = series[index]) === null || _g === void 0 ? void 0 : _g.sources) === null || _h === void 0 ? void 0 : _h[0]);
|
|
3685
3686
|
var pointsXml = count
|
|
3686
3687
|
? "<chart:data-point chart:repeated=\"".concat(count, "\"/>")
|
|
3687
3688
|
: "";
|
|
@@ -3792,6 +3793,18 @@ var buildChartLabelAddress = function (label, sheetNameById, sheetId) {
|
|
|
3792
3793
|
}
|
|
3793
3794
|
return "";
|
|
3794
3795
|
};
|
|
3796
|
+
/** The header cell a series name is linked to (`dataLabelSource`). */
|
|
3797
|
+
var buildChartLabelAddressFromCell = function (cell, sheetNameById) {
|
|
3798
|
+
if (!cell)
|
|
3799
|
+
return "";
|
|
3800
|
+
var sheetName = sheetNameById.get(cell.sheetId);
|
|
3801
|
+
if (!sheetName)
|
|
3802
|
+
return "";
|
|
3803
|
+
var labelRef = cellToAddress({ rowIndex: cell.startRowIndex, columnIndex: cell.startColumnIndex }, true, true);
|
|
3804
|
+
if (!labelRef)
|
|
3805
|
+
return "";
|
|
3806
|
+
return "".concat(escapeSheetName(sheetName), ".").concat(labelRef);
|
|
3807
|
+
};
|
|
3795
3808
|
var buildChartLabelAddressFromRange = function (range, sheetNameById) {
|
|
3796
3809
|
if (!range || range.startRowIndex <= 1)
|
|
3797
3810
|
return "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-builder.d.ts","sourceRoot":"","sources":["../../../../exporter/xlsx/chart-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,aAAa,EAEd,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"chart-builder.d.ts","sourceRoot":"","sources":["../../../../exporter/xlsx/chart-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,aAAa,EAEd,MAAM,2BAA2B,CAAC;AAi6CnC;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,CACnC,YAAY,EAAE,MAAM,GAAG,MAAM,KAC1B,MAAM,GAAG,SAAS,CAAC;AAExB,eAAO,MAAM,aAAa,GACxB,OAAO,aAAa,EACpB,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,yBAAyB,sBAAsB,KAC9C,MAAM,GAAG,SA2rBX,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign, __read, __spreadArray, __values } from "tslib";
|
|
2
|
-
import { cellRangeToAddress, chartPaletteColorAt, sanitizeSheetName, } from "@rowsncolumns/utils";
|
|
2
|
+
import { cellRangeToAddress, cellToAddress, chartPaletteColorAt, sanitizeSheetName, } from "@rowsncolumns/utils";
|
|
3
3
|
import { XMLBuilder } from "fast-xml-parser";
|
|
4
4
|
import { area_series, bubble_series, chart_template, column_json, column_series, donut_json, line_series, scatter_json, scatter_series, static_title, } from "./chart-templates";
|
|
5
5
|
var XML_DECLARATION = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
|
|
@@ -136,6 +136,24 @@ var formatSourcesRef = function (sources, sheetNameById) {
|
|
|
136
136
|
.filter(function (ref) { return Boolean(ref); });
|
|
137
137
|
return parts.length ? parts.join(",") : undefined;
|
|
138
138
|
};
|
|
139
|
+
/**
|
|
140
|
+
* The `<c:tx><c:strRef>` formula of a series whose name is linked to a
|
|
141
|
+
* header cell — `dataLabelSource` (a `SheetRange`), else the address an
|
|
142
|
+
* earlier import captured as `dataLabelRef`.
|
|
143
|
+
*/
|
|
144
|
+
var seriesLabelRef = function (entry, sheetNameById) {
|
|
145
|
+
var _a, _b;
|
|
146
|
+
return (_b = (_a = ((entry === null || entry === void 0 ? void 0 : entry.dataLabelSource)
|
|
147
|
+
? formatCellRef(entry.dataLabelSource, sheetNameById)
|
|
148
|
+
: undefined)) !== null && _a !== void 0 ? _a : entry === null || entry === void 0 ? void 0 : entry.dataLabelRef) !== null && _b !== void 0 ? _b : undefined;
|
|
149
|
+
};
|
|
150
|
+
/** `'Sheet'!$B$1` — the absolute single-cell form Excel writes for a series name. */
|
|
151
|
+
var formatCellRef = function (cell, sheetNameById) {
|
|
152
|
+
var sheetName = sheetNameById.get(cell.sheetId);
|
|
153
|
+
if (!sheetName)
|
|
154
|
+
return undefined;
|
|
155
|
+
return "".concat(sanitizeSheetName(sheetName), "!").concat(cellToAddress({ rowIndex: cell.startRowIndex, columnIndex: cell.startColumnIndex }, true, true));
|
|
156
|
+
};
|
|
139
157
|
var seriesCategoryRef = function (entry, sheetNameById) {
|
|
140
158
|
return formatSourcesRef(entry === null || entry === void 0 ? void 0 : entry.categorySources, sheetNameById);
|
|
141
159
|
};
|
|
@@ -806,8 +824,9 @@ var isComboChart = function (series, defaultChartType) {
|
|
|
806
824
|
/**
|
|
807
825
|
* Build a bar/column series node.
|
|
808
826
|
*/
|
|
809
|
-
var buildBarSeriesNode = function (index, ref, seriesData, domainRef, sheetName, isFirstInGroup) {
|
|
827
|
+
var buildBarSeriesNode = function (index, ref, seriesData, domainRef, sheetName, isFirstInGroup, sheetNameById) {
|
|
810
828
|
var _a;
|
|
829
|
+
if (sheetNameById === void 0) { sheetNameById = new Map(); }
|
|
811
830
|
var seriesNode = cloneTemplate(column_series);
|
|
812
831
|
seriesNode["c:idx"] = { a$: { val: index.toString() } };
|
|
813
832
|
seriesNode["c:order"] = { a$: { val: index.toString() } };
|
|
@@ -865,7 +884,7 @@ var buildBarSeriesNode = function (index, ref, seriesData, domainRef, sheetName,
|
|
|
865
884
|
removeProp(seriesNode, "c:val");
|
|
866
885
|
seriesNode["c:val"] = buildInlineNumLit(inlineValues);
|
|
867
886
|
}
|
|
868
|
-
var labelNode = buildSeriesLabel((_a = seriesData === null || seriesData === void 0 ? void 0 : seriesData.dataLabel) !== null && _a !== void 0 ? _a : undefined, sheetName, seriesData
|
|
887
|
+
var labelNode = buildSeriesLabel((_a = seriesData === null || seriesData === void 0 ? void 0 : seriesData.dataLabel) !== null && _a !== void 0 ? _a : undefined, sheetName, seriesLabelRef(seriesData, sheetNameById));
|
|
869
888
|
if (labelNode) {
|
|
870
889
|
seriesNode["c:tx"] = labelNode["c:tx"];
|
|
871
890
|
}
|
|
@@ -880,9 +899,10 @@ var buildBarSeriesNode = function (index, ref, seriesData, domainRef, sheetName,
|
|
|
880
899
|
/**
|
|
881
900
|
* Build a line series node.
|
|
882
901
|
*/
|
|
883
|
-
var buildLineSeriesNode = function (index, ref, seriesData, domainRef, sheetName, smooth, showMarkers) {
|
|
902
|
+
var buildLineSeriesNode = function (index, ref, seriesData, domainRef, sheetName, smooth, showMarkers, sheetNameById) {
|
|
884
903
|
var _a, _b;
|
|
885
904
|
if (showMarkers === void 0) { showMarkers = false; }
|
|
905
|
+
if (sheetNameById === void 0) { sheetNameById = new Map(); }
|
|
886
906
|
var seriesNode = cloneTemplate(line_series);
|
|
887
907
|
seriesNode["c:idx"] = { a$: { val: index.toString() } };
|
|
888
908
|
seriesNode["c:order"] = { a$: { val: index.toString() } };
|
|
@@ -926,7 +946,7 @@ var buildLineSeriesNode = function (index, ref, seriesData, domainRef, sheetName
|
|
|
926
946
|
if (smooth) {
|
|
927
947
|
seriesNode["c:smooth"].a$.val = "1";
|
|
928
948
|
}
|
|
929
|
-
var labelNode = buildSeriesLabel((_b = seriesData === null || seriesData === void 0 ? void 0 : seriesData.dataLabel) !== null && _b !== void 0 ? _b : undefined, sheetName, seriesData
|
|
949
|
+
var labelNode = buildSeriesLabel((_b = seriesData === null || seriesData === void 0 ? void 0 : seriesData.dataLabel) !== null && _b !== void 0 ? _b : undefined, sheetName, seriesLabelRef(seriesData, sheetNameById));
|
|
930
950
|
if (labelNode) {
|
|
931
951
|
seriesNode["c:tx"] = labelNode["c:tx"];
|
|
932
952
|
}
|
|
@@ -935,8 +955,9 @@ var buildLineSeriesNode = function (index, ref, seriesData, domainRef, sheetName
|
|
|
935
955
|
/**
|
|
936
956
|
* Build an area series node.
|
|
937
957
|
*/
|
|
938
|
-
var buildAreaSeriesNode = function (index, ref, seriesData, domainRef, sheetName) {
|
|
958
|
+
var buildAreaSeriesNode = function (index, ref, seriesData, domainRef, sheetName, sheetNameById) {
|
|
939
959
|
var _a, _b, _c;
|
|
960
|
+
if (sheetNameById === void 0) { sheetNameById = new Map(); }
|
|
940
961
|
var seriesNode = cloneTemplate(area_series);
|
|
941
962
|
seriesNode["c:idx"] = { a$: { val: index.toString() } };
|
|
942
963
|
seriesNode["c:order"] = { a$: { val: index.toString() } };
|
|
@@ -966,7 +987,7 @@ var buildAreaSeriesNode = function (index, ref, seriesData, domainRef, sheetName
|
|
|
966
987
|
removeProp(seriesNode, "c:cat");
|
|
967
988
|
}
|
|
968
989
|
seriesNode["c:val"]["c:numRef"]["c:f"] = ref;
|
|
969
|
-
var labelNode = buildSeriesLabel((_c = seriesData === null || seriesData === void 0 ? void 0 : seriesData.dataLabel) !== null && _c !== void 0 ? _c : undefined, sheetName, seriesData
|
|
990
|
+
var labelNode = buildSeriesLabel((_c = seriesData === null || seriesData === void 0 ? void 0 : seriesData.dataLabel) !== null && _c !== void 0 ? _c : undefined, sheetName, seriesLabelRef(seriesData, sheetNameById));
|
|
970
991
|
if (labelNode) {
|
|
971
992
|
seriesNode["c:tx"] = labelNode["c:tx"];
|
|
972
993
|
}
|
|
@@ -979,9 +1000,10 @@ var buildAreaSeriesNode = function (index, ref, seriesData, domainRef, sheetName
|
|
|
979
1000
|
* remaining series, each with its own idx/order, name, category and value
|
|
980
1001
|
* reference.
|
|
981
1002
|
*/
|
|
982
|
-
var appendExtraCircularSeries = function (chartNode, groupKey, seriesRefs, seriesCatRefs, domainRef, series, sheetName) {
|
|
1003
|
+
var appendExtraCircularSeries = function (chartNode, groupKey, seriesRefs, seriesCatRefs, domainRef, series, sheetName, sheetNameById) {
|
|
983
1004
|
var e_7, _a;
|
|
984
|
-
var _b, _c, _d, _e, _f, _g
|
|
1005
|
+
var _b, _c, _d, _e, _f, _g;
|
|
1006
|
+
if (sheetNameById === void 0) { sheetNameById = new Map(); }
|
|
985
1007
|
var group = (_b = chartNode["c:plotArea"]) === null || _b === void 0 ? void 0 : _b[groupKey];
|
|
986
1008
|
if (!group)
|
|
987
1009
|
return;
|
|
@@ -1003,16 +1025,16 @@ var appendExtraCircularSeries = function (chartNode, groupKey, seriesRefs, serie
|
|
|
1003
1025
|
}
|
|
1004
1026
|
try {
|
|
1005
1027
|
for (var extra_1 = __values(extra), extra_1_1 = extra_1.next(); !extra_1_1.done; extra_1_1 = extra_1.next()) {
|
|
1006
|
-
var
|
|
1028
|
+
var _h = extra_1_1.value, ref = _h.ref, index = _h.index;
|
|
1007
1029
|
var node = {
|
|
1008
1030
|
"c:idx": { a$: { val: String(index) } },
|
|
1009
1031
|
"c:order": { a$: { val: String(index) } },
|
|
1010
1032
|
};
|
|
1011
|
-
var labelNode = buildSeriesLabel((_f = (_e = series[index]) === null || _e === void 0 ? void 0 : _e.dataLabel) !== null && _f !== void 0 ? _f : undefined, sheetName, (
|
|
1033
|
+
var labelNode = buildSeriesLabel((_f = (_e = series[index]) === null || _e === void 0 ? void 0 : _e.dataLabel) !== null && _f !== void 0 ? _f : undefined, sheetName, seriesLabelRef(series[index], sheetNameById));
|
|
1012
1034
|
if (labelNode) {
|
|
1013
1035
|
node["c:tx"] = labelNode["c:tx"];
|
|
1014
1036
|
}
|
|
1015
|
-
var catRef = (
|
|
1037
|
+
var catRef = (_g = seriesCatRefs[index]) !== null && _g !== void 0 ? _g : domainRef;
|
|
1016
1038
|
if (catRef) {
|
|
1017
1039
|
node["c:cat"] = { "c:strRef": { "c:f": catRef } };
|
|
1018
1040
|
}
|
|
@@ -1299,7 +1321,7 @@ export var buildChartXml = function (input, sheetNameById, resolvePivotSourceNam
|
|
|
1299
1321
|
};
|
|
1300
1322
|
for (var i = 0; i < groupSeries.length; i++) {
|
|
1301
1323
|
var _14 = groupSeries[i], index = _14.index, ref = _14.ref, data = _14.data;
|
|
1302
|
-
var seriesNode = buildBarSeriesNode(index, ref, data, (_q = seriesCatRefs[index]) !== null && _q !== void 0 ? _q : domainRef, sheetName, i === 0);
|
|
1324
|
+
var seriesNode = buildBarSeriesNode(index, ref, data, (_q = seriesCatRefs[index]) !== null && _q !== void 0 ? _q : domainRef, sheetName, i === 0, sheetNameById);
|
|
1303
1325
|
barChartNode["c:ser"].push(seriesNode);
|
|
1304
1326
|
}
|
|
1305
1327
|
comboGroups.push(["c:barChart", barChartNode]);
|
|
@@ -1326,7 +1348,7 @@ export var buildChartXml = function (input, sheetNameById, resolvePivotSourceNam
|
|
|
1326
1348
|
try {
|
|
1327
1349
|
for (var groupSeries_1 = (e_10 = void 0, __values(groupSeries)), groupSeries_1_1 = groupSeries_1.next(); !groupSeries_1_1.done; groupSeries_1_1 = groupSeries_1.next()) {
|
|
1328
1350
|
var _15 = groupSeries_1_1.value, index = _15.index, ref = _15.ref, data = _15.data;
|
|
1329
|
-
var seriesNode = buildLineSeriesNode(index, ref, data, (_r = seriesCatRefs[index]) !== null && _r !== void 0 ? _r : domainRef, sheetName, smooth, showMarkers);
|
|
1351
|
+
var seriesNode = buildLineSeriesNode(index, ref, data, (_r = seriesCatRefs[index]) !== null && _r !== void 0 ? _r : domainRef, sheetName, smooth, showMarkers, sheetNameById);
|
|
1330
1352
|
lineChartNode["c:ser"].push(seriesNode);
|
|
1331
1353
|
}
|
|
1332
1354
|
}
|
|
@@ -1350,7 +1372,7 @@ export var buildChartXml = function (input, sheetNameById, resolvePivotSourceNam
|
|
|
1350
1372
|
try {
|
|
1351
1373
|
for (var groupSeries_2 = (e_11 = void 0, __values(groupSeries)), groupSeries_2_1 = groupSeries_2.next(); !groupSeries_2_1.done; groupSeries_2_1 = groupSeries_2.next()) {
|
|
1352
1374
|
var _16 = groupSeries_2_1.value, index = _16.index, ref = _16.ref, data = _16.data;
|
|
1353
|
-
var seriesNode = buildAreaSeriesNode(index, ref, data, (_s = seriesCatRefs[index]) !== null && _s !== void 0 ? _s : domainRef, sheetName);
|
|
1375
|
+
var seriesNode = buildAreaSeriesNode(index, ref, data, (_s = seriesCatRefs[index]) !== null && _s !== void 0 ? _s : domainRef, sheetName, sheetNameById);
|
|
1354
1376
|
areaChartNode["c:ser"].push(seriesNode);
|
|
1355
1377
|
}
|
|
1356
1378
|
}
|
|
@@ -1392,7 +1414,7 @@ export var buildChartXml = function (input, sheetNameById, resolvePivotSourceNam
|
|
|
1392
1414
|
bar["c:barDir"].a$.val = "col";
|
|
1393
1415
|
var seriesContainer_1 = bar["c:ser"];
|
|
1394
1416
|
seriesRefs.forEach(function (ref, index) {
|
|
1395
|
-
var _a, _b, _c, _d
|
|
1417
|
+
var _a, _b, _c, _d;
|
|
1396
1418
|
if (!ref)
|
|
1397
1419
|
return;
|
|
1398
1420
|
var seriesNode = cloneTemplate(column_series);
|
|
@@ -1417,7 +1439,7 @@ export var buildChartXml = function (input, sheetNameById, resolvePivotSourceNam
|
|
|
1417
1439
|
};
|
|
1418
1440
|
}
|
|
1419
1441
|
seriesNode["c:val"]["c:numRef"]["c:f"] = ref;
|
|
1420
|
-
var labelNode = buildSeriesLabel((_d = (_c = series[index]) === null || _c === void 0 ? void 0 : _c.dataLabel) !== null && _d !== void 0 ? _d : undefined, sheetNameById.get(chart.position.sheetId), (
|
|
1442
|
+
var labelNode = buildSeriesLabel((_d = (_c = series[index]) === null || _c === void 0 ? void 0 : _c.dataLabel) !== null && _d !== void 0 ? _d : undefined, sheetNameById.get(chart.position.sheetId), seriesLabelRef(series[index], sheetNameById));
|
|
1421
1443
|
if (labelNode) {
|
|
1422
1444
|
seriesNode["c:tx"] = labelNode["c:tx"];
|
|
1423
1445
|
}
|
|
@@ -1495,7 +1517,7 @@ export var buildChartXml = function (input, sheetNameById, resolvePivotSourceNam
|
|
|
1495
1517
|
var enrichedSeries = index === 0 && !domainRef && (inlineDomainValues_1 === null || inlineDomainValues_1 === void 0 ? void 0 : inlineDomainValues_1.length)
|
|
1496
1518
|
? __assign(__assign({}, series[index]), { inlineDomainValues: inlineDomainValues_1 })
|
|
1497
1519
|
: series[index];
|
|
1498
|
-
var seriesNode = buildBarSeriesNode(index, ref !== null && ref !== void 0 ? ref : "", enrichedSeries, (_b = seriesCatRefs[index]) !== null && _b !== void 0 ? _b : domainRef, sheetNameById.get(chart.position.sheetId), index === 0);
|
|
1520
|
+
var seriesNode = buildBarSeriesNode(index, ref !== null && ref !== void 0 ? ref : "", enrichedSeries, (_b = seriesCatRefs[index]) !== null && _b !== void 0 ? _b : domainRef, sheetNameById.get(chart.position.sheetId), index === 0, sheetNameById);
|
|
1499
1521
|
seriesContainer_2.push(seriesNode);
|
|
1500
1522
|
});
|
|
1501
1523
|
chartSpace["c:chartSpace"]["c:chart"] = barChart;
|
|
@@ -1512,14 +1534,14 @@ export var buildChartXml = function (input, sheetNameById, resolvePivotSourceNam
|
|
|
1512
1534
|
? buildOfPieChart(domainRef, valueRef, chartTitle, specAny, chartSubtitle)
|
|
1513
1535
|
: buildPieChart(domainRef, valueRef, chartTitle, chartSubtitle);
|
|
1514
1536
|
if (!isOfPie) {
|
|
1515
|
-
appendExtraCircularSeries(pieChart, "c:pieChart", seriesRefs, seriesCatRefs, domainRef, series, sheetNameById.get(chart.position.sheetId));
|
|
1537
|
+
appendExtraCircularSeries(pieChart, "c:pieChart", seriesRefs, seriesCatRefs, domainRef, series, sheetNameById.get(chart.position.sheetId), sheetNameById);
|
|
1516
1538
|
}
|
|
1517
1539
|
chartSpace["c:chartSpace"]["c:chart"] = pieChart;
|
|
1518
1540
|
}
|
|
1519
1541
|
else if (chartType === "doughnut") {
|
|
1520
1542
|
var valueRef = seriesRefs.find(Boolean);
|
|
1521
1543
|
var doughnutChart = buildDoughnutChart(domainRef, valueRef, chartTitle, chartSubtitle);
|
|
1522
|
-
appendExtraCircularSeries(doughnutChart, "c:doughnutChart", seriesRefs, seriesCatRefs, domainRef, series, sheetNameById.get(chart.position.sheetId));
|
|
1544
|
+
appendExtraCircularSeries(doughnutChart, "c:doughnutChart", seriesRefs, seriesCatRefs, domainRef, series, sheetNameById.get(chart.position.sheetId), sheetNameById);
|
|
1523
1545
|
chartSpace["c:chartSpace"]["c:chart"] = doughnutChart;
|
|
1524
1546
|
}
|
|
1525
1547
|
else if (chartType === "radar") {
|
|
@@ -1562,7 +1584,7 @@ export var buildChartXml = function (input, sheetNameById, resolvePivotSourceNam
|
|
|
1562
1584
|
replacePlotAreaChartGroups(plotArea, [["c:lineChart", lineChartNode]]);
|
|
1563
1585
|
var seriesContainer_3 = lineChartNode["c:ser"];
|
|
1564
1586
|
seriesRefs.forEach(function (ref, index) {
|
|
1565
|
-
var _a, _b, _c, _d, _e
|
|
1587
|
+
var _a, _b, _c, _d, _e;
|
|
1566
1588
|
if (!ref)
|
|
1567
1589
|
return;
|
|
1568
1590
|
var seriesNode = cloneTemplate(line_series);
|
|
@@ -1599,7 +1621,7 @@ export var buildChartXml = function (input, sheetNameById, resolvePivotSourceNam
|
|
|
1599
1621
|
else if (showMarkers_1) {
|
|
1600
1622
|
removeProp(seriesNode, "c:marker");
|
|
1601
1623
|
}
|
|
1602
|
-
var labelNode = buildSeriesLabel((_e = (_d = series[index]) === null || _d === void 0 ? void 0 : _d.dataLabel) !== null && _e !== void 0 ? _e : undefined, sheetNameById.get(chart.position.sheetId), (
|
|
1624
|
+
var labelNode = buildSeriesLabel((_e = (_d = series[index]) === null || _d === void 0 ? void 0 : _d.dataLabel) !== null && _e !== void 0 ? _e : undefined, sheetNameById.get(chart.position.sheetId), seriesLabelRef(series[index], sheetNameById));
|
|
1603
1625
|
if (labelNode) {
|
|
1604
1626
|
seriesNode["c:tx"] = labelNode["c:tx"];
|
|
1605
1627
|
}
|
|
@@ -1630,7 +1652,7 @@ export var buildChartXml = function (input, sheetNameById, resolvePivotSourceNam
|
|
|
1630
1652
|
replacePlotAreaChartGroups(plotArea, [["c:areaChart", areaChartNode]]);
|
|
1631
1653
|
var seriesContainer_4 = areaChartNode["c:ser"];
|
|
1632
1654
|
seriesRefs.forEach(function (ref, index) {
|
|
1633
|
-
var _a, _b, _c, _d
|
|
1655
|
+
var _a, _b, _c, _d;
|
|
1634
1656
|
if (!ref)
|
|
1635
1657
|
return;
|
|
1636
1658
|
var seriesNode = cloneTemplate(area_series);
|
|
@@ -1656,7 +1678,7 @@ export var buildChartXml = function (input, sheetNameById, resolvePivotSourceNam
|
|
|
1656
1678
|
removeProp(seriesNode, "c:cat");
|
|
1657
1679
|
}
|
|
1658
1680
|
seriesNode["c:val"]["c:numRef"]["c:f"] = ref;
|
|
1659
|
-
var labelNode = buildSeriesLabel((_d = (_c = series[index]) === null || _c === void 0 ? void 0 : _c.dataLabel) !== null && _d !== void 0 ? _d : undefined, sheetNameById.get(chart.position.sheetId), (
|
|
1681
|
+
var labelNode = buildSeriesLabel((_d = (_c = series[index]) === null || _c === void 0 ? void 0 : _c.dataLabel) !== null && _d !== void 0 ? _d : undefined, sheetNameById.get(chart.position.sheetId), seriesLabelRef(series[index], sheetNameById));
|
|
1660
1682
|
if (labelNode) {
|
|
1661
1683
|
seriesNode["c:tx"] = labelNode["c:tx"];
|
|
1662
1684
|
}
|
|
@@ -1709,7 +1731,7 @@ export var buildChartXml = function (input, sheetNameById, resolvePivotSourceNam
|
|
|
1709
1731
|
else if (smooth) {
|
|
1710
1732
|
seriesNode["c:smooth"].a$.val = "1";
|
|
1711
1733
|
}
|
|
1712
|
-
var labelNode = buildSeriesLabel((_f = (_d = entry === null || entry === void 0 ? void 0 : entry.dataLabel) !== null && _d !== void 0 ? _d : (_e = bubbleLabelEntries_1[index]) === null || _e === void 0 ? void 0 : _e.dataLabel) !== null && _f !== void 0 ? _f : undefined, sheetNameById.get(chart.position.sheetId), entry
|
|
1734
|
+
var labelNode = buildSeriesLabel((_f = (_d = entry === null || entry === void 0 ? void 0 : entry.dataLabel) !== null && _d !== void 0 ? _d : (_e = bubbleLabelEntries_1[index]) === null || _e === void 0 ? void 0 : _e.dataLabel) !== null && _f !== void 0 ? _f : undefined, sheetNameById.get(chart.position.sheetId), seriesLabelRef(entry, sheetNameById));
|
|
1713
1735
|
if (labelNode) {
|
|
1714
1736
|
seriesNode["c:tx"] = labelNode["c:tx"];
|
|
1715
1737
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charts.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/charts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EAGT,aAAa,EACb,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAEhB,UAAU,EACV,UAAU,EACX,MAAM,2BAA2B,CAAC;AAKnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAA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AAK,GAAG,KAAK,CAAC;IACzB,SAAS,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACD,SAAS,CAiCZ"}
|
|
@@ -1320,6 +1320,27 @@ function isSecondaryGroupContainer(container, secondaryIds) {
|
|
|
1320
1320
|
* model expects (one entry per parsed selection, with the data sheet's
|
|
1321
1321
|
* sheetId — not the chart's host sheet).
|
|
1322
1322
|
*/
|
|
1323
|
+
/**
|
|
1324
|
+
* A series name linked to a header cell (`<c:tx><c:strRef><c:f>`) → the
|
|
1325
|
+
* spec's `dataLabelSource`, so the renderers read the cell's current text
|
|
1326
|
+
* and the link survives inserted rows / columns and a sheet rename (#1100).
|
|
1327
|
+
* A reference that names no known sheet (or several cells) is dropped and
|
|
1328
|
+
* the cached title stays the literal name.
|
|
1329
|
+
*/
|
|
1330
|
+
function seriesLabelSource(nameRef, hostSheetId, resolveSheetId) {
|
|
1331
|
+
if (!nameRef)
|
|
1332
|
+
return {};
|
|
1333
|
+
const [source] = resolveSourcesFromRef(nameRef, hostSheetId, resolveSheetId);
|
|
1334
|
+
if (!source)
|
|
1335
|
+
return {};
|
|
1336
|
+
return {
|
|
1337
|
+
dataLabelSource: {
|
|
1338
|
+
...source,
|
|
1339
|
+
endRowIndex: source.startRowIndex,
|
|
1340
|
+
endColumnIndex: source.startColumnIndex,
|
|
1341
|
+
},
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1323
1344
|
function resolveSourcesFromRef(ref, hostSheetId, resolveSheetId) {
|
|
1324
1345
|
const selections = generateSelectionsFromFormula(`=${ref}`);
|
|
1325
1346
|
return selections.map((sel) => ({
|
|
@@ -1458,7 +1479,7 @@ export function extractChartSeries(plotArea, chartType, sheetId, resolveSheetId)
|
|
|
1458
1479
|
orders.push(seriesOrderOf(ser));
|
|
1459
1480
|
series.push({
|
|
1460
1481
|
dataLabel: seriesTitle || `Series ${seriesIndex + 1}`,
|
|
1461
|
-
...(nameRef
|
|
1482
|
+
...seriesLabelSource(nameRef, sheetId, resolveSheetId),
|
|
1462
1483
|
...(categorySources.length ? { categorySources } : {}),
|
|
1463
1484
|
color: colorInfo.color,
|
|
1464
1485
|
...(colorInfo.noFill ? { noFill: true } : {}),
|
|
@@ -1529,7 +1550,7 @@ export function extractChartSeries(plotArea, chartType, sheetId, resolveSheetId)
|
|
|
1529
1550
|
orders.push(seriesOrderOf(ser));
|
|
1530
1551
|
series.push({
|
|
1531
1552
|
dataLabel: seriesTitle || `Series ${index + 1}`,
|
|
1532
|
-
...(nameRef
|
|
1553
|
+
...seriesLabelSource(nameRef, sheetId, resolveSheetId),
|
|
1533
1554
|
...(categorySources.length ? { categorySources } : {}),
|
|
1534
1555
|
color: colorInfo.color,
|
|
1535
1556
|
...(colorInfo.noFill ? { noFill: true } : {}),
|
|
@@ -3183,7 +3183,8 @@ const buildChartObjectXml = (chart, sheetNameById) => {
|
|
|
3183
3183
|
let hasSeriesLabels = false;
|
|
3184
3184
|
const seriesXml = seriesRanges
|
|
3185
3185
|
.map((range, index) => {
|
|
3186
|
-
const labelAddress =
|
|
3186
|
+
const labelAddress = buildChartLabelAddressFromCell(series[index]?.dataLabelSource ?? undefined, sheetNameById) ||
|
|
3187
|
+
buildChartLabelAddress(series[index]?.dataLabel, sheetNameById, chart.position?.sheetId) ||
|
|
3187
3188
|
buildChartLabelAddressFromRange(series[index]?.sources?.[0], sheetNameById);
|
|
3188
3189
|
const labelAttr = labelAddress
|
|
3189
3190
|
? ` chart:label-cell-address="${escapeXmlAddress(labelAddress)}"`
|
|
@@ -3297,6 +3298,18 @@ const buildChartLabelAddress = (label, sheetNameById, sheetId) => {
|
|
|
3297
3298
|
}
|
|
3298
3299
|
return "";
|
|
3299
3300
|
};
|
|
3301
|
+
/** The header cell a series name is linked to (`dataLabelSource`). */
|
|
3302
|
+
const buildChartLabelAddressFromCell = (cell, sheetNameById) => {
|
|
3303
|
+
if (!cell)
|
|
3304
|
+
return "";
|
|
3305
|
+
const sheetName = sheetNameById.get(cell.sheetId);
|
|
3306
|
+
if (!sheetName)
|
|
3307
|
+
return "";
|
|
3308
|
+
const labelRef = cellToAddress({ rowIndex: cell.startRowIndex, columnIndex: cell.startColumnIndex }, true, true);
|
|
3309
|
+
if (!labelRef)
|
|
3310
|
+
return "";
|
|
3311
|
+
return `${escapeSheetName(sheetName)}.${labelRef}`;
|
|
3312
|
+
};
|
|
3300
3313
|
const buildChartLabelAddressFromRange = (range, sheetNameById) => {
|
|
3301
3314
|
if (!range || range.startRowIndex <= 1)
|
|
3302
3315
|
return "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-builder.d.ts","sourceRoot":"","sources":["../../../../exporter/xlsx/chart-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,aAAa,EAEd,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"chart-builder.d.ts","sourceRoot":"","sources":["../../../../exporter/xlsx/chart-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,aAAa,EAEd,MAAM,2BAA2B,CAAC;AAi6CnC;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,CACnC,YAAY,EAAE,MAAM,GAAG,MAAM,KAC1B,MAAM,GAAG,SAAS,CAAC;AAExB,eAAO,MAAM,aAAa,GACxB,OAAO,aAAa,EACpB,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,yBAAyB,sBAAsB,KAC9C,MAAM,GAAG,SA2rBX,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cellRangeToAddress, chartPaletteColorAt, sanitizeSheetName, } from "@rowsncolumns/utils";
|
|
1
|
+
import { cellRangeToAddress, cellToAddress, chartPaletteColorAt, sanitizeSheetName, } from "@rowsncolumns/utils";
|
|
2
2
|
import { XMLBuilder } from "fast-xml-parser";
|
|
3
3
|
import { area_series, bubble_series, chart_template, column_json, column_series, donut_json, line_series, scatter_json, scatter_series, static_title, } from "./chart-templates";
|
|
4
4
|
const XML_DECLARATION = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>`;
|
|
@@ -75,6 +75,21 @@ const formatSourcesRef = (sources, sheetNameById) => {
|
|
|
75
75
|
.filter((ref) => Boolean(ref));
|
|
76
76
|
return parts.length ? parts.join(",") : undefined;
|
|
77
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* The `<c:tx><c:strRef>` formula of a series whose name is linked to a
|
|
80
|
+
* header cell — `dataLabelSource` (a `SheetRange`), else the address an
|
|
81
|
+
* earlier import captured as `dataLabelRef`.
|
|
82
|
+
*/
|
|
83
|
+
const seriesLabelRef = (entry, sheetNameById) => (entry?.dataLabelSource
|
|
84
|
+
? formatCellRef(entry.dataLabelSource, sheetNameById)
|
|
85
|
+
: undefined) ?? entry?.dataLabelRef ?? undefined;
|
|
86
|
+
/** `'Sheet'!$B$1` — the absolute single-cell form Excel writes for a series name. */
|
|
87
|
+
const formatCellRef = (cell, sheetNameById) => {
|
|
88
|
+
const sheetName = sheetNameById.get(cell.sheetId);
|
|
89
|
+
if (!sheetName)
|
|
90
|
+
return undefined;
|
|
91
|
+
return `${sanitizeSheetName(sheetName)}!${cellToAddress({ rowIndex: cell.startRowIndex, columnIndex: cell.startColumnIndex }, true, true)}`;
|
|
92
|
+
};
|
|
78
93
|
const seriesCategoryRef = (entry, sheetNameById) => formatSourcesRef(entry?.categorySources, sheetNameById);
|
|
79
94
|
const buildSeriesLabel = (label, sheetName, labelRef) => {
|
|
80
95
|
// A captured source reference (`<c:tx><c:strRef>`) wins over the literal:
|
|
@@ -722,7 +737,7 @@ const isComboChart = (series, defaultChartType) => {
|
|
|
722
737
|
/**
|
|
723
738
|
* Build a bar/column series node.
|
|
724
739
|
*/
|
|
725
|
-
const buildBarSeriesNode = (index, ref, seriesData, domainRef, sheetName, isFirstInGroup) => {
|
|
740
|
+
const buildBarSeriesNode = (index, ref, seriesData, domainRef, sheetName, isFirstInGroup, sheetNameById = new Map()) => {
|
|
726
741
|
const seriesNode = cloneTemplate(column_series);
|
|
727
742
|
seriesNode["c:idx"] = { a$: { val: index.toString() } };
|
|
728
743
|
seriesNode["c:order"] = { a$: { val: index.toString() } };
|
|
@@ -780,7 +795,7 @@ const buildBarSeriesNode = (index, ref, seriesData, domainRef, sheetName, isFirs
|
|
|
780
795
|
removeProp(seriesNode, "c:val");
|
|
781
796
|
seriesNode["c:val"] = buildInlineNumLit(inlineValues);
|
|
782
797
|
}
|
|
783
|
-
const labelNode = buildSeriesLabel(seriesData?.dataLabel ?? undefined, sheetName, seriesData
|
|
798
|
+
const labelNode = buildSeriesLabel(seriesData?.dataLabel ?? undefined, sheetName, seriesLabelRef(seriesData, sheetNameById));
|
|
784
799
|
if (labelNode) {
|
|
785
800
|
seriesNode["c:tx"] = labelNode["c:tx"];
|
|
786
801
|
}
|
|
@@ -795,7 +810,7 @@ const buildBarSeriesNode = (index, ref, seriesData, domainRef, sheetName, isFirs
|
|
|
795
810
|
/**
|
|
796
811
|
* Build a line series node.
|
|
797
812
|
*/
|
|
798
|
-
const buildLineSeriesNode = (index, ref, seriesData, domainRef, sheetName, smooth, showMarkers = false) => {
|
|
813
|
+
const buildLineSeriesNode = (index, ref, seriesData, domainRef, sheetName, smooth, showMarkers = false, sheetNameById = new Map()) => {
|
|
799
814
|
const seriesNode = cloneTemplate(line_series);
|
|
800
815
|
seriesNode["c:idx"] = { a$: { val: index.toString() } };
|
|
801
816
|
seriesNode["c:order"] = { a$: { val: index.toString() } };
|
|
@@ -839,7 +854,7 @@ const buildLineSeriesNode = (index, ref, seriesData, domainRef, sheetName, smoot
|
|
|
839
854
|
if (smooth) {
|
|
840
855
|
seriesNode["c:smooth"].a$.val = "1";
|
|
841
856
|
}
|
|
842
|
-
const labelNode = buildSeriesLabel(seriesData?.dataLabel ?? undefined, sheetName, seriesData
|
|
857
|
+
const labelNode = buildSeriesLabel(seriesData?.dataLabel ?? undefined, sheetName, seriesLabelRef(seriesData, sheetNameById));
|
|
843
858
|
if (labelNode) {
|
|
844
859
|
seriesNode["c:tx"] = labelNode["c:tx"];
|
|
845
860
|
}
|
|
@@ -848,7 +863,7 @@ const buildLineSeriesNode = (index, ref, seriesData, domainRef, sheetName, smoot
|
|
|
848
863
|
/**
|
|
849
864
|
* Build an area series node.
|
|
850
865
|
*/
|
|
851
|
-
const buildAreaSeriesNode = (index, ref, seriesData, domainRef, sheetName) => {
|
|
866
|
+
const buildAreaSeriesNode = (index, ref, seriesData, domainRef, sheetName, sheetNameById = new Map()) => {
|
|
852
867
|
const seriesNode = cloneTemplate(area_series);
|
|
853
868
|
seriesNode["c:idx"] = { a$: { val: index.toString() } };
|
|
854
869
|
seriesNode["c:order"] = { a$: { val: index.toString() } };
|
|
@@ -878,7 +893,7 @@ const buildAreaSeriesNode = (index, ref, seriesData, domainRef, sheetName) => {
|
|
|
878
893
|
removeProp(seriesNode, "c:cat");
|
|
879
894
|
}
|
|
880
895
|
seriesNode["c:val"]["c:numRef"]["c:f"] = ref;
|
|
881
|
-
const labelNode = buildSeriesLabel(seriesData?.dataLabel ?? undefined, sheetName, seriesData
|
|
896
|
+
const labelNode = buildSeriesLabel(seriesData?.dataLabel ?? undefined, sheetName, seriesLabelRef(seriesData, sheetNameById));
|
|
882
897
|
if (labelNode) {
|
|
883
898
|
seriesNode["c:tx"] = labelNode["c:tx"];
|
|
884
899
|
}
|
|
@@ -891,7 +906,7 @@ const buildAreaSeriesNode = (index, ref, seriesData, domainRef, sheetName) => {
|
|
|
891
906
|
* remaining series, each with its own idx/order, name, category and value
|
|
892
907
|
* reference.
|
|
893
908
|
*/
|
|
894
|
-
const appendExtraCircularSeries = (chartNode, groupKey, seriesRefs, seriesCatRefs, domainRef, series, sheetName) => {
|
|
909
|
+
const appendExtraCircularSeries = (chartNode, groupKey, seriesRefs, seriesCatRefs, domainRef, series, sheetName, sheetNameById = new Map()) => {
|
|
895
910
|
const group = chartNode["c:plotArea"]?.[groupKey];
|
|
896
911
|
if (!group)
|
|
897
912
|
return;
|
|
@@ -913,7 +928,7 @@ const appendExtraCircularSeries = (chartNode, groupKey, seriesRefs, seriesCatRef
|
|
|
913
928
|
"c:idx": { a$: { val: String(index) } },
|
|
914
929
|
"c:order": { a$: { val: String(index) } },
|
|
915
930
|
};
|
|
916
|
-
const labelNode = buildSeriesLabel(series[index]?.dataLabel ?? undefined, sheetName, series[index]
|
|
931
|
+
const labelNode = buildSeriesLabel(series[index]?.dataLabel ?? undefined, sheetName, seriesLabelRef(series[index], sheetNameById));
|
|
917
932
|
if (labelNode) {
|
|
918
933
|
node["c:tx"] = labelNode["c:tx"];
|
|
919
934
|
}
|
|
@@ -1196,7 +1211,7 @@ export const buildChartXml = (input, sheetNameById, resolvePivotSourceName) => {
|
|
|
1196
1211
|
};
|
|
1197
1212
|
for (let i = 0; i < groupSeries.length; i++) {
|
|
1198
1213
|
const { index, ref, data } = groupSeries[i];
|
|
1199
|
-
const seriesNode = buildBarSeriesNode(index, ref, data, seriesCatRefs[index] ?? domainRef, sheetName, i === 0);
|
|
1214
|
+
const seriesNode = buildBarSeriesNode(index, ref, data, seriesCatRefs[index] ?? domainRef, sheetName, i === 0, sheetNameById);
|
|
1200
1215
|
barChartNode["c:ser"].push(seriesNode);
|
|
1201
1216
|
}
|
|
1202
1217
|
comboGroups.push(["c:barChart", barChartNode]);
|
|
@@ -1221,7 +1236,7 @@ export const buildChartXml = (input, sheetNameById, resolvePivotSourceName) => {
|
|
|
1221
1236
|
"c:axId": axisIds,
|
|
1222
1237
|
};
|
|
1223
1238
|
for (const { index, ref, data } of groupSeries) {
|
|
1224
|
-
const seriesNode = buildLineSeriesNode(index, ref, data, seriesCatRefs[index] ?? domainRef, sheetName, smooth, showMarkers);
|
|
1239
|
+
const seriesNode = buildLineSeriesNode(index, ref, data, seriesCatRefs[index] ?? domainRef, sheetName, smooth, showMarkers, sheetNameById);
|
|
1225
1240
|
lineChartNode["c:ser"].push(seriesNode);
|
|
1226
1241
|
}
|
|
1227
1242
|
comboGroups.push(["c:lineChart", lineChartNode]);
|
|
@@ -1235,7 +1250,7 @@ export const buildChartXml = (input, sheetNameById, resolvePivotSourceName) => {
|
|
|
1235
1250
|
"c:axId": axisIds,
|
|
1236
1251
|
};
|
|
1237
1252
|
for (const { index, ref, data } of groupSeries) {
|
|
1238
|
-
const seriesNode = buildAreaSeriesNode(index, ref, data, seriesCatRefs[index] ?? domainRef, sheetName);
|
|
1253
|
+
const seriesNode = buildAreaSeriesNode(index, ref, data, seriesCatRefs[index] ?? domainRef, sheetName, sheetNameById);
|
|
1239
1254
|
areaChartNode["c:ser"].push(seriesNode);
|
|
1240
1255
|
}
|
|
1241
1256
|
comboGroups.push(["c:areaChart", areaChartNode]);
|
|
@@ -1285,7 +1300,7 @@ export const buildChartXml = (input, sheetNameById, resolvePivotSourceName) => {
|
|
|
1285
1300
|
};
|
|
1286
1301
|
}
|
|
1287
1302
|
seriesNode["c:val"]["c:numRef"]["c:f"] = ref;
|
|
1288
|
-
const labelNode = buildSeriesLabel(series[index]?.dataLabel ?? undefined, sheetNameById.get(chart.position.sheetId), series[index]
|
|
1303
|
+
const labelNode = buildSeriesLabel(series[index]?.dataLabel ?? undefined, sheetNameById.get(chart.position.sheetId), seriesLabelRef(series[index], sheetNameById));
|
|
1289
1304
|
if (labelNode) {
|
|
1290
1305
|
seriesNode["c:tx"] = labelNode["c:tx"];
|
|
1291
1306
|
}
|
|
@@ -1366,7 +1381,7 @@ export const buildChartXml = (input, sheetNameById, resolvePivotSourceName) => {
|
|
|
1366
1381
|
inlineDomainValues,
|
|
1367
1382
|
}
|
|
1368
1383
|
: series[index];
|
|
1369
|
-
const seriesNode = buildBarSeriesNode(index, ref ?? "", enrichedSeries, seriesCatRefs[index] ?? domainRef, sheetNameById.get(chart.position.sheetId), index === 0);
|
|
1384
|
+
const seriesNode = buildBarSeriesNode(index, ref ?? "", enrichedSeries, seriesCatRefs[index] ?? domainRef, sheetNameById.get(chart.position.sheetId), index === 0, sheetNameById);
|
|
1370
1385
|
seriesContainer.push(seriesNode);
|
|
1371
1386
|
});
|
|
1372
1387
|
chartSpace["c:chartSpace"]["c:chart"] = barChart;
|
|
@@ -1383,14 +1398,14 @@ export const buildChartXml = (input, sheetNameById, resolvePivotSourceName) => {
|
|
|
1383
1398
|
? buildOfPieChart(domainRef, valueRef, chartTitle, specAny, chartSubtitle)
|
|
1384
1399
|
: buildPieChart(domainRef, valueRef, chartTitle, chartSubtitle);
|
|
1385
1400
|
if (!isOfPie) {
|
|
1386
|
-
appendExtraCircularSeries(pieChart, "c:pieChart", seriesRefs, seriesCatRefs, domainRef, series, sheetNameById.get(chart.position.sheetId));
|
|
1401
|
+
appendExtraCircularSeries(pieChart, "c:pieChart", seriesRefs, seriesCatRefs, domainRef, series, sheetNameById.get(chart.position.sheetId), sheetNameById);
|
|
1387
1402
|
}
|
|
1388
1403
|
chartSpace["c:chartSpace"]["c:chart"] = pieChart;
|
|
1389
1404
|
}
|
|
1390
1405
|
else if (chartType === "doughnut") {
|
|
1391
1406
|
const valueRef = seriesRefs.find(Boolean);
|
|
1392
1407
|
const doughnutChart = buildDoughnutChart(domainRef, valueRef, chartTitle, chartSubtitle);
|
|
1393
|
-
appendExtraCircularSeries(doughnutChart, "c:doughnutChart", seriesRefs, seriesCatRefs, domainRef, series, sheetNameById.get(chart.position.sheetId));
|
|
1408
|
+
appendExtraCircularSeries(doughnutChart, "c:doughnutChart", seriesRefs, seriesCatRefs, domainRef, series, sheetNameById.get(chart.position.sheetId), sheetNameById);
|
|
1394
1409
|
chartSpace["c:chartSpace"]["c:chart"] = doughnutChart;
|
|
1395
1410
|
}
|
|
1396
1411
|
else if (chartType === "radar") {
|
|
@@ -1469,7 +1484,7 @@ export const buildChartXml = (input, sheetNameById, resolvePivotSourceName) => {
|
|
|
1469
1484
|
else if (showMarkers) {
|
|
1470
1485
|
removeProp(seriesNode, "c:marker");
|
|
1471
1486
|
}
|
|
1472
|
-
const labelNode = buildSeriesLabel(series[index]?.dataLabel ?? undefined, sheetNameById.get(chart.position.sheetId), series[index]
|
|
1487
|
+
const labelNode = buildSeriesLabel(series[index]?.dataLabel ?? undefined, sheetNameById.get(chart.position.sheetId), seriesLabelRef(series[index], sheetNameById));
|
|
1473
1488
|
if (labelNode) {
|
|
1474
1489
|
seriesNode["c:tx"] = labelNode["c:tx"];
|
|
1475
1490
|
}
|
|
@@ -1525,7 +1540,7 @@ export const buildChartXml = (input, sheetNameById, resolvePivotSourceName) => {
|
|
|
1525
1540
|
removeProp(seriesNode, "c:cat");
|
|
1526
1541
|
}
|
|
1527
1542
|
seriesNode["c:val"]["c:numRef"]["c:f"] = ref;
|
|
1528
|
-
const labelNode = buildSeriesLabel(series[index]?.dataLabel ?? undefined, sheetNameById.get(chart.position.sheetId), series[index]
|
|
1543
|
+
const labelNode = buildSeriesLabel(series[index]?.dataLabel ?? undefined, sheetNameById.get(chart.position.sheetId), seriesLabelRef(series[index], sheetNameById));
|
|
1529
1544
|
if (labelNode) {
|
|
1530
1545
|
seriesNode["c:tx"] = labelNode["c:tx"];
|
|
1531
1546
|
}
|
|
@@ -1580,7 +1595,7 @@ export const buildChartXml = (input, sheetNameById, resolvePivotSourceName) => {
|
|
|
1580
1595
|
else if (smooth) {
|
|
1581
1596
|
seriesNode["c:smooth"].a$.val = "1";
|
|
1582
1597
|
}
|
|
1583
|
-
const labelNode = buildSeriesLabel(entry?.dataLabel ?? bubbleLabelEntries[index]?.dataLabel ?? undefined, sheetNameById.get(chart.position.sheetId), entry
|
|
1598
|
+
const labelNode = buildSeriesLabel(entry?.dataLabel ?? bubbleLabelEntries[index]?.dataLabel ?? undefined, sheetNameById.get(chart.position.sheetId), seriesLabelRef(entry, sheetNameById));
|
|
1584
1599
|
if (labelNode) {
|
|
1585
1600
|
seriesNode["c:tx"] = labelNode["c:tx"];
|
|
1586
1601
|
}
|