@office-open/core 0.10.15 → 0.12.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.
Files changed (93) hide show
  1. package/README.md +2 -1
  2. package/dist/chart/index.d.mts +2 -2
  3. package/dist/chart/index.mjs +2 -2
  4. package/dist/chart-DED4tXC9.mjs +2325 -0
  5. package/dist/chart-DED4tXC9.mjs.map +1 -0
  6. package/dist/color-mapping-CFF0vRSe.mjs +117 -0
  7. package/dist/color-mapping-CFF0vRSe.mjs.map +1 -0
  8. package/dist/data-type-CZMKVaaT.d.mts.map +1 -1
  9. package/dist/descriptor/index.d.mts +2 -2
  10. package/dist/descriptor/index.mjs +1 -1
  11. package/dist/{descriptor-BjNkn5jo.mjs → descriptor-BqaNZrrZ.mjs} +43 -11
  12. package/dist/{descriptor-BjNkn5jo.mjs.map → descriptor-BqaNZrrZ.mjs.map} +1 -1
  13. package/dist/drawing/index.d.mts +2 -0
  14. package/dist/drawing/index.mjs +2 -0
  15. package/dist/{drawingml-sj1J3lb0.mjs → drawing-BCAyrCCw.mjs} +4456 -3452
  16. package/dist/drawing-BCAyrCCw.mjs.map +1 -0
  17. package/dist/{converters-C_Y2QX1w.mjs → ext-uri-BHBcIrW7.mjs} +742 -45
  18. package/dist/ext-uri-BHBcIrW7.mjs.map +1 -0
  19. package/dist/index-BAxlDUQ1.d.mts +590 -0
  20. package/dist/index-BAxlDUQ1.d.mts.map +1 -0
  21. package/dist/index-BP541uS-.d.mts +489 -0
  22. package/dist/index-BP541uS-.d.mts.map +1 -0
  23. package/dist/{index-BVK2dv6C.d.mts → index-BQLIofaF.d.mts} +10 -4
  24. package/dist/index-BQLIofaF.d.mts.map +1 -0
  25. package/dist/{index-k8WKLXnA.d.mts → index-CaNwM5_e.d.mts} +19 -20
  26. package/dist/index-CaNwM5_e.d.mts.map +1 -0
  27. package/dist/index-DPkf_CtG.d.mts +1578 -0
  28. package/dist/index-DPkf_CtG.d.mts.map +1 -0
  29. package/dist/index-DcukVskh.d.mts +31 -0
  30. package/dist/index-DcukVskh.d.mts.map +1 -0
  31. package/dist/index-Di6XPdGl.d.mts +322 -0
  32. package/dist/index-Di6XPdGl.d.mts.map +1 -0
  33. package/dist/index-L6AXewfV.d.mts +872 -0
  34. package/dist/index-L6AXewfV.d.mts.map +1 -0
  35. package/dist/index.d.mts +294 -30
  36. package/dist/index.d.mts.map +1 -1
  37. package/dist/index.mjs +1327 -112
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/{output-D_G_JR_8.d.mts → output-yyxdkG0C.d.mts} +2 -3
  40. package/dist/output-yyxdkG0C.d.mts.map +1 -0
  41. package/dist/patch/index.d.mts +2 -2
  42. package/dist/patch/index.mjs +2 -2
  43. package/dist/{patch-BmRfghOo.mjs → patch-AkQY17CD.mjs} +73 -28
  44. package/dist/patch-AkQY17CD.mjs.map +1 -0
  45. package/dist/smartart/index.d.mts +2 -2
  46. package/dist/smartart/index.mjs +2 -2
  47. package/dist/smartart-n1kYJ6Jg.mjs +1650 -0
  48. package/dist/smartart-n1kYJ6Jg.mjs.map +1 -0
  49. package/dist/style-matrix-B6jhPAT3.mjs +123 -0
  50. package/dist/style-matrix-B6jhPAT3.mjs.map +1 -0
  51. package/dist/theme/index.d.mts +4 -2
  52. package/dist/theme/index.mjs +4 -2
  53. package/dist/theme-BKnXRmvn.mjs +426 -0
  54. package/dist/theme-BKnXRmvn.mjs.map +1 -0
  55. package/dist/theme-options-kO89NUEX.d.mts +109 -0
  56. package/dist/theme-options-kO89NUEX.d.mts.map +1 -0
  57. package/dist/util/index.d.mts +3 -3
  58. package/dist/util/index.mjs +3 -3
  59. package/dist/{util-Tq9PSjK0.mjs → util-ptE16MEk.mjs} +237 -459
  60. package/dist/util-ptE16MEk.mjs.map +1 -0
  61. package/dist/{values-8di32lIe.d.mts → values-BECDm4zr.d.mts} +17 -31
  62. package/dist/values-BECDm4zr.d.mts.map +1 -0
  63. package/dist/vector/index.d.mts +2 -0
  64. package/dist/vector/index.mjs +2 -0
  65. package/dist/vector-DhLGZjP5.mjs +3049 -0
  66. package/dist/vector-DhLGZjP5.mjs.map +1 -0
  67. package/package.json +16 -8
  68. package/dist/chart-DIGJna_6.mjs +0 -582
  69. package/dist/chart-DIGJna_6.mjs.map +0 -1
  70. package/dist/converters-C_Y2QX1w.mjs.map +0 -1
  71. package/dist/drawingml/index.d.mts +0 -2
  72. package/dist/drawingml/index.mjs +0 -2
  73. package/dist/drawingml-sj1J3lb0.mjs.map +0 -1
  74. package/dist/index-BVK2dv6C.d.mts.map +0 -1
  75. package/dist/index-BfHfKuKy.d.mts +0 -275
  76. package/dist/index-BfHfKuKy.d.mts.map +0 -1
  77. package/dist/index-CE53SwpZ.d.mts +0 -1463
  78. package/dist/index-CE53SwpZ.d.mts.map +0 -1
  79. package/dist/index-D6VE-MnJ.d.mts +0 -43
  80. package/dist/index-D6VE-MnJ.d.mts.map +0 -1
  81. package/dist/index-DE4CLElr.d.mts +0 -145
  82. package/dist/index-DE4CLElr.d.mts.map +0 -1
  83. package/dist/index-DlPA26cw.d.mts +0 -91
  84. package/dist/index-DlPA26cw.d.mts.map +0 -1
  85. package/dist/index-k8WKLXnA.d.mts.map +0 -1
  86. package/dist/output-D_G_JR_8.d.mts.map +0 -1
  87. package/dist/patch-BmRfghOo.mjs.map +0 -1
  88. package/dist/smartart-B7ukZ-Tw.mjs +0 -305
  89. package/dist/smartart-B7ukZ-Tw.mjs.map +0 -1
  90. package/dist/theme-CiNzdl-9.mjs +0 -177
  91. package/dist/theme-CiNzdl-9.mjs.map +0 -1
  92. package/dist/util-Tq9PSjK0.mjs.map +0 -1
  93. package/dist/values-8di32lIe.d.mts.map +0 -1
@@ -1,582 +0,0 @@
1
- import { attr, children, escapeXml, findChild, textOf } from "@office-open/xml";
2
- //#region src/chart/chart-collection.ts
3
- var ChartCollection = class {
4
- map;
5
- constructor() {
6
- this.map = /* @__PURE__ */ new Map();
7
- }
8
- addChart(key, chartData) {
9
- this.map.set(key, chartData);
10
- }
11
- get array() {
12
- return [...this.map.values()];
13
- }
14
- };
15
- //#endregion
16
- //#region src/chart/chart-descriptors.ts
17
- /**
18
- * Chart descriptors — CustomDescriptor for c:chartSpace serialization.
19
- *
20
- * @module
21
- */
22
- const CHART_TYPE_TAGS = {
23
- column: "c:barChart",
24
- bar: "c:barChart",
25
- line: "c:lineChart",
26
- pie: "c:pieChart",
27
- area: "c:areaChart",
28
- scatter: "c:scatterChart",
29
- bubble: "c:bubbleChart",
30
- doughnut: "c:doughnutChart",
31
- radar: "c:radarChart",
32
- stock: "c:stockChart",
33
- surface: "c:surfaceChart"
34
- };
35
- const CHART_TYPE_TAGS_3D = {
36
- column: "c:bar3DChart",
37
- bar: "c:bar3DChart",
38
- line: "c:line3DChart",
39
- pie: "c:pie3DChart",
40
- area: "c:area3DChart"
41
- };
42
- const NO_AXES_TYPES = new Set(["pie", "doughnut"]);
43
- const TAG_TO_CHART_TYPE = {
44
- "c:barChart": { type: "column" },
45
- "c:bar3DChart": {
46
- type: "column",
47
- threeD: true
48
- },
49
- "c:lineChart": { type: "line" },
50
- "c:line3DChart": {
51
- type: "line",
52
- threeD: true
53
- },
54
- "c:pieChart": { type: "pie" },
55
- "c:pie3DChart": {
56
- type: "pie",
57
- threeD: true
58
- },
59
- "c:areaChart": { type: "area" },
60
- "c:area3DChart": {
61
- type: "area",
62
- threeD: true
63
- },
64
- "c:scatterChart": { type: "scatter" },
65
- "c:bubbleChart": { type: "bubble" },
66
- "c:doughnutChart": { type: "doughnut" },
67
- "c:radarChart": { type: "radar" },
68
- "c:stockChart": { type: "stock" },
69
- "c:surfaceChart": { type: "surface" },
70
- "c:surface3DChart": {
71
- type: "surface",
72
- threeD: true
73
- }
74
- };
75
- function attrVal(name, value) {
76
- return `${name}="${escapeXml(String(value))}"`;
77
- }
78
- function emptyEl(tag) {
79
- return `<${tag}/>`;
80
- }
81
- function valEl(tag, value) {
82
- return `<${tag} ${attrVal("val", value)}/>`;
83
- }
84
- function boolVal(value) {
85
- return value === false ? ` val="0"` : "";
86
- }
87
- function stringifyNumLit(value) {
88
- return `<c:numLit><c:formatCode>General</c:formatCode><c:ptCount val="1"/><c:pt idx="0"><c:v>${value}</c:v></c:pt></c:numLit>`;
89
- }
90
- function stringifyTrendline(opts) {
91
- const parts = [];
92
- if (opts.name !== void 0) parts.push(`<c:name>${escapeXml(opts.name)}</c:name>`);
93
- parts.push(valEl("c:trendlineType", opts.type ?? "linear"));
94
- if (opts.order !== void 0) parts.push(valEl("c:order", opts.order));
95
- if (opts.period !== void 0) parts.push(valEl("c:period", opts.period));
96
- if (opts.forward !== void 0) parts.push(valEl("c:forward", opts.forward));
97
- if (opts.backward !== void 0) parts.push(valEl("c:backward", opts.backward));
98
- if (opts.intercept !== void 0) parts.push(valEl("c:intercept", opts.intercept));
99
- if (opts.dispRSqr !== void 0) parts.push(`<c:dispRSqr${boolVal(opts.dispRSqr)}/>`);
100
- if (opts.dispEq !== void 0) parts.push(`<c:dispEq${boolVal(opts.dispEq)}/>`);
101
- const labelFmt = opts.label?.numberFormat;
102
- if (labelFmt !== void 0) parts.push(`<c:trendlineLbl><c:numFmt formatCode="${escapeXml(labelFmt)}" sourceLinked="0"/></c:trendlineLbl>`);
103
- return `<c:trendline>${parts.join("")}</c:trendline>`;
104
- }
105
- function stringifyErrBars(opts) {
106
- const parts = [];
107
- if (opts.direction !== void 0) parts.push(valEl("c:errDir", opts.direction));
108
- parts.push(valEl("c:errBarType", opts.barType ?? "both"));
109
- parts.push(valEl("c:errValType", opts.valueType ?? "fixedVal"));
110
- if (opts.noEndCap !== void 0) parts.push(`<c:noEndCap${boolVal(opts.noEndCap)}/>`);
111
- if (opts.plusValue !== void 0) parts.push(`<c:plus>${stringifyNumLit(opts.plusValue)}</c:plus>`);
112
- if (opts.minusValue !== void 0) parts.push(`<c:minus>${stringifyNumLit(opts.minusValue)}</c:minus>`);
113
- if (opts.value !== void 0) parts.push(valEl("c:val", opts.value));
114
- return `<c:errBars>${parts.join("")}</c:errBars>`;
115
- }
116
- function stringifyDataLabel(opts) {
117
- if (opts.delete) return `<c:dLbl><c:idx val="${opts.index}"/><c:delete val="1"/></c:dLbl>`;
118
- const inner = [];
119
- if (opts.numberFormat !== void 0) inner.push(`<c:numFmt formatCode="${escapeXml(opts.numberFormat)}" sourceLinked="0"/>`);
120
- if (opts.position !== void 0) inner.push(valEl("c:dLblPos", opts.position));
121
- return `<c:dLbl><c:idx val="${opts.index}"/>${inner.join("")}</c:dLbl>`;
122
- }
123
- function stringifyDataLabels(opts) {
124
- const parts = [];
125
- if (opts.labels) for (const lbl of opts.labels) parts.push(stringifyDataLabel(lbl));
126
- if (opts.position !== void 0) parts.push(valEl("c:dLblPos", opts.position));
127
- if (opts.showLegendKey !== void 0) parts.push(`<c:showLegendKey${boolVal(opts.showLegendKey)}/>`);
128
- if (opts.showVal !== void 0) parts.push(`<c:showVal${boolVal(opts.showVal)}/>`);
129
- if (opts.showCatName !== void 0) parts.push(`<c:showCatName${boolVal(opts.showCatName)}/>`);
130
- if (opts.showSerName !== void 0) parts.push(`<c:showSerName${boolVal(opts.showSerName)}/>`);
131
- if (opts.showPercent !== void 0) parts.push(`<c:showPercent${boolVal(opts.showPercent)}/>`);
132
- if (opts.showBubbleSize !== void 0) parts.push(`<c:showBubbleSize${boolVal(opts.showBubbleSize)}/>`);
133
- if (opts.separator !== void 0) parts.push(`<c:separator>${escapeXml(opts.separator)}</c:separator>`);
134
- if (opts.showLeaderLines !== void 0) parts.push(`<c:showLeaderLines${boolVal(opts.showLeaderLines)}/>`);
135
- if (opts.leaderLines) parts.push(emptyEl("c:leaderLines"));
136
- return `<c:dLbls>${parts.join("")}</c:dLbls>`;
137
- }
138
- function stringifyView3D(opts) {
139
- const parts = [];
140
- if (opts.rotX !== void 0) parts.push(valEl("c:rotX", opts.rotX));
141
- if (opts.hPercent !== void 0) parts.push(valEl("c:hPercent", opts.hPercent));
142
- if (opts.rotY !== void 0) parts.push(valEl("c:rotY", opts.rotY));
143
- if (opts.depthPercent !== void 0) parts.push(valEl("c:depthPercent", opts.depthPercent));
144
- if (opts.rAngAx !== void 0) parts.push(`<c:rAngAx${boolVal(opts.rAngAx)}/>`);
145
- if (opts.perspective !== void 0) parts.push(valEl("c:perspective", opts.perspective));
146
- return `<c:view3D>${parts.join("")}</c:view3D>`;
147
- }
148
- function stringifyStrRef(values) {
149
- const pts = values.map((v, i) => `<c:pt idx="${i}"><c:v>${escapeXml(v)}</c:v></c:pt>`).join("");
150
- return `<c:strRef><c:f/><c:strCache><c:ptCount ${attrVal("val", values.length)}/>${pts}</c:strCache></c:strRef>`;
151
- }
152
- function stringifyNumRef(values) {
153
- const pts = values.map((v, i) => `<c:pt idx="${i}"><c:v>${v}</c:v></c:pt>`).join("");
154
- return `<c:numRef><c:f/><c:numCache><c:formatCode>General</c:formatCode><c:ptCount ${attrVal("val", values.length)}/>${pts}</c:numCache></c:numRef>`;
155
- }
156
- function chartTypeHeader(opts) {
157
- const tag = opts.threeD ? CHART_TYPE_TAGS_3D[opts.type] : CHART_TYPE_TAGS[opts.type];
158
- if (!tag) throw new Error(`Unsupported chart type: ${opts.type}`);
159
- const headerParts = [];
160
- switch (opts.type) {
161
- case "column":
162
- case "bar":
163
- headerParts.push(valEl("c:barDir", opts.type === "column" ? "col" : "bar"));
164
- headerParts.push(valEl("c:grouping", "clustered"));
165
- break;
166
- case "line":
167
- case "area":
168
- headerParts.push(valEl("c:grouping", "standard"));
169
- break;
170
- case "scatter":
171
- headerParts.push(valEl("c:scatterStyle", "line"));
172
- break;
173
- case "radar":
174
- headerParts.push(valEl("c:radarStyle", "standard"));
175
- break;
176
- case "pie":
177
- case "doughnut":
178
- case "bubble":
179
- headerParts.push(valEl("c:varyColors", 1));
180
- break;
181
- }
182
- return `<${tag}>${headerParts.join("")}`;
183
- }
184
- function chartTypeFooter(opts) {
185
- const tag = opts.threeD ? CHART_TYPE_TAGS_3D[opts.type] : CHART_TYPE_TAGS[opts.type];
186
- if (NO_AXES_TYPES.has(opts.type)) return `</${tag}>`;
187
- const axIds = [valEl("c:axId", 10), valEl("c:axId", 20)];
188
- if (opts.threeD || opts.type === "surface") axIds.push(valEl("c:axId", 30));
189
- return `${axIds.join("")}</${tag}>`;
190
- }
191
- function stringifySeries(index, series, categories, chartType) {
192
- const parts = [];
193
- parts.push(valEl("c:idx", index));
194
- parts.push(valEl("c:order", index));
195
- parts.push(`<c:tx>${stringifyStrRef([series.name])}</c:tx>`);
196
- parts.push(emptyEl("c:spPr"));
197
- const s = series;
198
- if (s.dataLabels) parts.push(stringifyDataLabels(s.dataLabels));
199
- if (s.trendlines) for (const tl of s.trendlines) parts.push(stringifyTrendline(tl));
200
- if (s.errorBars) parts.push(stringifyErrBars(s.errorBars));
201
- if (chartType === "bubble") {
202
- const bs = series;
203
- parts.push(`<c:xVal>${stringifyNumRef(bs.xValues)}</c:xVal>`);
204
- parts.push(`<c:yVal>${stringifyNumRef(bs.yValues)}</c:yVal>`);
205
- parts.push(`<c:bubbleSize>${stringifyNumRef(bs.bubbleSize)}</c:bubbleSize>`);
206
- } else if (chartType === "scatter") {
207
- parts.push(`<c:xVal>${stringifyStrRef(categories)}</c:xVal>`);
208
- parts.push(`<c:yVal>${stringifyNumRef(s.values)}</c:yVal>`);
209
- } else {
210
- parts.push(`<c:cat>${stringifyStrRef(categories)}</c:cat>`);
211
- parts.push(`<c:val>${stringifyNumRef(s.values)}</c:val>`);
212
- }
213
- return `<c:ser>${parts.join("")}</c:ser>`;
214
- }
215
- function stringifyTitle(title) {
216
- return `<c:title><c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r><a:t>${escapeXml(title)}</a:t></a:r></a:p></c:rich></c:tx><c:overlay val="0"/></c:title>`;
217
- }
218
- function stringifyLegend() {
219
- return `<c:legend><c:legendPos val="b"/><c:layout/><c:overlay val="0"/><c:spPr><a:noFill/><a:ln><a:noFill/></a:ln><a:effectLst/></c:spPr><c:txPr><a:bodyPr rot="0" spcFirstLastPara="1" vertOverflow="ellipsis" vert="horz" wrap="square" anchor="ctr" anchorCtr="1"/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:endParaRPr lang="en-US"/></a:p></c:txPr></c:legend>`;
220
- }
221
- function noFillSpPr() {
222
- return `<c:spPr><a:noFill/><a:ln><a:noFill/></a:ln><a:effectLst/></c:spPr>`;
223
- }
224
- function chartTxPr() {
225
- return `<c:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:endParaRPr lang="en-US"/></a:p></c:txPr>`;
226
- }
227
- function stringifyAxes(chartType, threeD) {
228
- if (NO_AXES_TYPES.has(chartType)) return "";
229
- const parts = [];
230
- if (chartType === "scatter" || chartType === "bubble") {
231
- parts.push(valAxXml(10, 20));
232
- parts.push(valAxXml(20, 10));
233
- } else if (chartType === "stock" || chartType === "surface") {
234
- parts.push(catAxXml(10, 20));
235
- parts.push(valAxXml(20, 10));
236
- if (chartType === "surface") parts.push(serAxXml(30, 10));
237
- } else {
238
- parts.push(catAxXml(10, 20));
239
- parts.push(valAxXml(20, 10));
240
- if (threeD) parts.push(catAxXml(30, 10));
241
- }
242
- return parts.join("");
243
- }
244
- function catAxXml(axId, crossAx) {
245
- return `<c:catAx><c:axId ${attrVal("val", axId)}/><c:scaling><c:orientation val="minMax"/></c:scaling><c:delete val="0"/><c:axPos val="b"/><c:crossAx ${attrVal("val", crossAx)}/><c:crosses val="autoZero"/><c:auto val="1"/><c:lblOffset val="100"/><c:noMultiLvlLbl val="0"/></c:catAx>`;
246
- }
247
- function valAxXml(axId, crossAx) {
248
- return `<c:valAx><c:axId ${attrVal("val", axId)}/><c:scaling><c:orientation val="minMax"/></c:scaling><c:delete val="0"/><c:axPos val="l"/><c:numFmt formatCode="General" sourceLinked="1"/><c:spPr/><c:crossAx ${attrVal("val", crossAx)}/><c:crosses val="autoZero"/></c:valAx>`;
249
- }
250
- function serAxXml(axId, crossAx) {
251
- return `<c:serAx><c:axId ${attrVal("val", axId)}/><c:scaling><c:orientation val="minMax"/></c:scaling><c:delete val="0"/><c:axPos val="b"/><c:numFmt formatCode="General" sourceLinked="1"/><c:spPr/><c:crossAx ${attrVal("val", crossAx)}/><c:crosses val="autoZero"/><c:tickLblSkip val="1"/></c:serAx>`;
252
- }
253
- function readStrCache(el) {
254
- const strRef = findChild(el, "c:strRef");
255
- if (!strRef) return [];
256
- const strCache = findChild(strRef, "c:strCache");
257
- if (!strCache?.elements) return [];
258
- const result = [];
259
- for (const pt of strCache.elements) if (pt.name === "c:pt" && pt.elements) {
260
- const v = pt.elements.find((c) => c.name === "c:v");
261
- if (v?.text !== void 0) result.push(String(v.text));
262
- }
263
- return result;
264
- }
265
- function readNumCache(el) {
266
- const numRef = findChild(el, "c:numRef");
267
- if (!numRef) return [];
268
- const numCache = findChild(numRef, "c:numCache");
269
- if (!numCache?.elements) return [];
270
- const result = [];
271
- for (const pt of numCache.elements) if (pt.name === "c:pt" && pt.elements) {
272
- const v = pt.elements.find((c) => c.name === "c:v");
273
- if (v?.text !== void 0) result.push(Number(v.text));
274
- }
275
- return result;
276
- }
277
- function readSeriesName(serEl) {
278
- const tx = findChild(serEl, "c:tx");
279
- if (!tx) return "";
280
- return readStrCache(tx)[0] ?? "";
281
- }
282
- function readTitleText(titleEl) {
283
- const tx = findChild(titleEl, "c:tx");
284
- if (!tx?.elements) return void 0;
285
- for (const child of tx.elements) if (child.name === "c:rich" && child.elements) {
286
- for (const sub of child.elements) if (sub.name === "a:p" && sub.elements) {
287
- for (const r of sub.elements) if (r.name === "a:r" && r.elements) {
288
- for (const t of r.elements) if (t.name === "a:t" && t.text !== void 0) return String(t.text);
289
- }
290
- }
291
- }
292
- }
293
- function readBoolAttr(el, childName) {
294
- const child = findChild(el, childName);
295
- if (!child) return void 0;
296
- const v = attr(child, "val");
297
- if (v === void 0) return true;
298
- return v !== "0" && v !== "false";
299
- }
300
- function readValNum(el, childName) {
301
- const child = findChild(el, childName);
302
- if (!child) return void 0;
303
- const v = attr(child, "val");
304
- return v !== void 0 ? Number(v) : void 0;
305
- }
306
- function readValStr(el, childName) {
307
- const child = findChild(el, childName);
308
- if (!child) return void 0;
309
- return attr(child, "val") ?? void 0;
310
- }
311
- function readNumLit(el, childName) {
312
- const child = findChild(el, childName);
313
- if (!child) return void 0;
314
- const numLit = findChild(child, "c:numLit");
315
- if (!numLit?.elements) return void 0;
316
- for (const pt of numLit.elements) if (pt.name === "c:pt" && pt.elements) {
317
- const v = pt.elements.find((c) => c.name === "c:v");
318
- if (v) {
319
- const text = textOf(v);
320
- if (text) return Number(text);
321
- }
322
- }
323
- }
324
- function readTrendlines(serEl) {
325
- const tlEls = children(serEl, "c:trendline");
326
- if (tlEls.length === 0) return void 0;
327
- return tlEls.map((tl) => {
328
- const opts = {};
329
- const type = readValStr(tl, "c:trendlineType");
330
- if (type) opts.type = type;
331
- const order = readValNum(tl, "c:order");
332
- if (order !== void 0) opts.order = order;
333
- const period = readValNum(tl, "c:period");
334
- if (period !== void 0) opts.period = period;
335
- const forward = readValNum(tl, "c:forward");
336
- if (forward !== void 0) opts.forward = forward;
337
- const backward = readValNum(tl, "c:backward");
338
- if (backward !== void 0) opts.backward = backward;
339
- const intercept = readValNum(tl, "c:intercept");
340
- if (intercept !== void 0) opts.intercept = intercept;
341
- const dispRSqr = readBoolAttr(tl, "c:dispRSqr");
342
- if (dispRSqr !== void 0) opts.dispRSqr = dispRSqr;
343
- const dispEq = readBoolAttr(tl, "c:dispEq");
344
- if (dispEq !== void 0) opts.dispEq = dispEq;
345
- const nameText = textOf(findChild(tl, "c:name"));
346
- if (nameText) opts.name = nameText;
347
- const labelFmt = attr(findChild(findChild(tl, "c:trendlineLbl"), "c:numFmt"), "formatCode");
348
- if (labelFmt) opts.label = { numberFormat: labelFmt };
349
- return opts;
350
- });
351
- }
352
- function readErrBars(serEl) {
353
- const ebEl = findChild(serEl, "c:errBars");
354
- if (!ebEl) return void 0;
355
- const opts = {};
356
- const direction = readValStr(ebEl, "c:errDir");
357
- if (direction) opts.direction = direction;
358
- const barType = readValStr(ebEl, "c:errBarType");
359
- if (barType) opts.barType = barType;
360
- const valueType = readValStr(ebEl, "c:errValType");
361
- if (valueType) opts.valueType = valueType;
362
- const noEndCap = readBoolAttr(ebEl, "c:noEndCap");
363
- if (noEndCap !== void 0) opts.noEndCap = noEndCap;
364
- const plusValue = readNumLit(ebEl, "c:plus");
365
- if (plusValue !== void 0) opts.plusValue = plusValue;
366
- const minusValue = readNumLit(ebEl, "c:minus");
367
- if (minusValue !== void 0) opts.minusValue = minusValue;
368
- const value = readValNum(ebEl, "c:val");
369
- if (value !== void 0) opts.value = value;
370
- return opts;
371
- }
372
- function readDataLabels(serEl) {
373
- const dlEl = findChild(serEl, "c:dLbls");
374
- if (!dlEl) return void 0;
375
- const opts = {};
376
- const position = readValStr(dlEl, "c:dLblPos");
377
- if (position) opts.position = position;
378
- const showLegendKey = readBoolAttr(dlEl, "c:showLegendKey");
379
- if (showLegendKey !== void 0) opts.showLegendKey = showLegendKey;
380
- const showVal = readBoolAttr(dlEl, "c:showVal");
381
- if (showVal !== void 0) opts.showVal = showVal;
382
- const showCatName = readBoolAttr(dlEl, "c:showCatName");
383
- if (showCatName !== void 0) opts.showCatName = showCatName;
384
- const showSerName = readBoolAttr(dlEl, "c:showSerName");
385
- if (showSerName !== void 0) opts.showSerName = showSerName;
386
- const showPercent = readBoolAttr(dlEl, "c:showPercent");
387
- if (showPercent !== void 0) opts.showPercent = showPercent;
388
- const showBubbleSize = readBoolAttr(dlEl, "c:showBubbleSize");
389
- if (showBubbleSize !== void 0) opts.showBubbleSize = showBubbleSize;
390
- const showLeaderLines = readBoolAttr(dlEl, "c:showLeaderLines");
391
- if (showLeaderLines !== void 0) opts.showLeaderLines = showLeaderLines;
392
- const sepText = textOf(findChild(dlEl, "c:separator"));
393
- if (sepText) opts.separator = sepText;
394
- const lblEls = children(dlEl, "c:dLbl");
395
- if (lblEls.length > 0) opts.labels = lblEls.map((el) => {
396
- const result = { index: readValNum(el, "c:idx") ?? 0 };
397
- if (findChild(el, "c:delete")) result.delete = true;
398
- const numFmt = attr(findChild(el, "c:numFmt"), "formatCode");
399
- if (numFmt) result.numberFormat = numFmt;
400
- const pos = readValStr(el, "c:dLblPos");
401
- if (pos) result.position = pos;
402
- return result;
403
- });
404
- if (findChild(dlEl, "c:leaderLines")) opts.leaderLines = true;
405
- return opts;
406
- }
407
- function readView3D(chartEl) {
408
- const v3d = findChild(chartEl, "c:view3D");
409
- if (!v3d) return void 0;
410
- const opts = {};
411
- const rotX = readValNum(v3d, "c:rotX");
412
- if (rotX !== void 0) opts.rotX = rotX;
413
- const hPercent = readValNum(v3d, "c:hPercent");
414
- if (hPercent !== void 0) opts.hPercent = hPercent;
415
- const rotY = readValNum(v3d, "c:rotY");
416
- if (rotY !== void 0) opts.rotY = rotY;
417
- const depthPercent = readValNum(v3d, "c:depthPercent");
418
- if (depthPercent !== void 0) opts.depthPercent = depthPercent;
419
- const rAngAx = readBoolAttr(v3d, "c:rAngAx");
420
- if (rAngAx !== void 0) opts.rAngAx = rAngAx;
421
- const perspective = readValNum(v3d, "c:perspective");
422
- if (perspective !== void 0) opts.perspective = perspective;
423
- return opts;
424
- }
425
- const chartSpaceDesc = {
426
- kind: "custom",
427
- stringify(opts, _ctx) {
428
- const parts = [];
429
- parts.push(`<c:chartSpace xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">`);
430
- parts.push(valEl("c:date1904", 0));
431
- parts.push(valEl("c:lang", "en-US"));
432
- parts.push(valEl("c:roundedCorners", 0));
433
- if (opts.style !== void 0) parts.push(valEl("c:style", opts.style));
434
- parts.push("<c:chart>");
435
- if (opts.title) parts.push(stringifyTitle(opts.title));
436
- parts.push(valEl("c:autoTitleDeleted", 0));
437
- if (opts.view3D) parts.push(stringifyView3D(opts.view3D));
438
- parts.push("<c:plotArea><c:layout/>");
439
- parts.push(chartTypeHeader(opts));
440
- const categories = opts.categories ?? [];
441
- for (const [i, series] of opts.series.entries()) parts.push(stringifySeries(i, series, categories, opts.type));
442
- parts.push(chartTypeFooter(opts));
443
- parts.push(stringifyAxes(opts.type, opts.threeD));
444
- parts.push("</c:plotArea>");
445
- if (opts.showLegend !== false) parts.push(stringifyLegend());
446
- parts.push("</c:chart>");
447
- parts.push(noFillSpPr());
448
- parts.push(chartTxPr());
449
- parts.push("</c:chartSpace>");
450
- return parts.join("");
451
- },
452
- parse(el, _ctx) {
453
- const result = {};
454
- const styleEl = findChild(el, "c:style");
455
- if (styleEl?.attributes?.["val"] !== void 0) result.style = Number(styleEl.attributes["val"]);
456
- const chart = findChild(el, "c:chart");
457
- if (!chart) return result;
458
- const titleEl = findChild(chart, "c:title");
459
- if (titleEl) {
460
- const title = readTitleText(titleEl);
461
- if (title !== void 0) result.title = title;
462
- }
463
- const view3D = readView3D(chart);
464
- if (view3D) result.view3D = view3D;
465
- const plotArea = findChild(chart, "c:plotArea");
466
- if (plotArea?.elements) {
467
- let detectedType;
468
- let threeD = false;
469
- let chartTypeEl;
470
- for (const child of plotArea.elements) {
471
- if (!child.name) continue;
472
- const mapping = TAG_TO_CHART_TYPE[child.name];
473
- if (mapping) {
474
- detectedType = mapping.type;
475
- threeD = mapping.threeD ?? false;
476
- chartTypeEl = child;
477
- if (child.name === "c:barChart" || child.name === "c:bar3DChart") {
478
- const barDir = findChild(child, "c:barDir");
479
- const barDirVal = barDir ? attr(barDir, "val") : void 0;
480
- if (barDirVal === "bar") detectedType = "bar";
481
- else if (barDirVal === "col") detectedType = "column";
482
- }
483
- break;
484
- }
485
- }
486
- if (detectedType) {
487
- result.type = detectedType;
488
- if (threeD) result.threeD = true;
489
- }
490
- const seriesEls = chartTypeEl ? children(chartTypeEl, "c:ser") : [];
491
- if (seriesEls.length > 0) if (detectedType === "bubble") {
492
- const bubbleSeries = [];
493
- for (const serEl of seriesEls) {
494
- const name = readSeriesName(serEl);
495
- const xVal = findChild(serEl, "c:xVal");
496
- const yVal = findChild(serEl, "c:yVal");
497
- const bubbleSize = findChild(serEl, "c:bubbleSize");
498
- bubbleSeries.push({
499
- name,
500
- xValues: xVal ? readNumCache(xVal) : [],
501
- yValues: yVal ? readNumCache(yVal) : [],
502
- bubbleSize: bubbleSize ? readNumCache(bubbleSize) : []
503
- });
504
- }
505
- result.series = bubbleSeries;
506
- } else {
507
- const chartSeries = [];
508
- let categories;
509
- for (const serEl of seriesEls) {
510
- const name = readSeriesName(serEl);
511
- if (!categories) {
512
- const catEl = findChild(serEl, "c:cat") ?? findChild(serEl, "c:xVal");
513
- if (catEl) categories = readStrCache(catEl);
514
- }
515
- const valEl = findChild(serEl, "c:val") ?? findChild(serEl, "c:yVal");
516
- const ser = {
517
- name,
518
- values: valEl ? readNumCache(valEl) : []
519
- };
520
- const trendlines = readTrendlines(serEl);
521
- if (trendlines) ser.trendlines = trendlines;
522
- const errorBars = readErrBars(serEl);
523
- if (errorBars) ser.errorBars = errorBars;
524
- const dataLabels = readDataLabels(serEl);
525
- if (dataLabels) ser.dataLabels = dataLabels;
526
- chartSeries.push(ser);
527
- }
528
- result.series = chartSeries;
529
- if (categories?.length) result.categories = categories;
530
- }
531
- }
532
- if (!findChild(chart, "c:legend")) result.showLegend = false;
533
- return result;
534
- }
535
- };
536
- //#endregion
537
- //#region src/chart/types.ts
538
- const TrendlineType = {
539
- EXP: "exp",
540
- LINEAR: "linear",
541
- LOG: "log",
542
- MOVING_AVG: "movingAvg",
543
- POLY: "poly",
544
- POWER: "power"
545
- };
546
- const ErrorBarDirection = {
547
- BOTH: "both",
548
- X: "x",
549
- Y: "y"
550
- };
551
- const ErrorBarType = {
552
- BOTH: "both",
553
- MINUS: "minus",
554
- PLUS: "plus"
555
- };
556
- const ErrorValueType = {
557
- CUST: "cust",
558
- FIXED: "fixedVal",
559
- PERCENTAGE: "percentage",
560
- STD_DEV: "stdDev",
561
- STD_ERR: "stdErr"
562
- };
563
- const DataLabelPosition = {
564
- BEST_FIT: "bestFit",
565
- B: "b",
566
- CTRL: "ctr",
567
- IN_BASE: "inBase",
568
- IN_END: "inEnd",
569
- L: "l",
570
- OUT_END: "outEnd",
571
- R: "r",
572
- T: "t"
573
- };
574
- const TimeUnit = {
575
- DAYS: "days",
576
- MONTHS: "months",
577
- YEARS: "years"
578
- };
579
- //#endregion
580
- export { TimeUnit as a, ChartCollection as c, ErrorValueType as i, ErrorBarDirection as n, TrendlineType as o, ErrorBarType as r, chartSpaceDesc as s, DataLabelPosition as t };
581
-
582
- //# sourceMappingURL=chart-DIGJna_6.mjs.map