@officedk/pptxdk 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/dist/build-zrZuX4fK.d.ts +3 -0
- package/dist/build.d.ts +35 -0
- package/dist/build.js +128 -0
- package/dist/capabilities/dist/all.js +34 -0
- package/dist/capabilities/dist/box/box-codegen.js +84 -0
- package/dist/capabilities/dist/box/box-declaration.js +32 -0
- package/dist/capabilities/dist/box/box-elements.js +17 -0
- package/dist/capabilities/dist/box/box.js +142 -0
- package/dist/capabilities/dist/chart/chart-codegen.js +79 -0
- package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
- package/dist/capabilities/dist/chart/chart-elements.js +12 -0
- package/dist/capabilities/dist/chart/chart-import.js +2403 -0
- package/dist/capabilities/dist/chart/chart-labels.js +86 -0
- package/dist/capabilities/dist/chart/chart-model.js +9 -0
- package/dist/capabilities/dist/chart/chart-schemas.js +1088 -0
- package/dist/capabilities/dist/chart/chart-xml.js +788 -0
- package/dist/capabilities/dist/chart/chart.js +1119 -0
- package/dist/capabilities/dist/chart/preview/axes-and-grid.js +311 -0
- package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
- package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
- package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
- package/dist/capabilities/dist/chart/preview/index.js +192 -0
- package/dist/capabilities/dist/chart/preview/layout.js +592 -0
- package/dist/capabilities/dist/chart/preview/legend.js +273 -0
- package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
- package/dist/capabilities/dist/chart/preview/markers.js +100 -0
- package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
- package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
- package/dist/capabilities/dist/chart/preview/scales.js +365 -0
- package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
- package/dist/capabilities/dist/chart/preview/style.js +60 -0
- package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
- package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
- package/dist/capabilities/dist/chart/preview/types.js +5 -0
- package/dist/capabilities/dist/document.js +168 -0
- package/dist/capabilities/dist/font/font-embedding.js +119 -0
- package/dist/capabilities/dist/font/font-engine.js +834 -0
- package/dist/capabilities/dist/font/font-import.js +766 -0
- package/dist/capabilities/dist/font/font-subset.js +55 -0
- package/dist/capabilities/dist/font/font.js +72 -0
- package/dist/capabilities/dist/group/group-codegen.js +74 -0
- package/dist/capabilities/dist/group/group-declaration.js +41 -0
- package/dist/capabilities/dist/group/group-elements.js +12 -0
- package/dist/capabilities/dist/group/group-import.js +649 -0
- package/dist/capabilities/dist/group/group-xml.js +8 -0
- package/dist/capabilities/dist/group/group.js +260 -0
- package/dist/capabilities/dist/image/gif-decoder.js +244 -0
- package/dist/capabilities/dist/image/image-codegen.js +164 -0
- package/dist/capabilities/dist/image/image-declaration.js +8 -0
- package/dist/capabilities/dist/image/image-decode.js +244 -0
- package/dist/capabilities/dist/image/image-elements.js +12 -0
- package/dist/capabilities/dist/image/image-import.js +984 -0
- package/dist/capabilities/dist/image/image-schemas.js +147 -0
- package/dist/capabilities/dist/image/image-xml.js +12 -0
- package/dist/capabilities/dist/image/image.js +552 -0
- package/dist/capabilities/dist/line/line-codegen.js +89 -0
- package/dist/capabilities/dist/line/line-declaration.js +72 -0
- package/dist/capabilities/dist/line/line-elements.js +12 -0
- package/dist/capabilities/dist/line/line-import.js +504 -0
- package/dist/capabilities/dist/line/line-xml.js +9 -0
- package/dist/capabilities/dist/line/line.js +331 -0
- package/dist/capabilities/dist/masters/footer-placeholder.js +683 -0
- package/dist/capabilities/dist/masters/masters-codegen.js +69 -0
- package/dist/capabilities/dist/masters/masters.js +250 -0
- package/dist/capabilities/dist/motion/motion-api.js +757 -0
- package/dist/capabilities/dist/motion/motion-codegen.js +406 -0
- package/dist/capabilities/dist/motion/motion-elements.js +43 -0
- package/dist/capabilities/dist/motion/motion-import.js +1568 -0
- package/dist/capabilities/dist/motion/motion-plan.js +2340 -0
- package/dist/capabilities/dist/motion/motion-query.js +423 -0
- package/dist/capabilities/dist/motion/motion-schemas.js +339 -0
- package/dist/capabilities/dist/motion/motion.js +1617 -0
- package/dist/capabilities/dist/notes/notes-codegen.js +19 -0
- package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
- package/dist/capabilities/dist/notes/notes-elements.js +12 -0
- package/dist/capabilities/dist/notes/notes-import.js +292 -0
- package/dist/capabilities/dist/notes/notes-schemas.js +38 -0
- package/dist/capabilities/dist/notes/notes-xml.js +38 -0
- package/dist/capabilities/dist/notes/notes.js +194 -0
- package/dist/capabilities/dist/placeholder/placeholder-codegen.js +54 -0
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +13 -0
- package/dist/capabilities/dist/placeholder/placeholder-schemas.js +33 -0
- package/dist/capabilities/dist/placeholder/placeholder.js +451 -0
- package/dist/capabilities/dist/shape/shape-codegen.js +236 -0
- package/dist/capabilities/dist/shape/shape-declaration.js +45 -0
- package/dist/capabilities/dist/shape/shape-elements.js +12 -0
- package/dist/capabilities/dist/shape/shape-import.js +628 -0
- package/dist/capabilities/dist/shape/shape-xml.js +6 -0
- package/dist/capabilities/dist/shape/shape.js +320 -0
- package/dist/capabilities/dist/shared/geometry.js +1681 -0
- package/dist/capabilities/dist/shared/identity.js +205 -0
- package/dist/capabilities/dist/shared/morph-api.js +11 -0
- package/dist/capabilities/dist/shared/placeholder-import.js +238 -0
- package/dist/capabilities/dist/shared/preset-definitions.js +22423 -0
- package/dist/capabilities/dist/shared/style-inheritance.js +161 -0
- package/dist/capabilities/dist/shared/text-schemas.js +241 -0
- package/dist/capabilities/dist/shared/text-service.js +2252 -0
- package/dist/capabilities/dist/shared/visual.js +1197 -0
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
- package/dist/capabilities/dist/slide-background/slide-background-import.js +166 -0
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +34 -0
- package/dist/capabilities/dist/slide-background/slide-background.js +238 -0
- package/dist/capabilities/dist/table/table-codegen.js +125 -0
- package/dist/capabilities/dist/table/table-declaration.js +15 -0
- package/dist/capabilities/dist/table/table-elements.js +27 -0
- package/dist/capabilities/dist/table/table-import.js +606 -0
- package/dist/capabilities/dist/table/table-schemas.js +334 -0
- package/dist/capabilities/dist/table/table-xml.js +30 -0
- package/dist/capabilities/dist/table/table.js +739 -0
- package/dist/capabilities/dist/text/text-codegen.js +198 -0
- package/dist/capabilities/dist/text/text-declaration.js +27 -0
- package/dist/capabilities/dist/text/text-elements.js +54 -0
- package/dist/capabilities/dist/text/text-import.js +1224 -0
- package/dist/capabilities/dist/text/text-xml.js +9 -0
- package/dist/capabilities/dist/text/text.js +320 -0
- package/dist/capabilities/dist/transition/transition-api.js +136 -0
- package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
- package/dist/capabilities/dist/transition/transition-import.js +477 -0
- package/dist/capabilities/dist/transition/transition.js +260 -0
- package/dist/capability-BbKW9w4O.d.ts +2131 -0
- package/dist/cli.js +20 -0
- package/dist/codegen/dist/assets.js +79 -0
- package/dist/codegen/dist/codegen.js +691 -0
- package/dist/codegen/dist/identifiers.js +203 -0
- package/dist/codegen/dist/index.js +3 -0
- package/dist/codegen/dist/printer.js +143 -0
- package/dist/codegen/dist/types.js +77 -0
- package/dist/core/dist/author-ids.js +51 -0
- package/dist/core/dist/author-schemas.js +330 -0
- package/dist/core/dist/block-flex-layout.js +801 -0
- package/dist/core/dist/build.js +4 -0
- package/dist/core/dist/capability.js +15 -0
- package/dist/core/dist/declaration.js +16 -0
- package/dist/core/dist/diagnostics.js +353 -0
- package/dist/core/dist/document-internals.js +26 -0
- package/dist/core/dist/document.js +417 -0
- package/dist/core/dist/font-seal.js +204 -0
- package/dist/core/dist/geometry-schemas.js +256 -0
- package/dist/core/dist/grid-layout.js +449 -0
- package/dist/core/dist/host.js +40 -0
- package/dist/core/dist/index.js +15 -0
- package/dist/core/dist/input-values.js +61 -0
- package/dist/core/dist/layout-protocol.js +61 -0
- package/dist/core/dist/layout-schemas.js +201 -0
- package/dist/core/dist/layout.js +340 -0
- package/dist/core/dist/masters.js +194 -0
- package/dist/core/dist/morph.js +30 -0
- package/dist/core/dist/placeholders.js +275 -0
- package/dist/core/dist/query.js +190 -0
- package/dist/core/dist/resolution.js +12 -0
- package/dist/core/dist/resolve.js +2246 -0
- package/dist/core/dist/stage-options.js +300 -0
- package/dist/core/dist/theme.js +1023 -0
- package/dist/core/dist/transform-geometry.js +72 -0
- package/dist/document-41spD7bq.d.ts +1350 -0
- package/dist/emit/dist/emit.js +957 -0
- package/dist/emit/dist/index.js +5 -0
- package/dist/emit/dist/ooxml.js +661 -0
- package/dist/emit/dist/shape-tree.js +12 -0
- package/dist/import/dist/alternate-content.js +54 -0
- package/dist/import/dist/diagnostics.js +157 -0
- package/dist/import/dist/fonts.js +309 -0
- package/dist/import/dist/import.js +513 -0
- package/dist/import/dist/index.js +16 -0
- package/dist/import/dist/masters.js +1293 -0
- package/dist/import/dist/mechanism.js +10 -0
- package/dist/import/dist/namespaces.js +61 -0
- package/dist/import/dist/notes-masters.js +300 -0
- package/dist/import/dist/opc.js +233 -0
- package/dist/import/dist/resources.js +166 -0
- package/dist/import/dist/sections.js +139 -0
- package/dist/import/dist/themes.js +777 -0
- package/dist/import/dist/visual.js +821 -0
- package/dist/import/dist/xml-fragments.js +277 -0
- package/dist/import/dist/xml-reader.js +267 -0
- package/dist/index-1ag7U9Jt.d.ts +63 -0
- package/dist/index-BEwhk7c8.d.ts +72 -0
- package/dist/index-cK2KtukZ.d.ts +161 -0
- package/dist/index-v77CTJev.d.ts +55 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +82 -0
- package/dist/node.d.ts +53 -0
- package/dist/node.js +225 -0
- package/dist/pptxdk/src/cli-commands.js +907 -0
- package/dist/pptxdk/src/compose.js +53 -0
- package/dist/pptxdk/src/slide.js +9 -0
- package/dist/preview/dist/index.js +342 -0
- package/dist/preview/dist/options.js +40 -0
- package/dist/preview/dist/svg-guard.js +1089 -0
- package/dist/preview.d.ts +12 -0
- package/dist/preview.js +29 -0
- package/dist/react/dist/append.js +66 -0
- package/dist/react/dist/document-adapter.js +404 -0
- package/dist/react/dist/elements.js +82 -0
- package/dist/react/dist/from-vanilla.js +57 -0
- package/dist/react/dist/index.js +89 -0
- package/dist/react/dist/mount.js +34 -0
- package/dist/react/dist/reconciler.js +290 -0
- package/dist/react.d.ts +235 -0
- package/dist/react.js +31 -0
- package/dist/transition-6n8GZxSg.d.ts +9 -0
- package/dist/vanilla.d.ts +4 -0
- package/dist/vanilla.js +15 -0
- package/package.json +79 -3
- package/README.md +0 -3
|
@@ -0,0 +1,788 @@
|
|
|
1
|
+
import { placeholderRefXml, pxToEmu, resolvedColorXml, xmlEscape } from "../../../emit/dist/ooxml.js";
|
|
2
|
+
import "../../../emit/dist/index.js";
|
|
3
|
+
import { chartAxisPositionCodes, chartDataLabelPositions, chartErrorBarValueTypes, chartLegendPositions, chartLineDashValues, chartTrendlineTypeValues, mergeDataLabels } from "./chart-labels.js";
|
|
4
|
+
import { strToU8, zipSync } from "fflate";
|
|
5
|
+
// ../capabilities/dist/chart/chart-xml.js
|
|
6
|
+
const chartNamespace = "http://schemas.openxmlformats.org/drawingml/2006/chart";
|
|
7
|
+
const drawingNamespace = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
8
|
+
const relationshipNamespace = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
9
|
+
const sheet = "Sheet1";
|
|
10
|
+
const c15Namespace = "http://schemas.microsoft.com/office/drawing/2012/chart";
|
|
11
|
+
const categoryRangeExtensionUri = "{02D57815-91ED-43cb-92C2-25804820EDAC}";
|
|
12
|
+
const dataLabelRangeExtensionUri = "{CE6537A1-D6FC-4f65-9D91-7224C49458BB}";
|
|
13
|
+
function flatten(children, into) {
|
|
14
|
+
for (const child of children) {
|
|
15
|
+
if (child === void 0 || child === false || child === null) continue;
|
|
16
|
+
if (typeof child === "string" || !Array.isArray(child)) into.push(child);
|
|
17
|
+
else flatten(child, into);
|
|
18
|
+
}
|
|
19
|
+
return into;
|
|
20
|
+
}
|
|
21
|
+
function el(name, attributes = null, ...children) {
|
|
22
|
+
return {
|
|
23
|
+
name,
|
|
24
|
+
attributes: attributes ?? {},
|
|
25
|
+
children: flatten(children, [])
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function raw(value) {
|
|
29
|
+
return value === void 0 ? void 0 : { raw: value };
|
|
30
|
+
}
|
|
31
|
+
function write(node, into) {
|
|
32
|
+
if (typeof node === "string") {
|
|
33
|
+
into.push(xmlEscape(node));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if ("raw" in node) {
|
|
37
|
+
into.push(node.raw);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
into.push("<", node.name);
|
|
41
|
+
for (const [key, value] of Object.entries(node.attributes)) {
|
|
42
|
+
if (value === void 0) continue;
|
|
43
|
+
const rendered = typeof value === "boolean" ? value ? "1" : "0" : String(value);
|
|
44
|
+
into.push(" ", key, "=\"", xmlEscape(rendered), "\"");
|
|
45
|
+
}
|
|
46
|
+
if (node.children.length === 0) {
|
|
47
|
+
into.push("/>");
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
into.push(">");
|
|
51
|
+
for (const child of node.children) write(child, into);
|
|
52
|
+
into.push("</", node.name, ">");
|
|
53
|
+
}
|
|
54
|
+
function serialize(root) {
|
|
55
|
+
const into = ["<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"];
|
|
56
|
+
write(root, into);
|
|
57
|
+
return into.join("");
|
|
58
|
+
}
|
|
59
|
+
function serializeFragment(root) {
|
|
60
|
+
const into = [];
|
|
61
|
+
write(root, into);
|
|
62
|
+
return into.join("");
|
|
63
|
+
}
|
|
64
|
+
function columnName(index) {
|
|
65
|
+
let name = "";
|
|
66
|
+
for (let rest = index + 1; rest > 0; rest = Math.floor((rest - 1) / 26)) name = String.fromCharCode(65 + (rest - 1) % 26) + name;
|
|
67
|
+
return name;
|
|
68
|
+
}
|
|
69
|
+
function scatterXFormatCode(labels) {
|
|
70
|
+
return labels !== void 0 && labels !== false && labels.xValue === true ? labels.numberFormat ?? "General" : "General";
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Assigns workbook columns and scatter X label formats for every parsed series once.
|
|
74
|
+
*
|
|
75
|
+
* Category axes own the leading columns because several groups may share one ordered domain;
|
|
76
|
+
* each remaining category series owns one value column, and every scatter series owns its own
|
|
77
|
+
* X and Y columns. The chart cache, embedded workbook, and affected default X axis read this
|
|
78
|
+
* mapping so their coordinate formats stay aligned.
|
|
79
|
+
*/
|
|
80
|
+
function chartCells(parsed) {
|
|
81
|
+
const categoryColumns = /* @__PURE__ */ new Map();
|
|
82
|
+
const axislessCategoryColumns = /* @__PURE__ */ new Map();
|
|
83
|
+
const independentCategoryColumns = /* @__PURE__ */ new Map();
|
|
84
|
+
let nextColumn = 0;
|
|
85
|
+
for (const [groupIndex, group] of parsed.groups.entries()) {
|
|
86
|
+
if (group.kind === "scatter") continue;
|
|
87
|
+
if (group.data.kind === "independent-categories") continue;
|
|
88
|
+
if (group.kind === "pie" || group.kind === "doughnut") {
|
|
89
|
+
axislessCategoryColumns.set(groupIndex, {
|
|
90
|
+
column: nextColumn,
|
|
91
|
+
categories: group.data.categories
|
|
92
|
+
});
|
|
93
|
+
nextColumn += 1;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const name = group.axes.category.name;
|
|
97
|
+
if (categoryColumns.has(name)) continue;
|
|
98
|
+
categoryColumns.set(name, {
|
|
99
|
+
column: nextColumn,
|
|
100
|
+
categories: group.data.categories
|
|
101
|
+
});
|
|
102
|
+
nextColumn += 1;
|
|
103
|
+
}
|
|
104
|
+
if (categoryColumns.size === 0 && axislessCategoryColumns.size === 0 && parsed.groups.some((group) => group.kind === "scatter")) nextColumn = 1;
|
|
105
|
+
const series = /* @__PURE__ */ new Map();
|
|
106
|
+
const projectedScatterXAxes = /* @__PURE__ */ new Set();
|
|
107
|
+
for (const [groupIndex, group] of parsed.groups.entries()) {
|
|
108
|
+
if (group.kind === "scatter") {
|
|
109
|
+
for (const item of group.series) {
|
|
110
|
+
const seriesLabels = mergeDataLabels(group.dataLabels, item.dataLabels);
|
|
111
|
+
const pointBase = seriesLabels === false ? {} : seriesLabels;
|
|
112
|
+
const labelFormats = {
|
|
113
|
+
baseFormatCode: scatterXFormatCode(seriesLabels),
|
|
114
|
+
pointFormatCodes: item.x.map((value, index) => {
|
|
115
|
+
const formatCode = scatterXFormatCode(mergeDataLabels(pointBase, item.points?.[index]?.dataLabels));
|
|
116
|
+
if (value !== null && value !== void 0 && formatCode !== "General") projectedScatterXAxes.add(group.axes.x.id);
|
|
117
|
+
return formatCode;
|
|
118
|
+
})
|
|
119
|
+
};
|
|
120
|
+
series.set(item.seriesIndex, {
|
|
121
|
+
nameColumn: nextColumn,
|
|
122
|
+
x: {
|
|
123
|
+
column: nextColumn,
|
|
124
|
+
pointCount: item.x.length,
|
|
125
|
+
labelFormats
|
|
126
|
+
},
|
|
127
|
+
y: {
|
|
128
|
+
column: nextColumn + 1,
|
|
129
|
+
pointCount: item.y.length
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
nextColumn += 2;
|
|
133
|
+
}
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (group.data.kind === "independent-categories") {
|
|
137
|
+
for (const item of group.series) {
|
|
138
|
+
const categoryColumn = nextColumn;
|
|
139
|
+
const valueColumn = nextColumn + 1;
|
|
140
|
+
independentCategoryColumns.set(item.seriesIndex, {
|
|
141
|
+
column: categoryColumn,
|
|
142
|
+
categories: item.categories
|
|
143
|
+
});
|
|
144
|
+
series.set(item.seriesIndex, {
|
|
145
|
+
nameColumn: valueColumn,
|
|
146
|
+
category: {
|
|
147
|
+
column: categoryColumn,
|
|
148
|
+
pointCount: item.categories.length
|
|
149
|
+
},
|
|
150
|
+
value: { column: valueColumn }
|
|
151
|
+
});
|
|
152
|
+
nextColumn += 2;
|
|
153
|
+
}
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const category = group.kind === "pie" || group.kind === "doughnut" ? axislessCategoryColumns.get(groupIndex) : categoryColumns.get(group.axes.category.name);
|
|
157
|
+
if (category === void 0) throw new Error("Category chart group is missing its workbook category column");
|
|
158
|
+
for (const item of group.series) {
|
|
159
|
+
series.set(item.seriesIndex, {
|
|
160
|
+
nameColumn: nextColumn,
|
|
161
|
+
category: {
|
|
162
|
+
column: category.column,
|
|
163
|
+
pointCount: group.data.categories.length
|
|
164
|
+
},
|
|
165
|
+
value: { column: nextColumn }
|
|
166
|
+
});
|
|
167
|
+
nextColumn += 1;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
categoryColumns,
|
|
172
|
+
axislessCategoryColumns,
|
|
173
|
+
independentCategoryColumns,
|
|
174
|
+
series,
|
|
175
|
+
projectedScatterXAxes,
|
|
176
|
+
nextColumn
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function rangeFormula(column, pointCount) {
|
|
180
|
+
const name = columnName(column);
|
|
181
|
+
return `${sheet}!$${name}$2:$${name}$${pointCount + 1}`;
|
|
182
|
+
}
|
|
183
|
+
function strRef(formula, values) {
|
|
184
|
+
return el("c:strRef", null, el("c:f", null, formula), el("c:strCache", null, el("c:ptCount", { val: values.length }), values.map((value, index) => el("c:pt", { idx: index }, el("c:v", null, value)))));
|
|
185
|
+
}
|
|
186
|
+
function numRef(formula, values, labelFormats) {
|
|
187
|
+
const baseFormatCode = labelFormats?.baseFormatCode ?? "General";
|
|
188
|
+
return el("c:numRef", null, el("c:f", null, formula), el("c:numCache", null, el("c:formatCode", null, baseFormatCode), el("c:ptCount", { val: values.length }), values.flatMap((value, index) => value === null ? [] : [el("c:pt", {
|
|
189
|
+
idx: index,
|
|
190
|
+
formatCode: labelFormats?.pointFormatCodes[index] === baseFormatCode ? void 0 : labelFormats?.pointFormatCodes[index]
|
|
191
|
+
}, el("c:v", null, String(value)))])));
|
|
192
|
+
}
|
|
193
|
+
/** Literal numeric data source; zero-observation custom error bars use zero points. */
|
|
194
|
+
function numLit(values) {
|
|
195
|
+
return el("c:numLit", null, el("c:formatCode", null, "General"), el("c:ptCount", { val: values.length }), values.flatMap((value, index) => value === null ? [] : [el("c:pt", { idx: index }, el("c:v", null, String(value)))]));
|
|
196
|
+
}
|
|
197
|
+
function color(value, theme) {
|
|
198
|
+
return { raw: resolvedColorXml(theme.resolveColor(value)) };
|
|
199
|
+
}
|
|
200
|
+
function chartLine(value, theme) {
|
|
201
|
+
if (value === void 0) return void 0;
|
|
202
|
+
return el("a:ln", { w: pxToEmu(value.width ?? 1) }, el("a:solidFill", null, color(value.color ?? "dk1", theme)), value.dash === void 0 ? void 0 : el("a:prstDash", { val: chartLineDashValues[value.dash] }));
|
|
203
|
+
}
|
|
204
|
+
function markerShapeProperties(value, theme) {
|
|
205
|
+
if (value.fill === void 0 && value.line === void 0) return void 0;
|
|
206
|
+
return el("c:spPr", null, value.fill === void 0 ? void 0 : el("a:solidFill", null, color(value.fill, theme)), value.line === void 0 ? void 0 : chartLine(value.line, theme));
|
|
207
|
+
}
|
|
208
|
+
function chartMarker(value, theme) {
|
|
209
|
+
if (value === void 0 || value === false) return el("c:marker", null, el("c:symbol", { val: "none" }));
|
|
210
|
+
if (value === true) return el("c:marker", null, el("c:symbol", { val: "circle" }));
|
|
211
|
+
return el("c:marker", null, el("c:symbol", { val: value.symbol ?? "circle" }), value.size === void 0 ? void 0 : el("c:size", { val: value.size }), markerShapeProperties(value, theme));
|
|
212
|
+
}
|
|
213
|
+
function shapeProperties(value, theme) {
|
|
214
|
+
if (value === void 0) return void 0;
|
|
215
|
+
return el("c:spPr", null, value === "none" ? el("a:ln", null, el("a:noFill")) : chartLine(value, theme));
|
|
216
|
+
}
|
|
217
|
+
function transparent() {
|
|
218
|
+
return el("c:spPr", null, el("a:noFill"), el("a:ln", null, el("a:noFill")));
|
|
219
|
+
}
|
|
220
|
+
function errorBarChannelKey(seriesIndex, channelDirection, side) {
|
|
221
|
+
return `${seriesIndex}:${channelDirection}:${side}`;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Allocates one workbook column per declared custom error-bar side after the unique
|
|
225
|
+
* `chartCells()` data columns. Those columns can include multiple category and XY ranges,
|
|
226
|
+
* so this function appends after `cells.nextColumn` instead of assuming a single A column.
|
|
227
|
+
* Both the chart writer and the workbook writer consume this mapping so a formula and its
|
|
228
|
+
* cells cannot drift apart. A category custom series always has the channel identity `value`;
|
|
229
|
+
* the writer decides separately whether the native element stores x or y errDir. Null magnitudes
|
|
230
|
+
* keep their original slot through numRef indices.
|
|
231
|
+
*/
|
|
232
|
+
function errorBarChannels(parsed, startColumn) {
|
|
233
|
+
let nextColumn = startColumn;
|
|
234
|
+
const channels = /* @__PURE__ */ new Map();
|
|
235
|
+
const add = (seriesIndex, seriesName, channelDirection, bars, pointCount, axisLabel) => {
|
|
236
|
+
if (bars === void 0 || bars.type !== "custom") return;
|
|
237
|
+
for (const side of ["plus", "minus"]) {
|
|
238
|
+
const values = bars[side];
|
|
239
|
+
if (values === void 0) continue;
|
|
240
|
+
const header = `${seriesName}${axisLabel === "" ? "" : ` ${axisLabel}`} ${side === "plus" ? "+" : "-"}`;
|
|
241
|
+
channels.set(errorBarChannelKey(seriesIndex, channelDirection, side), {
|
|
242
|
+
seriesIndex,
|
|
243
|
+
channelDirection,
|
|
244
|
+
side,
|
|
245
|
+
column: nextColumn,
|
|
246
|
+
pointCount,
|
|
247
|
+
values,
|
|
248
|
+
header
|
|
249
|
+
});
|
|
250
|
+
nextColumn += 1;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
for (const series of parsed.series) {
|
|
254
|
+
if (series.errorBars === void 0) continue;
|
|
255
|
+
if ("x" in series) {
|
|
256
|
+
add(series.seriesIndex, series.name, "x", series.errorBars.x, series.x.length, "X");
|
|
257
|
+
add(series.seriesIndex, series.name, "y", series.errorBars.y, series.y.length, "Y");
|
|
258
|
+
} else add(series.seriesIndex, series.name, "value", series.errorBars, series.values.length, "");
|
|
259
|
+
}
|
|
260
|
+
return channels;
|
|
261
|
+
}
|
|
262
|
+
function errorBarFormula(channel) {
|
|
263
|
+
const column = columnName(channel.column - 1);
|
|
264
|
+
return `${sheet}!$${column}$2:$${column}$${channel.pointCount + 1}`;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Writes one native error-bar element.
|
|
268
|
+
*
|
|
269
|
+
* `channelDirection` selects the author-facing series axis used by the workbook map; category
|
|
270
|
+
* custom bars always use `value` even when their native `errDir` is `y`. `nativeDirection` is
|
|
271
|
+
* the serialized c:errDir: scatters emit their X/Y axis, line emits y, and bar/column/area rely
|
|
272
|
+
* on the documented application default by omitting the element.
|
|
273
|
+
*/
|
|
274
|
+
function errorBarXml(bars, channelDirection, nativeDirection, seriesIndex, channels, theme) {
|
|
275
|
+
const channel = (side) => {
|
|
276
|
+
const result = channels.get(errorBarChannelKey(seriesIndex, channelDirection, side));
|
|
277
|
+
if (result === void 0) throw new Error("Missing workbook channel for a custom error bar");
|
|
278
|
+
return result;
|
|
279
|
+
};
|
|
280
|
+
let plus;
|
|
281
|
+
let minus;
|
|
282
|
+
if (bars.type === "custom") {
|
|
283
|
+
if (bars.plus !== void 0) {
|
|
284
|
+
const values = channel("plus");
|
|
285
|
+
plus = el("c:plus", null, values.values.length === 0 ? numLit(values.values) : numRef(errorBarFormula(values), values.values));
|
|
286
|
+
}
|
|
287
|
+
if (bars.minus !== void 0) {
|
|
288
|
+
const values = channel("minus");
|
|
289
|
+
minus = el("c:minus", null, values.values.length === 0 ? numLit(values.values) : numRef(errorBarFormula(values), values.values));
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return el("c:errBars", null, nativeDirection === void 0 ? void 0 : el("c:errDir", { val: nativeDirection }), el("c:errBarType", { val: bars.include ?? "both" }), el("c:errValType", { val: chartErrorBarValueTypes[bars.type] }), bars.endCap === false ? el("c:noEndCap", { val: true }) : void 0, plus, minus, bars.type === "custom" || bars.type === "standardError" ? void 0 : el("c:val", { val: bars.value }), bars.line === void 0 ? void 0 : el("c:spPr", null, chartLine(bars.line, theme)));
|
|
293
|
+
}
|
|
294
|
+
function categoryLabelFieldExtension(enabled) {
|
|
295
|
+
return el("c:extLst", null, el("c:ext", {
|
|
296
|
+
uri: dataLabelRangeExtensionUri,
|
|
297
|
+
"xmlns:c15": c15Namespace
|
|
298
|
+
}, el("c15:showDataLabelsRange", { val: enabled })));
|
|
299
|
+
}
|
|
300
|
+
function categoryRangeExtension(range) {
|
|
301
|
+
return el("c:extLst", null, el("c:ext", {
|
|
302
|
+
uri: categoryRangeExtensionUri,
|
|
303
|
+
"xmlns:c15": c15Namespace
|
|
304
|
+
}, el("c15:datalabelsRange", null, el("c15:f", null, range.formula), el("c15:dlblRangeCache", null, el("c:ptCount", { val: range.categories.length }), range.categories.map((category, index) => el("c:pt", { idx: index }, el("c:v", null, category)))))));
|
|
305
|
+
}
|
|
306
|
+
function categoryLabelsEnabled(labels) {
|
|
307
|
+
return labels !== void 0 && labels !== false && labels.category === true;
|
|
308
|
+
}
|
|
309
|
+
function dataLabels(group, series, groupIndex, textStyles, theme, categoryRange) {
|
|
310
|
+
const seriesLabels = mergeDataLabels(group.dataLabels, series.dataLabels);
|
|
311
|
+
const hasPosition = group.kind === "column" || group.kind === "bar" || group.kind === "line" || group.kind === "pie" || group.kind === "scatter";
|
|
312
|
+
const hasVisibleContent = (labels) => labels.value === true || labels.percent === true || labels.category === true || labels.xValue === true || labels.seriesName === true;
|
|
313
|
+
const leaderLineSettings = (labels) => {
|
|
314
|
+
if (labels.leaderLines === void 0) return [];
|
|
315
|
+
const visible = hasVisibleContent(labels);
|
|
316
|
+
if (labels.leaderLines === false) return visible ? [el("c:showLeaderLines", { val: false })] : [];
|
|
317
|
+
if (!visible) return [];
|
|
318
|
+
return [el("c:showLeaderLines", { val: true }), el("c:leaderLines", null, typeof labels.leaderLines === "object" ? el("c:spPr", null, chartLine(labels.leaderLines, theme)) : void 0)];
|
|
319
|
+
};
|
|
320
|
+
const settings = (labels, textStyle, includeLeaderLines, categoryField) => [
|
|
321
|
+
labels.numberFormat === void 0 ? void 0 : el("c:numFmt", {
|
|
322
|
+
formatCode: labels.numberFormat,
|
|
323
|
+
sourceLinked: false
|
|
324
|
+
}),
|
|
325
|
+
transparent(),
|
|
326
|
+
raw(textStyle),
|
|
327
|
+
labels.position === void 0 || !hasPosition ? void 0 : el("c:dLblPos", { val: chartDataLabelPositions[labels.position] }),
|
|
328
|
+
el("c:showLegendKey", { val: false }),
|
|
329
|
+
el("c:showVal", { val: labels.value ?? false }),
|
|
330
|
+
el("c:showCatName", { val: categoryRange === void 0 ? (group.kind === "scatter" ? labels.xValue : labels.category) ?? false : false }),
|
|
331
|
+
el("c:showSerName", { val: labels.seriesName ?? false }),
|
|
332
|
+
el("c:showPercent", { val: group.kind === "pie" || group.kind === "doughnut" ? labels.percent ?? false : false }),
|
|
333
|
+
el("c:showBubbleSize", { val: false }),
|
|
334
|
+
labels.separator === void 0 ? void 0 : el("c:separator", null, labels.separator),
|
|
335
|
+
includeLeaderLines ? leaderLineSettings(labels) : void 0,
|
|
336
|
+
categoryField ? categoryLabelFieldExtension(categoryLabelsEnabled(labels)) : void 0
|
|
337
|
+
];
|
|
338
|
+
const groupStyle = textStyles.groupDataLabels?.get(groupIndex);
|
|
339
|
+
const pointBase = seriesLabels === false ? {} : seriesLabels;
|
|
340
|
+
const pointLabels = Object.entries(series.points ?? {}).flatMap(([pointIndex, point]) => {
|
|
341
|
+
if (point.dataLabels === void 0 && point.labelColor === void 0) return [];
|
|
342
|
+
const index = Number(pointIndex);
|
|
343
|
+
const effective = mergeDataLabels(pointBase, point.dataLabels);
|
|
344
|
+
if (effective === false) return [el("c:dLbl", null, el("c:idx", { val: index }), el("c:delete", { val: true }))];
|
|
345
|
+
if (effective === void 0) return [];
|
|
346
|
+
if (point.dataLabels === void 0 && !hasVisibleContent(effective)) return [];
|
|
347
|
+
const style = textStyles.pointLabels?.get(`${series.seriesIndex}:${pointIndex}`) ?? groupStyle;
|
|
348
|
+
return [el("c:dLbl", null, el("c:idx", { val: index }), settings(effective, style, false, categoryRange !== void 0))];
|
|
349
|
+
});
|
|
350
|
+
const base = seriesLabels === false ? pointLabels.length > 0 ? {} : false : seriesLabels ?? (pointLabels.length > 0 ? {} : void 0);
|
|
351
|
+
if (base === void 0) return void 0;
|
|
352
|
+
if (base === false) return el("c:dLbls", null, el("c:delete", { val: true }));
|
|
353
|
+
return el("c:dLbls", null, pointLabels, settings(base, groupStyle, true, categoryRange !== void 0));
|
|
354
|
+
}
|
|
355
|
+
function seriesShape(kind, itemColor, line, theme) {
|
|
356
|
+
if (kind === "line") {
|
|
357
|
+
const stroke = line === void 0 ? itemColor === void 0 ? void 0 : { color: itemColor } : {
|
|
358
|
+
...line,
|
|
359
|
+
...line.color === void 0 && itemColor !== void 0 ? { color: itemColor } : {}
|
|
360
|
+
};
|
|
361
|
+
return stroke === void 0 ? void 0 : el("c:spPr", null, chartLine(stroke, theme));
|
|
362
|
+
}
|
|
363
|
+
if (itemColor === void 0 && line === void 0) return void 0;
|
|
364
|
+
return el("c:spPr", null, itemColor === void 0 ? void 0 : el("a:solidFill", null, color(itemColor, theme)), line === void 0 ? void 0 : chartLine(line, theme));
|
|
365
|
+
}
|
|
366
|
+
function pointShape(kind, point, theme) {
|
|
367
|
+
const line = kind === "line" ? point.line === void 0 ? point.color === void 0 ? void 0 : { color: point.color } : {
|
|
368
|
+
...point.line,
|
|
369
|
+
...point.line.color === void 0 && point.color !== void 0 ? { color: point.color } : {}
|
|
370
|
+
} : point.line;
|
|
371
|
+
if (kind === "line") return line === void 0 ? void 0 : el("c:spPr", null, chartLine(line, theme));
|
|
372
|
+
if (point.color === void 0 && line === void 0) return void 0;
|
|
373
|
+
return el("c:spPr", null, point.color === void 0 ? void 0 : el("a:solidFill", null, color(point.color, theme)), line === void 0 ? void 0 : chartLine(line, theme));
|
|
374
|
+
}
|
|
375
|
+
function trendlineXml(value, theme) {
|
|
376
|
+
const type = chartTrendlineTypeValues[value.type];
|
|
377
|
+
return el("c:trendline", null, value.line === void 0 ? void 0 : el("c:spPr", null, chartLine(value.line, theme)), el("c:trendlineType", { val: type }), value.type === "polynomial" ? el("c:order", { val: value.order }) : void 0, value.type === "movingAverage" ? el("c:period", { val: value.period }) : void 0, value.forward === void 0 ? void 0 : el("c:forward", { val: value.forward }), value.backward === void 0 ? void 0 : el("c:backward", { val: value.backward }), value.type === "linear" || value.type === "exponential" || value.type === "polynomial" ? value.intercept === void 0 ? void 0 : el("c:intercept", { val: value.intercept }) : void 0, value.type === "movingAverage" ? void 0 : value.displayRSquared === void 0 ? void 0 : el("c:dispRSqr", { val: value.displayRSquared }), value.type === "movingAverage" ? void 0 : value.displayEquation === void 0 ? void 0 : el("c:dispEq", { val: value.displayEquation }));
|
|
378
|
+
}
|
|
379
|
+
/** Maps an independent-ring series to its columns for c15 label-range detection. */
|
|
380
|
+
function seriesCells(group, series) {
|
|
381
|
+
if (group.kind !== "scatter" && group.data.kind === "independent-categories") return {
|
|
382
|
+
categoryColumn: series.seriesIndex * 2,
|
|
383
|
+
valueColumn: series.seriesIndex * 2 + 1,
|
|
384
|
+
rows: series.categories.length
|
|
385
|
+
};
|
|
386
|
+
return {
|
|
387
|
+
categoryColumn: 0,
|
|
388
|
+
valueColumn: series.seriesIndex + 1,
|
|
389
|
+
rows: series.categories.length
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
function categoryLabelRange(group, series, cells) {
|
|
393
|
+
if (group.kind !== "doughnut" || group.data.kind !== "independent-categories" || series.categories.length === 0) return;
|
|
394
|
+
const seriesLabels = mergeDataLabels(group.dataLabels, series.dataLabels);
|
|
395
|
+
const pointBase = seriesLabels === false ? {} : seriesLabels;
|
|
396
|
+
const seriesNeedsLabels = categoryLabelsEnabled(seriesLabels);
|
|
397
|
+
const pointNeedsLabels = Object.values(series.points ?? {}).some((point) => categoryLabelsEnabled(mergeDataLabels(pointBase, point.dataLabels)));
|
|
398
|
+
if (!seriesNeedsLabels && !pointNeedsLabels) return void 0;
|
|
399
|
+
const categoryColumn = columnName(cells.categoryColumn);
|
|
400
|
+
return {
|
|
401
|
+
formula: `${sheet}!$${categoryColumn}$2:$${categoryColumn}$${cells.rows + 1}`,
|
|
402
|
+
categories: series.categories
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function chartUsesCategoryLabelRange(parsed) {
|
|
406
|
+
for (const group of parsed.groups) {
|
|
407
|
+
if (group.kind === "scatter") continue;
|
|
408
|
+
if (group.kind !== "doughnut" || group.data.kind !== "independent-categories") continue;
|
|
409
|
+
for (const series of group.series) if (categoryLabelRange(group, series, seriesCells(group, series)) !== void 0) return true;
|
|
410
|
+
}
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
function categoryChartSeries(group, series, seriesCells, groupIndex, textStyles, channels, theme) {
|
|
414
|
+
const category = seriesCells.category;
|
|
415
|
+
const value = seriesCells.value;
|
|
416
|
+
if (category === void 0 || value === void 0) throw new Error("Category chart series is missing workbook columns");
|
|
417
|
+
const categoryRange = categoryLabelRange(group, series, {
|
|
418
|
+
categoryColumn: category.column,
|
|
419
|
+
valueColumn: value.column,
|
|
420
|
+
rows: series.categories.length
|
|
421
|
+
});
|
|
422
|
+
const kind = group.kind;
|
|
423
|
+
const bar = kind === "column" || kind === "bar";
|
|
424
|
+
const lineChart = kind === "line";
|
|
425
|
+
const pie = kind === "pie" || kind === "doughnut";
|
|
426
|
+
const itemShape = seriesShape(kind, series.color, series.line, theme);
|
|
427
|
+
const seriesExplosion = series.explosion ?? (group.kind === "pie" || group.kind === "doughnut" ? group.explosion : void 0);
|
|
428
|
+
const points = Object.entries(series.points ?? {}).flatMap(([pointIndex, point]) => {
|
|
429
|
+
const shape = pointShape(kind, point, theme);
|
|
430
|
+
const marker = lineChart && point.marker !== void 0 ? chartMarker(point.marker, theme) : void 0;
|
|
431
|
+
if (shape === void 0 && marker === void 0 && point.explosion === void 0) return [];
|
|
432
|
+
return [el("c:dPt", null, el("c:idx", { val: Number(pointIndex) }), bar ? el("c:invertIfNegative", { val: false }) : void 0, bar ? el("c:bubble3D", { val: false }) : void 0, marker, point.explosion === void 0 ? void 0 : el("c:explosion", { val: Math.round(point.explosion) }), shape)];
|
|
433
|
+
});
|
|
434
|
+
return el("c:ser", null, el("c:idx", { val: series.seriesIndex }), el("c:order", { val: series.seriesIndex }), el("c:tx", null, strRef(`${sheet}!$${columnName(seriesCells.nameColumn)}$1`, [series.name])), itemShape, bar ? el("c:invertIfNegative", { val: false }) : void 0, lineChart ? chartMarker(series.marker, theme) : void 0, pie && seriesExplosion !== void 0 ? el("c:explosion", { val: Math.round(seriesExplosion) }) : void 0, points, dataLabels(group, series, groupIndex, textStyles, theme, categoryRange), (series.trendlines ?? []).map((trendline) => trendlineXml(trendline, theme)), series.errorBars === void 0 ? void 0 : errorBarXml(series.errorBars, "value", group.kind === "line" ? "y" : void 0, series.seriesIndex, channels, theme), series.values.length === 0 ? void 0 : el("c:cat", null, strRef(rangeFormula(category.column, category.pointCount), series.categories)), series.values.length === 0 ? void 0 : el("c:val", null, numRef(rangeFormula(value.column, category.pointCount), series.values)), lineChart ? el("c:smooth", { val: series.smooth ?? false }) : void 0, categoryRange === void 0 ? void 0 : categoryRangeExtension(categoryRange));
|
|
435
|
+
}
|
|
436
|
+
function scatterMarkerXml(group, series, theme) {
|
|
437
|
+
if (!group.markers || series.marker === false) return el("c:marker", null, el("c:symbol", { val: "none" }));
|
|
438
|
+
if (series.marker === void 0 || series.marker === true) return chartMarker({
|
|
439
|
+
symbol: "circle",
|
|
440
|
+
...series.color === void 0 ? {} : { fill: series.color }
|
|
441
|
+
}, theme);
|
|
442
|
+
return chartMarker({
|
|
443
|
+
...series.marker,
|
|
444
|
+
...series.marker.fill === void 0 && series.color !== void 0 ? { fill: series.color } : {}
|
|
445
|
+
}, theme);
|
|
446
|
+
}
|
|
447
|
+
function scatterChartSeries(group, series, seriesCells, groupIndex, textStyles, channels, theme) {
|
|
448
|
+
if (seriesCells.x === void 0 || seriesCells.y === void 0) throw new Error("Scatter chart series is missing workbook columns");
|
|
449
|
+
const itemShape = group.line === void 0 || group.line === false ? el("c:spPr", null, el("a:ln", null, el("a:noFill"))) : seriesShape("line", series.color, series.line, theme);
|
|
450
|
+
const points = Object.entries(series.points ?? {}).flatMap(([pointIndex, point]) => {
|
|
451
|
+
const shape = pointShape("scatter", point, theme);
|
|
452
|
+
const marker = point.marker === void 0 ? void 0 : chartMarker(point.marker, theme);
|
|
453
|
+
if (shape === void 0 && marker === void 0) return [];
|
|
454
|
+
return [el("c:dPt", null, el("c:idx", { val: Number(pointIndex) }), marker, shape)];
|
|
455
|
+
});
|
|
456
|
+
return el("c:ser", null, el("c:idx", { val: series.seriesIndex }), el("c:order", { val: series.seriesIndex }), el("c:tx", null, strRef(`${sheet}!$${columnName(seriesCells.nameColumn)}$1`, [series.name])), itemShape, scatterMarkerXml(group, series, theme), points, dataLabels(group, series, groupIndex, textStyles, theme), (series.trendlines ?? []).map((trendline) => trendlineXml(trendline, theme)), series.errorBars?.x === void 0 ? void 0 : errorBarXml(series.errorBars.x, "x", "x", series.seriesIndex, channels, theme), series.errorBars?.y === void 0 ? void 0 : errorBarXml(series.errorBars.y, "y", "y", series.seriesIndex, channels, theme), series.x.length === 0 ? void 0 : el("c:xVal", null, numRef(rangeFormula(seriesCells.x.column, seriesCells.x.pointCount), series.x, seriesCells.x.labelFormats)), series.x.length === 0 ? void 0 : el("c:yVal", null, numRef(rangeFormula(seriesCells.y.column, seriesCells.y.pointCount), series.y)), group.line === "smooth" || group.line === "straight" ? el("c:smooth", { val: group.line === "smooth" }) : void 0);
|
|
457
|
+
}
|
|
458
|
+
function assertNever(value) {
|
|
459
|
+
throw new Error(`Unhandled chart model variant: ${JSON.stringify(value)}`);
|
|
460
|
+
}
|
|
461
|
+
function grouping(stacking) {
|
|
462
|
+
switch (stacking) {
|
|
463
|
+
case "clustered": return "clustered";
|
|
464
|
+
case "standard": return "standard";
|
|
465
|
+
case "stacked": return "stacked";
|
|
466
|
+
case "percent": return "percentStacked";
|
|
467
|
+
default: return assertNever(stacking);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
function scatterStyle(group) {
|
|
471
|
+
if (group.line === "smooth") return group.markers ? "smoothMarker" : "smooth";
|
|
472
|
+
if (group.line === "straight") return group.markers ? "lineMarker" : "line";
|
|
473
|
+
return "marker";
|
|
474
|
+
}
|
|
475
|
+
function chartGroup(group, groupIndex, cells, textStyles, channels, theme) {
|
|
476
|
+
const seriesCell = (seriesIndex) => {
|
|
477
|
+
const value = cells.series.get(seriesIndex);
|
|
478
|
+
if (value === void 0) throw new Error(`Chart series ${seriesIndex} is missing workbook columns`);
|
|
479
|
+
return value;
|
|
480
|
+
};
|
|
481
|
+
switch (group.kind) {
|
|
482
|
+
case "scatter": {
|
|
483
|
+
const items = group.series.map((item) => scatterChartSeries(group, item, seriesCell(item.seriesIndex), groupIndex, textStyles, channels, theme));
|
|
484
|
+
return el("c:scatterChart", null, el("c:scatterStyle", { val: scatterStyle(group) }), el("c:varyColors", { val: false }), items, el("c:axId", { val: group.axes.x.id }), el("c:axId", { val: group.axes.y.id }));
|
|
485
|
+
}
|
|
486
|
+
case "column":
|
|
487
|
+
case "bar": {
|
|
488
|
+
const items = group.series.map((item) => categoryChartSeries(group, item, seriesCell(item.seriesIndex), groupIndex, textStyles, channels, theme));
|
|
489
|
+
const axes = [el("c:axId", { val: group.axes.category.id }), el("c:axId", { val: group.axes.value.id })];
|
|
490
|
+
return el("c:barChart", null, el("c:barDir", { val: group.kind === "bar" ? "bar" : "col" }), el("c:grouping", { val: grouping(group.stacking) }), el("c:varyColors", { val: false }), items, el("c:gapWidth", { val: Math.round(group.gapWidth) }), group.overlap !== void 0 ? el("c:overlap", { val: Math.round(group.overlap) }) : group.stacking === "clustered" ? void 0 : el("c:overlap", { val: 100 }), axes);
|
|
491
|
+
}
|
|
492
|
+
case "line": {
|
|
493
|
+
const items = group.series.map((item) => categoryChartSeries(group, item, seriesCell(item.seriesIndex), groupIndex, textStyles, channels, theme));
|
|
494
|
+
const axes = [el("c:axId", { val: group.axes.category.id }), el("c:axId", { val: group.axes.value.id })];
|
|
495
|
+
return el("c:lineChart", null, el("c:grouping", { val: grouping(group.stacking) }), el("c:varyColors", { val: false }), items, el("c:marker", { val: true }), axes);
|
|
496
|
+
}
|
|
497
|
+
case "area": {
|
|
498
|
+
const items = group.series.map((item) => categoryChartSeries(group, item, seriesCell(item.seriesIndex), groupIndex, textStyles, channels, theme));
|
|
499
|
+
const axes = [el("c:axId", { val: group.axes.category.id }), el("c:axId", { val: group.axes.value.id })];
|
|
500
|
+
return el("c:areaChart", null, el("c:grouping", { val: grouping(group.stacking) }), el("c:varyColors", { val: false }), items, axes);
|
|
501
|
+
}
|
|
502
|
+
case "pie":
|
|
503
|
+
case "doughnut": {
|
|
504
|
+
const items = group.series.map((item) => categoryChartSeries(group, item, seriesCell(item.seriesIndex), groupIndex, textStyles, channels, theme));
|
|
505
|
+
return el(group.kind === "pie" ? "c:pieChart" : "c:doughnutChart", null, el("c:varyColors", { val: true }), items, el("c:firstSliceAng", { val: group.firstSliceAngle }), group.kind === "doughnut" ? el("c:holeSize", { val: group.holeSize }) : void 0);
|
|
506
|
+
}
|
|
507
|
+
default: return assertNever(group);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
function lineXml(value, theme) {
|
|
511
|
+
if (value === void 0 || value === true) return void 0;
|
|
512
|
+
if (value === false) return el("c:spPr", null, el("a:ln", null, el("a:noFill")));
|
|
513
|
+
return shapeProperties(value, theme);
|
|
514
|
+
}
|
|
515
|
+
function gridlines(value, kind, theme) {
|
|
516
|
+
const setting = kind === "major" ? value?.gridlines : value?.minorGridlines;
|
|
517
|
+
if (setting === void 0 || setting === false) return void 0;
|
|
518
|
+
return el(kind === "major" ? "c:majorGridlines" : "c:minorGridlines", null, setting === true ? void 0 : shapeProperties(setting, theme));
|
|
519
|
+
}
|
|
520
|
+
function axisTitle(spec, textStyles, name) {
|
|
521
|
+
return raw(textStyles.axisTitles?.get(name));
|
|
522
|
+
}
|
|
523
|
+
function axisScaling(spec, valueAxis) {
|
|
524
|
+
const valueSpec = valueAxis ? spec : void 0;
|
|
525
|
+
return el("c:scaling", null, valueSpec?.logBase === void 0 ? void 0 : el("c:logBase", { val: valueSpec.logBase }), el("c:orientation", { val: spec.reversed === true ? "maxMin" : "minMax" }), valueSpec?.max === void 0 ? void 0 : el("c:max", { val: valueSpec.max }), valueSpec?.min === void 0 ? void 0 : el("c:min", { val: valueSpec.min }));
|
|
526
|
+
}
|
|
527
|
+
function axisCrossing(crossing) {
|
|
528
|
+
return crossing.kind === "crossesAt" ? el("c:crossesAt", { val: crossing.value }) : el("c:crosses", { val: crossing.value });
|
|
529
|
+
}
|
|
530
|
+
function axisCrossBetween(parsed, axis) {
|
|
531
|
+
let categoryUse = false;
|
|
532
|
+
let areaOnly = true;
|
|
533
|
+
for (const group of parsed.groups) {
|
|
534
|
+
if (group.kind === "scatter" || group.kind === "pie" || group.kind === "doughnut") continue;
|
|
535
|
+
if (group.axes.value !== axis) continue;
|
|
536
|
+
categoryUse = true;
|
|
537
|
+
if (group.kind !== "area") areaOnly = false;
|
|
538
|
+
}
|
|
539
|
+
if (!categoryUse) return "midCat";
|
|
540
|
+
return areaOnly ? "midCat" : "between";
|
|
541
|
+
}
|
|
542
|
+
function axisXml(parsed, axis, projectedScatterXAxes, textStyles, theme) {
|
|
543
|
+
switch (axis.kind) {
|
|
544
|
+
case "category": {
|
|
545
|
+
const spec = axis.spec;
|
|
546
|
+
return el("c:catAx", null, el("c:axId", { val: axis.id }), axisScaling(spec, false), el("c:delete", { val: spec.visible === false }), el("c:axPos", { val: chartAxisPositionCodes[axis.position] }), gridlines(spec, "major", theme), gridlines(spec, "minor", theme), axisTitle(spec, textStyles, axis.name), el("c:numFmt", {
|
|
547
|
+
formatCode: "General",
|
|
548
|
+
sourceLinked: true
|
|
549
|
+
}), el("c:majorTickMark", { val: spec.majorTickMark ?? "none" }), el("c:minorTickMark", { val: spec.minorTickMark ?? "none" }), el("c:tickLblPos", { val: spec.tickLabelPosition ?? "nextTo" }), lineXml(spec.line, theme), raw(textStyles.axisStyles?.get(axis.name)), el("c:crossAx", { val: axis.crossAxisId }), axisCrossing(axis.crossing), [
|
|
550
|
+
el("c:auto", { val: true }),
|
|
551
|
+
el("c:lblAlgn", { val: "ctr" }),
|
|
552
|
+
el("c:lblOffset", { val: 100 }),
|
|
553
|
+
el("c:noMultiLvlLbl", { val: false })
|
|
554
|
+
]);
|
|
555
|
+
}
|
|
556
|
+
case "value": {
|
|
557
|
+
const spec = axis.spec;
|
|
558
|
+
const isolateDefaultXFormat = spec.numberFormat === void 0 && projectedScatterXAxes.has(axis.id);
|
|
559
|
+
return el("c:valAx", null, el("c:axId", { val: axis.id }), axisScaling(spec, true), el("c:delete", { val: spec.visible === false }), el("c:axPos", { val: chartAxisPositionCodes[axis.position] }), gridlines(spec, "major", theme), gridlines(spec, "minor", theme), axisTitle(spec, textStyles, axis.name), el("c:numFmt", {
|
|
560
|
+
formatCode: isolateDefaultXFormat ? "General" : spec.numberFormat ?? "General",
|
|
561
|
+
sourceLinked: spec.numberFormat === void 0 && !isolateDefaultXFormat
|
|
562
|
+
}), el("c:majorTickMark", { val: spec.majorTickMark ?? "none" }), el("c:minorTickMark", { val: spec.minorTickMark ?? "none" }), el("c:tickLblPos", { val: spec.tickLabelPosition ?? "nextTo" }), lineXml(spec.line, theme), raw(textStyles.axisStyles?.get(axis.name)), el("c:crossAx", { val: axis.crossAxisId }), axisCrossing(axis.crossing), [
|
|
563
|
+
el("c:crossBetween", { val: axisCrossBetween(parsed, axis) }),
|
|
564
|
+
spec.majorUnit === void 0 ? void 0 : el("c:majorUnit", { val: spec.majorUnit }),
|
|
565
|
+
spec.minorUnit === void 0 ? void 0 : el("c:minorUnit", { val: spec.minorUnit })
|
|
566
|
+
]);
|
|
567
|
+
}
|
|
568
|
+
default: return assertNever(axis);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
function axes(parsed, cells, textStyles, theme) {
|
|
572
|
+
return parsed.axes.map((axis) => axisXml(parsed, axis, cells.projectedScatterXAxes, textStyles, theme));
|
|
573
|
+
}
|
|
574
|
+
function independentLegendEntries(parsed) {
|
|
575
|
+
if (parsed.groups.length !== 1) return [];
|
|
576
|
+
const group = parsed.groups[0];
|
|
577
|
+
if (group.kind !== "doughnut" || group.data.kind !== "independent-categories") return [];
|
|
578
|
+
const first = group.series[0];
|
|
579
|
+
if (first === void 0) return [];
|
|
580
|
+
const firstCount = first.categories.length;
|
|
581
|
+
const maximumCount = Math.max(firstCount, ...group.series.map((series) => series.categories.length));
|
|
582
|
+
return Array.from({ length: Math.max(0, maximumCount - firstCount) }, (_, offset) => el("c:legendEntry", null, el("c:idx", { val: firstCount + offset }), el("c:delete", { val: true })));
|
|
583
|
+
}
|
|
584
|
+
function plotLayout(parsed, box) {
|
|
585
|
+
const area = parsed.plotArea;
|
|
586
|
+
if (area === void 0) return el("c:layout");
|
|
587
|
+
const fraction = (value, total) => Math.round(value / total * 1e6) / 1e6;
|
|
588
|
+
return el("c:layout", null, el("c:manualLayout", null, el("c:layoutTarget", { val: "inner" }), el("c:xMode", { val: "edge" }), el("c:yMode", { val: "edge" }), el("c:x", { val: fraction(area.left, box.width) }), el("c:y", { val: fraction(area.top, box.height) }), el("c:w", { val: fraction(area.width, box.width) }), el("c:h", { val: fraction(area.height, box.height) })));
|
|
589
|
+
}
|
|
590
|
+
function chartPartXml(parsed, box, relatedRelationshipId, textStyles, theme) {
|
|
591
|
+
const chartLang = (typeof parsed.style?.lang === "string" ? parsed.style.lang : void 0) ?? theme.textStyle.lang ?? "en-US";
|
|
592
|
+
const cells = chartCells(parsed);
|
|
593
|
+
const channels = errorBarChannels(parsed, cells.nextColumn + 1);
|
|
594
|
+
return serialize(el("c:chartSpace", {
|
|
595
|
+
"xmlns:c": chartNamespace,
|
|
596
|
+
"xmlns:a": drawingNamespace,
|
|
597
|
+
"xmlns:r": relationshipNamespace
|
|
598
|
+
}, el("c:date1904", { val: false }), el("c:lang", { val: chartLang }), el("c:roundedCorners", { val: false }), el("c:chart", null, raw(textStyles.title), el("c:autoTitleDeleted", { val: parsed.title === void 0 }), el("c:plotArea", null, plotLayout(parsed, box), parsed.groups.map((group, groupIndex) => chartGroup(group, groupIndex, cells, textStyles, channels, theme)), axes(parsed, cells, textStyles, theme), transparent()), parsed.legend === void 0 || parsed.legend === false ? void 0 : el("c:legend", null, el("c:legendPos", { val: chartLegendPositions[parsed.legend] }), independentLegendEntries(parsed), el("c:overlay", { val: false })), el("c:plotVisOnly", { val: true }), parsed.displayBlanksAs === void 0 ? void 0 : el("c:dispBlanksAs", { val: parsed.displayBlanksAs })), transparent(), raw(textStyles.chart), el("c:externalData", { "r:id": relatedRelationshipId }, el("c:autoUpdate", { val: false }))));
|
|
599
|
+
}
|
|
600
|
+
function chartFrameXml(id, name, box, relationshipId, link, placeholder) {
|
|
601
|
+
const linkAttributes = {
|
|
602
|
+
...link?.relationshipId === void 0 ? {} : { "r:id": link.relationshipId },
|
|
603
|
+
...link?.action === void 0 ? {} : { action: link.action }
|
|
604
|
+
};
|
|
605
|
+
return serializeFragment(el("p:graphicFrame", null, el("p:nvGraphicFramePr", null, el("p:cNvPr", {
|
|
606
|
+
id,
|
|
607
|
+
name
|
|
608
|
+
}, link === void 0 ? void 0 : el("a:hlinkClick", linkAttributes)), placeholder === void 0 ? el("p:cNvGraphicFramePr") : el("p:cNvGraphicFramePr", null, el("a:graphicFrameLocks", { noGrp: "1" })), placeholder === void 0 ? el("p:nvPr") : el("p:nvPr", null, raw(placeholderRefXml(placeholder)))), el("p:xfrm", null, el("a:off", {
|
|
609
|
+
x: pxToEmu(box.x),
|
|
610
|
+
y: pxToEmu(box.y)
|
|
611
|
+
}), el("a:ext", {
|
|
612
|
+
cx: pxToEmu(box.width),
|
|
613
|
+
cy: pxToEmu(box.height)
|
|
614
|
+
})), el("a:graphic", null, el("a:graphicData", { uri: chartNamespace }, el("c:chart", {
|
|
615
|
+
"xmlns:c": chartNamespace,
|
|
616
|
+
"xmlns:r": relationshipNamespace,
|
|
617
|
+
"r:id": relationshipId
|
|
618
|
+
})))));
|
|
619
|
+
}
|
|
620
|
+
function inlineString(reference, value) {
|
|
621
|
+
return el("c", {
|
|
622
|
+
r: reference,
|
|
623
|
+
t: "inlineStr"
|
|
624
|
+
}, el("is", null, el("t", null, value)));
|
|
625
|
+
}
|
|
626
|
+
function chartWorkbook(parsed) {
|
|
627
|
+
const spreadsheet = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
|
628
|
+
const officeRelationships = relationshipNamespace;
|
|
629
|
+
const cells = chartCells(parsed);
|
|
630
|
+
const channels = [...errorBarChannels(parsed, cells.nextColumn + 1).values()];
|
|
631
|
+
const xNumberFormats = [...new Set([...cells.series.values()].flatMap((item) => item.x?.labelFormats.pointFormatCodes ?? []))].filter((formatCode) => formatCode !== "General");
|
|
632
|
+
const numberFormatIds = new Map(xNumberFormats.map((formatCode, index) => [formatCode, 164 + index]));
|
|
633
|
+
const numberFormatStyleIndices = new Map(xNumberFormats.map((formatCode, index) => [formatCode, index + 1]));
|
|
634
|
+
const independent = parsed.groups.length === 1 && parsed.groups[0].kind === "doughnut" && parsed.groups[0].data.kind === "independent-categories";
|
|
635
|
+
const headerCells = [inlineString("A1", " ")];
|
|
636
|
+
if (independent) for (const item of parsed.series) {
|
|
637
|
+
const itemCells = cells.series.get(item.seriesIndex);
|
|
638
|
+
if (itemCells?.value === void 0) throw new Error(`Chart series ${item.seriesIndex} is missing workbook columns`);
|
|
639
|
+
headerCells.push(inlineString(`${columnName(itemCells.value.column)}1`, item.name));
|
|
640
|
+
}
|
|
641
|
+
else {
|
|
642
|
+
for (const { column } of [...cells.categoryColumns.values(), ...cells.axislessCategoryColumns.values()]) if (column !== 0) headerCells.push(inlineString(`${columnName(column)}1`, " "));
|
|
643
|
+
for (const group of parsed.groups) for (const series of group.series) {
|
|
644
|
+
const item = cells.series.get(series.seriesIndex);
|
|
645
|
+
if (item === void 0) throw new Error(`Chart series ${series.seriesIndex} is missing workbook columns`);
|
|
646
|
+
headerCells.push(inlineString(`${columnName(item.nameColumn)}1`, series.name));
|
|
647
|
+
if (group.kind === "scatter" && item.y !== void 0) headerCells.push(inlineString(`${columnName(item.y.column)}1`, "Y"));
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
for (const channel of channels) headerCells.push(inlineString(`${columnName(channel.column - 1)}1`, channel.header));
|
|
651
|
+
const header = el("row", { r: 1 }, headerCells);
|
|
652
|
+
let rowXml;
|
|
653
|
+
if (independent) {
|
|
654
|
+
const rows = [];
|
|
655
|
+
const series = parsed.series;
|
|
656
|
+
const rowCount = Math.max(0, ...series.map((item) => item.categories.length));
|
|
657
|
+
for (let row = 0; row < rowCount; row += 1) rows.push([]);
|
|
658
|
+
for (const item of series) {
|
|
659
|
+
const itemCells = cells.series.get(item.seriesIndex);
|
|
660
|
+
if (itemCells?.category === void 0 || itemCells.value === void 0) throw new Error(`Chart series ${item.seriesIndex} is missing workbook columns`);
|
|
661
|
+
for (const [row, category] of item.categories.entries()) {
|
|
662
|
+
rows[row].push(inlineString(`${columnName(itemCells.category.column)}${row + 2}`, category));
|
|
663
|
+
const value = item.values[row];
|
|
664
|
+
if (value !== null && value !== void 0) rows[row].push(el("c", { r: `${columnName(itemCells.value.column)}${row + 2}` }, el("v", null, String(value))));
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
rowXml = rows.map((items, index) => el("row", { r: index + 2 }, items));
|
|
668
|
+
} else {
|
|
669
|
+
const rows = /* @__PURE__ */ new Map();
|
|
670
|
+
const addCell = (row, cell) => {
|
|
671
|
+
if (cell === void 0) return;
|
|
672
|
+
const items = rows.get(row);
|
|
673
|
+
if (items === void 0) rows.set(row, [cell]);
|
|
674
|
+
else items.push(cell);
|
|
675
|
+
};
|
|
676
|
+
const categoryRanges = [...cells.categoryColumns.values(), ...cells.axislessCategoryColumns.values()];
|
|
677
|
+
for (const { column, categories } of categoryRanges) for (const [index, category] of categories.entries()) {
|
|
678
|
+
const row = index + 2;
|
|
679
|
+
addCell(row, inlineString(`${columnName(column)}${row}`, category));
|
|
680
|
+
}
|
|
681
|
+
for (const group of parsed.groups) for (const series of group.series) {
|
|
682
|
+
const item = cells.series.get(series.seriesIndex);
|
|
683
|
+
if (item === void 0) continue;
|
|
684
|
+
if (group.kind === "scatter") {
|
|
685
|
+
const scatter = series;
|
|
686
|
+
for (let index = 0; index < scatter.x.length; index += 1) {
|
|
687
|
+
const row = index + 2;
|
|
688
|
+
const x = scatter.x[index];
|
|
689
|
+
const y = scatter.y[index];
|
|
690
|
+
if (item.x !== void 0) {
|
|
691
|
+
const reference = `${columnName(item.x.column)}${row}`;
|
|
692
|
+
const formatCode = item.x.labelFormats.pointFormatCodes[index] ?? "General";
|
|
693
|
+
const styleIndex = numberFormatStyleIndices.get(formatCode);
|
|
694
|
+
if (x !== null && x !== void 0) addCell(row, el("c", {
|
|
695
|
+
r: reference,
|
|
696
|
+
s: styleIndex
|
|
697
|
+
}, el("v", null, String(x))));
|
|
698
|
+
else if (styleIndex !== void 0) addCell(row, el("c", {
|
|
699
|
+
r: reference,
|
|
700
|
+
s: styleIndex
|
|
701
|
+
}));
|
|
702
|
+
}
|
|
703
|
+
if (y !== null && y !== void 0 && item.y !== void 0) addCell(row, el("c", { r: `${columnName(item.y.column)}${row}` }, el("v", null, String(y))));
|
|
704
|
+
}
|
|
705
|
+
continue;
|
|
706
|
+
}
|
|
707
|
+
const category = series;
|
|
708
|
+
for (let index = 0; index < category.values.length; index += 1) {
|
|
709
|
+
const value = category.values[index];
|
|
710
|
+
if (value === null || value === void 0 || item.value === void 0) continue;
|
|
711
|
+
const row = index + 2;
|
|
712
|
+
addCell(row, el("c", { r: `${columnName(item.value.column)}${row}` }, el("v", null, String(value))));
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
for (const channel of channels) for (let index = 0; index < channel.pointCount; index += 1) {
|
|
716
|
+
const value = channel.values[index];
|
|
717
|
+
if (value === null || value === void 0) continue;
|
|
718
|
+
addCell(index + 2, el("c", { r: `${columnName(channel.column - 1)}${index + 2}` }, el("v", null, String(value))));
|
|
719
|
+
}
|
|
720
|
+
rowXml = [...rows.entries()].sort(([left], [right]) => left - right).map(([row, items]) => el("row", { r: row }, items));
|
|
721
|
+
}
|
|
722
|
+
const parts = {
|
|
723
|
+
"[Content_Types].xml": el("Types", { xmlns: "http://schemas.openxmlformats.org/package/2006/content-types" }, el("Default", {
|
|
724
|
+
Extension: "rels",
|
|
725
|
+
ContentType: "application/vnd.openxmlformats-package.relationships+xml"
|
|
726
|
+
}), el("Default", {
|
|
727
|
+
Extension: "xml",
|
|
728
|
+
ContentType: "application/xml"
|
|
729
|
+
}), el("Override", {
|
|
730
|
+
PartName: "/xl/workbook.xml",
|
|
731
|
+
ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"
|
|
732
|
+
}), el("Override", {
|
|
733
|
+
PartName: "/xl/worksheets/sheet1.xml",
|
|
734
|
+
ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"
|
|
735
|
+
}), el("Override", {
|
|
736
|
+
PartName: "/xl/styles.xml",
|
|
737
|
+
ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"
|
|
738
|
+
})),
|
|
739
|
+
"_rels/.rels": el("Relationships", { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" }, el("Relationship", {
|
|
740
|
+
Id: "rId1",
|
|
741
|
+
Type: `${officeRelationships}/officeDocument`,
|
|
742
|
+
Target: "xl/workbook.xml"
|
|
743
|
+
})),
|
|
744
|
+
"xl/workbook.xml": el("workbook", {
|
|
745
|
+
xmlns: spreadsheet,
|
|
746
|
+
"xmlns:r": officeRelationships
|
|
747
|
+
}, el("sheets", null, el("sheet", {
|
|
748
|
+
name: sheet,
|
|
749
|
+
sheetId: 1,
|
|
750
|
+
"r:id": "rId1"
|
|
751
|
+
}))),
|
|
752
|
+
"xl/_rels/workbook.xml.rels": el("Relationships", { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" }, el("Relationship", {
|
|
753
|
+
Id: "rId1",
|
|
754
|
+
Type: `${officeRelationships}/worksheet`,
|
|
755
|
+
Target: "worksheets/sheet1.xml"
|
|
756
|
+
}), el("Relationship", {
|
|
757
|
+
Id: "rId2",
|
|
758
|
+
Type: `${officeRelationships}/styles`,
|
|
759
|
+
Target: "styles.xml"
|
|
760
|
+
})),
|
|
761
|
+
"xl/worksheets/sheet1.xml": el("worksheet", { xmlns: spreadsheet }, el("sheetData", null, header, rowXml)),
|
|
762
|
+
"xl/styles.xml": el("styleSheet", { xmlns: spreadsheet }, xNumberFormats.length === 0 ? void 0 : el("numFmts", { count: xNumberFormats.length }, xNumberFormats.map((formatCode) => el("numFmt", {
|
|
763
|
+
numFmtId: numberFormatIds.get(formatCode),
|
|
764
|
+
formatCode
|
|
765
|
+
}))), el("fonts", { count: 1 }, el("font", null, el("sz", { val: 11 }), el("name", { val: "Calibri" }))), el("fills", { count: 2 }, el("fill", null, el("patternFill", { patternType: "none" })), el("fill", null, el("patternFill", { patternType: "gray125" }))), el("borders", { count: 1 }, el("border", null, el("left"), el("right"), el("top"), el("bottom"), el("diagonal"))), el("cellStyleXfs", { count: 1 }, el("xf", {
|
|
766
|
+
numFmtId: 0,
|
|
767
|
+
fontId: 0,
|
|
768
|
+
fillId: 0,
|
|
769
|
+
borderId: 0
|
|
770
|
+
})), el("cellXfs", { count: xNumberFormats.length + 1 }, el("xf", {
|
|
771
|
+
numFmtId: 0,
|
|
772
|
+
fontId: 0,
|
|
773
|
+
fillId: 0,
|
|
774
|
+
borderId: 0,
|
|
775
|
+
xfId: 0
|
|
776
|
+
}), xNumberFormats.map((formatCode) => el("xf", {
|
|
777
|
+
numFmtId: numberFormatIds.get(formatCode),
|
|
778
|
+
fontId: 0,
|
|
779
|
+
fillId: 0,
|
|
780
|
+
borderId: 0,
|
|
781
|
+
xfId: 0,
|
|
782
|
+
applyNumberFormat: true
|
|
783
|
+
}))))
|
|
784
|
+
};
|
|
785
|
+
const mtime = /* @__PURE__ */ new Date("2020-01-01T00:00:00Z");
|
|
786
|
+
return zipSync(Object.fromEntries(Object.entries(parts).map(([path, xml]) => [path, [strToU8(serialize(xml)), { mtime }]])));
|
|
787
|
+
}
|
|
788
|
+
export { chartFrameXml, chartPartXml, chartUsesCategoryLabelRange, chartWorkbook };
|