ooxml-core 1.17.0 → 1.19.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/dist/{PptxHandler-K7GMS2ST.mjs → PptxHandler-5GBBVJCR.mjs} +2 -2
- package/dist/{PptxHandler-L3JPWOBN.mjs → PptxHandler-H43MAMTO.mjs} +1 -1
- package/dist/{PptxHandler-U6EFO73T.cjs → PptxHandler-ZHPGBSAF.cjs} +2 -2
- package/dist/{PresentationBuilder-XC3F3OPY.mjs → PresentationBuilder-7ZSUKCX5.mjs} +1 -1
- package/dist/{PresentationBuilder-OK526SZ4.mjs → PresentationBuilder-IJW42L3R.mjs} +2 -2
- package/dist/{PresentationBuilder-LUR6LGHU.cjs → PresentationBuilder-O4H4MMWB.cjs} +4 -4
- package/dist/automation/index.cjs +5198 -3235
- package/dist/automation/index.mjs +5198 -3235
- package/dist/chart/axis-range-auto.d.ts +10 -0
- package/dist/chart/axis-range-auto.d.ts.map +1 -0
- package/dist/chart/axis-range-types.d.ts +27 -0
- package/dist/chart/axis-range-types.d.ts.map +1 -0
- package/dist/chart/axis-range.d.ts +37 -0
- package/dist/chart/axis-range.d.ts.map +1 -0
- package/dist/chart/axis-ticks.d.ts +8 -0
- package/dist/chart/axis-ticks.d.ts.map +1 -0
- package/dist/chart/data-label-text.d.ts +70 -0
- package/dist/chart/data-label-text.d.ts.map +1 -0
- package/dist/chart/formatting-nodes.d.ts +6 -0
- package/dist/chart/formatting-nodes.d.ts.map +1 -1
- package/dist/chart/index.cjs +1536 -571
- package/dist/chart/index.d.ts +7 -0
- package/dist/chart/index.d.ts.map +1 -1
- package/dist/chart/index.mjs +1512 -572
- package/dist/chart/line-dash.d.ts +2 -0
- package/dist/chart/line-dash.d.ts.map +1 -0
- package/dist/chart/marker-shape.d.ts +70 -0
- package/dist/chart/marker-shape.d.ts.map +1 -0
- package/dist/chart/read-formatting.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-axes.d.ts +9 -0
- package/dist/chart/render/chart-svg-axes.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-bars.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-cartesian.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-labels.d.ts +42 -0
- package/dist/chart/render/chart-svg-labels.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-markers.d.ts +6 -0
- package/dist/chart/render/chart-svg-markers.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-radial.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-xy.d.ts.map +1 -1
- package/dist/chart/render/chart-view-axes.d.ts +30 -0
- package/dist/chart/render/chart-view-axes.d.ts.map +1 -0
- package/dist/chart/render/chart-view-labels.d.ts +16 -0
- package/dist/chart/render/chart-view-labels.d.ts.map +1 -0
- package/dist/chart/render/chart-view-markers.d.ts +27 -0
- package/dist/chart/render/chart-view-markers.d.ts.map +1 -0
- package/dist/chart/render/chart-view-series.d.ts.map +1 -1
- package/dist/chart/render/chart-view.d.ts +7 -1
- package/dist/chart/render/chart-view.d.ts.map +1 -1
- package/dist/chart/render/index.d.ts +2 -0
- package/dist/chart/render/index.d.ts.map +1 -1
- package/dist/chart/render/summary-from-space.d.ts +2 -2
- package/dist/chart/render/summary-from-space.d.ts.map +1 -1
- package/dist/chart/render/summary-labels.d.ts +9 -0
- package/dist/chart/render/summary-labels.d.ts.map +1 -0
- package/dist/chart/render/summary.d.ts +29 -1
- package/dist/chart/render/summary.d.ts.map +1 -1
- package/dist/{chunk-IM5LFEA2.mjs → chunk-3XFPCZKB.mjs} +1 -1
- package/dist/{chunk-YS43OMM3.mjs → chunk-75GLSRZE.mjs} +4 -4
- package/dist/{chunk-A7S2NYAU.mjs → chunk-BIVNVDAH.mjs} +1 -1
- package/dist/{chunk-UFGJNXRG.mjs → chunk-QBJRB6WW.mjs} +1 -1
- package/dist/{chunk-HLZIALC5.mjs → chunk-RUZEMWDI.mjs} +1 -1
- package/dist/docx/embedded.cjs +15 -0
- package/dist/docx/embedded.mjs +15 -0
- package/dist/docx/index.cjs +1825 -693
- package/dist/docx/index.mjs +1825 -693
- package/dist/docx/layout/index.cjs +1684 -567
- package/dist/docx/layout/index.mjs +1684 -567
- package/dist/docx/load/index.cjs +15 -0
- package/dist/docx/load/index.mjs +15 -0
- package/dist/docx/ui/index.cjs +1696 -579
- package/dist/docx/ui/index.mjs +1696 -579
- package/dist/index.cjs +1623 -658
- package/dist/index.mjs +1623 -658
- package/dist/pptx/automation/index.cjs +61 -0
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/cli/index.cjs +61 -0
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/slide-operations.cjs +1 -1
- package/dist/pptx/editor/render/slide-operations.mjs +1 -1
- package/dist/pptx/index.cjs +61 -0
- package/dist/pptx/index.mjs +5 -5
- package/dist/teams/index.cjs +212 -50
- package/dist/teams/index.mjs +212 -50
- package/dist/visio/edit-chart-object-commands.d.ts +36 -0
- package/dist/visio/edit-chart-object-commands.d.ts.map +1 -0
- package/dist/visio/edit-chart-object.d.ts +7 -0
- package/dist/visio/edit-chart-object.d.ts.map +1 -0
- package/dist/visio/edit-commands.d.ts +2 -1
- package/dist/visio/edit-commands.d.ts.map +1 -1
- package/dist/visio/edit-foreign-frame.d.ts +8 -0
- package/dist/visio/edit-foreign-frame.d.ts.map +1 -0
- package/dist/visio/edit-metadata-commands.d.ts +7 -0
- package/dist/visio/edit-metadata-commands.d.ts.map +1 -1
- package/dist/visio/edit-picture.d.ts +8 -0
- package/dist/visio/edit-picture.d.ts.map +1 -1
- package/dist/visio/edit.d.ts.map +1 -1
- package/dist/visio/emf-bitmap.d.ts +8 -0
- package/dist/visio/emf-bitmap.d.ts.map +1 -0
- package/dist/visio/index.cjs +17505 -6279
- package/dist/visio/index.d.ts +2 -0
- package/dist/visio/index.d.ts.map +1 -1
- package/dist/visio/index.mjs +17503 -6280
- package/dist/visio/model.d.ts +18 -0
- package/dist/visio/model.d.ts.map +1 -1
- package/dist/visio/prepare-embedded.d.ts +10 -0
- package/dist/visio/prepare-embedded.d.ts.map +1 -0
- package/dist/visio/prepare-images.d.ts.map +1 -1
- package/dist/visio/shapes.d.ts.map +1 -1
- package/dist/visio/sheet.d.ts +2 -1
- package/dist/visio/sheet.d.ts.map +1 -1
- package/dist/visio/ui/edit-commands.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +33580 -22875
- package/dist/visio/ui/index.mjs +33578 -22875
- package/dist/visio/ui/insert.d.ts +11 -0
- package/dist/visio/ui/insert.d.ts.map +1 -1
- package/dist/xlsx/edit/chart-colors.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +1965 -817
- package/dist/xlsx/index.mjs +1965 -817
- package/dist/xlsx/load/index.cjs +190 -51
- package/dist/xlsx/load/index.mjs +190 -51
- package/dist/xlsx/model.d.ts +5 -0
- package/dist/xlsx/model.d.ts.map +1 -1
- package/dist/xlsx/read/chart.d.ts.map +1 -1
- package/dist/xlsx/read/load.d.ts.map +1 -1
- package/dist/xlsx/read/workbook-part.d.ts +2 -0
- package/dist/xlsx/read/workbook-part.d.ts.map +1 -1
- package/dist/xlsx/ui/dialogs/grid-chart.d.ts +22 -1
- package/dist/xlsx/ui/dialogs/grid-chart.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +17482 -4364
- package/dist/xlsx/ui/index.mjs +17472 -4362
- package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/visio/edit-foreign-bitmap.d.ts +0 -7
- package/dist/visio/edit-foreign-bitmap.d.ts.map +0 -1
- /package/dist/{chunk-KU3SMBFU.mjs → chunk-H6TNNXJK.mjs} +0 -0
- /package/dist/{chunk-UWWS6VVJ.cjs → chunk-MHMVD23Y.cjs} +0 -0
package/dist/docx/index.mjs
CHANGED
|
@@ -67,17 +67,17 @@ function checkXmlLimits(xml, label, limits = {}) {
|
|
|
67
67
|
throw new Error(`${label} XML exceeds the nesting depth limit of ${maxDepth}`);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
function parseXml(xml,
|
|
71
|
-
const label =
|
|
70
|
+
function parseXml(xml, options2 = {}) {
|
|
71
|
+
const label = options2.label ?? "OOXML";
|
|
72
72
|
if (/<!DOCTYPE|<!ENTITY/i.test(xml))
|
|
73
73
|
throw new Error(`${label} XML with DTD or entity declarations is not supported`);
|
|
74
|
-
checkXmlLimits(xml, label,
|
|
74
|
+
checkXmlLimits(xml, label, options2.limits);
|
|
75
75
|
let parseError = "";
|
|
76
76
|
let parsed;
|
|
77
77
|
try {
|
|
78
78
|
parsed = new DOMParser({
|
|
79
|
-
onError: (
|
|
80
|
-
if (
|
|
79
|
+
onError: (level2, message) => {
|
|
80
|
+
if (level2 !== "warning") parseError = message;
|
|
81
81
|
}
|
|
82
82
|
}).parseFromString(xml, "application/xml");
|
|
83
83
|
} catch (error) {
|
|
@@ -1285,8 +1285,8 @@ function parseTableStyleCatalog(xml) {
|
|
|
1285
1285
|
|
|
1286
1286
|
// docx/default-styles.ts
|
|
1287
1287
|
var W = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
|
|
1288
|
-
var heading = (id, name,
|
|
1289
|
-
var toc = (
|
|
1288
|
+
var heading = (id, name, level2, before, size, color) => `<w:style w:type="paragraph" w:styleId="${id}"><w:name w:val="${name}"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="9"/><w:qFormat/><w:pPr><w:keepNext/><w:keepLines/><w:spacing w:before="${before}" w:after="0"/><w:outlineLvl w:val="${level2}"/></w:pPr><w:rPr><w:rFonts w:ascii="Calibri Light" w:hAnsi="Calibri Light" w:eastAsia="Calibri Light" w:cs="Times New Roman"/><w:color w:val="${color}"/><w:sz w:val="${size}"/><w:szCs w:val="${size}"/></w:rPr></w:style>`;
|
|
1289
|
+
var toc = (level2) => `<w:style w:type="paragraph" w:styleId="TOC${level2}"><w:name w:val="toc ${level2}"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="39"/><w:unhideWhenUsed/><w:pPr><w:spacing w:after="100"/>${level2 > 1 ? `<w:ind w:left="${(level2 - 1) * 220}"/>` : ""}</w:pPr></w:style>`;
|
|
1290
1290
|
var noteStyles = (id, name) => `<w:style w:type="paragraph" w:styleId="${id}Text"><w:name w:val="${name} text"/><w:basedOn w:val="Normal"/><w:link w:val="${id}TextChar"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:rPr><w:sz w:val="20"/><w:szCs w:val="20"/></w:rPr></w:style><w:style w:type="character" w:styleId="${id}TextChar"><w:name w:val="${name} Text Char"/><w:basedOn w:val="DefaultParagraphFont"/><w:link w:val="${id}Text"/><w:uiPriority w:val="99"/><w:semiHidden/><w:rPr><w:sz w:val="20"/><w:szCs w:val="20"/></w:rPr></w:style><w:style w:type="character" w:styleId="${id}Reference"><w:name w:val="${name} reference"/><w:basedOn w:val="DefaultParagraphFont"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/><w:rPr><w:vertAlign w:val="superscript"/></w:rPr></w:style>`;
|
|
1291
1291
|
var DEFAULT_STYLES_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles xmlns:w="${W}"><w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii="Calibri" w:eastAsia="Calibri" w:hAnsi="Calibri" w:cs="Times New Roman"/><w:sz w:val="22"/><w:szCs w:val="22"/><w:lang w:val="en-US" w:eastAsia="en-US" w:bidi="ar-SA"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr><w:spacing w:after="160" w:line="259" w:lineRule="auto"/></w:pPr></w:pPrDefault></w:docDefaults><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/></w:style><w:style w:type="character" w:default="1" w:styleId="DefaultParagraphFont"><w:name w:val="Default Paragraph Font"/><w:uiPriority w:val="1"/><w:semiHidden/><w:unhideWhenUsed/></w:style><w:style w:type="table" w:default="1" w:styleId="TableNormal"><w:name w:val="Normal Table"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/><w:tblPr><w:tblInd w:w="0" w:type="dxa"/><w:tblCellMar><w:top w:w="0" w:type="dxa"/><w:left w:w="108" w:type="dxa"/><w:bottom w:w="0" w:type="dxa"/><w:right w:w="108" w:type="dxa"/></w:tblCellMar></w:tblPr></w:style><w:style w:type="numbering" w:default="1" w:styleId="NoList"><w:name w:val="No List"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/></w:style><w:style w:type="paragraph" w:styleId="Title"><w:name w:val="Title"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="10"/><w:qFormat/><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/><w:contextualSpacing/></w:pPr><w:rPr><w:rFonts w:ascii="Calibri Light" w:hAnsi="Calibri Light" w:eastAsia="Calibri Light" w:cs="Times New Roman"/><w:spacing w:val="-10"/><w:kern w:val="28"/><w:sz w:val="56"/><w:szCs w:val="56"/></w:rPr></w:style>` + heading("Heading1", "heading 1", 0, 240, 32, "2F5496") + heading("Heading2", "heading 2", 1, 40, 26, "2F5496") + heading("Heading3", "heading 3", 2, 40, 24, "1F3763") + toc(1) + toc(2) + toc(3) + noteStyles("Footnote", "footnote") + noteStyles("Endnote", "endnote") + '<w:style w:type="character" w:styleId="Hyperlink"><w:name w:val="Hyperlink"/><w:basedOn w:val="DefaultParagraphFont"/><w:uiPriority w:val="99"/><w:unhideWhenUsed/><w:rPr><w:color w:val="0563C1"/><w:u w:val="single"/></w:rPr></w:style><w:style w:type="character" w:styleId="PlaceholderText"><w:name w:val="Placeholder Text"/><w:basedOn w:val="DefaultParagraphFont"/><w:uiPriority w:val="99"/><w:semiHidden/><w:rPr><w:color w:val="808080"/></w:rPr></w:style></w:styles>';
|
|
1292
1292
|
var cached;
|
|
@@ -1495,8 +1495,8 @@ function resolveRunFormatting(run, context = {}) {
|
|
|
1495
1495
|
if (state) result[key] = true;
|
|
1496
1496
|
}
|
|
1497
1497
|
for (const key of OVERRIDE_KEYS) {
|
|
1498
|
-
for (const
|
|
1499
|
-
const value =
|
|
1498
|
+
for (const level2 of levels) {
|
|
1499
|
+
const value = level2[key];
|
|
1500
1500
|
if (value !== void 0) result[key] = value;
|
|
1501
1501
|
}
|
|
1502
1502
|
}
|
|
@@ -1569,8 +1569,8 @@ function rgbToHsl(r, g, b) {
|
|
|
1569
1569
|
}
|
|
1570
1570
|
return { h, s: clampUnitInterval(s), l: clampUnitInterval(l) };
|
|
1571
1571
|
}
|
|
1572
|
-
function hslToRgb(h, s, l, roundChannel = Math.round,
|
|
1573
|
-
const sC =
|
|
1572
|
+
function hslToRgb(h, s, l, roundChannel = Math.round, options2) {
|
|
1573
|
+
const sC = options2?.clampSaturation === false ? s : clampUnitInterval(s);
|
|
1574
1574
|
const lC = clampUnitInterval(l);
|
|
1575
1575
|
const hN = (h % 360 + 360) % 360;
|
|
1576
1576
|
const c2 = (1 - Math.abs(2 * lC - 1)) * sC;
|
|
@@ -2107,13 +2107,13 @@ var APPLIED = /* @__PURE__ */ new Set([
|
|
|
2107
2107
|
"lumMod",
|
|
2108
2108
|
"lumOff"
|
|
2109
2109
|
]);
|
|
2110
|
-
function resolveDrawingColor(color, theme,
|
|
2110
|
+
function resolveDrawingColor(color, theme, options2) {
|
|
2111
2111
|
const base = baseHex(color, theme);
|
|
2112
2112
|
const rgb = base ? hexToRgbChannels(base) : null;
|
|
2113
2113
|
if (!rgb) return void 0;
|
|
2114
|
-
if (
|
|
2114
|
+
if (options2?.transformOrder === "document") {
|
|
2115
2115
|
const value = orderedColorTransforms(rgb, color.transforms);
|
|
2116
|
-
const round2 =
|
|
2116
|
+
const round2 = options2.hslRounding === "halfDown" ? (channel) => Math.ceil(channel - 0.5) : Math.round;
|
|
2117
2117
|
return {
|
|
2118
2118
|
hex: `#${toHex(round2(value.r))}${toHex(round2(value.g))}${toHex(round2(value.b))}`,
|
|
2119
2119
|
alpha: value.alpha,
|
|
@@ -2164,7 +2164,7 @@ function resolveDrawingColor(color, theme, options) {
|
|
|
2164
2164
|
if (lumMod !== void 0) hsl.l = clampUnitInterval(hsl.l * lumMod);
|
|
2165
2165
|
const lumOff = parseDrawingFraction(find("lumOff"));
|
|
2166
2166
|
if (lumOff !== void 0) hsl.l = clampUnitInterval(hsl.l + lumOff);
|
|
2167
|
-
const round2 =
|
|
2167
|
+
const round2 = options2?.hslRounding === "halfDown" ? (value) => Math.ceil(value - 0.5) : Math.round;
|
|
2168
2168
|
({ r, g, b } = hslToRgb(hsl.h, hsl.s, hsl.l, round2));
|
|
2169
2169
|
}
|
|
2170
2170
|
let alpha = parseDrawingPercent(find("alpha")) ?? 1;
|
|
@@ -2832,13 +2832,13 @@ function parseKind(sdtPr) {
|
|
|
2832
2832
|
return "richText";
|
|
2833
2833
|
}
|
|
2834
2834
|
var generated = 0;
|
|
2835
|
-
function parseContentControl(sdt,
|
|
2835
|
+
function parseContentControl(sdt, level2) {
|
|
2836
2836
|
const sdtPr = first2(sdt, "sdtPr");
|
|
2837
|
-
if (!sdtPr) return { id: `sdt-gen-${++generated}`, level, kind: "richText" };
|
|
2837
|
+
if (!sdtPr) return { id: `sdt-gen-${++generated}`, level: level2, kind: "richText" };
|
|
2838
2838
|
const kind = parseKind(sdtPr);
|
|
2839
2839
|
const control = {
|
|
2840
2840
|
id: getW(first2(sdtPr, "id"), "val") ?? `sdt-gen-${++generated}`,
|
|
2841
|
-
level,
|
|
2841
|
+
level: level2,
|
|
2842
2842
|
kind
|
|
2843
2843
|
};
|
|
2844
2844
|
const alias = getW(first2(sdtPr, "alias"), "val");
|
|
@@ -3020,7 +3020,7 @@ function parseInlineControl(sdt, parseRun3, parseOther, resolveLink, comments, m
|
|
|
3020
3020
|
for (const run of runs) run.contentControl ??= control;
|
|
3021
3021
|
return runs;
|
|
3022
3022
|
}
|
|
3023
|
-
function flatChildren(parent, names,
|
|
3023
|
+
function flatChildren(parent, names, level2 = "block", enclosing, controls = /* @__PURE__ */ new Map()) {
|
|
3024
3024
|
const found = [];
|
|
3025
3025
|
for (const child4 of Array.from(parent.childNodes).filter(isElement)) {
|
|
3026
3026
|
if (isSdt(child4)) {
|
|
@@ -3028,10 +3028,10 @@ function flatChildren(parent, names, level = "block", enclosing, controls = /* @
|
|
|
3028
3028
|
if (!content) continue;
|
|
3029
3029
|
let control = controls.get(child4);
|
|
3030
3030
|
if (!control) {
|
|
3031
|
-
control = parseContentControl(child4,
|
|
3031
|
+
control = parseContentControl(child4, level2);
|
|
3032
3032
|
controls.set(child4, control);
|
|
3033
3033
|
}
|
|
3034
|
-
found.push(...flatChildren(content, names,
|
|
3034
|
+
found.push(...flatChildren(content, names, level2, { control, sdt: child4 }, controls));
|
|
3035
3035
|
} else if (names.some((name) => named2(child4, name)))
|
|
3036
3036
|
found.push({
|
|
3037
3037
|
element: child4,
|
|
@@ -4522,8 +4522,8 @@ function writeNewReferences(doc, sectPr, section, previous, references) {
|
|
|
4522
4522
|
}
|
|
4523
4523
|
}
|
|
4524
4524
|
var paragraphSection = (node) => node?.localName === "p" ? first2(first2(node, "pPr"), "sectPr") : void 0;
|
|
4525
|
-
function applySectionEdits(doc, body, blocks,
|
|
4526
|
-
if (!
|
|
4525
|
+
function applySectionEdits(doc, body, blocks, sections2, base, references = /* @__PURE__ */ new Map()) {
|
|
4526
|
+
if (!sections2.length) {
|
|
4527
4527
|
if (base.length)
|
|
4528
4528
|
throw new Error("A document needs at least one section; the section list cannot be emptied.");
|
|
4529
4529
|
return;
|
|
@@ -4532,7 +4532,7 @@ function applySectionEdits(doc, body, blocks, sections, base, references = /* @_
|
|
|
4532
4532
|
(node) => node.nodeType === 1 && ["p", "tbl"].includes(node.localName)
|
|
4533
4533
|
);
|
|
4534
4534
|
const nodeFor = (id) => topLevel2[blocks.findIndex((block) => block.id === id)];
|
|
4535
|
-
const ends = new Set(
|
|
4535
|
+
const ends = new Set(sections2.slice(0, -1).map((section) => section.endsAtBlockId));
|
|
4536
4536
|
blocks.forEach((block, index) => {
|
|
4537
4537
|
const sectPr = paragraphSection(topLevel2[index]);
|
|
4538
4538
|
if (sectPr && !ends.has(block.id)) sectPr.parentNode?.removeChild(sectPr);
|
|
@@ -4544,10 +4544,10 @@ function applySectionEdits(doc, body, blocks, sections, base, references = /* @_
|
|
|
4544
4544
|
}
|
|
4545
4545
|
const baseByEnd = new Map(base.map((section) => [section.endsAtBlockId, section]));
|
|
4546
4546
|
let following = bodySection;
|
|
4547
|
-
for (let index =
|
|
4548
|
-
const section =
|
|
4547
|
+
for (let index = sections2.length - 1; index >= 0; index--) {
|
|
4548
|
+
const section = sections2[index];
|
|
4549
4549
|
if (!section) continue;
|
|
4550
|
-
const last = index ===
|
|
4550
|
+
const last = index === sections2.length - 1;
|
|
4551
4551
|
let sectPr = last ? bodySection : paragraphSection(nodeFor(section.endsAtBlockId));
|
|
4552
4552
|
const previous = last ? base.at(-1) : baseByEnd.get(section.endsAtBlockId);
|
|
4553
4553
|
if (!sectPr) {
|
|
@@ -5887,7 +5887,7 @@ function resolveInnerRect(fillToRect, focalPoint) {
|
|
|
5887
5887
|
function lerpEdge(inner, outer, t) {
|
|
5888
5888
|
return inner + (outer - inner) * t;
|
|
5889
5889
|
}
|
|
5890
|
-
function buildRectPathGradientSvg(stops, focalPoint, fillToRect,
|
|
5890
|
+
function buildRectPathGradientSvg(stops, focalPoint, fillToRect, options2) {
|
|
5891
5891
|
if (stops.length === 0) {
|
|
5892
5892
|
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"/>';
|
|
5893
5893
|
}
|
|
@@ -5896,7 +5896,7 @@ function buildRectPathGradientSvg(stops, focalPoint, fillToRect, options) {
|
|
|
5896
5896
|
const rects = [];
|
|
5897
5897
|
const alphaRects = [];
|
|
5898
5898
|
const masked = sorted.some((stop) => (stop.opacity ?? 1) < 1);
|
|
5899
|
-
const bands =
|
|
5899
|
+
const bands = options2?.bands;
|
|
5900
5900
|
if (!Number.isInteger(bands) || bands < 1) throw new RangeError("Invalid gradient band count");
|
|
5901
5901
|
for (let i = bands; i >= 0; i -= 1) {
|
|
5902
5902
|
const t = i / bands;
|
|
@@ -15765,16 +15765,16 @@ function parseDiagramLayoutSummary(source) {
|
|
|
15765
15765
|
|
|
15766
15766
|
// diagram/drawing.ts
|
|
15767
15767
|
var IDENTITY = { offsetX: 0, offsetY: 0, scaleX: 1, scaleY: 1 };
|
|
15768
|
-
function applyGroup(frame2,
|
|
15768
|
+
function applyGroup(frame2, group2) {
|
|
15769
15769
|
return {
|
|
15770
|
-
x: Math.round(
|
|
15771
|
-
y: Math.round(
|
|
15772
|
-
width: Math.round(frame2.width *
|
|
15773
|
-
height: Math.round(frame2.height *
|
|
15770
|
+
x: Math.round(group2.offsetX + frame2.x * group2.scaleX),
|
|
15771
|
+
y: Math.round(group2.offsetY + frame2.y * group2.scaleY),
|
|
15772
|
+
width: Math.round(frame2.width * group2.scaleX),
|
|
15773
|
+
height: Math.round(frame2.height * group2.scaleY)
|
|
15774
15774
|
};
|
|
15775
15775
|
}
|
|
15776
|
-
function groupTransform(
|
|
15777
|
-
const xfrm = first(first(
|
|
15776
|
+
function groupTransform(group2, parent) {
|
|
15777
|
+
const xfrm = first(first(group2, "grpSpPr", NS.dsp), "xfrm", NS.a);
|
|
15778
15778
|
const off = first(xfrm, "off", NS.a);
|
|
15779
15779
|
const ext = first(xfrm, "ext", NS.a);
|
|
15780
15780
|
const chOff = first(xfrm, "chOff", NS.a);
|
|
@@ -15801,14 +15801,14 @@ function groupTransform(group, parent) {
|
|
|
15801
15801
|
scaleY: parent.scaleY * local.scaleY
|
|
15802
15802
|
};
|
|
15803
15803
|
}
|
|
15804
|
-
function parseShape2(sp, index,
|
|
15804
|
+
function parseShape2(sp, index, group2, issues) {
|
|
15805
15805
|
const spPr = first(sp, "spPr", NS.dsp);
|
|
15806
15806
|
const transform2 = parseTransform(first(spPr, "xfrm", NS.a));
|
|
15807
15807
|
if (!transform2) return void 0;
|
|
15808
15808
|
const modelId = stringAttribute(sp, "modelId") ?? stringAttribute(first(first(sp, "nvSpPr", NS.dsp), "cNvPr", NS.dsp), "id") ?? `dsp-${index}`;
|
|
15809
15809
|
const { geometry: geometry2, adjustments, paths, issue } = parseDrawingGeometry(spPr);
|
|
15810
15810
|
if (issue) issues.push({ code: issue, message: `Shape ${modelId}: ${issue}.` });
|
|
15811
|
-
const frame2 = applyGroup(transform2.frame,
|
|
15811
|
+
const frame2 = applyGroup(transform2.frame, group2);
|
|
15812
15812
|
if ((frame2.width <= 0 || frame2.height <= 0) && geometry2 !== "line") return void 0;
|
|
15813
15813
|
const shape2 = {
|
|
15814
15814
|
modelId,
|
|
@@ -15830,7 +15830,7 @@ function parseShape2(sp, index, group, issues) {
|
|
|
15830
15830
|
const text3 = parseDrawingTextBody(first(sp, "txBody", NS.dsp));
|
|
15831
15831
|
if (text3) shape2.text = text3;
|
|
15832
15832
|
const textFrame = parseFrame(first(sp, "txXfrm", NS.dsp));
|
|
15833
|
-
if (textFrame) shape2.textFrame = applyGroup(textFrame,
|
|
15833
|
+
if (textFrame) shape2.textFrame = applyGroup(textFrame, group2);
|
|
15834
15834
|
return shape2;
|
|
15835
15835
|
}
|
|
15836
15836
|
function parseDiagramDrawing(source, part) {
|
|
@@ -15839,14 +15839,14 @@ function parseDiagramDrawing(source, part) {
|
|
|
15839
15839
|
const shapes = [];
|
|
15840
15840
|
const tree = root.localName === "spTree" ? root : first(root, "spTree", NS.dsp);
|
|
15841
15841
|
let counter = 0;
|
|
15842
|
-
const visit = (container,
|
|
15842
|
+
const visit = (container, group2) => {
|
|
15843
15843
|
for (const child4 of Array.from(container.childNodes)) {
|
|
15844
15844
|
if (child4.nodeType !== 1) continue;
|
|
15845
15845
|
const element = child4;
|
|
15846
15846
|
if (element.localName === "sp") {
|
|
15847
|
-
const shape2 = parseShape2(element, counter++,
|
|
15847
|
+
const shape2 = parseShape2(element, counter++, group2, issues);
|
|
15848
15848
|
if (shape2) shapes.push(shape2);
|
|
15849
|
-
} else if (element.localName === "grpSp") visit(element, groupTransform(element,
|
|
15849
|
+
} else if (element.localName === "grpSp") visit(element, groupTransform(element, group2));
|
|
15850
15850
|
else if (element.localName === "pic")
|
|
15851
15851
|
issues.push({
|
|
15852
15852
|
code: "DIAGRAM_DRAWING_PICTURE_SKIPPED",
|
|
@@ -16193,13 +16193,297 @@ function groupRowsByCategory(rawCategories) {
|
|
|
16193
16193
|
return { uniqueCategories, rowIndexesByCategory };
|
|
16194
16194
|
}
|
|
16195
16195
|
|
|
16196
|
+
// chart/number-format-pattern.ts
|
|
16197
|
+
var NAMED_FORMAT_COLORS = {
|
|
16198
|
+
black: "#000000",
|
|
16199
|
+
blue: "#0000FF",
|
|
16200
|
+
cyan: "#00FFFF",
|
|
16201
|
+
green: "#00FF00",
|
|
16202
|
+
magenta: "#FF00FF",
|
|
16203
|
+
red: "#FF0000",
|
|
16204
|
+
white: "#FFFFFF",
|
|
16205
|
+
yellow: "#FFFF00"
|
|
16206
|
+
};
|
|
16207
|
+
var PLACEHOLDER = /[0#?]/u;
|
|
16208
|
+
function parsePattern(code) {
|
|
16209
|
+
let scale = 1;
|
|
16210
|
+
let scientific = false;
|
|
16211
|
+
let color;
|
|
16212
|
+
const chars = [];
|
|
16213
|
+
let inQuotes = false;
|
|
16214
|
+
for (let i = 0; i < code.length; i += 1) {
|
|
16215
|
+
const ch = code[i] ?? "";
|
|
16216
|
+
if (ch === '"') {
|
|
16217
|
+
inQuotes = !inQuotes;
|
|
16218
|
+
continue;
|
|
16219
|
+
}
|
|
16220
|
+
if (inQuotes) {
|
|
16221
|
+
chars.push({ ch, literal: true });
|
|
16222
|
+
continue;
|
|
16223
|
+
}
|
|
16224
|
+
if (ch === "\\" || ch === "*" || ch === "_") {
|
|
16225
|
+
const next = code[i + 1];
|
|
16226
|
+
i += 1;
|
|
16227
|
+
if (ch === "\\" && next !== void 0) {
|
|
16228
|
+
chars.push({ ch: next, literal: true });
|
|
16229
|
+
}
|
|
16230
|
+
continue;
|
|
16231
|
+
}
|
|
16232
|
+
if (ch === "%") {
|
|
16233
|
+
scale *= 100;
|
|
16234
|
+
chars.push({ ch, literal: true });
|
|
16235
|
+
continue;
|
|
16236
|
+
}
|
|
16237
|
+
if (ch === "E" && (code[i + 1] === "+" || code[i + 1] === "-")) {
|
|
16238
|
+
scientific = true;
|
|
16239
|
+
chars.push({ ch: "E", literal: false });
|
|
16240
|
+
i += 1;
|
|
16241
|
+
continue;
|
|
16242
|
+
}
|
|
16243
|
+
if (ch === "[") {
|
|
16244
|
+
const close = code.indexOf("]", i);
|
|
16245
|
+
const token = code.slice(i + 1, close === -1 ? code.length : close);
|
|
16246
|
+
const named3 = NAMED_FORMAT_COLORS[token.trim().toLowerCase()];
|
|
16247
|
+
if (named3 && color === void 0) {
|
|
16248
|
+
color = named3;
|
|
16249
|
+
}
|
|
16250
|
+
i = close === -1 ? code.length : close;
|
|
16251
|
+
continue;
|
|
16252
|
+
}
|
|
16253
|
+
chars.push({ ch, literal: false });
|
|
16254
|
+
}
|
|
16255
|
+
const firstDigit = chars.findIndex((c2) => !c2.literal && PLACEHOLDER.test(c2.ch));
|
|
16256
|
+
if (firstDigit === -1) {
|
|
16257
|
+
return void 0;
|
|
16258
|
+
}
|
|
16259
|
+
let lastDigit = firstDigit;
|
|
16260
|
+
for (let i = chars.length - 1; i >= firstDigit; i -= 1) {
|
|
16261
|
+
const c2 = chars[i];
|
|
16262
|
+
if (c2 && !c2.literal && (PLACEHOLDER.test(c2.ch) || c2.ch === "." || c2.ch === "," || c2.ch === "E")) {
|
|
16263
|
+
lastDigit = i;
|
|
16264
|
+
break;
|
|
16265
|
+
}
|
|
16266
|
+
}
|
|
16267
|
+
const numeric = chars.slice(firstDigit, lastDigit + 1);
|
|
16268
|
+
const prefix2 = chars.slice(0, firstDigit).map((c2) => c2.ch).join("");
|
|
16269
|
+
const suffix = chars.slice(lastDigit + 1).map((c2) => c2.ch).join("");
|
|
16270
|
+
let grouped = false;
|
|
16271
|
+
let intDigits = 0;
|
|
16272
|
+
let required = 0;
|
|
16273
|
+
let optional = 0;
|
|
16274
|
+
let afterPoint = false;
|
|
16275
|
+
let inExponent = false;
|
|
16276
|
+
for (let i = 0; i < numeric.length; i += 1) {
|
|
16277
|
+
const { ch, literal } = numeric[i] ?? { ch: "", literal: true };
|
|
16278
|
+
if (literal) {
|
|
16279
|
+
continue;
|
|
16280
|
+
}
|
|
16281
|
+
if (ch === "E") {
|
|
16282
|
+
inExponent = true;
|
|
16283
|
+
continue;
|
|
16284
|
+
}
|
|
16285
|
+
if (inExponent) {
|
|
16286
|
+
continue;
|
|
16287
|
+
}
|
|
16288
|
+
if (ch === ".") {
|
|
16289
|
+
afterPoint = true;
|
|
16290
|
+
continue;
|
|
16291
|
+
}
|
|
16292
|
+
if (ch === ",") {
|
|
16293
|
+
const next = numeric.slice(i + 1).find((c2) => !c2.literal);
|
|
16294
|
+
if (!next || next.ch === "." || !PLACEHOLDER.test(next.ch)) {
|
|
16295
|
+
scale /= 1e3;
|
|
16296
|
+
} else {
|
|
16297
|
+
grouped = true;
|
|
16298
|
+
}
|
|
16299
|
+
continue;
|
|
16300
|
+
}
|
|
16301
|
+
if (!PLACEHOLDER.test(ch)) {
|
|
16302
|
+
continue;
|
|
16303
|
+
}
|
|
16304
|
+
if (afterPoint) {
|
|
16305
|
+
if (ch === "0") {
|
|
16306
|
+
required += 1;
|
|
16307
|
+
} else {
|
|
16308
|
+
optional += 1;
|
|
16309
|
+
}
|
|
16310
|
+
} else if (ch === "0") {
|
|
16311
|
+
intDigits += 1;
|
|
16312
|
+
}
|
|
16313
|
+
}
|
|
16314
|
+
return {
|
|
16315
|
+
prefix: prefix2,
|
|
16316
|
+
suffix,
|
|
16317
|
+
intDigits,
|
|
16318
|
+
decimals: { required, optional },
|
|
16319
|
+
grouped,
|
|
16320
|
+
scale,
|
|
16321
|
+
scientific,
|
|
16322
|
+
color
|
|
16323
|
+
};
|
|
16324
|
+
}
|
|
16325
|
+
function group(intPart) {
|
|
16326
|
+
return intPart.replace(/\B(?=(\d{3})+(?!\d))/gu, ",");
|
|
16327
|
+
}
|
|
16328
|
+
function applyPattern(value, pattern, forcePositive) {
|
|
16329
|
+
const scaled = value * pattern.scale;
|
|
16330
|
+
const magnitude = forcePositive ? Math.abs(scaled) : scaled;
|
|
16331
|
+
if (pattern.scientific) {
|
|
16332
|
+
const digits = pattern.decimals.required + pattern.decimals.optional;
|
|
16333
|
+
const exponential = magnitude.toExponential(digits);
|
|
16334
|
+
const [mantissa = "", exponent = "0"] = exponential.split("e");
|
|
16335
|
+
const sign = exponent.startsWith("-") ? "-" : "+";
|
|
16336
|
+
const power = Math.abs(Number(exponent)).toString().padStart(2, "0");
|
|
16337
|
+
return `${pattern.prefix}${mantissa}E${sign}${power}${pattern.suffix}`;
|
|
16338
|
+
}
|
|
16339
|
+
const maxDecimals = pattern.decimals.required + pattern.decimals.optional;
|
|
16340
|
+
let body = magnitude.toFixed(maxDecimals);
|
|
16341
|
+
if (pattern.decimals.optional > 0) {
|
|
16342
|
+
body = body.replace(/(\.\d*?)0+$/u, "$1").replace(/\.$/u, "");
|
|
16343
|
+
const [, frac = ""] = body.split(".");
|
|
16344
|
+
if (frac.length < pattern.decimals.required) {
|
|
16345
|
+
body = Number(body).toFixed(pattern.decimals.required);
|
|
16346
|
+
}
|
|
16347
|
+
}
|
|
16348
|
+
const [rawIntPart = "", fracPart] = body.split(".");
|
|
16349
|
+
let intPart = rawIntPart;
|
|
16350
|
+
const hasMinusChar = intPart.startsWith("-");
|
|
16351
|
+
const negative = hasMinusChar && Number(body) !== 0;
|
|
16352
|
+
if (hasMinusChar) {
|
|
16353
|
+
intPart = intPart.slice(1);
|
|
16354
|
+
}
|
|
16355
|
+
if (intPart.length < pattern.intDigits) {
|
|
16356
|
+
intPart = intPart.padStart(pattern.intDigits, "0");
|
|
16357
|
+
}
|
|
16358
|
+
if (pattern.intDigits === 0 && intPart === "0" && fracPart !== void 0) {
|
|
16359
|
+
intPart = "";
|
|
16360
|
+
}
|
|
16361
|
+
if (pattern.grouped) {
|
|
16362
|
+
intPart = group(intPart);
|
|
16363
|
+
}
|
|
16364
|
+
const number = fracPart === void 0 ? intPart : `${intPart}.${fracPart}`;
|
|
16365
|
+
return `${negative ? "-" : ""}${pattern.prefix}${number}${pattern.suffix}`;
|
|
16366
|
+
}
|
|
16367
|
+
|
|
16368
|
+
// chart/number-format.ts
|
|
16369
|
+
var GENERAL = /* @__PURE__ */ new Set(["", "general", "@"]);
|
|
16370
|
+
function sections(code) {
|
|
16371
|
+
const out = [];
|
|
16372
|
+
let current = "";
|
|
16373
|
+
let inQuotes = false;
|
|
16374
|
+
for (let i = 0; i < code.length; i += 1) {
|
|
16375
|
+
const ch = code[i];
|
|
16376
|
+
if (ch === '"') {
|
|
16377
|
+
inQuotes = !inQuotes;
|
|
16378
|
+
current += ch;
|
|
16379
|
+
continue;
|
|
16380
|
+
}
|
|
16381
|
+
if (ch === "\\") {
|
|
16382
|
+
current += ch + (code[i + 1] ?? "");
|
|
16383
|
+
i += 1;
|
|
16384
|
+
continue;
|
|
16385
|
+
}
|
|
16386
|
+
if (ch === ";" && !inQuotes) {
|
|
16387
|
+
out.push(current);
|
|
16388
|
+
current = "";
|
|
16389
|
+
continue;
|
|
16390
|
+
}
|
|
16391
|
+
current += ch;
|
|
16392
|
+
}
|
|
16393
|
+
out.push(current);
|
|
16394
|
+
return out;
|
|
16395
|
+
}
|
|
16396
|
+
function sectionFor(value, parts) {
|
|
16397
|
+
if (parts.length === 1) {
|
|
16398
|
+
return { code: parts[0] ?? "", forcePositive: false };
|
|
16399
|
+
}
|
|
16400
|
+
if (value < 0 && parts[1] !== void 0) {
|
|
16401
|
+
return { code: parts[1] ?? "", forcePositive: true };
|
|
16402
|
+
}
|
|
16403
|
+
if (value === 0 && parts[2] !== void 0) {
|
|
16404
|
+
return { code: parts[2] ?? "", forcePositive: false };
|
|
16405
|
+
}
|
|
16406
|
+
return { code: parts[0] ?? "", forcePositive: false };
|
|
16407
|
+
}
|
|
16408
|
+
function formatChartNumberWithColor(value, formatCode) {
|
|
16409
|
+
if (!Number.isFinite(value)) {
|
|
16410
|
+
return void 0;
|
|
16411
|
+
}
|
|
16412
|
+
const code = (formatCode ?? "").trim();
|
|
16413
|
+
if (GENERAL.has(code.toLowerCase())) {
|
|
16414
|
+
return void 0;
|
|
16415
|
+
}
|
|
16416
|
+
if (/(?:^|[^\\"])(?:yy|mm?m|dd?|hh|ss)/iu.test(code) && !/[0#?]/u.test(code)) {
|
|
16417
|
+
return void 0;
|
|
16418
|
+
}
|
|
16419
|
+
const { code: section, forcePositive } = sectionFor(value, sections(code));
|
|
16420
|
+
const pattern = parsePattern(section);
|
|
16421
|
+
if (!pattern) {
|
|
16422
|
+
return void 0;
|
|
16423
|
+
}
|
|
16424
|
+
try {
|
|
16425
|
+
return { text: applyPattern(value, pattern, forcePositive), color: pattern.color };
|
|
16426
|
+
} catch {
|
|
16427
|
+
return void 0;
|
|
16428
|
+
}
|
|
16429
|
+
}
|
|
16430
|
+
function formatChartNumber(value, formatCode) {
|
|
16431
|
+
return formatChartNumberWithColor(value, formatCode)?.text;
|
|
16432
|
+
}
|
|
16433
|
+
|
|
16434
|
+
// chart/data-label-text.ts
|
|
16435
|
+
var DATA_LABEL_SEPARATOR = ", ";
|
|
16436
|
+
var DATA_LABEL_CATEGORY_PERCENT_SEPARATOR = "\n";
|
|
16437
|
+
var FLAG_KEYS = [
|
|
16438
|
+
"showValue",
|
|
16439
|
+
"showCategory",
|
|
16440
|
+
"showSeriesName",
|
|
16441
|
+
"showPercent",
|
|
16442
|
+
"showBubbleSize"
|
|
16443
|
+
];
|
|
16444
|
+
function resolveDataLabelFlags(levels) {
|
|
16445
|
+
const { point, series, chart } = levels;
|
|
16446
|
+
const picked = {};
|
|
16447
|
+
for (const key of FLAG_KEYS) picked[key] = point?.[key] ?? series?.[key] ?? chart?.[key];
|
|
16448
|
+
const anyDeclared = FLAG_KEYS.some((key) => picked[key] !== void 0);
|
|
16449
|
+
return {
|
|
16450
|
+
showValue: anyDeclared ? picked.showValue === true : levels.siblingOwnsLabels !== true,
|
|
16451
|
+
showCategory: picked.showCategory === true,
|
|
16452
|
+
showSeriesName: picked.showSeriesName === true,
|
|
16453
|
+
showPercent: picked.showPercent === true,
|
|
16454
|
+
showBubbleSize: picked.showBubbleSize === true,
|
|
16455
|
+
separator: point?.separator ?? series?.separator ?? chart?.separator ?? (picked.showCategory === true && picked.showPercent === true ? DATA_LABEL_CATEGORY_PERCENT_SEPARATOR : DATA_LABEL_SEPARATOR)
|
|
16456
|
+
};
|
|
16457
|
+
}
|
|
16458
|
+
function composeDataLabelText(input) {
|
|
16459
|
+
const { flags, value, numberFormat: numberFormat2 } = input;
|
|
16460
|
+
const parts = [];
|
|
16461
|
+
let valueColor;
|
|
16462
|
+
if (flags.showSeriesName && input.seriesName) parts.push(input.seriesName);
|
|
16463
|
+
if (flags.showCategory && input.category) parts.push(input.category);
|
|
16464
|
+
if (flags.showValue) {
|
|
16465
|
+
const formatted = formatChartNumberWithColor(value, numberFormat2);
|
|
16466
|
+
parts.push(formatted?.text ?? (input.formatValue ?? String)(value, numberFormat2));
|
|
16467
|
+
valueColor = formatted?.color;
|
|
16468
|
+
}
|
|
16469
|
+
if (flags.showPercent) {
|
|
16470
|
+
const base = input.percentBase;
|
|
16471
|
+
parts.push(base > 0 ? `${Math.round(Math.abs(value) / base * 100)}%` : "0%");
|
|
16472
|
+
}
|
|
16473
|
+
if (flags.showBubbleSize && input.bubbleSize !== void 0)
|
|
16474
|
+
parts.push((input.formatBubbleSize ?? String)(input.bubbleSize));
|
|
16475
|
+
const text3 = parts.join(flags.separator);
|
|
16476
|
+
if (text3.length === 0) return void 0;
|
|
16477
|
+
return { text: text3, color: parts.length === 1 && flags.showValue ? valueColor : void 0 };
|
|
16478
|
+
}
|
|
16479
|
+
|
|
16196
16480
|
// chart/bubble-radius.ts
|
|
16197
|
-
function computeBubbleRadius(sizeVal, maxBubble, medianRadius,
|
|
16198
|
-
const scale = (
|
|
16481
|
+
function computeBubbleRadius(sizeVal, maxBubble, medianRadius, options2) {
|
|
16482
|
+
const scale = (options2?.bubbleScale ?? 100) / 100;
|
|
16199
16483
|
if (sizeVal === void 0) return medianRadius * scale;
|
|
16200
16484
|
const denom = maxBubble > 0 ? maxBubble : 1;
|
|
16201
16485
|
const magnitude = Math.abs(sizeVal);
|
|
16202
|
-
const ratio = (
|
|
16486
|
+
const ratio = (options2?.sizeRepresents ?? "w") === "area" ? Math.sqrt(magnitude) / Math.sqrt(denom) : magnitude / denom;
|
|
16203
16487
|
return medianRadius * scale * 0.5 + ratio * medianRadius * scale * 1.5;
|
|
16204
16488
|
}
|
|
16205
16489
|
function maxBubbleSize(sizes) {
|
|
@@ -16305,10 +16589,10 @@ function squarify(nodes, box) {
|
|
|
16305
16589
|
|
|
16306
16590
|
// chart/hierarchy.ts
|
|
16307
16591
|
function normalizeLevels(levels, pointCount) {
|
|
16308
|
-
return levels.map((
|
|
16592
|
+
return levels.map((level2) => {
|
|
16309
16593
|
let previous = "";
|
|
16310
16594
|
return Array.from({ length: pointCount }, (_, index) => {
|
|
16311
|
-
const label =
|
|
16595
|
+
const label = level2[index]?.trim() ?? "";
|
|
16312
16596
|
if (label) previous = label;
|
|
16313
16597
|
return label || previous;
|
|
16314
16598
|
});
|
|
@@ -16466,12 +16750,12 @@ function computeSunburstArcs(series, cx2, cy, maxR) {
|
|
|
16466
16750
|
});
|
|
16467
16751
|
return out;
|
|
16468
16752
|
}
|
|
16469
|
-
function hierarchyKey(levels,
|
|
16470
|
-
return levels.slice(
|
|
16753
|
+
function hierarchyKey(levels, level2, index) {
|
|
16754
|
+
return levels.slice(level2).map((labels) => labels[index] ?? "").join("\0");
|
|
16471
16755
|
}
|
|
16472
16756
|
function computeHierarchicalSunburstArcs(categoryLevels2, values, cx2, cy, maxR) {
|
|
16473
|
-
const levels = categoryLevels2.filter((
|
|
16474
|
-
const leafCount = Math.max(values.length, ...levels.map((
|
|
16757
|
+
const levels = categoryLevels2.filter((level2) => level2.length > 0);
|
|
16758
|
+
const leafCount = Math.max(values.length, ...levels.map((level2) => level2.length), 0);
|
|
16475
16759
|
if (levels.length === 0 || leafCount === 0) return [];
|
|
16476
16760
|
const rawWeights = Array.from({ length: leafCount }, (_, index) => Math.abs(values[index] ?? 0));
|
|
16477
16761
|
const weights = rawWeights.some((value) => value !== 0) ? rawWeights : rawWeights.map(() => 1);
|
|
@@ -16482,15 +16766,15 @@ function computeHierarchicalSunburstArcs(categoryLevels2, values, cx2, cy, maxR)
|
|
|
16482
16766
|
const rootLabels = levels[levels.length - 1] ?? [];
|
|
16483
16767
|
const rootColors = /* @__PURE__ */ new Map();
|
|
16484
16768
|
const out = [];
|
|
16485
|
-
for (let
|
|
16486
|
-
const ringIndex = levels.length - 1 -
|
|
16769
|
+
for (let level2 = levels.length - 1; level2 >= 0; level2--) {
|
|
16770
|
+
const ringIndex = levels.length - 1 - level2;
|
|
16487
16771
|
const innerRadius = ringWidth * (ringIndex + 0.5);
|
|
16488
16772
|
const outerRadius = ringWidth * (ringIndex + 1.5);
|
|
16489
16773
|
let start = 0;
|
|
16490
16774
|
while (start < leafCount) {
|
|
16491
|
-
const key = hierarchyKey(levels,
|
|
16775
|
+
const key = hierarchyKey(levels, level2, start);
|
|
16492
16776
|
let end = start + 1;
|
|
16493
|
-
while (end < leafCount && hierarchyKey(levels,
|
|
16777
|
+
while (end < leafCount && hierarchyKey(levels, level2, end) === key) end++;
|
|
16494
16778
|
const startAngle = -Math.PI / 2 + (prefix2[start] ?? 0) / total * Math.PI * 2;
|
|
16495
16779
|
const endAngle = -Math.PI / 2 + (prefix2[end] ?? 0) / total * Math.PI * 2;
|
|
16496
16780
|
const rootLabel = rootLabels[start] ?? "";
|
|
@@ -16500,8 +16784,8 @@ function computeHierarchicalSunburstArcs(categoryLevels2, values, cx2, cy, maxR)
|
|
|
16500
16784
|
colorIndex: rootColors.get(rootLabel) ?? start,
|
|
16501
16785
|
opacity: Math.max(0.1, 0.9 - ringIndex * 0.1),
|
|
16502
16786
|
level: ringIndex,
|
|
16503
|
-
label: levels[
|
|
16504
|
-
...
|
|
16787
|
+
label: levels[level2]?.[start] ?? "",
|
|
16788
|
+
...level2 === 0 && end === start + 1 ? { pointIndex: start } : {},
|
|
16505
16789
|
...arcLabelPlacement(cx2, cy, (innerRadius + outerRadius) / 2, startAngle, endAngle)
|
|
16506
16790
|
});
|
|
16507
16791
|
start = end;
|
|
@@ -16527,14 +16811,14 @@ function scottBinCount(values, min, max) {
|
|
|
16527
16811
|
const width = 3.49 * sd * values.length ** (-1 / 3);
|
|
16528
16812
|
return Math.max(1, Math.ceil((max - min) / width));
|
|
16529
16813
|
}
|
|
16530
|
-
function computeHistogramBins(values,
|
|
16531
|
-
const closed =
|
|
16814
|
+
function computeHistogramBins(values, options2, format = String) {
|
|
16815
|
+
const closed = options2.intervalClosed ?? "l";
|
|
16532
16816
|
const finite2 = values.map((value, sourceIndex) => ({ value, sourceIndex })).filter((item) => Number.isFinite(item.value));
|
|
16533
16817
|
if (finite2.length === 0) {
|
|
16534
16818
|
return [];
|
|
16535
16819
|
}
|
|
16536
|
-
const underflow = typeof
|
|
16537
|
-
const overflow = typeof
|
|
16820
|
+
const underflow = typeof options2.underflow === "number" ? options2.underflow : void 0;
|
|
16821
|
+
const overflow = typeof options2.overflow === "number" ? options2.overflow : void 0;
|
|
16538
16822
|
const under = underflow === void 0 ? [] : finite2.filter(
|
|
16539
16823
|
(item) => closed === "r" ? item.value <= underflow : item.value < underflow
|
|
16540
16824
|
);
|
|
@@ -16551,8 +16835,8 @@ function computeHistogramBins(values, options, format = String) {
|
|
|
16551
16835
|
if (regular.length > 0) {
|
|
16552
16836
|
const min = Math.min(...regular.map((item) => item.value));
|
|
16553
16837
|
const max = Math.max(...regular.map((item) => item.value));
|
|
16554
|
-
const requestedSize =
|
|
16555
|
-
const requestedCount =
|
|
16838
|
+
const requestedSize = options2.binSize && options2.binSize > 0 ? options2.binSize : void 0;
|
|
16839
|
+
const requestedCount = options2.binCount && options2.binCount > 0 ? options2.binCount : void 0;
|
|
16556
16840
|
const start = requestedSize ? Math.floor(min / requestedSize) * requestedSize : min;
|
|
16557
16841
|
const count = requestedSize ? Math.max(
|
|
16558
16842
|
closed === "l" ? Math.floor((max - start) / requestedSize) + 1 : Math.ceil((max - start) / requestedSize),
|
|
@@ -16603,9 +16887,9 @@ function aggregateByCategory(values, rawCategories) {
|
|
|
16603
16887
|
}
|
|
16604
16888
|
|
|
16605
16889
|
// chart/waterfall.ts
|
|
16606
|
-
function buildWaterfallSteps(values,
|
|
16890
|
+
function buildWaterfallSteps(values, options2) {
|
|
16607
16891
|
const subtotalIndices = new Set(
|
|
16608
|
-
|
|
16892
|
+
options2?.subtotalIndices ?? (values.length > 0 ? [values.length - 1] : [])
|
|
16609
16893
|
);
|
|
16610
16894
|
const steps = [];
|
|
16611
16895
|
let runningTotal = 0;
|
|
@@ -16665,13 +16949,13 @@ var noFit = () => ({
|
|
|
16665
16949
|
rSquared: 0,
|
|
16666
16950
|
coefficients: []
|
|
16667
16951
|
});
|
|
16668
|
-
function fitModel(
|
|
16952
|
+
function fitModel(options2, xVals, yVals) {
|
|
16669
16953
|
const xs = [...xVals];
|
|
16670
16954
|
const ys = [...yVals];
|
|
16671
|
-
switch (
|
|
16955
|
+
switch (options2.kind) {
|
|
16672
16956
|
case "linear": {
|
|
16673
16957
|
const reg = computeLinearRegression(xs, ys);
|
|
16674
|
-
const fixed =
|
|
16958
|
+
const fixed = options2.intercept;
|
|
16675
16959
|
const slope = fixed !== void 0 ? ys.reduce((s, y, i) => s + (y - fixed) * xs[i], 0) / xs.reduce((s, x) => s + x * x, 0) : reg.slope;
|
|
16676
16960
|
const b = fixed ?? reg.intercept;
|
|
16677
16961
|
return {
|
|
@@ -16721,7 +17005,7 @@ function fitModel(options, xVals, yVals) {
|
|
|
16721
17005
|
};
|
|
16722
17006
|
}
|
|
16723
17007
|
case "polynomial": {
|
|
16724
|
-
const order = Math.min(
|
|
17008
|
+
const order = Math.min(options2.order ?? 2, 6);
|
|
16725
17009
|
const coeffs = fitPolynomial(xs, ys, order);
|
|
16726
17010
|
const evaluate = (x) => coeffs.reduce((s, c2, i) => s + c2 * x ** i, 0);
|
|
16727
17011
|
return {
|
|
@@ -16735,11 +17019,11 @@ function fitModel(options, xVals, yVals) {
|
|
|
16735
17019
|
return void 0;
|
|
16736
17020
|
}
|
|
16737
17021
|
}
|
|
16738
|
-
function fitChartTrendline(
|
|
17022
|
+
function fitChartTrendline(options2, xVals, yVals) {
|
|
16739
17023
|
const count = yVals.length;
|
|
16740
17024
|
if (count < 2) return noFit();
|
|
16741
|
-
if (
|
|
16742
|
-
const period =
|
|
17025
|
+
if (options2.kind === "movingAvg") {
|
|
17026
|
+
const period = options2.period ?? 2;
|
|
16743
17027
|
const points2 = [];
|
|
16744
17028
|
for (let i = period - 1; i < count; i++) {
|
|
16745
17029
|
let sum = 0;
|
|
@@ -16748,10 +17032,10 @@ function fitChartTrendline(options, xVals, yVals) {
|
|
|
16748
17032
|
}
|
|
16749
17033
|
return { points: points2, equation: `${period}-period moving average`, rSquared: 0, coefficients: [] };
|
|
16750
17034
|
}
|
|
16751
|
-
const model = fitModel(
|
|
17035
|
+
const model = fitModel(options2, xVals, yVals);
|
|
16752
17036
|
if (!model) return noFit();
|
|
16753
|
-
const startX = Math.min(...xVals) - (
|
|
16754
|
-
const endX = Math.max(...xVals) + (
|
|
17037
|
+
const startX = Math.min(...xVals) - (options2.backward ?? 0);
|
|
17038
|
+
const endX = Math.max(...xVals) + (options2.forward ?? 0);
|
|
16755
17039
|
const steps = Math.max(Math.ceil((endX - startX) * 4), 20);
|
|
16756
17040
|
const points = [];
|
|
16757
17041
|
for (let step = 0; step <= steps; step++) {
|
|
@@ -16774,19 +17058,78 @@ function chartSampleVariance(values) {
|
|
|
16774
17058
|
const mean = values.reduce((sum, value) => sum + value, 0) / count;
|
|
16775
17059
|
return values.reduce((sum, value) => sum + (value - mean) ** 2, 0) / Math.max(count - 1, 1);
|
|
16776
17060
|
}
|
|
16777
|
-
function chartErrorBarAmount(
|
|
16778
|
-
switch (
|
|
17061
|
+
function chartErrorBarAmount(options2, values, displayIndex, sourceIndex, side) {
|
|
17062
|
+
switch (options2.valueType) {
|
|
16779
17063
|
case "fixedVal":
|
|
16780
|
-
return
|
|
17064
|
+
return options2.value ?? 0;
|
|
16781
17065
|
case "percentage":
|
|
16782
|
-
return Math.abs(values[displayIndex] ?? 0) * ((
|
|
17066
|
+
return Math.abs(values[displayIndex] ?? 0) * ((options2.value ?? 0) / 100);
|
|
16783
17067
|
case "stdDev":
|
|
16784
|
-
return Math.sqrt(chartSampleVariance(values)) * (
|
|
17068
|
+
return Math.sqrt(chartSampleVariance(values)) * (options2.value ?? 1);
|
|
16785
17069
|
case "stdErr":
|
|
16786
17070
|
return Math.sqrt(chartSampleVariance(values) / Math.max(values.length, 1));
|
|
16787
17071
|
case "cust":
|
|
16788
|
-
return side === "plus" ?
|
|
17072
|
+
return side === "plus" ? options2.customPlus?.[sourceIndex] ?? 0 : options2.customMinus?.[sourceIndex] ?? 0;
|
|
17073
|
+
}
|
|
17074
|
+
}
|
|
17075
|
+
|
|
17076
|
+
// chart/pie-best-fit.ts
|
|
17077
|
+
var PX_PER_PT = 4 / 3;
|
|
17078
|
+
var BEST_FIT_RIM_INSET = 4 * PX_PER_PT;
|
|
17079
|
+
var BEST_FIT_EDGE_TOLERANCE = 1.5 * PX_PER_PT;
|
|
17080
|
+
var BEST_FIT_OUTSIDE_GAP = 2 * PX_PER_PT;
|
|
17081
|
+
function farCorner(x, y, w, h) {
|
|
17082
|
+
return Math.hypot(Math.abs(x) + w / 2, Math.abs(y) + h / 2);
|
|
17083
|
+
}
|
|
17084
|
+
function insideDistance(ux, uy, w, h, limit) {
|
|
17085
|
+
if (farCorner(0, 0, w, h) > limit) {
|
|
17086
|
+
return void 0;
|
|
17087
|
+
}
|
|
17088
|
+
let lo = 0;
|
|
17089
|
+
let hi = limit;
|
|
17090
|
+
for (let i = 0; i < 40; i++) {
|
|
17091
|
+
const mid = (lo + hi) / 2;
|
|
17092
|
+
if (farCorner(mid * ux, mid * uy, w, h) > limit) {
|
|
17093
|
+
hi = mid;
|
|
17094
|
+
} else {
|
|
17095
|
+
lo = mid;
|
|
17096
|
+
}
|
|
17097
|
+
}
|
|
17098
|
+
return lo;
|
|
17099
|
+
}
|
|
17100
|
+
function edgeOverhang(x, y, w, h, slice) {
|
|
17101
|
+
let worst = Number.NEGATIVE_INFINITY;
|
|
17102
|
+
const corners = [
|
|
17103
|
+
[-w / 2, -h / 2],
|
|
17104
|
+
[w / 2, -h / 2],
|
|
17105
|
+
[-w / 2, h / 2],
|
|
17106
|
+
[w / 2, h / 2]
|
|
17107
|
+
];
|
|
17108
|
+
for (const [dx, dy] of corners) {
|
|
17109
|
+
const px3 = x + dx;
|
|
17110
|
+
const py = y + dy;
|
|
17111
|
+
const fromStart = Math.cos(slice.startAngle) * py - Math.sin(slice.startAngle) * px3;
|
|
17112
|
+
const fromEnd = Math.sin(slice.endAngle) * px3 - Math.cos(slice.endAngle) * py;
|
|
17113
|
+
worst = Math.max(worst, -fromStart, -fromEnd);
|
|
17114
|
+
}
|
|
17115
|
+
return worst;
|
|
17116
|
+
}
|
|
17117
|
+
function placeBestFitLabel(slice, w, h) {
|
|
17118
|
+
const mid = (slice.startAngle + slice.endAngle) / 2;
|
|
17119
|
+
const ux = Math.cos(mid);
|
|
17120
|
+
const uy = Math.sin(mid);
|
|
17121
|
+
const distance = insideDistance(ux, uy, w, h, slice.outerR - BEST_FIT_RIM_INSET);
|
|
17122
|
+
if (distance !== void 0) {
|
|
17123
|
+
const x = distance * ux;
|
|
17124
|
+
const y = distance * uy;
|
|
17125
|
+
const reflex = slice.endAngle - slice.startAngle >= Math.PI;
|
|
17126
|
+
if (reflex || edgeOverhang(x, y, w, h, slice) <= BEST_FIT_EDGE_TOLERANCE) {
|
|
17127
|
+
return { x: slice.cx + x, y: slice.cy + y, inside: true };
|
|
17128
|
+
}
|
|
16789
17129
|
}
|
|
17130
|
+
const extent = Math.abs(ux) * w / 2 + Math.abs(uy) * h / 2;
|
|
17131
|
+
const outside = slice.outerR + BEST_FIT_OUTSIDE_GAP + extent;
|
|
17132
|
+
return { x: slice.cx + outside * ux, y: slice.cy + outside * uy, inside: false };
|
|
16790
17133
|
}
|
|
16791
17134
|
|
|
16792
17135
|
// chart/color-palettes.ts
|
|
@@ -16997,6 +17340,19 @@ function readChartAppearance(text3, properties2) {
|
|
|
16997
17340
|
}
|
|
16998
17341
|
|
|
16999
17342
|
// chart/formatting-nodes.ts
|
|
17343
|
+
function chartDataLabelNode(root) {
|
|
17344
|
+
const plot = first(first(root, "chart", NS.c), "plotArea", NS.c);
|
|
17345
|
+
const groups = plot ? elements(plot).filter((node) => node.localName.endsWith("Chart")) : [];
|
|
17346
|
+
const candidates = groups.flatMap((group2) => [
|
|
17347
|
+
...children(group2, "ser", NS.c).map((ser) => first(ser, "dLbls", NS.c)),
|
|
17348
|
+
first(group2, "dLbls", NS.c)
|
|
17349
|
+
]);
|
|
17350
|
+
return candidates.find(
|
|
17351
|
+
(node) => node !== void 0 && (first(node, "txPr", NS.c) !== void 0 || elements(node).some(
|
|
17352
|
+
(child4) => child4.localName.startsWith("show") && child4.getAttribute("val") === "1"
|
|
17353
|
+
))
|
|
17354
|
+
);
|
|
17355
|
+
}
|
|
17000
17356
|
function chartFormattingNodes(root) {
|
|
17001
17357
|
const chart = first(root, "chart", NS.c);
|
|
17002
17358
|
const plot = first(chart, "plotArea", NS.c);
|
|
@@ -17092,6 +17448,8 @@ function readChartFormatting(root) {
|
|
|
17092
17448
|
const entries = Object.fromEntries(
|
|
17093
17449
|
Object.entries(nodes).flatMap(([name, node]) => node ? [[name, entry(node)]] : [])
|
|
17094
17450
|
);
|
|
17451
|
+
const labels = chartDataLabelNode(root);
|
|
17452
|
+
if (labels) entries["dataLabel"] = entry(labels);
|
|
17095
17453
|
const builtInStyle = readBuiltInChartStyle(root);
|
|
17096
17454
|
const textBody = c(root, "txPr");
|
|
17097
17455
|
const textDefaults = textBody ? {
|
|
@@ -18210,6 +18568,191 @@ function drawingLineXml(line3) {
|
|
|
18210
18568
|
return buildXml(doc);
|
|
18211
18569
|
}
|
|
18212
18570
|
|
|
18571
|
+
// chart/marker-shape.ts
|
|
18572
|
+
var CHART_PX_PER_PT = 4 / 3;
|
|
18573
|
+
var DEFAULT_MARKER_OUTLINE_PT = 0.75;
|
|
18574
|
+
var AUTOMATIC_MARKER_CYCLE = [
|
|
18575
|
+
"diamond",
|
|
18576
|
+
"square",
|
|
18577
|
+
"triangle",
|
|
18578
|
+
"x",
|
|
18579
|
+
"star",
|
|
18580
|
+
"circle",
|
|
18581
|
+
"plus",
|
|
18582
|
+
"dot",
|
|
18583
|
+
"dash"
|
|
18584
|
+
];
|
|
18585
|
+
function automaticMarkerSymbol(seriesIdx) {
|
|
18586
|
+
const length = AUTOMATIC_MARKER_CYCLE.length;
|
|
18587
|
+
const normalized = (Math.trunc(seriesIdx) % length + length) % length;
|
|
18588
|
+
return AUTOMATIC_MARKER_CYCLE[Number.isFinite(normalized) ? normalized : 0];
|
|
18589
|
+
}
|
|
18590
|
+
function markerRadius(size, defaultRadius) {
|
|
18591
|
+
if (size === void 0 || !Number.isFinite(size) || size <= 0) {
|
|
18592
|
+
return defaultRadius;
|
|
18593
|
+
}
|
|
18594
|
+
return size / 2;
|
|
18595
|
+
}
|
|
18596
|
+
function polygonPoints(vertices) {
|
|
18597
|
+
return vertices.map(([x, y]) => `${x.toFixed(2)},${y.toFixed(2)}`).join(" ");
|
|
18598
|
+
}
|
|
18599
|
+
function starVertices(cx2, cy, r) {
|
|
18600
|
+
const inner = r * 0.5;
|
|
18601
|
+
const out = [];
|
|
18602
|
+
for (let i = 0; i < 10; i++) {
|
|
18603
|
+
const radius = i % 2 === 0 ? r : inner;
|
|
18604
|
+
const angle = -Math.PI / 2 + Math.PI * i / 5;
|
|
18605
|
+
out.push([cx2 + radius * Math.cos(angle), cy + radius * Math.sin(angle)]);
|
|
18606
|
+
}
|
|
18607
|
+
return out;
|
|
18608
|
+
}
|
|
18609
|
+
function rectPolygon(x, y, w, h) {
|
|
18610
|
+
return polygonPoints([
|
|
18611
|
+
[x, y],
|
|
18612
|
+
[x + w, y],
|
|
18613
|
+
[x + w, y + h],
|
|
18614
|
+
[x, y + h]
|
|
18615
|
+
]);
|
|
18616
|
+
}
|
|
18617
|
+
function buildMarkerPrimitive(input) {
|
|
18618
|
+
const { symbol, cx: cx2, cy, fill } = input;
|
|
18619
|
+
const part = input.part === void 0 ? {} : { part: input.part };
|
|
18620
|
+
if (symbol === "none") {
|
|
18621
|
+
return null;
|
|
18622
|
+
}
|
|
18623
|
+
const r = markerRadius(input.size, input.defaultRadius);
|
|
18624
|
+
const outline2 = input.stroke ? {
|
|
18625
|
+
stroke: input.stroke,
|
|
18626
|
+
strokeWidth: input.strokeWidth ?? DEFAULT_MARKER_OUTLINE_PT * CHART_PX_PER_PT
|
|
18627
|
+
} : void 0;
|
|
18628
|
+
const polygonStroke = outline2 ?? { stroke: fill, strokeWidth: 0 };
|
|
18629
|
+
const lineStroke = input.stroke ?? fill;
|
|
18630
|
+
switch (symbol) {
|
|
18631
|
+
case "square":
|
|
18632
|
+
case "dash": {
|
|
18633
|
+
const h = symbol === "dash" ? r * 0.64 : r * 2;
|
|
18634
|
+
const y = cy - h / 2;
|
|
18635
|
+
if (outline2) {
|
|
18636
|
+
return {
|
|
18637
|
+
kind: "polygon",
|
|
18638
|
+
points: rectPolygon(cx2 - r, y, r * 2, h),
|
|
18639
|
+
fill,
|
|
18640
|
+
...outline2,
|
|
18641
|
+
...part
|
|
18642
|
+
};
|
|
18643
|
+
}
|
|
18644
|
+
return { kind: "rect", x: cx2 - r, y, w: r * 2, h, fill, ...part };
|
|
18645
|
+
}
|
|
18646
|
+
case "diamond":
|
|
18647
|
+
return {
|
|
18648
|
+
kind: "polygon",
|
|
18649
|
+
points: polygonPoints([
|
|
18650
|
+
[cx2, cy - r],
|
|
18651
|
+
[cx2 + r, cy],
|
|
18652
|
+
[cx2, cy + r],
|
|
18653
|
+
[cx2 - r, cy]
|
|
18654
|
+
]),
|
|
18655
|
+
fill,
|
|
18656
|
+
...polygonStroke,
|
|
18657
|
+
...part
|
|
18658
|
+
};
|
|
18659
|
+
case "triangle":
|
|
18660
|
+
return {
|
|
18661
|
+
kind: "polygon",
|
|
18662
|
+
points: polygonPoints([
|
|
18663
|
+
[cx2, cy - r],
|
|
18664
|
+
[cx2 + r * 0.9, cy + r * 0.75],
|
|
18665
|
+
[cx2 - r * 0.9, cy + r * 0.75]
|
|
18666
|
+
]),
|
|
18667
|
+
fill,
|
|
18668
|
+
...polygonStroke,
|
|
18669
|
+
...part
|
|
18670
|
+
};
|
|
18671
|
+
case "star":
|
|
18672
|
+
return {
|
|
18673
|
+
kind: "polygon",
|
|
18674
|
+
points: polygonPoints(starVertices(cx2, cy, r)),
|
|
18675
|
+
fill,
|
|
18676
|
+
...polygonStroke,
|
|
18677
|
+
...part
|
|
18678
|
+
};
|
|
18679
|
+
case "plus":
|
|
18680
|
+
return {
|
|
18681
|
+
kind: "path",
|
|
18682
|
+
d: `M${(cx2 - r).toFixed(2)},${cy.toFixed(2)} L${(cx2 + r).toFixed(2)},${cy.toFixed(2)} M${cx2.toFixed(2)},${(cy - r).toFixed(2)} L${cx2.toFixed(2)},${(cy + r).toFixed(2)}`,
|
|
18683
|
+
fill: "none",
|
|
18684
|
+
stroke: lineStroke,
|
|
18685
|
+
strokeWidth: Math.max(1, r * 0.4),
|
|
18686
|
+
...part
|
|
18687
|
+
};
|
|
18688
|
+
case "x":
|
|
18689
|
+
return {
|
|
18690
|
+
kind: "path",
|
|
18691
|
+
d: `M${(cx2 - r).toFixed(2)},${(cy - r).toFixed(2)} L${(cx2 + r).toFixed(2)},${(cy + r).toFixed(2)} M${(cx2 + r).toFixed(2)},${(cy - r).toFixed(2)} L${(cx2 - r).toFixed(2)},${(cy + r).toFixed(2)}`,
|
|
18692
|
+
fill: "none",
|
|
18693
|
+
stroke: lineStroke,
|
|
18694
|
+
strokeWidth: Math.max(1, r * 0.4),
|
|
18695
|
+
...part
|
|
18696
|
+
};
|
|
18697
|
+
case "dot":
|
|
18698
|
+
return { kind: "circle", cx: cx2, cy, r: Math.max(r * 0.6, 1), fill, ...part, ...outline2 };
|
|
18699
|
+
default:
|
|
18700
|
+
return { kind: "circle", cx: cx2, cy, r, fill, ...part, ...outline2 };
|
|
18701
|
+
}
|
|
18702
|
+
}
|
|
18703
|
+
|
|
18704
|
+
// chart/render/chart-view-markers.ts
|
|
18705
|
+
function summaryMarkers(source, group2, seriesPosition) {
|
|
18706
|
+
if (!["line", "scatter", "radar"].includes(group2.kind)) return {};
|
|
18707
|
+
const enabled2 = group2.kind === "line" ? group2.marker === true : group2.kind === "radar" ? group2.radarStyle === "marker" : !["line", "smooth", "none"].includes(group2.scatterStyle ?? "marker");
|
|
18708
|
+
const symbol = source.marker?.symbol;
|
|
18709
|
+
const marker = {
|
|
18710
|
+
...source.marker,
|
|
18711
|
+
symbol: symbol && symbol !== "auto" ? symbol : source.marker || enabled2 ? automaticMarkerSymbol(source.index ?? seriesPosition) : "none"
|
|
18712
|
+
};
|
|
18713
|
+
const pointMarkers = {};
|
|
18714
|
+
for (const point of source.dataPoints) {
|
|
18715
|
+
if (point.index === void 0 || !point.marker) continue;
|
|
18716
|
+
const override = point.marker;
|
|
18717
|
+
pointMarkers[point.index] = {
|
|
18718
|
+
...marker,
|
|
18719
|
+
...override,
|
|
18720
|
+
...override.symbol === "auto" || !source.marker && override.symbol === void 0 ? { symbol: automaticMarkerSymbol(source.index ?? seriesPosition) } : {},
|
|
18721
|
+
...marker.spPr || override.spPr ? {
|
|
18722
|
+
spPr: {
|
|
18723
|
+
...marker.spPr,
|
|
18724
|
+
...override.spPr,
|
|
18725
|
+
...marker.spPr?.line || override.spPr?.line ? { line: { ...marker.spPr?.line, ...override.spPr?.line } } : {}
|
|
18726
|
+
}
|
|
18727
|
+
} : {}
|
|
18728
|
+
};
|
|
18729
|
+
}
|
|
18730
|
+
return { marker, ...Object.keys(pointMarkers).length ? { pointMarkers } : {} };
|
|
18731
|
+
}
|
|
18732
|
+
function seriesMarkerViews(source, drawingColor) {
|
|
18733
|
+
const fillColor = (fill) => fill?.kind === "none" ? "none" : fill?.kind === "solid" ? drawingColor(fill.color) : void 0;
|
|
18734
|
+
const resolve = (marker) => {
|
|
18735
|
+
const fill = fillColor(marker.spPr?.fill);
|
|
18736
|
+
const stroke = fillColor(marker.spPr?.line?.fill);
|
|
18737
|
+
const width = marker.spPr?.line?.widthEmu;
|
|
18738
|
+
return {
|
|
18739
|
+
...marker.symbol !== void 0 ? { symbol: marker.symbol } : {},
|
|
18740
|
+
...marker.size !== void 0 ? { size: marker.size } : {},
|
|
18741
|
+
...fill !== void 0 ? { fill } : {},
|
|
18742
|
+
...stroke !== void 0 ? { stroke } : {},
|
|
18743
|
+
...width !== void 0 ? { strokeWidth: width / 9525 } : {}
|
|
18744
|
+
};
|
|
18745
|
+
};
|
|
18746
|
+
return {
|
|
18747
|
+
...source.marker ? { marker: resolve(source.marker) } : {},
|
|
18748
|
+
...source.pointMarkers ? {
|
|
18749
|
+
pointMarkers: Object.fromEntries(
|
|
18750
|
+
Object.entries(source.pointMarkers).map(([i, marker]) => [i, resolve(marker)])
|
|
18751
|
+
)
|
|
18752
|
+
} : {}
|
|
18753
|
+
};
|
|
18754
|
+
}
|
|
18755
|
+
|
|
18213
18756
|
// chart/render/summary-analysis.ts
|
|
18214
18757
|
function summaryTrendline(source) {
|
|
18215
18758
|
const kind = chartTrendlineKind(source.trendlineType);
|
|
@@ -18250,6 +18793,41 @@ function summaryAnalysis(series) {
|
|
|
18250
18793
|
};
|
|
18251
18794
|
}
|
|
18252
18795
|
|
|
18796
|
+
// chart/render/summary-labels.ts
|
|
18797
|
+
function level(options2, custom) {
|
|
18798
|
+
const out = {};
|
|
18799
|
+
if (options2.deleted !== void 0) out.deleted = options2.deleted;
|
|
18800
|
+
if (options2.showValue !== void 0) out.showValue = options2.showValue;
|
|
18801
|
+
if (options2.showCategoryName !== void 0) out.showCategory = options2.showCategoryName;
|
|
18802
|
+
if (options2.showSeriesName !== void 0) out.showSeriesName = options2.showSeriesName;
|
|
18803
|
+
if (options2.showPercent !== void 0) out.showPercent = options2.showPercent;
|
|
18804
|
+
if (options2.showBubbleSize !== void 0) out.showBubbleSize = options2.showBubbleSize;
|
|
18805
|
+
if (options2.separator !== void 0) out.separator = options2.separator;
|
|
18806
|
+
if (options2.position) out.position = options2.position;
|
|
18807
|
+
if (options2.numberFormat?.formatCode) out.numberFormat = options2.numberFormat.formatCode;
|
|
18808
|
+
if (custom?.text !== void 0) out.text = custom.text;
|
|
18809
|
+
return out;
|
|
18810
|
+
}
|
|
18811
|
+
function shows(levels, point) {
|
|
18812
|
+
const flags = resolveDataLabelFlags({ ...levels, ...point ? { point } : {} });
|
|
18813
|
+
return point?.text !== void 0 || Object.values(flags).some((value) => value === true);
|
|
18814
|
+
}
|
|
18815
|
+
function summaryDataLabels(series, group2) {
|
|
18816
|
+
const own2 = series.dataLabels;
|
|
18817
|
+
if (!own2 && !group2) return void 0;
|
|
18818
|
+
const out = {};
|
|
18819
|
+
if (group2) out.chart = level(group2);
|
|
18820
|
+
if (own2) out.series = level(own2);
|
|
18821
|
+
const points = {};
|
|
18822
|
+
for (const labels of [group2, own2])
|
|
18823
|
+
for (const label of labels?.labels ?? [])
|
|
18824
|
+
if (label.index !== void 0)
|
|
18825
|
+
points[label.index] = { ...points[label.index], ...level(label, label.tx) };
|
|
18826
|
+
if (Object.keys(points).length) out.points = points;
|
|
18827
|
+
if (!shows(out) && !Object.values(points).some((point) => shows(out, point))) return void 0;
|
|
18828
|
+
return out;
|
|
18829
|
+
}
|
|
18830
|
+
|
|
18253
18831
|
// chart/render/summary-from-space.ts
|
|
18254
18832
|
var solidColor = (fill) => fill?.kind === "solid" ? fill.color : void 0;
|
|
18255
18833
|
var isSolidFill = (fill) => fill?.kind === "solid" || fill?.kind === "unsupported" && fill.element === "solidFill";
|
|
@@ -18267,7 +18845,7 @@ var GROUP_TYPES = {
|
|
|
18267
18845
|
surface: "surface"
|
|
18268
18846
|
};
|
|
18269
18847
|
var GROUPINGS = /* @__PURE__ */ new Set(["clustered", "stacked", "percentStacked", "standard"]);
|
|
18270
|
-
function chartSummarySeries(source, chartType) {
|
|
18848
|
+
function chartSummarySeries(source, chartType, groupLabels) {
|
|
18271
18849
|
const categories = source.categories ?? source.xValues;
|
|
18272
18850
|
const values = source.values ?? source.yValues;
|
|
18273
18851
|
const numeric = (v) => typeof v === "number" ? v : v === "" ? null : Number.isFinite(Number(v)) ? Number(v) : null;
|
|
@@ -18275,6 +18853,7 @@ function chartSummarySeries(source, chartType) {
|
|
|
18275
18853
|
categories: chartSourceValues(categories),
|
|
18276
18854
|
values: chartSourceValues(values).map(numeric)
|
|
18277
18855
|
};
|
|
18856
|
+
if (values?.cache?.formatCode !== void 0) out.numberFormat = values.cache.formatCode;
|
|
18278
18857
|
if (source.bubbleSizes) {
|
|
18279
18858
|
out.bubbleSizes = chartSourceValues(source.bubbleSizes).map(numeric);
|
|
18280
18859
|
if (source.bubbleSizes.formula) out.bubbleSizesRef = source.bubbleSizes.formula;
|
|
@@ -18303,6 +18882,8 @@ function chartSummarySeries(source, chartType) {
|
|
|
18303
18882
|
}
|
|
18304
18883
|
if (Object.keys(points).length) out.pointColors = points;
|
|
18305
18884
|
if (Object.keys(pointFills).length) out.pointFills = pointFills;
|
|
18885
|
+
const dataLabels = summaryDataLabels(source, groupLabels);
|
|
18886
|
+
if (dataLabels) out.dataLabels = dataLabels;
|
|
18306
18887
|
Object.assign(out, summaryAnalysis(source));
|
|
18307
18888
|
return out;
|
|
18308
18889
|
}
|
|
@@ -18311,12 +18892,12 @@ function valueAxisId(chartSpace, axisIds) {
|
|
|
18311
18892
|
(id) => chartSpace.plotArea.axes.some((a2) => a2.id === id && a2.kind === "val")
|
|
18312
18893
|
);
|
|
18313
18894
|
}
|
|
18314
|
-
function stockStyle(
|
|
18895
|
+
function stockStyle(group2) {
|
|
18315
18896
|
return {
|
|
18316
|
-
...
|
|
18317
|
-
...
|
|
18318
|
-
...
|
|
18319
|
-
...
|
|
18897
|
+
...group2.hiLowLinesSpPr ? { hiLowLines: group2.hiLowLinesSpPr } : {},
|
|
18898
|
+
...group2.upBars?.spPr ? { upBars: group2.upBars.spPr } : {},
|
|
18899
|
+
...group2.downBars?.spPr ? { downBars: group2.downBars.spPr } : {},
|
|
18900
|
+
...group2.upDownBarsGapWidth === void 0 ? {} : { gapWidth: group2.upDownBarsGapWidth }
|
|
18320
18901
|
};
|
|
18321
18902
|
}
|
|
18322
18903
|
function extraGroups(chartSpace, firstType) {
|
|
@@ -18324,54 +18905,62 @@ function extraGroups(chartSpace, firstType) {
|
|
|
18324
18905
|
if (!first3 || !["column", "line", "area"].includes(firstType)) return [];
|
|
18325
18906
|
const primary = valueAxisId(chartSpace, first3.axisIds);
|
|
18326
18907
|
const out = [];
|
|
18327
|
-
for (const
|
|
18328
|
-
const stockOverColumns =
|
|
18329
|
-
if (
|
|
18330
|
-
const type =
|
|
18908
|
+
for (const group2 of rest) {
|
|
18909
|
+
const stockOverColumns = group2.kind === "stock" && firstType === "column";
|
|
18910
|
+
if (group2.is3D || !(["bar", "line", "area"].includes(group2.kind) || stockOverColumns)) continue;
|
|
18911
|
+
const type = group2.kind === "bar" ? "column" : group2.kind;
|
|
18331
18912
|
const entry2 = {
|
|
18332
18913
|
chartType: type,
|
|
18333
|
-
series:
|
|
18334
|
-
|
|
18914
|
+
series: group2.series.map((source, index) => ({
|
|
18915
|
+
...chartSummarySeries(source, type, group2.dataLabels),
|
|
18916
|
+
...summaryMarkers(source, group2, index)
|
|
18917
|
+
})),
|
|
18918
|
+
secondary: valueAxisId(chartSpace, group2.axisIds) !== primary
|
|
18335
18919
|
};
|
|
18336
|
-
if (
|
|
18337
|
-
entry2.grouping =
|
|
18338
|
-
if (type === "stock") entry2.stock = stockStyle(
|
|
18920
|
+
if (group2.grouping && GROUPINGS.has(group2.grouping))
|
|
18921
|
+
entry2.grouping = group2.grouping;
|
|
18922
|
+
if (type === "stock") entry2.stock = stockStyle(group2);
|
|
18339
18923
|
if (type === "column") {
|
|
18340
|
-
if (
|
|
18341
|
-
if (
|
|
18924
|
+
if (group2.gapWidth !== void 0) entry2.barGapWidth = group2.gapWidth;
|
|
18925
|
+
if (group2.overlap !== void 0) entry2.barOverlap = group2.overlap;
|
|
18342
18926
|
}
|
|
18343
18927
|
if (entry2.series.length) out.push(entry2);
|
|
18344
18928
|
}
|
|
18345
18929
|
return out;
|
|
18346
18930
|
}
|
|
18347
18931
|
function chartSummaryFromSpace(chartSpace, extras = {}) {
|
|
18348
|
-
const
|
|
18349
|
-
let chartType =
|
|
18350
|
-
if (chartType === "bar" &&
|
|
18351
|
-
const series = (
|
|
18932
|
+
const group2 = chartSpace.plotArea.groups[0];
|
|
18933
|
+
let chartType = group2 ? GROUP_TYPES[group2.kind] : "column";
|
|
18934
|
+
if (chartType === "bar" && group2?.barDirection !== "bar") chartType = "column";
|
|
18935
|
+
const series = (group2?.series ?? []).map((source, index) => ({
|
|
18936
|
+
...chartSummarySeries(source, chartType, group2?.dataLabels),
|
|
18937
|
+
...group2 ? summaryMarkers(source, group2, index) : {}
|
|
18938
|
+
}));
|
|
18352
18939
|
const summary = {
|
|
18353
18940
|
chartType,
|
|
18354
18941
|
series,
|
|
18355
|
-
showLegend: chartSpace.legend !== void 0
|
|
18942
|
+
showLegend: chartSpace.legend !== void 0,
|
|
18943
|
+
axes: chartSpace.plotArea.axes,
|
|
18944
|
+
axisIds: group2?.axisIds ?? []
|
|
18356
18945
|
};
|
|
18357
18946
|
const combined = extraGroups(chartSpace, chartType);
|
|
18358
18947
|
if (combined.length) summary.extraGroups = combined;
|
|
18359
|
-
if (chartType === "stock" &&
|
|
18360
|
-
if (chartType === "bubble" &&
|
|
18361
|
-
const sizeRepresents =
|
|
18948
|
+
if (chartType === "stock" && group2) summary.stock = stockStyle(group2);
|
|
18949
|
+
if (chartType === "bubble" && group2) {
|
|
18950
|
+
const sizeRepresents = group2.sizeRepresents === "w" ? "w" : "area";
|
|
18362
18951
|
summary.bubble = {
|
|
18363
18952
|
sizeRepresents,
|
|
18364
|
-
...
|
|
18365
|
-
showNegativeBubbles:
|
|
18953
|
+
...group2.bubbleScale === void 0 ? {} : { bubbleScale: group2.bubbleScale },
|
|
18954
|
+
showNegativeBubbles: group2.showNegativeBubbles === true
|
|
18366
18955
|
};
|
|
18367
18956
|
}
|
|
18368
|
-
const grouping =
|
|
18957
|
+
const grouping = group2?.grouping;
|
|
18369
18958
|
if (grouping && GROUPINGS.has(grouping))
|
|
18370
18959
|
summary.grouping = grouping;
|
|
18371
18960
|
if (chartType === "bar" || chartType === "column") {
|
|
18372
18961
|
for (const [value, field, fallback, min, max] of [
|
|
18373
|
-
[
|
|
18374
|
-
[
|
|
18962
|
+
[group2?.gapWidth, "barGapWidth", 150, 0, 500],
|
|
18963
|
+
[group2?.overlap, "barOverlap", 0, -100, 100]
|
|
18375
18964
|
]) {
|
|
18376
18965
|
const resolved = value ?? fallback;
|
|
18377
18966
|
if (Number.isInteger(resolved) && resolved >= min && resolved <= max)
|
|
@@ -18414,9 +19003,9 @@ function dimension(data, kind, type) {
|
|
|
18414
19003
|
const out = { points: [] };
|
|
18415
19004
|
const formula = text(cx(element, "f"));
|
|
18416
19005
|
if (formula) out.formula = formula;
|
|
18417
|
-
const
|
|
18418
|
-
const count = Number(
|
|
18419
|
-
for (const point of
|
|
19006
|
+
const level2 = cx(element, "lvl");
|
|
19007
|
+
const count = Number(level2?.getAttribute("ptCount") ?? 0);
|
|
19008
|
+
for (const point of level2 ? children(level2, "pt", NS.cx) : []) {
|
|
18420
19009
|
const index = Number(point.getAttribute("idx") ?? out.points.length);
|
|
18421
19010
|
if (Number.isInteger(index) && index >= 0) out.points[index] = text(point);
|
|
18422
19011
|
}
|
|
@@ -18425,10 +19014,10 @@ function dimension(data, kind, type) {
|
|
|
18425
19014
|
}
|
|
18426
19015
|
function categoryLevels(data) {
|
|
18427
19016
|
const element = data ? children(data, "strDim", NS.cx).find((d) => (d.getAttribute("type") ?? "") === "cat") : void 0;
|
|
18428
|
-
return (element ? children(element, "lvl", NS.cx) : []).map((
|
|
19017
|
+
return (element ? children(element, "lvl", NS.cx) : []).map((level2) => {
|
|
18429
19018
|
const points = [];
|
|
18430
|
-
const count = Number(
|
|
18431
|
-
for (const point of children(
|
|
19019
|
+
const count = Number(level2.getAttribute("ptCount") ?? 0);
|
|
19020
|
+
for (const point of children(level2, "pt", NS.cx)) {
|
|
18432
19021
|
const index = Number(point.getAttribute("idx") ?? points.length);
|
|
18433
19022
|
if (Number.isInteger(index) && index >= 0) points[index] = text(point);
|
|
18434
19023
|
}
|
|
@@ -18592,64 +19181,430 @@ function chartBarSpacing(chart) {
|
|
|
18592
19181
|
};
|
|
18593
19182
|
}
|
|
18594
19183
|
|
|
18595
|
-
// chart/render/
|
|
18596
|
-
|
|
18597
|
-
|
|
18598
|
-
|
|
18599
|
-
|
|
18600
|
-
|
|
18601
|
-
|
|
18602
|
-
|
|
18603
|
-
|
|
18604
|
-
|
|
18605
|
-
|
|
18606
|
-
|
|
18607
|
-
|
|
18608
|
-
|
|
18609
|
-
|
|
18610
|
-
|
|
18611
|
-
|
|
18612
|
-
|
|
18613
|
-
|
|
18614
|
-
|
|
18615
|
-
|
|
18616
|
-
|
|
18617
|
-
|
|
18618
|
-
|
|
18619
|
-
|
|
18620
|
-
|
|
18621
|
-
|
|
18622
|
-
|
|
18623
|
-
|
|
18624
|
-
|
|
18625
|
-
|
|
18626
|
-
|
|
18627
|
-
|
|
18628
|
-
|
|
18629
|
-
|
|
18630
|
-
|
|
18631
|
-
|
|
18632
|
-
|
|
18633
|
-
|
|
18634
|
-
|
|
18635
|
-
|
|
18636
|
-
|
|
18637
|
-
|
|
18638
|
-
|
|
18639
|
-
|
|
18640
|
-
|
|
18641
|
-
|
|
18642
|
-
|
|
18643
|
-
|
|
18644
|
-
|
|
18645
|
-
|
|
18646
|
-
|
|
18647
|
-
|
|
18648
|
-
|
|
18649
|
-
|
|
18650
|
-
|
|
18651
|
-
|
|
18652
|
-
|
|
19184
|
+
// chart/render/theme-palette.ts
|
|
19185
|
+
var THEME_SLOTS = [
|
|
19186
|
+
"lt1",
|
|
19187
|
+
"dk1",
|
|
19188
|
+
"lt2",
|
|
19189
|
+
"dk2",
|
|
19190
|
+
"accent1",
|
|
19191
|
+
"accent2",
|
|
19192
|
+
"accent3",
|
|
19193
|
+
"accent4",
|
|
19194
|
+
"accent5",
|
|
19195
|
+
"accent6",
|
|
19196
|
+
"hlink",
|
|
19197
|
+
"folHlink"
|
|
19198
|
+
];
|
|
19199
|
+
var DEFAULT_THEME_COLORS = [
|
|
19200
|
+
"FFFFFF",
|
|
19201
|
+
"000000",
|
|
19202
|
+
"E7E6E6",
|
|
19203
|
+
"44546A",
|
|
19204
|
+
"4472C4",
|
|
19205
|
+
"ED7D31",
|
|
19206
|
+
"A5A5A5",
|
|
19207
|
+
"FFC000",
|
|
19208
|
+
"5B9BD5",
|
|
19209
|
+
"70AD47",
|
|
19210
|
+
"0563C1",
|
|
19211
|
+
"954F72"
|
|
19212
|
+
];
|
|
19213
|
+
function themeColor(theme, index) {
|
|
19214
|
+
const hex = theme.colors[index] ?? DEFAULT_THEME_COLORS[index];
|
|
19215
|
+
return hex && parseArgbHex(hex) ? hex.replace(/^#/, "") : void 0;
|
|
19216
|
+
}
|
|
19217
|
+
|
|
19218
|
+
// chart/render/chart-colors.ts
|
|
19219
|
+
function chartColorScheme(theme) {
|
|
19220
|
+
const slots = Object.fromEntries(
|
|
19221
|
+
THEME_SLOTS.map((slot2, index) => [slot2, `#${themeColor(theme, index) ?? "000000"}`])
|
|
19222
|
+
);
|
|
19223
|
+
return {
|
|
19224
|
+
...slots,
|
|
19225
|
+
bg1: slots.lt1,
|
|
19226
|
+
tx1: slots.dk1,
|
|
19227
|
+
bg2: slots.lt2,
|
|
19228
|
+
tx2: slots.dk2
|
|
19229
|
+
};
|
|
19230
|
+
}
|
|
19231
|
+
function autoSeriesColor(theme, index) {
|
|
19232
|
+
const i = Math.max(0, Math.floor(index));
|
|
19233
|
+
return chartPaletteSeriesColor(findChartColorPalette(10), i, i + 1, chartColorScheme(theme));
|
|
19234
|
+
}
|
|
19235
|
+
|
|
19236
|
+
// chart/text-inheritance.ts
|
|
19237
|
+
var TEXT_KEYS = [
|
|
19238
|
+
"fontSize",
|
|
19239
|
+
"bold",
|
|
19240
|
+
"italic",
|
|
19241
|
+
"underline",
|
|
19242
|
+
"typeface",
|
|
19243
|
+
"textColor",
|
|
19244
|
+
"fontRef"
|
|
19245
|
+
];
|
|
19246
|
+
var TEXT_PARTS = [
|
|
19247
|
+
"title",
|
|
19248
|
+
"axisTitle",
|
|
19249
|
+
"categoryAxis",
|
|
19250
|
+
"valueAxis",
|
|
19251
|
+
"legend",
|
|
19252
|
+
"dataLabel"
|
|
19253
|
+
];
|
|
19254
|
+
function inheritChartText(part, entry2, builtIn, root) {
|
|
19255
|
+
if (!root || !TEXT_PARTS.includes(part)) return entry2;
|
|
19256
|
+
const out = { ...entry2 };
|
|
19257
|
+
for (const key of TEXT_KEYS) {
|
|
19258
|
+
delete out[key];
|
|
19259
|
+
const value = root[key] ?? builtIn?.[key];
|
|
19260
|
+
if (value !== void 0) Object.assign(out, { [key]: value });
|
|
19261
|
+
}
|
|
19262
|
+
if (part === "title" && root.fontSize !== void 0) out.fontSize = root.fontSize * 1.2;
|
|
19263
|
+
if (root.textEffectsXml !== void 0) out.textEffectsXml = root.textEffectsXml;
|
|
19264
|
+
return out;
|
|
19265
|
+
}
|
|
19266
|
+
|
|
19267
|
+
// chart/render/chart-appearance.ts
|
|
19268
|
+
var chartPointsToPixels = (points) => points * EMU_PER_POINT / EMU_PER_PIXEL;
|
|
19269
|
+
function typeface(entry2, theme) {
|
|
19270
|
+
const name = entry2.typeface;
|
|
19271
|
+
if (name?.startsWith("+mj-")) return theme.majorFont;
|
|
19272
|
+
if (name?.startsWith("+mn-")) return theme.minorFont;
|
|
19273
|
+
return name ?? (entry2.fontRef?.index === "major" ? theme.majorFont : entry2.fontRef?.index === "minor" ? theme.minorFont : void 0);
|
|
19274
|
+
}
|
|
19275
|
+
function chartAppearance(chart, theme) {
|
|
19276
|
+
const defaults = builtInChartTextStyle(effectiveBuiltInChartStyle(chart.formatting));
|
|
19277
|
+
const entries = {};
|
|
19278
|
+
for (const part of CHART_STYLE_PARTS) {
|
|
19279
|
+
const base = chart.styleDefinition?.entries[part];
|
|
19280
|
+
const direct = chart.formatting?.entries[part];
|
|
19281
|
+
if (!defaults[part] && !base && !direct) continue;
|
|
19282
|
+
const entry2 = {
|
|
19283
|
+
...inheritChartText(
|
|
19284
|
+
part,
|
|
19285
|
+
{ ...defaults[part], ...base, sourceXml: base?.sourceXml ?? "" },
|
|
19286
|
+
defaults[part],
|
|
19287
|
+
chart.formatting?.textDefaults
|
|
19288
|
+
),
|
|
19289
|
+
...direct,
|
|
19290
|
+
sourceXml: direct?.sourceXml ?? base?.sourceXml ?? ""
|
|
19291
|
+
};
|
|
19292
|
+
if (base?.line || direct?.line) entry2.line = { ...base?.line, ...direct?.line };
|
|
19293
|
+
entries[part] = entry2;
|
|
19294
|
+
}
|
|
19295
|
+
const scheme = chartColorScheme(theme);
|
|
19296
|
+
const resolve = (color) => resolveDrawingColor(
|
|
19297
|
+
color,
|
|
19298
|
+
{ scheme: (name) => scheme[name] },
|
|
19299
|
+
{ hslRounding: "halfDown", transformOrder: "document" }
|
|
19300
|
+
);
|
|
19301
|
+
const out = resolveChartStyleDefinition(
|
|
19302
|
+
{ entries},
|
|
19303
|
+
(color) => drawingColorCss(resolve(color))
|
|
19304
|
+
) ?? {};
|
|
19305
|
+
for (const part of CHART_STYLE_PARTS) {
|
|
19306
|
+
const entry2 = entries[part];
|
|
19307
|
+
if (!entry2) continue;
|
|
19308
|
+
const family = typeface(entry2, theme);
|
|
19309
|
+
const shadow = resolveDrawingShadowXml(entry2.textEffectsXml, {
|
|
19310
|
+
scheme: (name) => scheme[name]
|
|
19311
|
+
});
|
|
19312
|
+
if (shadow) (out[part] ??= {}).textShadow = shadow;
|
|
19313
|
+
if (family) (out[part] ??= {}).typeface = family;
|
|
19314
|
+
if (entry2.axisVisible !== void 0) (out[part] ??= {}).axisVisible = entry2.axisVisible;
|
|
19315
|
+
if (entry2.labelsVisible !== void 0) (out[part] ??= {}).labelsVisible = entry2.labelsVisible;
|
|
19316
|
+
if (entry2.line?.widthEmu === 0) (out[part] ??= {}).lineWidth = 0;
|
|
19317
|
+
if (entry2.fill?.kind === "gradient") {
|
|
19318
|
+
(out[part] ??= {}).gradient = resolveChartGradient(entry2.fill, resolve);
|
|
19319
|
+
}
|
|
19320
|
+
}
|
|
19321
|
+
return out;
|
|
19322
|
+
}
|
|
19323
|
+
|
|
19324
|
+
// text/css-font-family.ts
|
|
19325
|
+
var FALLBACKS = {
|
|
19326
|
+
calibri: '"Calibri", "Carlito", "Segoe UI", Arial, sans-serif',
|
|
19327
|
+
"calibri light": '"Calibri Light", "Calibri", "Carlito", "Segoe UI", Arial, sans-serif',
|
|
19328
|
+
cambria: '"Cambria", "Caladea", Georgia, serif',
|
|
19329
|
+
arial: 'Arial, "Liberation Sans", Helvetica, sans-serif',
|
|
19330
|
+
"times new roman": '"Times New Roman", "Liberation Serif", Times, serif',
|
|
19331
|
+
"courier new": '"Courier New", "Liberation Mono", monospace',
|
|
19332
|
+
aptos: '"Aptos", "Calibri", "Carlito", "Segoe UI", sans-serif'
|
|
19333
|
+
};
|
|
19334
|
+
function cssFontFamily(name) {
|
|
19335
|
+
const known = FALLBACKS[name.toLowerCase()];
|
|
19336
|
+
if (known) return known;
|
|
19337
|
+
const quoted = `"${name.replace(/["\\]/g, "")}"`;
|
|
19338
|
+
return `${quoted}, "Calibri", "Carlito", "Segoe UI", sans-serif`;
|
|
19339
|
+
}
|
|
19340
|
+
|
|
19341
|
+
// chart/render/chart-svg-appearance.ts
|
|
19342
|
+
var nextPaintId = 0;
|
|
19343
|
+
function chartGradientPaint(model, width = 1024, height = 768) {
|
|
19344
|
+
const prefix2 = `xlsx-chart-${++nextPaintId}`;
|
|
19345
|
+
const appearance = { ...model.appearance };
|
|
19346
|
+
const defs = [];
|
|
19347
|
+
const shadowPaint = (shadow, suffix) => {
|
|
19348
|
+
const id = `${prefix2}-${suffix}`;
|
|
19349
|
+
const pad = Math.max(4, shadow.blur * 3 + Math.abs(shadow.dx) + Math.abs(shadow.dy));
|
|
19350
|
+
defs.push(
|
|
19351
|
+
`<filter id="${id}" filterUnits="userSpaceOnUse" x="${n(-pad)}" y="${n(-pad)}" width="${n(width + pad * 2)}" height="${n(height + pad * 2)}" color-interpolation-filters="sRGB">${svgDropShadowElement(shadow, { number: n, color: (value) => esc(value) })}</filter>`
|
|
19352
|
+
);
|
|
19353
|
+
return `url(#${id})`;
|
|
19354
|
+
};
|
|
19355
|
+
for (const [part, entry2] of Object.entries(appearance)) {
|
|
19356
|
+
if (entry2?.textShadow)
|
|
19357
|
+
appearance[part] = {
|
|
19358
|
+
...entry2,
|
|
19359
|
+
textShadowFilter: shadowPaint(entry2.textShadow, `${part}-text-shadow`)
|
|
19360
|
+
};
|
|
19361
|
+
}
|
|
19362
|
+
const paint2 = (gradient, suffix, bounds) => {
|
|
19363
|
+
const def = buildChartGradientDef(`${prefix2}-${suffix}`, gradient, bounds);
|
|
19364
|
+
defs.push(chartGradientMarkup(def));
|
|
19365
|
+
return `url(#${def.id})`;
|
|
19366
|
+
};
|
|
19367
|
+
for (const part of ["chartArea", "plotArea"]) {
|
|
19368
|
+
const entry2 = appearance[part];
|
|
19369
|
+
if (!entry2?.gradient) continue;
|
|
19370
|
+
if (part === "plotArea" && ["circle", "shape"].includes(entry2.gradient.path ?? "")) continue;
|
|
19371
|
+
appearance[part] = {
|
|
19372
|
+
...entry2,
|
|
19373
|
+
fillColor: paint2(entry2.gradient, part, { width, height, shape: "rect" })
|
|
19374
|
+
};
|
|
19375
|
+
}
|
|
19376
|
+
const series = model.series.map((source, index) => {
|
|
19377
|
+
const view = { ...source };
|
|
19378
|
+
if (source.shadow) view.shadowFilter = shadowPaint(source.shadow, `s${index}-shadow`);
|
|
19379
|
+
const bounds = model.type === "bar" || model.type === "column" ? { width: 1, height: 1, shape: "rect" } : void 0;
|
|
19380
|
+
if (source.gradient) view.color = paint2(source.gradient, `s${index}`, bounds);
|
|
19381
|
+
if (source.pointGradients) {
|
|
19382
|
+
view.pointColors = [...source.pointColors ?? []];
|
|
19383
|
+
for (const [key, gradient] of Object.entries(source.pointGradients))
|
|
19384
|
+
view.pointColors[Number(key)] = paint2(gradient, `s${index}-p${key}`, bounds);
|
|
19385
|
+
}
|
|
19386
|
+
return view;
|
|
19387
|
+
});
|
|
19388
|
+
return defs.length ? { model: { ...model, appearance, series }, defs: `<defs>${defs.join("")}</defs>` } : { model, defs: "" };
|
|
19389
|
+
}
|
|
19390
|
+
function chartTextAttributes(model, part, fallbackSize = FONT_SIZE) {
|
|
19391
|
+
const entry2 = model.appearance?.[part];
|
|
19392
|
+
return {
|
|
19393
|
+
size: entry2?.fontSize === void 0 ? fallbackSize : chartPointsToPixels(entry2.fontSize),
|
|
19394
|
+
...entry2?.color === void 0 ? {} : { fill: entry2.color },
|
|
19395
|
+
...entry2?.bold === void 0 ? {} : { weight: entry2.bold ? "bold" : "normal" },
|
|
19396
|
+
...entry2?.italic === void 0 ? {} : { italic: entry2.italic },
|
|
19397
|
+
...entry2?.underline === void 0 ? {} : { underline: entry2.underline },
|
|
19398
|
+
...entry2?.typeface === void 0 ? {} : { family: cssFontFamily(entry2.typeface) },
|
|
19399
|
+
...entry2?.textShadowFilter === void 0 ? {} : { filter: entry2.textShadowFilter }
|
|
19400
|
+
};
|
|
19401
|
+
}
|
|
19402
|
+
function chartStroke(model, part) {
|
|
19403
|
+
const entry2 = model.appearance?.[part];
|
|
19404
|
+
return {
|
|
19405
|
+
color: entry2?.axisVisible === false ? "none" : entry2?.lineColor ?? (part.startsWith("gridline") ? GRID_COLOR : AXIS_COLOR),
|
|
19406
|
+
width: entry2?.lineWidth === void 0 ? 1 : chartPointsToPixels(entry2.lineWidth)
|
|
19407
|
+
};
|
|
19408
|
+
}
|
|
19409
|
+
function chartAreaRect(model, part, area) {
|
|
19410
|
+
if (area.w <= 0 || area.h <= 0) return "";
|
|
19411
|
+
const entry2 = model.appearance?.[part];
|
|
19412
|
+
let fill = entry2?.fillColor ?? (part === "chartArea" ? "#FFFFFF" : "none");
|
|
19413
|
+
let defs = "";
|
|
19414
|
+
if (part !== "chartArea" && entry2?.gradient && (part !== "plotArea" || ["circle", "shape"].includes(entry2.gradient.path ?? ""))) {
|
|
19415
|
+
const def = buildChartGradientDef(`xlsx-chart-${++nextPaintId}-${part}`, entry2.gradient, {
|
|
19416
|
+
width: area.w,
|
|
19417
|
+
height: area.h,
|
|
19418
|
+
shape: "rect"
|
|
19419
|
+
});
|
|
19420
|
+
defs = `<defs>${chartGradientMarkup(def)}</defs>`;
|
|
19421
|
+
fill = `url(#${def.id})`;
|
|
19422
|
+
}
|
|
19423
|
+
const stroke = entry2?.lineColor ?? "none";
|
|
19424
|
+
if (fill === "none" && stroke === "none") return "";
|
|
19425
|
+
const width = entry2?.lineWidth === void 0 ? 1 : chartPointsToPixels(entry2.lineWidth);
|
|
19426
|
+
return `${defs}<rect x="${n(area.x)}" y="${n(area.y)}" width="${n(area.w)}" height="${n(area.h)}" fill="${esc(fill)}" stroke="${esc(stroke)}" stroke-width="${n(width)}" data-chart-part="${part}"/>`;
|
|
19427
|
+
}
|
|
19428
|
+
|
|
19429
|
+
// chart/render/chart-svg-labels.ts
|
|
19430
|
+
var GAP = 3;
|
|
19431
|
+
var LINE = 1.2;
|
|
19432
|
+
var NAMED_COLORS = /^(black|blue|cyan|green|magenta|red|white|yellow)$/iu;
|
|
19433
|
+
function measure(model, label) {
|
|
19434
|
+
const attrs2 = chartTextAttributes(model, "dataLabel", 10);
|
|
19435
|
+
const size = attrs2.size ?? 10;
|
|
19436
|
+
const lines = label.text.split("\n");
|
|
19437
|
+
return {
|
|
19438
|
+
lines,
|
|
19439
|
+
size,
|
|
19440
|
+
w: Math.max(...lines.map((l) => textWidth(l, size))),
|
|
19441
|
+
h: lines.length * size * LINE,
|
|
19442
|
+
attrs: attrs2
|
|
19443
|
+
};
|
|
19444
|
+
}
|
|
19445
|
+
function draw(m, label, x, y, anchor, out) {
|
|
19446
|
+
const fill = label.color && NAMED_COLORS.test(label.color) ? label.color.toLowerCase() : void 0;
|
|
19447
|
+
m.lines.forEach((line3, k) => {
|
|
19448
|
+
const lineY = y - m.h / 2 + (k + 0.5) * m.size * LINE + m.size * 0.35;
|
|
19449
|
+
out.push(text2(x, lineY, line3, { ...m.attrs, ...fill ? { fill } : {}, anchor }));
|
|
19450
|
+
});
|
|
19451
|
+
}
|
|
19452
|
+
function barLabels(model, marks, out) {
|
|
19453
|
+
const stacked = model.grouping === "stacked" || model.grouping === "percentStacked";
|
|
19454
|
+
for (const mark of marks) {
|
|
19455
|
+
const label = mark.series.labels?.[mark.index];
|
|
19456
|
+
if (!label) continue;
|
|
19457
|
+
const m = measure(model, label);
|
|
19458
|
+
let position2 = label.position ?? (stacked ? "ctr" : "outEnd");
|
|
19459
|
+
if (stacked && position2 === "outEnd") position2 = "ctr";
|
|
19460
|
+
const cx2 = mark.x + mark.w / 2;
|
|
19461
|
+
const cy = mark.y + mark.h / 2;
|
|
19462
|
+
if (model.horizontal) {
|
|
19463
|
+
const end = mark.negative ? mark.x : mark.x + mark.w;
|
|
19464
|
+
const base = mark.negative ? mark.x + mark.w : mark.x;
|
|
19465
|
+
const dir2 = mark.negative ? -1 : 1;
|
|
19466
|
+
const side = (at, outward) => [
|
|
19467
|
+
at + (outward ? dir2 : -dir2) * GAP,
|
|
19468
|
+
(outward ? dir2 : -dir2) > 0 ? "start" : "end"
|
|
19469
|
+
];
|
|
19470
|
+
const [x, anchor] = position2 === "ctr" ? [cx2, "middle"] : position2 === "inEnd" ? side(end, false) : position2 === "inBase" ? side(base, true) : side(end, true);
|
|
19471
|
+
draw(m, label, x, cy, anchor, out);
|
|
19472
|
+
continue;
|
|
19473
|
+
}
|
|
19474
|
+
const top = mark.negative ? mark.y + mark.h : mark.y;
|
|
19475
|
+
const bottom = mark.negative ? mark.y : mark.y + mark.h;
|
|
19476
|
+
const dir = mark.negative ? 1 : -1;
|
|
19477
|
+
const y = position2 === "ctr" ? cy : position2 === "inEnd" ? top - dir * (GAP + m.h / 2) : position2 === "inBase" ? bottom + dir * (GAP + m.h / 2) : top + dir * (GAP + m.h / 2);
|
|
19478
|
+
draw(m, label, cx2, y, "middle", out);
|
|
19479
|
+
}
|
|
19480
|
+
}
|
|
19481
|
+
function pointLabels(model, marks, out) {
|
|
19482
|
+
for (const mark of marks) {
|
|
19483
|
+
const label = mark.series.labels?.[mark.index];
|
|
19484
|
+
if (!label) continue;
|
|
19485
|
+
const m = measure(model, label);
|
|
19486
|
+
const reach = mark.radius + GAP;
|
|
19487
|
+
switch (model.type === "area" ? "ctr" : label.position ?? "r") {
|
|
19488
|
+
case "ctr":
|
|
19489
|
+
draw(m, label, mark.x, mark.y, "middle", out);
|
|
19490
|
+
break;
|
|
19491
|
+
case "t":
|
|
19492
|
+
draw(m, label, mark.x, mark.y - reach - m.h / 2, "middle", out);
|
|
19493
|
+
break;
|
|
19494
|
+
case "b":
|
|
19495
|
+
draw(m, label, mark.x, mark.y + reach + m.h / 2, "middle", out);
|
|
19496
|
+
break;
|
|
19497
|
+
case "l":
|
|
19498
|
+
draw(m, label, mark.x - reach, mark.y, "end", out);
|
|
19499
|
+
break;
|
|
19500
|
+
default:
|
|
19501
|
+
draw(m, label, mark.x + reach, mark.y, "start", out);
|
|
19502
|
+
}
|
|
19503
|
+
}
|
|
19504
|
+
}
|
|
19505
|
+
function sliceLabels(model, marks, out) {
|
|
19506
|
+
for (const mark of marks) {
|
|
19507
|
+
const label = mark.series.labels?.[mark.index];
|
|
19508
|
+
if (!label) continue;
|
|
19509
|
+
const m = measure(model, label);
|
|
19510
|
+
const mid = (mark.start + mark.end) / 2;
|
|
19511
|
+
const ux = Math.sin(mid);
|
|
19512
|
+
const uy = -Math.cos(mid);
|
|
19513
|
+
const place2 = (radius) => [
|
|
19514
|
+
mark.cx + radius * ux,
|
|
19515
|
+
mark.cy + radius * uy
|
|
19516
|
+
];
|
|
19517
|
+
const position2 = model.type === "doughnut" ? "ctr" : label.position ?? "bestFit";
|
|
19518
|
+
let x;
|
|
19519
|
+
let y;
|
|
19520
|
+
if (position2 === "ctr") [x, y] = place2(mark.inner + (mark.outer - mark.inner) / 2);
|
|
19521
|
+
else if (position2 === "inEnd") {
|
|
19522
|
+
const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
|
|
19523
|
+
[x, y] = place2(Math.max(0, mark.outer - GAP - extent));
|
|
19524
|
+
} else if (position2 === "outEnd") {
|
|
19525
|
+
const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
|
|
19526
|
+
[x, y] = place2(mark.outer + GAP + extent);
|
|
19527
|
+
} else {
|
|
19528
|
+
const placed = placeBestFitLabel(
|
|
19529
|
+
{
|
|
19530
|
+
cx: mark.cx,
|
|
19531
|
+
cy: mark.cy,
|
|
19532
|
+
outerR: mark.outer,
|
|
19533
|
+
startAngle: mark.start - Math.PI / 2,
|
|
19534
|
+
endAngle: mark.end - Math.PI / 2
|
|
19535
|
+
},
|
|
19536
|
+
m.w,
|
|
19537
|
+
m.h
|
|
19538
|
+
);
|
|
19539
|
+
x = placed.x;
|
|
19540
|
+
y = placed.y;
|
|
19541
|
+
}
|
|
19542
|
+
draw(m, label, x, y, "middle", out);
|
|
19543
|
+
}
|
|
19544
|
+
}
|
|
19545
|
+
function hasOutsideLabels(model) {
|
|
19546
|
+
return model.series.some(
|
|
19547
|
+
(s) => s.labels?.some(
|
|
19548
|
+
(l) => l !== void 0 && ["bestFit", "outEnd"].includes(l.position ?? "bestFit")
|
|
19549
|
+
)
|
|
19550
|
+
);
|
|
19551
|
+
}
|
|
19552
|
+
|
|
19553
|
+
// chart/render/chart-svg-bars.ts
|
|
19554
|
+
function barLayout(model, frame2) {
|
|
19555
|
+
const count = Math.max(1, model.series.length);
|
|
19556
|
+
const geometry2 = clusteredBarGeometry(frame2.bandSize, count, chartBarSpacing(model));
|
|
19557
|
+
const barSize = geometry2.singleBarWidth;
|
|
19558
|
+
const offset = (si) => model.horizontal ? geometry2.clusterWidth / 2 - barSize - si * geometry2.step : -geometry2.clusterWidth / 2 + si * geometry2.step;
|
|
19559
|
+
return { barSize, offset };
|
|
19560
|
+
}
|
|
19561
|
+
function bars(model, frame2, out, values) {
|
|
19562
|
+
const stacked = model.grouping === "stacked" || model.grouping === "percentStacked";
|
|
19563
|
+
const { barSize, offset: barOffset } = barLayout(model, frame2);
|
|
19564
|
+
const base = frame2.value(0);
|
|
19565
|
+
const pos = new Array(model.categories.length).fill(0);
|
|
19566
|
+
const neg = new Array(model.categories.length).fill(0);
|
|
19567
|
+
const marks = [];
|
|
19568
|
+
model.series.forEach((s, si) => {
|
|
19569
|
+
values[si]?.forEach((v, i) => {
|
|
19570
|
+
if (v === null || i >= model.categories.length) return;
|
|
19571
|
+
let from = 0;
|
|
19572
|
+
let to = v;
|
|
19573
|
+
if (stacked) {
|
|
19574
|
+
const acc = v >= 0 ? pos : neg;
|
|
19575
|
+
from = acc[i] ?? 0;
|
|
19576
|
+
to = from + v;
|
|
19577
|
+
acc[i] = to;
|
|
19578
|
+
}
|
|
19579
|
+
const a2 = stacked ? frame2.value(from) : base;
|
|
19580
|
+
const b = frame2.value(to);
|
|
19581
|
+
const offset = barOffset(si);
|
|
19582
|
+
const center = frame2.band(i);
|
|
19583
|
+
const width = model.horizontal ? Math.abs(b - a2) : barSize;
|
|
19584
|
+
const height = model.horizontal ? barSize : Math.abs(b - a2);
|
|
19585
|
+
let color = s.pointColors?.[i] ?? s.color;
|
|
19586
|
+
const gradient = s.pointGradients?.[i] ?? (s.pointColors?.[i] === void 0 ? s.gradient : void 0);
|
|
19587
|
+
if (gradient && (gradient.path === "circle" || gradient.path === "shape")) {
|
|
19588
|
+
const baseId = color.match(/^url\(#(.+)\)$/)?.[1];
|
|
19589
|
+
if (baseId) {
|
|
19590
|
+
const id = baseId.replace(/(-s\d+(?:-p\d+)?)$/, `-mark${i}$1`);
|
|
19591
|
+
const def = buildChartGradientDef(id, gradient, {
|
|
19592
|
+
width: Number(n(width)),
|
|
19593
|
+
height: Number(n(height)),
|
|
19594
|
+
shape: "rect"
|
|
19595
|
+
});
|
|
19596
|
+
out.push(`<defs>${chartGradientMarkup(def)}</defs>`);
|
|
19597
|
+
color = `url(#${id})`;
|
|
19598
|
+
}
|
|
19599
|
+
}
|
|
19600
|
+
out.push(`<g data-chart-series="${si}" data-chart-point="${i}">`);
|
|
19601
|
+
const box = model.horizontal ? { x: Math.min(a2, b), y: center + offset, w: Math.abs(b - a2), h: barSize } : { x: center + offset, y: Math.min(a2, b), w: barSize, h: Math.abs(b - a2) };
|
|
19602
|
+
out.push(rect2(box.x, box.y, box.w, box.h, color, s.shadowFilter));
|
|
19603
|
+
out.push("</g>");
|
|
19604
|
+
marks.push({ series: s, index: i, ...box, negative: v < 0 });
|
|
19605
|
+
});
|
|
19606
|
+
});
|
|
19607
|
+
barLabels(model, marks, out);
|
|
18653
19608
|
}
|
|
18654
19609
|
|
|
18655
19610
|
// chart/render/chart-svg-analysis.ts
|
|
@@ -18738,6 +19693,60 @@ function scatterAnalysis(model, px3, py, out) {
|
|
|
18738
19693
|
});
|
|
18739
19694
|
}
|
|
18740
19695
|
|
|
19696
|
+
// chart/render/chart-svg-markers.ts
|
|
19697
|
+
function chartMarkerRadius(series, index, defaultRadius = 3) {
|
|
19698
|
+
const marker = { ...series.marker, ...series.pointMarkers?.[index] };
|
|
19699
|
+
if (marker.symbol === "none") return 0;
|
|
19700
|
+
const radius = markerRadius(marker.size, defaultRadius);
|
|
19701
|
+
return marker.symbol === "dot" ? Math.max(radius * 0.6, 1) : radius;
|
|
19702
|
+
}
|
|
19703
|
+
function chartSeriesMarkerSvg(series, index, cx2, cy, defaultRadius = 3) {
|
|
19704
|
+
const marker = { ...series.marker, ...series.pointMarkers?.[index] };
|
|
19705
|
+
const primitive = buildMarkerPrimitive({
|
|
19706
|
+
...marker,
|
|
19707
|
+
symbol: marker.symbol,
|
|
19708
|
+
size: marker.size,
|
|
19709
|
+
cx: cx2,
|
|
19710
|
+
cy,
|
|
19711
|
+
fill: marker.fill ?? series.pointColors?.[index] ?? series.color,
|
|
19712
|
+
defaultRadius
|
|
19713
|
+
});
|
|
19714
|
+
if (!primitive) return "";
|
|
19715
|
+
let geometry2;
|
|
19716
|
+
switch (primitive.kind) {
|
|
19717
|
+
case "circle":
|
|
19718
|
+
geometry2 = `cx="${n(primitive.cx)}" cy="${n(primitive.cy)}" r="${n(primitive.r)}"`;
|
|
19719
|
+
break;
|
|
19720
|
+
case "rect":
|
|
19721
|
+
geometry2 = `x="${n(primitive.x)}" y="${n(primitive.y)}" width="${n(primitive.w)}" height="${n(primitive.h)}"`;
|
|
19722
|
+
break;
|
|
19723
|
+
case "path":
|
|
19724
|
+
geometry2 = `d="${esc(primitive.d)}"`;
|
|
19725
|
+
break;
|
|
19726
|
+
case "polygon":
|
|
19727
|
+
geometry2 = `points="${esc(primitive.points)}"`;
|
|
19728
|
+
break;
|
|
19729
|
+
}
|
|
19730
|
+
const outline2 = primitive.stroke ? ` stroke="${esc(primitive.stroke)}" stroke-width="${n(primitive.strokeWidth ?? 1)}"` : "";
|
|
19731
|
+
const filter = series.shadowFilter ? ` filter="${esc(series.shadowFilter)}"` : "";
|
|
19732
|
+
return `<${primitive.kind} ${geometry2} fill="${esc(primitive.fill)}"${outline2}${filter}/>`;
|
|
19733
|
+
}
|
|
19734
|
+
|
|
19735
|
+
// chart/line-dash.ts
|
|
19736
|
+
function chartLineDashArray(style, width) {
|
|
19737
|
+
if (!style || style === "solid") {
|
|
19738
|
+
return void 0;
|
|
19739
|
+
}
|
|
19740
|
+
const unit = Math.max(width, 1);
|
|
19741
|
+
if (style === "dot" || style === "sysDot") {
|
|
19742
|
+
return `${unit} ${unit * 2}`;
|
|
19743
|
+
}
|
|
19744
|
+
if (style === "lgDash") {
|
|
19745
|
+
return `${unit * 6} ${unit * 3}`;
|
|
19746
|
+
}
|
|
19747
|
+
return `${unit * 3} ${unit * 2}`;
|
|
19748
|
+
}
|
|
19749
|
+
|
|
18741
19750
|
// chart/render/chart-scale.ts
|
|
18742
19751
|
var clean = (n2) => Number(n2.toPrecision(12));
|
|
18743
19752
|
function* units(raw) {
|
|
@@ -18748,14 +19757,14 @@ function* units(raw) {
|
|
|
18748
19757
|
exp++;
|
|
18749
19758
|
}
|
|
18750
19759
|
}
|
|
18751
|
-
function niceScale(dataMin, dataMax,
|
|
18752
|
-
const maxIntervals = Math.max(1,
|
|
19760
|
+
function niceScale(dataMin, dataMax, options2 = {}) {
|
|
19761
|
+
const maxIntervals = Math.max(1, options2.maxIntervals ?? 10);
|
|
18753
19762
|
let lo = Number.isFinite(dataMin) ? dataMin : 0;
|
|
18754
19763
|
let hi = Number.isFinite(dataMax) ? dataMax : 0;
|
|
18755
19764
|
if (lo > hi) [lo, hi] = [hi, lo];
|
|
18756
19765
|
if (lo === hi) {
|
|
18757
19766
|
if (lo === 0) hi = 1;
|
|
18758
|
-
else if (
|
|
19767
|
+
else if (options2.noZero) {
|
|
18759
19768
|
const pad = Math.abs(lo) * 0.1 || 1;
|
|
18760
19769
|
lo -= pad;
|
|
18761
19770
|
hi += pad;
|
|
@@ -18764,7 +19773,7 @@ function niceScale(dataMin, dataMax, options = {}) {
|
|
|
18764
19773
|
}
|
|
18765
19774
|
let fixedLo = false;
|
|
18766
19775
|
let fixedHi = false;
|
|
18767
|
-
if (!
|
|
19776
|
+
if (!options2.noZero) {
|
|
18768
19777
|
if (lo >= 0 && hi - lo >= hi / 6) {
|
|
18769
19778
|
lo = 0;
|
|
18770
19779
|
fixedLo = true;
|
|
@@ -18795,153 +19804,240 @@ var PERCENT_SCALE = {
|
|
|
18795
19804
|
ticks: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
|
|
18796
19805
|
};
|
|
18797
19806
|
function formatAxisValue(value, percent = false) {
|
|
18798
|
-
if (percent) return `${clean(value * 100)}%`;
|
|
18799
|
-
const v = clean(value);
|
|
18800
|
-
if (Math.abs(v) >= 1e15 || v !== 0 && Math.abs(v) < 1e-6)
|
|
18801
|
-
return v.toExponential(2).replace("e+", "E+").replace("e-", "E-");
|
|
18802
|
-
const [int2 = "0", frac] = String(Math.abs(v)).split(".");
|
|
18803
|
-
const grouped = int2.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
18804
|
-
return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
|
|
18805
|
-
}
|
|
18806
|
-
|
|
18807
|
-
// chart/render/
|
|
18808
|
-
|
|
18809
|
-
|
|
18810
|
-
|
|
18811
|
-
|
|
18812
|
-
"
|
|
18813
|
-
|
|
18814
|
-
|
|
18815
|
-
|
|
18816
|
-
|
|
18817
|
-
|
|
18818
|
-
"
|
|
18819
|
-
|
|
18820
|
-
|
|
18821
|
-
|
|
18822
|
-
|
|
18823
|
-
|
|
18824
|
-
|
|
18825
|
-
|
|
18826
|
-
|
|
18827
|
-
|
|
18828
|
-
|
|
18829
|
-
|
|
18830
|
-
|
|
18831
|
-
|
|
18832
|
-
|
|
18833
|
-
"
|
|
18834
|
-
"
|
|
18835
|
-
|
|
18836
|
-
|
|
18837
|
-
|
|
18838
|
-
|
|
18839
|
-
|
|
18840
|
-
|
|
18841
|
-
|
|
18842
|
-
|
|
18843
|
-
|
|
18844
|
-
|
|
18845
|
-
);
|
|
18846
|
-
|
|
18847
|
-
|
|
18848
|
-
|
|
18849
|
-
|
|
18850
|
-
|
|
18851
|
-
|
|
18852
|
-
|
|
18853
|
-
|
|
18854
|
-
|
|
18855
|
-
|
|
18856
|
-
|
|
18857
|
-
}
|
|
18858
|
-
|
|
18859
|
-
|
|
18860
|
-
|
|
18861
|
-
|
|
18862
|
-
|
|
18863
|
-
|
|
18864
|
-
|
|
18865
|
-
|
|
18866
|
-
"textColor",
|
|
18867
|
-
"fontRef"
|
|
18868
|
-
];
|
|
18869
|
-
var TEXT_PARTS = [
|
|
18870
|
-
"title",
|
|
18871
|
-
"axisTitle",
|
|
18872
|
-
"categoryAxis",
|
|
18873
|
-
"valueAxis",
|
|
18874
|
-
"legend",
|
|
18875
|
-
"dataLabel"
|
|
18876
|
-
];
|
|
18877
|
-
function inheritChartText(part, entry2, builtIn, root) {
|
|
18878
|
-
if (!root || !TEXT_PARTS.includes(part)) return entry2;
|
|
18879
|
-
const out = { ...entry2 };
|
|
18880
|
-
for (const key of TEXT_KEYS) {
|
|
18881
|
-
delete out[key];
|
|
18882
|
-
const value = root[key] ?? builtIn?.[key];
|
|
18883
|
-
if (value !== void 0) Object.assign(out, { [key]: value });
|
|
19807
|
+
if (percent) return `${clean(value * 100)}%`;
|
|
19808
|
+
const v = clean(value);
|
|
19809
|
+
if (Math.abs(v) >= 1e15 || v !== 0 && Math.abs(v) < 1e-6)
|
|
19810
|
+
return v.toExponential(2).replace("e+", "E+").replace("e-", "E-");
|
|
19811
|
+
const [int2 = "0", frac] = String(Math.abs(v)).split(".");
|
|
19812
|
+
const grouped = int2.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
19813
|
+
return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
|
|
19814
|
+
}
|
|
19815
|
+
|
|
19816
|
+
// chart/render/chart-svg-axes.ts
|
|
19817
|
+
function axisTickText(value, axis, percent = false) {
|
|
19818
|
+
return formatChartNumber(value, axis?.source.numberFormat?.formatCode) ?? formatAxisValue(value, percent);
|
|
19819
|
+
}
|
|
19820
|
+
function axisLine(model, axis, part, x1, y1, x2, y2) {
|
|
19821
|
+
if (axis?.source.deleted) return "";
|
|
19822
|
+
return styledAxisLine(x1, y1, x2, y2, axis?.line, chartStroke(model, part));
|
|
19823
|
+
}
|
|
19824
|
+
function styledAxisLine(x1, y1, x2, y2, paint2, fallback) {
|
|
19825
|
+
const color = paint2?.color ?? fallback.color;
|
|
19826
|
+
const width = paint2?.width ?? fallback.width;
|
|
19827
|
+
if (color === "none" || width === 0) return "";
|
|
19828
|
+
const dash = chartLineDashArray(paint2?.dash, width);
|
|
19829
|
+
return line2(x1, y1, x2, y2, esc(color), width).replace(
|
|
19830
|
+
"/>",
|
|
19831
|
+
dash ? ` stroke-dasharray="${dash}"/>` : "/>"
|
|
19832
|
+
);
|
|
19833
|
+
}
|
|
19834
|
+
function axisGridlines(model, axis, ticks, position2, plot, vertical) {
|
|
19835
|
+
const draw2 = (values, paint2, minor2) => {
|
|
19836
|
+
const fallback = chartStroke(model, minor2 ? "gridlineMinor" : "gridlineMajor");
|
|
19837
|
+
return values.map((value) => {
|
|
19838
|
+
const p = position2(value);
|
|
19839
|
+
return vertical ? styledAxisLine(p, plot.y, p, plot.y + plot.h, paint2, fallback) : styledAxisLine(plot.x, p, plot.x + plot.w, p, paint2, fallback);
|
|
19840
|
+
}).join("");
|
|
19841
|
+
};
|
|
19842
|
+
const major = !axis || axis.source.majorGridlines ? draw2(ticks, axis?.majorGrid, false) : "";
|
|
19843
|
+
const minor = axis?.source.minorGridlines ? draw2(axis.minorTicks, axis.minorGrid, true) : "";
|
|
19844
|
+
return major + minor;
|
|
19845
|
+
}
|
|
19846
|
+
|
|
19847
|
+
// chart/axis-range.ts
|
|
19848
|
+
function computeLogValueRange(series, logBase) {
|
|
19849
|
+
const allValues = series.flatMap((item) => item.values).filter((value) => value !== null && Number.isFinite(value) && value > 0);
|
|
19850
|
+
if (allValues.length === 0) {
|
|
19851
|
+
return { min: 1, max: logBase, span: 1, logScale: true, logBase };
|
|
19852
|
+
}
|
|
19853
|
+
const dataMin = Math.min(...allValues);
|
|
19854
|
+
const dataMax = Math.max(...allValues);
|
|
19855
|
+
const logMin = Math.floor(Math.log(dataMin) / Math.log(logBase));
|
|
19856
|
+
const logMax = Math.ceil(Math.log(dataMax) / Math.log(logBase));
|
|
19857
|
+
const min = logBase ** logMin;
|
|
19858
|
+
const max = logBase ** Math.max(logMax, logMin + 1);
|
|
19859
|
+
return {
|
|
19860
|
+
min,
|
|
19861
|
+
max,
|
|
19862
|
+
span: Math.max(Math.log(max) / Math.log(logBase) - Math.log(min) / Math.log(logBase), 1),
|
|
19863
|
+
logScale: true,
|
|
19864
|
+
logBase
|
|
19865
|
+
};
|
|
19866
|
+
}
|
|
19867
|
+
function withAxisBounds(automatic, axis, logBase) {
|
|
19868
|
+
const validMin = typeof axis?.min === "number" && Number.isFinite(axis.min) && (!logBase || axis.min > 0) ? axis.min : void 0;
|
|
19869
|
+
const validMax = typeof axis?.max === "number" && Number.isFinite(axis.max) && (!logBase || axis.max > 0) ? axis.max : void 0;
|
|
19870
|
+
const min = validMin ?? automatic.min;
|
|
19871
|
+
let max = validMax ?? automatic.max;
|
|
19872
|
+
const majorUnit = validMin === void 0 && validMax === void 0 ? automatic.majorUnit : void 0;
|
|
19873
|
+
if (max <= min) {
|
|
19874
|
+
max = logBase ? min * logBase : min + 1;
|
|
18884
19875
|
}
|
|
18885
|
-
|
|
18886
|
-
|
|
18887
|
-
|
|
19876
|
+
const span = logBase ? Math.log(max) / Math.log(logBase) - Math.log(min) / Math.log(logBase) : max - min;
|
|
19877
|
+
return {
|
|
19878
|
+
min,
|
|
19879
|
+
max,
|
|
19880
|
+
span: Math.max(span, Number.EPSILON),
|
|
19881
|
+
...majorUnit !== void 0 ? { majorUnit } : {},
|
|
19882
|
+
...logBase ? { logScale: true, logBase } : {},
|
|
19883
|
+
...axis?.orientation === "maxMin" ? { reverseOrder: true } : {}
|
|
19884
|
+
};
|
|
18888
19885
|
}
|
|
18889
19886
|
|
|
18890
|
-
// chart/
|
|
18891
|
-
var
|
|
18892
|
-
function
|
|
18893
|
-
|
|
18894
|
-
|
|
18895
|
-
|
|
18896
|
-
|
|
19887
|
+
// chart/axis-ticks.ts
|
|
19888
|
+
var LOG_EXPONENT_TOLERANCE = 1e-12;
|
|
19889
|
+
function generateLogTicks(range) {
|
|
19890
|
+
if (!range.logScale || !range.logBase) {
|
|
19891
|
+
return [];
|
|
19892
|
+
}
|
|
19893
|
+
const base = range.logBase;
|
|
19894
|
+
const logMin = Math.log(range.min) / Math.log(base);
|
|
19895
|
+
const logMax = Math.log(range.max) / Math.log(base);
|
|
19896
|
+
const firstExponent = Math.ceil(logMin - LOG_EXPONENT_TOLERANCE);
|
|
19897
|
+
const lastExponent = Math.floor(logMax + LOG_EXPONENT_TOLERANCE);
|
|
19898
|
+
if (lastExponent < firstExponent) {
|
|
19899
|
+
return range.min === range.max ? [range.min] : [range.min, range.max];
|
|
19900
|
+
}
|
|
19901
|
+
return Array.from(
|
|
19902
|
+
{ length: lastExponent - firstExponent + 1 },
|
|
19903
|
+
(_unused, index) => base ** (firstExponent + index)
|
|
19904
|
+
);
|
|
18897
19905
|
}
|
|
18898
|
-
function
|
|
18899
|
-
|
|
18900
|
-
|
|
18901
|
-
for (const part of CHART_STYLE_PARTS) {
|
|
18902
|
-
const base = chart.styleDefinition?.entries[part];
|
|
18903
|
-
const direct = chart.formatting?.entries[part];
|
|
18904
|
-
if (!defaults[part] && !base && !direct) continue;
|
|
18905
|
-
const entry2 = {
|
|
18906
|
-
...inheritChartText(
|
|
18907
|
-
part,
|
|
18908
|
-
{ ...defaults[part], ...base, sourceXml: base?.sourceXml ?? "" },
|
|
18909
|
-
defaults[part],
|
|
18910
|
-
chart.formatting?.textDefaults
|
|
18911
|
-
),
|
|
18912
|
-
...direct,
|
|
18913
|
-
sourceXml: direct?.sourceXml ?? base?.sourceXml ?? ""
|
|
18914
|
-
};
|
|
18915
|
-
if (base?.line || direct?.line) entry2.line = { ...base?.line, ...direct?.line };
|
|
18916
|
-
entries[part] = entry2;
|
|
19906
|
+
function generateIntervalTicks(range, unit) {
|
|
19907
|
+
if (!Number.isFinite(unit) || unit <= 0 || range.logScale) {
|
|
19908
|
+
return [];
|
|
18917
19909
|
}
|
|
18918
|
-
const
|
|
18919
|
-
const
|
|
18920
|
-
|
|
18921
|
-
|
|
18922
|
-
|
|
19910
|
+
const tolerance = Math.max(1, Math.abs(range.min), Math.abs(range.max)) * 1e-12;
|
|
19911
|
+
const first3 = Math.ceil((range.min - tolerance) / unit);
|
|
19912
|
+
const last = Math.floor((range.max + tolerance) / unit);
|
|
19913
|
+
const count = Math.min(Math.max(last - first3 + 1, 0), 2e3);
|
|
19914
|
+
return Array.from({ length: count }, (_, index) => (first3 + index) * unit);
|
|
19915
|
+
}
|
|
19916
|
+
function generateAxisTicks(range, axis, defaultIntervals) {
|
|
19917
|
+
if (range.logScale && range.logBase) {
|
|
19918
|
+
return generateLogTicks(range);
|
|
19919
|
+
}
|
|
19920
|
+
const explicit = generateIntervalTicks(range, axis?.majorUnit ?? 0);
|
|
19921
|
+
if (explicit.length > 0) {
|
|
19922
|
+
return explicit;
|
|
19923
|
+
}
|
|
19924
|
+
const automatic = generateIntervalTicks(range, range.majorUnit ?? 0);
|
|
19925
|
+
if (automatic.length > 0) {
|
|
19926
|
+
return automatic;
|
|
19927
|
+
}
|
|
19928
|
+
return Array.from(
|
|
19929
|
+
{ length: defaultIntervals + 1 },
|
|
19930
|
+
(_, index) => range.min + range.span / defaultIntervals * index
|
|
18923
19931
|
);
|
|
18924
|
-
|
|
18925
|
-
|
|
18926
|
-
|
|
18927
|
-
)
|
|
18928
|
-
|
|
18929
|
-
const entry2 = entries[part];
|
|
18930
|
-
if (!entry2) continue;
|
|
18931
|
-
const family = typeface(entry2, theme);
|
|
18932
|
-
const shadow = resolveDrawingShadowXml(entry2.textEffectsXml, {
|
|
18933
|
-
scheme: (name) => scheme[name]
|
|
18934
|
-
});
|
|
18935
|
-
if (shadow) (out[part] ??= {}).textShadow = shadow;
|
|
18936
|
-
if (family) (out[part] ??= {}).typeface = family;
|
|
18937
|
-
if (entry2.axisVisible !== void 0) (out[part] ??= {}).axisVisible = entry2.axisVisible;
|
|
18938
|
-
if (entry2.labelsVisible !== void 0) (out[part] ??= {}).labelsVisible = entry2.labelsVisible;
|
|
18939
|
-
if (entry2.line?.widthEmu === 0) (out[part] ??= {}).lineWidth = 0;
|
|
18940
|
-
if (entry2.fill?.kind === "gradient") {
|
|
18941
|
-
(out[part] ??= {}).gradient = resolveChartGradient(entry2.fill, resolve);
|
|
18942
|
-
}
|
|
19932
|
+
}
|
|
19933
|
+
function generateMinorAxisTicks(range, axis) {
|
|
19934
|
+
const minor = generateIntervalTicks(range, axis?.minorUnit ?? 0);
|
|
19935
|
+
if (minor.length === 0) {
|
|
19936
|
+
return [];
|
|
18943
19937
|
}
|
|
18944
|
-
|
|
19938
|
+
const majorUnit = axis?.majorUnit;
|
|
19939
|
+
if (!majorUnit || !Number.isFinite(majorUnit) || majorUnit <= 0) {
|
|
19940
|
+
return minor;
|
|
19941
|
+
}
|
|
19942
|
+
const tolerance = Math.max(1, Math.abs(range.min), Math.abs(range.max)) * 1e-10;
|
|
19943
|
+
return minor.filter(
|
|
19944
|
+
(value) => Math.abs(value / majorUnit - Math.round(value / majorUnit)) > tolerance
|
|
19945
|
+
);
|
|
19946
|
+
}
|
|
19947
|
+
|
|
19948
|
+
// chart/render/chart-view-axes.ts
|
|
19949
|
+
function chartAxisRatio(value, scale, axis) {
|
|
19950
|
+
const range = axis?.range;
|
|
19951
|
+
const ratio = range?.logScale ? Math.log(Math.max(value, range.min) / range.min) / Math.log(range.max / range.min) : (value - scale.min) / (scale.max - scale.min || 1);
|
|
19952
|
+
return range?.reverseOrder ? 1 - ratio : ratio;
|
|
19953
|
+
}
|
|
19954
|
+
function chartAxisLabels(axis) {
|
|
19955
|
+
return axis?.source.deleted !== true && axis?.source.tickLabelPosition !== "none";
|
|
19956
|
+
}
|
|
19957
|
+
function options(axis) {
|
|
19958
|
+
return {
|
|
19959
|
+
...axis.scaling,
|
|
19960
|
+
...axis.scaling.logBase === void 0 ? {} : { logScale: true },
|
|
19961
|
+
...axis.majorUnit === void 0 ? {} : { majorUnit: axis.majorUnit },
|
|
19962
|
+
...axis.minorUnit === void 0 ? {} : { minorUnit: axis.minorUnit }
|
|
19963
|
+
};
|
|
19964
|
+
}
|
|
19965
|
+
function applyChartAxes(model, chart, color) {
|
|
19966
|
+
if (!chart.axes?.length) return;
|
|
19967
|
+
const axes = chart.axes;
|
|
19968
|
+
const linked = axes.filter((axis) => axis.id !== void 0 && chart.axisIds?.includes(axis.id));
|
|
19969
|
+
const candidates = linked.length ? linked : axes;
|
|
19970
|
+
const xy = model.type === "scatter" || model.type === "bubble";
|
|
19971
|
+
const value = candidates.find((axis) => axis.kind === "val" && !["b", "t"].includes(axis.position ?? "")) ?? candidates.find((axis) => axis.kind === "val");
|
|
19972
|
+
const category = candidates.find(
|
|
19973
|
+
(axis) => xy ? axis.kind === "val" && axis !== value : axis.kind === "cat" || axis.kind === "date"
|
|
19974
|
+
);
|
|
19975
|
+
const secondary = axes.find((axis) => axis.kind === "val" && axis !== value && axis !== category);
|
|
19976
|
+
const paint2 = (shape2) => {
|
|
19977
|
+
const ln = shape2?.line;
|
|
19978
|
+
const fill = ln?.fill;
|
|
19979
|
+
const resolved = fill?.kind === "none" ? "none" : color(fill?.kind === "solid" ? fill.color : void 0);
|
|
19980
|
+
return {
|
|
19981
|
+
...resolved === void 0 ? {} : { color: resolved },
|
|
19982
|
+
...ln?.widthEmu === void 0 ? {} : { width: ln.widthEmu / EMU_PER_PIXEL },
|
|
19983
|
+
...ln?.dash === void 0 ? {} : { dash: ln.dash }
|
|
19984
|
+
};
|
|
19985
|
+
};
|
|
19986
|
+
const bind = (axis, scale, values) => {
|
|
19987
|
+
const opts = options(axis);
|
|
19988
|
+
const automatic = opts.logScale ? computeLogValueRange(
|
|
19989
|
+
[{ values: values ?? [] }],
|
|
19990
|
+
opts.logBase && Number.isFinite(opts.logBase) && opts.logBase > 1 ? opts.logBase : 10
|
|
19991
|
+
) : {
|
|
19992
|
+
min: scale?.min ?? 0,
|
|
19993
|
+
max: scale?.max ?? 1,
|
|
19994
|
+
span: (scale?.max ?? 1) - (scale?.min ?? 0),
|
|
19995
|
+
...scale ? { majorUnit: scale.majorUnit } : {}
|
|
19996
|
+
};
|
|
19997
|
+
const logBase = automatic.logBase;
|
|
19998
|
+
const range = withAxisBounds(automatic, opts, logBase);
|
|
19999
|
+
if (scale) {
|
|
20000
|
+
scale.min = range.min;
|
|
20001
|
+
scale.max = range.max;
|
|
20002
|
+
scale.ticks = generateAxisTicks(range, opts, 5);
|
|
20003
|
+
}
|
|
20004
|
+
return {
|
|
20005
|
+
source: axis,
|
|
20006
|
+
range,
|
|
20007
|
+
minorTicks: generateMinorAxisTicks(range, opts),
|
|
20008
|
+
line: paint2(axis.spPr),
|
|
20009
|
+
majorGrid: paint2(axis.majorGridlinesSpPr),
|
|
20010
|
+
minorGrid: paint2(axis.minorGridlinesSpPr)
|
|
20011
|
+
};
|
|
20012
|
+
};
|
|
20013
|
+
const out = {};
|
|
20014
|
+
if (value)
|
|
20015
|
+
out.value = bind(
|
|
20016
|
+
value,
|
|
20017
|
+
model.valueAxis,
|
|
20018
|
+
[
|
|
20019
|
+
...model.series,
|
|
20020
|
+
...model.extraGroups?.filter((g) => !g.secondary).flatMap((g) => g.series) ?? []
|
|
20021
|
+
].flatMap((s) => s.values)
|
|
20022
|
+
);
|
|
20023
|
+
if (category)
|
|
20024
|
+
out.category = bind(
|
|
20025
|
+
category,
|
|
20026
|
+
model.xAxis ?? {
|
|
20027
|
+
min: 0,
|
|
20028
|
+
max: Math.max(1, model.categories.length - 1),
|
|
20029
|
+
majorUnit: 1,
|
|
20030
|
+
ticks: []
|
|
20031
|
+
},
|
|
20032
|
+
model.series.flatMap((s) => s.xValues ?? [])
|
|
20033
|
+
);
|
|
20034
|
+
if (secondary)
|
|
20035
|
+
out.secondary = bind(
|
|
20036
|
+
secondary,
|
|
20037
|
+
model.secondaryAxis,
|
|
20038
|
+
model.extraGroups?.filter((g) => g.secondary).flatMap((g) => g.series.flatMap((s) => s.values))
|
|
20039
|
+
);
|
|
20040
|
+
model.axes = out;
|
|
18945
20041
|
}
|
|
18946
20042
|
|
|
18947
20043
|
// chart/render/chart-view-analysis.ts
|
|
@@ -18993,15 +20089,15 @@ function seriesName(series, index, evaluateRef) {
|
|
|
18993
20089
|
const fromRef = resolveRef(series.nameRef, evaluateRef)?.map(toText).filter((t) => t !== "").join(" ");
|
|
18994
20090
|
return fromRef || series.name || `Series${index + 1}`;
|
|
18995
20091
|
}
|
|
18996
|
-
function seriesContext(chart, theme,
|
|
20092
|
+
function seriesContext(chart, theme, options2) {
|
|
18997
20093
|
const scheme = chartColorScheme(theme);
|
|
18998
20094
|
const resolver = { scheme: (name) => scheme[name] };
|
|
18999
20095
|
return {
|
|
19000
20096
|
theme,
|
|
19001
20097
|
scheme,
|
|
19002
20098
|
palette: chart.colorPalette === void 0 ? void 0 : findChartColorPalette(chart.colorPalette),
|
|
19003
|
-
evaluateRef:
|
|
19004
|
-
seriesColor:
|
|
20099
|
+
evaluateRef: options2.evaluateRef ?? (() => []),
|
|
20100
|
+
seriesColor: options2.seriesColor,
|
|
19005
20101
|
drawingColor: (color) => color && drawingColorCss(resolveDrawingColor(color, resolver, { transformOrder: "document" })),
|
|
19006
20102
|
gradient: (fill) => fill?.kind === "gradient" ? resolveChartGradient(
|
|
19007
20103
|
fill,
|
|
@@ -19027,7 +20123,11 @@ function seriesView(ctx, s, index, total, categoriesOf) {
|
|
|
19027
20123
|
})
|
|
19028
20124
|
);
|
|
19029
20125
|
if (Object.keys(points).length) view.pointGradients = points;
|
|
19030
|
-
Object.assign(
|
|
20126
|
+
Object.assign(
|
|
20127
|
+
view,
|
|
20128
|
+
analysisView(s, color, ctx.drawingColor),
|
|
20129
|
+
seriesMarkerViews(s, ctx.drawingColor)
|
|
20130
|
+
);
|
|
19031
20131
|
return view;
|
|
19032
20132
|
}
|
|
19033
20133
|
|
|
@@ -19200,12 +20300,70 @@ function chartTitleText(chart, theme) {
|
|
|
19200
20300
|
};
|
|
19201
20301
|
}
|
|
19202
20302
|
|
|
20303
|
+
// chart/render/chart-view-labels.ts
|
|
20304
|
+
function labelsOf(source, view, categories, numberFormat2) {
|
|
20305
|
+
const { chart, series, points } = source;
|
|
20306
|
+
if ((series?.deleted ?? chart?.deleted) === true) return void 0;
|
|
20307
|
+
const percentBase = view.values.reduce(
|
|
20308
|
+
(sum, v) => sum + (v === null ? 0 : Math.abs(v)),
|
|
20309
|
+
0
|
|
20310
|
+
);
|
|
20311
|
+
const out = [];
|
|
20312
|
+
let any = false;
|
|
20313
|
+
view.values.forEach((value, i) => {
|
|
20314
|
+
const point = points?.[i];
|
|
20315
|
+
if (value === null || point?.deleted === true) return;
|
|
20316
|
+
const position2 = point?.position ?? series?.position ?? chart?.position;
|
|
20317
|
+
const x = view.xValues?.[i];
|
|
20318
|
+
const category = x === void 0 || x === null ? categories[i] : formatAxisValue(x);
|
|
20319
|
+
let built;
|
|
20320
|
+
if (point?.text !== void 0) built = { text: point.text };
|
|
20321
|
+
else {
|
|
20322
|
+
const flags = resolveDataLabelFlags({
|
|
20323
|
+
...point ? { point } : {},
|
|
20324
|
+
...series ? { series } : {},
|
|
20325
|
+
...chart ? { chart } : {}
|
|
20326
|
+
});
|
|
20327
|
+
built = composeDataLabelText({
|
|
20328
|
+
flags,
|
|
20329
|
+
seriesName: view.name,
|
|
20330
|
+
category,
|
|
20331
|
+
value,
|
|
20332
|
+
numberFormat: point?.numberFormat ?? series?.numberFormat ?? chart?.numberFormat ?? numberFormat2,
|
|
20333
|
+
percentBase,
|
|
20334
|
+
bubbleSize: view.sizes?.[i] ?? void 0,
|
|
20335
|
+
formatValue: (v) => formatAxisValue(v),
|
|
20336
|
+
formatBubbleSize: (size) => formatAxisValue(size)
|
|
20337
|
+
});
|
|
20338
|
+
}
|
|
20339
|
+
if (!built) return;
|
|
20340
|
+
any = true;
|
|
20341
|
+
out[i] = {
|
|
20342
|
+
text: built.text,
|
|
20343
|
+
...position2 ? { position: position2 } : {},
|
|
20344
|
+
...built.color ? { color: built.color } : {}
|
|
20345
|
+
};
|
|
20346
|
+
});
|
|
20347
|
+
return any ? out : void 0;
|
|
20348
|
+
}
|
|
20349
|
+
function applyDataLabels(model, sources, extra) {
|
|
20350
|
+
const apply = (source, view) => {
|
|
20351
|
+
if (!source?.dataLabels) return;
|
|
20352
|
+
const labels = labelsOf(source.dataLabels, view, model.categories, source.numberFormat);
|
|
20353
|
+
if (labels) view.labels = labels;
|
|
20354
|
+
};
|
|
20355
|
+
model.series.forEach((view, i) => apply(sources[i], view));
|
|
20356
|
+
model.extraGroups?.forEach(
|
|
20357
|
+
(group2, g) => group2.series.forEach((view, i) => apply(extra[g]?.series[i], view))
|
|
20358
|
+
);
|
|
20359
|
+
}
|
|
20360
|
+
|
|
19203
20361
|
// chart/render/chart-view-ex.ts
|
|
19204
20362
|
function groupsAxis(groups, categories) {
|
|
19205
20363
|
let min = Infinity;
|
|
19206
20364
|
let max = -Infinity;
|
|
19207
|
-
for (const
|
|
19208
|
-
const extent = valueExtent(
|
|
20365
|
+
for (const group2 of groups) {
|
|
20366
|
+
const extent = valueExtent(group2.type, group2.grouping, group2.series, categories);
|
|
19209
20367
|
min = Math.min(min, extent.min);
|
|
19210
20368
|
max = Math.max(max, extent.max);
|
|
19211
20369
|
}
|
|
@@ -19214,17 +20372,17 @@ function groupsAxis(groups, categories) {
|
|
|
19214
20372
|
function chartExtraView(chart, model, ctx, total, categoriesOf) {
|
|
19215
20373
|
let index = chart.series.length;
|
|
19216
20374
|
const groups = [];
|
|
19217
|
-
for (const
|
|
19218
|
-
const series =
|
|
20375
|
+
for (const group2 of chart.extraGroups ?? []) {
|
|
20376
|
+
const series = group2.series.map((s) => seriesView(ctx, s, index++, total, categoriesOf));
|
|
19219
20377
|
const view = {
|
|
19220
|
-
type:
|
|
19221
|
-
grouping:
|
|
20378
|
+
type: group2.chartType,
|
|
20379
|
+
grouping: group2.grouping ?? (group2.chartType === "column" ? "clustered" : "standard"),
|
|
19222
20380
|
series,
|
|
19223
|
-
secondary:
|
|
20381
|
+
secondary: group2.secondary
|
|
19224
20382
|
};
|
|
19225
|
-
if (
|
|
19226
|
-
if (
|
|
19227
|
-
if (
|
|
20383
|
+
if (group2.chartType === "stock") view.stock = stockView(group2.stock, ctx);
|
|
20384
|
+
if (group2.barGapWidth !== void 0) view.barGapWidth = group2.barGapWidth;
|
|
20385
|
+
if (group2.barOverlap !== void 0) view.barOverlap = group2.barOverlap;
|
|
19228
20386
|
groups.push(view);
|
|
19229
20387
|
}
|
|
19230
20388
|
if (!groups.length) return;
|
|
@@ -19241,8 +20399,8 @@ function chartExtraAxes(model) {
|
|
|
19241
20399
|
const own2 = valueExtent(model.type, model.grouping, model.series, count);
|
|
19242
20400
|
let min = own2.min;
|
|
19243
20401
|
let max = own2.max;
|
|
19244
|
-
for (const
|
|
19245
|
-
const extent = valueExtent(
|
|
20402
|
+
for (const group2 of shared) {
|
|
20403
|
+
const extent = valueExtent(group2.type, group2.grouping, group2.series, count);
|
|
19246
20404
|
min = Math.min(min, extent.min);
|
|
19247
20405
|
max = Math.max(max, extent.max);
|
|
19248
20406
|
}
|
|
@@ -19269,11 +20427,11 @@ function histogramView(chart, model) {
|
|
|
19269
20427
|
const first3 = model.series[0];
|
|
19270
20428
|
if (!first3) return;
|
|
19271
20429
|
const raw = first3.values.map((v) => v ?? Number.NaN);
|
|
19272
|
-
const
|
|
19273
|
-
const bins =
|
|
20430
|
+
const options2 = chart.histogram ?? {};
|
|
20431
|
+
const bins = options2.aggregateByCategory ? aggregateByCategory(
|
|
19274
20432
|
first3.values.map((v) => v ?? 0),
|
|
19275
20433
|
model.categories
|
|
19276
|
-
) : computeHistogramBins(raw,
|
|
20434
|
+
) : computeHistogramBins(raw, options2, formatAxisValue);
|
|
19277
20435
|
model.categories = bins.map((bin) => bin.label);
|
|
19278
20436
|
first3.values = bins.map((bin) => bin.value);
|
|
19279
20437
|
model.barGapWidth = 0;
|
|
@@ -19297,11 +20455,11 @@ var SUPPORTED = /* @__PURE__ */ new Set([
|
|
|
19297
20455
|
"treemap",
|
|
19298
20456
|
"sunburst"
|
|
19299
20457
|
]);
|
|
19300
|
-
function chartSummaryView(chart, theme,
|
|
20458
|
+
function chartSummaryView(chart, theme, options2 = {}) {
|
|
19301
20459
|
const type = chart.chartType;
|
|
19302
20460
|
const radial = type === "pie" || type === "doughnut";
|
|
19303
20461
|
const byPoint = radial || type === "treemap" || type === "sunburst";
|
|
19304
|
-
const ctx = seriesContext(chart, theme,
|
|
20462
|
+
const ctx = seriesContext(chart, theme, options2);
|
|
19305
20463
|
const { palette, scheme, drawingColor } = ctx;
|
|
19306
20464
|
const grouping = chart.grouping ?? (type === "bar" || type === "column" ? "clustered" : "standard");
|
|
19307
20465
|
const rawCategories = [];
|
|
@@ -19385,128 +20543,23 @@ function chartSummaryView(chart, theme, options = {}) {
|
|
|
19385
20543
|
chartExtraView(chart, model, ctx, total, collect);
|
|
19386
20544
|
if (type === "waterfall") waterfallView(chart, model, ctx);
|
|
19387
20545
|
else if (!byPoint) model.valueAxis = valueAxis(model);
|
|
20546
|
+
applyDataLabels(model, chart.series, extra);
|
|
19388
20547
|
chartExtraAxes(model);
|
|
20548
|
+
applyChartAxes(model, chart, ctx.drawingColor);
|
|
19389
20549
|
return model;
|
|
19390
20550
|
}
|
|
19391
20551
|
|
|
19392
|
-
// text/css-font-family.ts
|
|
19393
|
-
var FALLBACKS = {
|
|
19394
|
-
calibri: '"Calibri", "Carlito", "Segoe UI", Arial, sans-serif',
|
|
19395
|
-
"calibri light": '"Calibri Light", "Calibri", "Carlito", "Segoe UI", Arial, sans-serif',
|
|
19396
|
-
cambria: '"Cambria", "Caladea", Georgia, serif',
|
|
19397
|
-
arial: 'Arial, "Liberation Sans", Helvetica, sans-serif',
|
|
19398
|
-
"times new roman": '"Times New Roman", "Liberation Serif", Times, serif',
|
|
19399
|
-
"courier new": '"Courier New", "Liberation Mono", monospace',
|
|
19400
|
-
aptos: '"Aptos", "Calibri", "Carlito", "Segoe UI", sans-serif'
|
|
19401
|
-
};
|
|
19402
|
-
function cssFontFamily(name) {
|
|
19403
|
-
const known = FALLBACKS[name.toLowerCase()];
|
|
19404
|
-
if (known) return known;
|
|
19405
|
-
const quoted = `"${name.replace(/["\\]/g, "")}"`;
|
|
19406
|
-
return `${quoted}, "Calibri", "Carlito", "Segoe UI", sans-serif`;
|
|
19407
|
-
}
|
|
19408
|
-
|
|
19409
|
-
// chart/render/chart-svg-appearance.ts
|
|
19410
|
-
var nextPaintId = 0;
|
|
19411
|
-
function chartGradientPaint(model, width = 1024, height = 768) {
|
|
19412
|
-
const prefix2 = `xlsx-chart-${++nextPaintId}`;
|
|
19413
|
-
const appearance = { ...model.appearance };
|
|
19414
|
-
const defs = [];
|
|
19415
|
-
const shadowPaint = (shadow, suffix) => {
|
|
19416
|
-
const id = `${prefix2}-${suffix}`;
|
|
19417
|
-
const pad = Math.max(4, shadow.blur * 3 + Math.abs(shadow.dx) + Math.abs(shadow.dy));
|
|
19418
|
-
defs.push(
|
|
19419
|
-
`<filter id="${id}" filterUnits="userSpaceOnUse" x="${n(-pad)}" y="${n(-pad)}" width="${n(width + pad * 2)}" height="${n(height + pad * 2)}" color-interpolation-filters="sRGB">${svgDropShadowElement(shadow, { number: n, color: (value) => esc(value) })}</filter>`
|
|
19420
|
-
);
|
|
19421
|
-
return `url(#${id})`;
|
|
19422
|
-
};
|
|
19423
|
-
for (const [part, entry2] of Object.entries(appearance)) {
|
|
19424
|
-
if (entry2?.textShadow)
|
|
19425
|
-
appearance[part] = {
|
|
19426
|
-
...entry2,
|
|
19427
|
-
textShadowFilter: shadowPaint(entry2.textShadow, `${part}-text-shadow`)
|
|
19428
|
-
};
|
|
19429
|
-
}
|
|
19430
|
-
const paint2 = (gradient, suffix, bounds) => {
|
|
19431
|
-
const def = buildChartGradientDef(`${prefix2}-${suffix}`, gradient, bounds);
|
|
19432
|
-
defs.push(chartGradientMarkup(def));
|
|
19433
|
-
return `url(#${def.id})`;
|
|
19434
|
-
};
|
|
19435
|
-
for (const part of ["chartArea", "plotArea"]) {
|
|
19436
|
-
const entry2 = appearance[part];
|
|
19437
|
-
if (!entry2?.gradient) continue;
|
|
19438
|
-
if (part === "plotArea" && ["circle", "shape"].includes(entry2.gradient.path ?? "")) continue;
|
|
19439
|
-
appearance[part] = {
|
|
19440
|
-
...entry2,
|
|
19441
|
-
fillColor: paint2(entry2.gradient, part, { width, height, shape: "rect" })
|
|
19442
|
-
};
|
|
19443
|
-
}
|
|
19444
|
-
const series = model.series.map((source, index) => {
|
|
19445
|
-
const view = { ...source };
|
|
19446
|
-
if (source.shadow) view.shadowFilter = shadowPaint(source.shadow, `s${index}-shadow`);
|
|
19447
|
-
const bounds = model.type === "bar" || model.type === "column" ? { width: 1, height: 1, shape: "rect" } : void 0;
|
|
19448
|
-
if (source.gradient) view.color = paint2(source.gradient, `s${index}`, bounds);
|
|
19449
|
-
if (source.pointGradients) {
|
|
19450
|
-
view.pointColors = [...source.pointColors ?? []];
|
|
19451
|
-
for (const [key, gradient] of Object.entries(source.pointGradients))
|
|
19452
|
-
view.pointColors[Number(key)] = paint2(gradient, `s${index}-p${key}`, bounds);
|
|
19453
|
-
}
|
|
19454
|
-
return view;
|
|
19455
|
-
});
|
|
19456
|
-
return defs.length ? { model: { ...model, appearance, series }, defs: `<defs>${defs.join("")}</defs>` } : { model, defs: "" };
|
|
19457
|
-
}
|
|
19458
|
-
function chartTextAttributes(model, part, fallbackSize = FONT_SIZE) {
|
|
19459
|
-
const entry2 = model.appearance?.[part];
|
|
19460
|
-
return {
|
|
19461
|
-
size: entry2?.fontSize === void 0 ? fallbackSize : chartPointsToPixels(entry2.fontSize),
|
|
19462
|
-
...entry2?.color === void 0 ? {} : { fill: entry2.color },
|
|
19463
|
-
...entry2?.bold === void 0 ? {} : { weight: entry2.bold ? "bold" : "normal" },
|
|
19464
|
-
...entry2?.italic === void 0 ? {} : { italic: entry2.italic },
|
|
19465
|
-
...entry2?.underline === void 0 ? {} : { underline: entry2.underline },
|
|
19466
|
-
...entry2?.typeface === void 0 ? {} : { family: cssFontFamily(entry2.typeface) },
|
|
19467
|
-
...entry2?.textShadowFilter === void 0 ? {} : { filter: entry2.textShadowFilter }
|
|
19468
|
-
};
|
|
19469
|
-
}
|
|
19470
|
-
function chartStroke(model, part) {
|
|
19471
|
-
const entry2 = model.appearance?.[part];
|
|
19472
|
-
return {
|
|
19473
|
-
color: entry2?.axisVisible === false ? "none" : entry2?.lineColor ?? (part === "gridlineMajor" ? GRID_COLOR : AXIS_COLOR),
|
|
19474
|
-
width: entry2?.lineWidth === void 0 ? 1 : chartPointsToPixels(entry2.lineWidth)
|
|
19475
|
-
};
|
|
19476
|
-
}
|
|
19477
|
-
function chartAreaRect(model, part, area) {
|
|
19478
|
-
if (area.w <= 0 || area.h <= 0) return "";
|
|
19479
|
-
const entry2 = model.appearance?.[part];
|
|
19480
|
-
let fill = entry2?.fillColor ?? (part === "chartArea" ? "#FFFFFF" : "none");
|
|
19481
|
-
let defs = "";
|
|
19482
|
-
if (part !== "chartArea" && entry2?.gradient && (part !== "plotArea" || ["circle", "shape"].includes(entry2.gradient.path ?? ""))) {
|
|
19483
|
-
const def = buildChartGradientDef(`xlsx-chart-${++nextPaintId}-${part}`, entry2.gradient, {
|
|
19484
|
-
width: area.w,
|
|
19485
|
-
height: area.h,
|
|
19486
|
-
shape: "rect"
|
|
19487
|
-
});
|
|
19488
|
-
defs = `<defs>${chartGradientMarkup(def)}</defs>`;
|
|
19489
|
-
fill = `url(#${def.id})`;
|
|
19490
|
-
}
|
|
19491
|
-
const stroke = entry2?.lineColor ?? "none";
|
|
19492
|
-
if (fill === "none" && stroke === "none") return "";
|
|
19493
|
-
const width = entry2?.lineWidth === void 0 ? 1 : chartPointsToPixels(entry2.lineWidth);
|
|
19494
|
-
return `${defs}<rect x="${n(area.x)}" y="${n(area.y)}" width="${n(area.w)}" height="${n(area.h)}" fill="${esc(fill)}" stroke="${esc(stroke)}" stroke-width="${n(width)}" data-chart-part="${part}"/>`;
|
|
19495
|
-
}
|
|
19496
|
-
|
|
19497
20552
|
// chart/render/chart-svg-cartesian.ts
|
|
19498
20553
|
function cartesianAxes(model, area, out) {
|
|
19499
20554
|
const scale = model.valueAxis;
|
|
19500
20555
|
if (!scale) return void 0;
|
|
19501
|
-
const labels = scale.ticks.map((t) =>
|
|
20556
|
+
const labels = scale.ticks.map((t) => axisTickText(t, model.axes?.value, scale.percent));
|
|
19502
20557
|
const valueAttrs = chartTextAttributes(model, "valueAxis");
|
|
19503
20558
|
const categoryAttrs = chartTextAttributes(model, "categoryAxis");
|
|
19504
20559
|
const valueSize = valueAttrs.size ?? 10;
|
|
19505
20560
|
const categorySize = categoryAttrs.size ?? 10;
|
|
19506
|
-
const
|
|
19507
|
-
const
|
|
19508
|
-
const valueLabels = model.appearance?.valueAxis?.labelsVisible !== false;
|
|
19509
|
-
const categoryLabels = model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
20561
|
+
const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
|
|
20562
|
+
const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
19510
20563
|
const labelW = valueLabels ? Math.max(...labels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
|
|
19511
20564
|
const horizontal = model.horizontal;
|
|
19512
20565
|
const cats = Math.max(1, model.categories.length);
|
|
@@ -19515,7 +20568,7 @@ function cartesianAxes(model, area, out) {
|
|
|
19515
20568
|
Math.max(...model.categories.map((c2) => textWidth(c2, categorySize)), 8) + 6
|
|
19516
20569
|
);
|
|
19517
20570
|
const second = horizontal ? void 0 : model.secondaryAxis;
|
|
19518
|
-
const secondLabels = second?.ticks.map((t) =>
|
|
20571
|
+
const secondLabels = second?.ticks.map((t) => axisTickText(t, model.axes?.secondary, second.percent)) ?? [];
|
|
19519
20572
|
const secondW = second ? valueLabels ? Math.max(...secondLabels.map((l) => textWidth(l, valueSize)), 8) + 8 : 4 : 0;
|
|
19520
20573
|
const plot = horizontal ? {
|
|
19521
20574
|
x: area.x + catW,
|
|
@@ -19528,29 +20581,47 @@ function cartesianAxes(model, area, out) {
|
|
|
19528
20581
|
w: Math.max(1, area.w - labelW - 4 - secondW),
|
|
19529
20582
|
h: Math.max(1, area.h - Math.max(20, categorySize * 1.5))
|
|
19530
20583
|
};
|
|
19531
|
-
const
|
|
19532
|
-
const value = horizontal ? (v) => plot.x + (v - scale.min) / span * plot.w : (v) => plot.y + plot.h - (v - scale.min) / span * plot.h;
|
|
20584
|
+
const value = horizontal ? (v) => plot.x + chartAxisRatio(v, scale, model.axes?.value) * plot.w : (v) => plot.y + plot.h - chartAxisRatio(v, scale, model.axes?.value) * plot.h;
|
|
19533
20585
|
const bandSize = (horizontal ? plot.h : plot.w) / cats;
|
|
19534
|
-
const
|
|
20586
|
+
const index = (i) => model.axes?.category?.range.reverseOrder ? cats - 1 - i : i;
|
|
20587
|
+
const band = horizontal ? (i) => plot.y + plot.h - bandSize * (index(i) + 0.5) : (i) => plot.x + bandSize * (index(i) + 0.5);
|
|
19535
20588
|
out.push(chartAreaRect(model, "plotArea", plot));
|
|
20589
|
+
out.push(axisGridlines(model, model.axes?.value, scale.ticks, value, plot, horizontal));
|
|
20590
|
+
if (model.axes?.category?.source.majorGridlines || model.axes?.category?.source.minorGridlines)
|
|
20591
|
+
out.push(
|
|
20592
|
+
axisGridlines(
|
|
20593
|
+
model,
|
|
20594
|
+
model.axes.category,
|
|
20595
|
+
model.categories.map((_, i) => i),
|
|
20596
|
+
band,
|
|
20597
|
+
plot,
|
|
20598
|
+
!horizontal
|
|
20599
|
+
)
|
|
20600
|
+
);
|
|
19536
20601
|
scale.ticks.forEach((t, i) => {
|
|
19537
20602
|
const p = value(t);
|
|
19538
20603
|
const label = labels[i] ?? "";
|
|
19539
20604
|
if (horizontal) {
|
|
19540
|
-
out.push(line2(p, plot.y, p, plot.y + plot.h, grid.color, grid.width));
|
|
19541
20605
|
if (valueLabels)
|
|
19542
20606
|
out.push(
|
|
19543
20607
|
text2(p, plot.y + plot.h + valueSize + 2, label, { anchor: "middle", ...valueAttrs })
|
|
19544
20608
|
);
|
|
19545
20609
|
} else {
|
|
19546
|
-
out.push(line2(plot.x, p, plot.x + plot.w, p, grid.color, grid.width));
|
|
19547
20610
|
if (valueLabels)
|
|
19548
20611
|
out.push(text2(plot.x - 4, p + valueSize * 0.3, label, { anchor: "end", ...valueAttrs }));
|
|
19549
20612
|
}
|
|
19550
20613
|
});
|
|
19551
|
-
const
|
|
19552
|
-
|
|
19553
|
-
|
|
20614
|
+
const source = model.axes?.value?.source;
|
|
20615
|
+
const crossing = source?.crosses === "max" ? scale.max : source?.crosses === "min" ? scale.min : source?.crossesAt ?? 0;
|
|
20616
|
+
const zero = value(Math.min(Math.max(crossing, scale.min), scale.max));
|
|
20617
|
+
if (horizontal)
|
|
20618
|
+
out.push(
|
|
20619
|
+
axisLine(model, model.axes?.category, "categoryAxis", zero, plot.y, zero, plot.y + plot.h)
|
|
20620
|
+
);
|
|
20621
|
+
else
|
|
20622
|
+
out.push(
|
|
20623
|
+
axisLine(model, model.axes?.category, "categoryAxis", plot.x, zero, plot.x + plot.w, zero)
|
|
20624
|
+
);
|
|
19554
20625
|
const step = Math.max(
|
|
19555
20626
|
1,
|
|
19556
20627
|
Math.ceil(cats / Math.max(1, Math.floor((horizontal ? plot.h : plot.w) / 14)))
|
|
@@ -19575,20 +20646,23 @@ function cartesianAxes(model, area, out) {
|
|
|
19575
20646
|
});
|
|
19576
20647
|
const frame2 = { plot, value, band, bandSize };
|
|
19577
20648
|
if (second) {
|
|
19578
|
-
|
|
19579
|
-
frame2.secondary = (v) => plot.y + plot.h - (v - second.min) / secondSpan * plot.h;
|
|
19580
|
-
const secondAxis = chartStroke(model, "valueAxis");
|
|
20649
|
+
frame2.secondary = (v) => plot.y + plot.h - chartAxisRatio(v, second, model.axes?.secondary) * plot.h;
|
|
19581
20650
|
out.push(
|
|
19582
|
-
|
|
20651
|
+
axisLine(
|
|
20652
|
+
model,
|
|
20653
|
+
model.axes?.secondary,
|
|
20654
|
+
"valueAxis",
|
|
19583
20655
|
plot.x + plot.w,
|
|
19584
20656
|
plot.y,
|
|
19585
20657
|
plot.x + plot.w,
|
|
19586
|
-
plot.y + plot.h
|
|
19587
|
-
secondAxis.color,
|
|
19588
|
-
secondAxis.width
|
|
20658
|
+
plot.y + plot.h
|
|
19589
20659
|
)
|
|
19590
20660
|
);
|
|
19591
|
-
if (
|
|
20661
|
+
if (model.axes?.secondary?.source.majorGridlines || model.axes?.secondary?.source.minorGridlines)
|
|
20662
|
+
out.push(
|
|
20663
|
+
axisGridlines(model, model.axes.secondary, second.ticks, frame2.secondary, plot, false)
|
|
20664
|
+
);
|
|
20665
|
+
if (chartAxisLabels(model.axes?.secondary))
|
|
19592
20666
|
second.ticks.forEach(
|
|
19593
20667
|
(t, i) => out.push(
|
|
19594
20668
|
text2(plot.x + plot.w + 4, frame2.secondary(t) + valueSize * 0.3, secondLabels[i] ?? "", {
|
|
@@ -19612,6 +20686,7 @@ function linesAndAreas(model, frame2, out) {
|
|
|
19612
20686
|
const stacked = model.grouping === "stacked" || model.grouping === "percentStacked";
|
|
19613
20687
|
const acc = new Array(model.categories.length).fill(0);
|
|
19614
20688
|
const area = model.type === "area";
|
|
20689
|
+
const marks = [];
|
|
19615
20690
|
const layers = [];
|
|
19616
20691
|
model.series.forEach((s, si) => {
|
|
19617
20692
|
const points = [];
|
|
@@ -19626,16 +20701,24 @@ function linesAndAreas(model, frame2, out) {
|
|
|
19626
20701
|
const top = below + (v ?? 0);
|
|
19627
20702
|
if (stacked) acc[i] = top;
|
|
19628
20703
|
points.push([frame2.band(i), frame2.value(top)]);
|
|
20704
|
+
marks.push({
|
|
20705
|
+
series: s,
|
|
20706
|
+
index: i,
|
|
20707
|
+
x: frame2.band(i),
|
|
20708
|
+
y: frame2.value(top),
|
|
20709
|
+
radius: area ? 0 : chartMarkerRadius(s, i, 2.5)
|
|
20710
|
+
});
|
|
19629
20711
|
lower.push([frame2.band(i), frame2.value(below)]);
|
|
19630
20712
|
});
|
|
19631
20713
|
layers.push({
|
|
20714
|
+
series: s,
|
|
19632
20715
|
points,
|
|
19633
20716
|
lower,
|
|
19634
20717
|
color: s.color,
|
|
19635
20718
|
filter: s.shadowFilter ? ` filter="${s.shadowFilter}"` : ""
|
|
19636
20719
|
});
|
|
19637
20720
|
});
|
|
19638
|
-
for (const { points, lower, color, filter } of area ? [...layers].reverse() : layers) {
|
|
20721
|
+
for (const { points, lower, color, filter, series } of area ? [...layers].reverse() : layers) {
|
|
19639
20722
|
if (area) {
|
|
19640
20723
|
const poly = [...points, ...[...lower].reverse()].map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
|
|
19641
20724
|
out.push(`<polygon points="${poly}" fill="${color}" fill-opacity="0.85"${filter}/>`);
|
|
@@ -19654,10 +20737,11 @@ function linesAndAreas(model, frame2, out) {
|
|
|
19654
20737
|
else segment2.push(`${n(x)},${n(y)}`);
|
|
19655
20738
|
}
|
|
19656
20739
|
flush();
|
|
19657
|
-
|
|
19658
|
-
if (!Number.isNaN(x))
|
|
19659
|
-
|
|
20740
|
+
points.forEach(([x, y], index) => {
|
|
20741
|
+
if (!Number.isNaN(x)) out.push(chartSeriesMarkerSvg(series, index, x, y, 2.5));
|
|
20742
|
+
});
|
|
19660
20743
|
}
|
|
20744
|
+
pointLabels(model, marks, out);
|
|
19661
20745
|
}
|
|
19662
20746
|
|
|
19663
20747
|
// chart/render/chart-svg-xy.ts
|
|
@@ -19665,16 +20749,14 @@ function scatter(model, area, out) {
|
|
|
19665
20749
|
const ys = model.valueAxis;
|
|
19666
20750
|
const xs = model.xAxis;
|
|
19667
20751
|
if (!ys || !xs) return;
|
|
19668
|
-
const yLabels = ys.ticks.map((t) =>
|
|
20752
|
+
const yLabels = ys.ticks.map((t) => axisTickText(t, model.axes?.value));
|
|
19669
20753
|
const valueAttrs = chartTextAttributes(model, "valueAxis");
|
|
19670
20754
|
const categoryAttrs = chartTextAttributes(model, "categoryAxis");
|
|
19671
20755
|
const valueSize = valueAttrs.size ?? 10;
|
|
19672
20756
|
const categorySize = categoryAttrs.size ?? 10;
|
|
19673
|
-
const grid = chartStroke(model, "gridlineMajor");
|
|
19674
20757
|
const xAxis = chartStroke(model, "categoryAxis");
|
|
19675
|
-
const
|
|
19676
|
-
const
|
|
19677
|
-
const categoryLabels = model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
20758
|
+
const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
|
|
20759
|
+
const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
19678
20760
|
const labelW = valueLabels ? Math.max(...yLabels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
|
|
19679
20761
|
const plot = {
|
|
19680
20762
|
x: area.x + labelW,
|
|
@@ -19694,17 +20776,24 @@ function scatter(model, area, out) {
|
|
|
19694
20776
|
s.values.forEach((_, i) => {
|
|
19695
20777
|
reach = Math.max(reach, radiusOf(s.sizes?.[i] ?? void 0) ?? 0);
|
|
19696
20778
|
});
|
|
19697
|
-
const widen = (s, length) => {
|
|
20779
|
+
const widen = (s, length, axis) => {
|
|
20780
|
+
if (axis?.range.logScale) return s;
|
|
19698
20781
|
const pad = reach * (s.max - s.min || 1) / Math.max(1, length - 2 * reach);
|
|
19699
|
-
return {
|
|
20782
|
+
return {
|
|
20783
|
+
...s,
|
|
20784
|
+
min: axis?.source.scaling.min === void 0 ? s.min - pad : s.min,
|
|
20785
|
+
max: axis?.source.scaling.max === void 0 ? s.max + pad : s.max
|
|
20786
|
+
};
|
|
19700
20787
|
};
|
|
19701
|
-
const xView = widen(xs, plot.w);
|
|
19702
|
-
const yView = widen(ys, plot.h);
|
|
19703
|
-
const px3 = (v) => plot.x + (v
|
|
19704
|
-
const py = (v) => plot.y + plot.h - (v
|
|
20788
|
+
const xView = widen(xs, plot.w, model.axes?.category);
|
|
20789
|
+
const yView = widen(ys, plot.h, model.axes?.value);
|
|
20790
|
+
const px3 = (v) => plot.x + chartAxisRatio(v, xView, model.axes?.category) * plot.w;
|
|
20791
|
+
const py = (v) => plot.y + plot.h - chartAxisRatio(v, yView, model.axes?.value) * plot.h;
|
|
19705
20792
|
out.push(chartAreaRect(model, "plotArea", plot));
|
|
20793
|
+
out.push(axisGridlines(model, model.axes?.value, ys.ticks, py, plot, false));
|
|
20794
|
+
if (model.axes?.category)
|
|
20795
|
+
out.push(axisGridlines(model, model.axes.category, xs.ticks, px3, plot, true));
|
|
19706
20796
|
ys.ticks.forEach((t, i) => {
|
|
19707
|
-
out.push(line2(plot.x, py(t), plot.x + plot.w, py(t), grid.color, grid.width));
|
|
19708
20797
|
if (valueLabels)
|
|
19709
20798
|
out.push(
|
|
19710
20799
|
text2(plot.x - 4, py(t) + valueSize * 0.3, yLabels[i] ?? "", {
|
|
@@ -19714,19 +20803,31 @@ function scatter(model, area, out) {
|
|
|
19714
20803
|
);
|
|
19715
20804
|
});
|
|
19716
20805
|
for (const t of xs.ticks) {
|
|
19717
|
-
|
|
20806
|
+
if (!model.axes?.category?.source.deleted)
|
|
20807
|
+
out.push(line2(px3(t), plot.y + plot.h, px3(t), plot.y + plot.h + 3, xAxis.color, xAxis.width));
|
|
19718
20808
|
if (categoryLabels)
|
|
19719
20809
|
out.push(
|
|
19720
|
-
text2(px3(t), plot.y + plot.h + categorySize + 3,
|
|
20810
|
+
text2(px3(t), plot.y + plot.h + categorySize + 3, axisTickText(t, model.axes?.category), {
|
|
19721
20811
|
anchor: "middle",
|
|
19722
20812
|
...categoryAttrs
|
|
19723
20813
|
})
|
|
19724
20814
|
);
|
|
19725
20815
|
}
|
|
19726
20816
|
out.push(
|
|
19727
|
-
|
|
20817
|
+
axisLine(
|
|
20818
|
+
model,
|
|
20819
|
+
model.axes?.category,
|
|
20820
|
+
"categoryAxis",
|
|
20821
|
+
plot.x,
|
|
20822
|
+
plot.y + plot.h,
|
|
20823
|
+
plot.x + plot.w,
|
|
20824
|
+
plot.y + plot.h
|
|
20825
|
+
)
|
|
20826
|
+
);
|
|
20827
|
+
out.push(
|
|
20828
|
+
axisLine(model, model.axes?.value, "valueAxis", plot.x, plot.y, plot.x, plot.y + plot.h)
|
|
19728
20829
|
);
|
|
19729
|
-
|
|
20830
|
+
const marks = [];
|
|
19730
20831
|
for (const [si, s] of model.series.entries())
|
|
19731
20832
|
s.values.forEach((v, i) => {
|
|
19732
20833
|
const x = s.xValues?.[i] ?? null;
|
|
@@ -19734,15 +20835,18 @@ function scatter(model, area, out) {
|
|
|
19734
20835
|
const filter = s.shadowFilter ? ` filter="${s.shadowFilter}"` : "";
|
|
19735
20836
|
const fill = s.pointColors?.[i] ?? s.color;
|
|
19736
20837
|
if (!bubble) {
|
|
19737
|
-
out.push(
|
|
20838
|
+
out.push(chartSeriesMarkerSvg(s, i, px3(x), py(v)));
|
|
20839
|
+
marks.push({ series: s, index: i, x: px3(x), y: py(v), radius: chartMarkerRadius(s, i) });
|
|
19738
20840
|
return;
|
|
19739
20841
|
}
|
|
19740
20842
|
const r = radiusOf(s.sizes?.[i] ?? void 0);
|
|
19741
20843
|
if (r === void 0) return;
|
|
20844
|
+
marks.push({ series: s, index: i, x: px3(x), y: py(v), radius: r });
|
|
19742
20845
|
out.push(
|
|
19743
20846
|
`<circle cx="${n(px3(x))}" cy="${n(py(v))}" r="${n(r)}" fill="${fill}" fill-opacity="0.6" data-chart-series="${si}" data-chart-point="${i}"${filter}/>`
|
|
19744
20847
|
);
|
|
19745
20848
|
});
|
|
20849
|
+
pointLabels(model, marks, out);
|
|
19746
20850
|
scatterAnalysis(model, px3, py, out);
|
|
19747
20851
|
}
|
|
19748
20852
|
|
|
@@ -19859,21 +20963,21 @@ function cartesianSvg(model, area) {
|
|
|
19859
20963
|
return out.join("");
|
|
19860
20964
|
}
|
|
19861
20965
|
const layers = [{ model, frame: frame2 }];
|
|
19862
|
-
for (const
|
|
20966
|
+
for (const group2 of model.extraGroups ?? []) {
|
|
19863
20967
|
const grouped = {
|
|
19864
20968
|
...model,
|
|
19865
|
-
type:
|
|
19866
|
-
grouping:
|
|
19867
|
-
series:
|
|
20969
|
+
type: group2.type,
|
|
20970
|
+
grouping: group2.grouping,
|
|
20971
|
+
series: group2.series,
|
|
19868
20972
|
horizontal: false
|
|
19869
20973
|
};
|
|
19870
|
-
if (
|
|
20974
|
+
if (group2.stock) grouped.stock = group2.stock;
|
|
19871
20975
|
else delete grouped.stock;
|
|
19872
|
-
if (
|
|
20976
|
+
if (group2.barGapWidth !== void 0) grouped.barGapWidth = group2.barGapWidth;
|
|
19873
20977
|
else delete grouped.barGapWidth;
|
|
19874
|
-
if (
|
|
20978
|
+
if (group2.barOverlap !== void 0) grouped.barOverlap = group2.barOverlap;
|
|
19875
20979
|
else delete grouped.barOverlap;
|
|
19876
|
-
const value =
|
|
20980
|
+
const value = group2.secondary && frame2.secondary ? frame2.secondary : frame2.value;
|
|
19877
20981
|
layers.push({ model: grouped, frame: { ...frame2, value } });
|
|
19878
20982
|
}
|
|
19879
20983
|
layers.map((layer, order) => ({ layer, order })).sort(
|
|
@@ -19907,7 +21011,9 @@ function pieSvg(model, area) {
|
|
|
19907
21011
|
const out = [chartAreaRect(model, "plotArea", area)];
|
|
19908
21012
|
const cx2 = area.x + area.w / 2;
|
|
19909
21013
|
const cy = area.y + area.h / 2;
|
|
19910
|
-
const
|
|
21014
|
+
const margin = hasOutsideLabels(model) ? Math.min(area.w, area.h) * 0.12 : 0;
|
|
21015
|
+
const radius = Math.max(1, Math.min(area.w, area.h) / 2 - 4 - margin);
|
|
21016
|
+
const slices = [];
|
|
19911
21017
|
const rings = model.type === "doughnut" ? model.series : model.series.slice(0, 1);
|
|
19912
21018
|
const hole = model.type === "doughnut" ? radius * 0.5 : 0;
|
|
19913
21019
|
const ringSize = (radius - hole) / Math.max(1, rings.length);
|
|
@@ -19924,9 +21030,20 @@ function pieSvg(model, area) {
|
|
|
19924
21030
|
out.push(
|
|
19925
21031
|
`<path d="${slicePath(cx2, cy, outer, inner, angle, angle + sweep)}" fill="${color}" stroke="#FFFFFF" stroke-width="1"${s.shadowFilter ? ` filter="${s.shadowFilter}"` : ""}/>`
|
|
19926
21032
|
);
|
|
21033
|
+
slices.push({
|
|
21034
|
+
series: s,
|
|
21035
|
+
index: i,
|
|
21036
|
+
cx: cx2,
|
|
21037
|
+
cy,
|
|
21038
|
+
outer,
|
|
21039
|
+
inner,
|
|
21040
|
+
start: angle,
|
|
21041
|
+
end: angle + sweep
|
|
21042
|
+
});
|
|
19927
21043
|
angle += sweep;
|
|
19928
21044
|
});
|
|
19929
21045
|
});
|
|
21046
|
+
sliceLabels(model, slices, out);
|
|
19930
21047
|
return out.join("");
|
|
19931
21048
|
}
|
|
19932
21049
|
function radarSvg(model, area) {
|
|
@@ -19939,32 +21056,37 @@ function radarSvg(model, area) {
|
|
|
19939
21056
|
const valueSize = valueAttrs.size ?? 9;
|
|
19940
21057
|
const categorySize = categoryAttrs.size ?? 10;
|
|
19941
21058
|
const grid = chartStroke(model, "gridlineMajor");
|
|
19942
|
-
const axis = chartStroke(model, "categoryAxis");
|
|
19943
21059
|
const cx2 = area.x + area.w / 2;
|
|
19944
21060
|
const cy = area.y + area.h / 2 + 4;
|
|
19945
21061
|
const radius = Math.max(1, Math.min(area.w, area.h) / 2 - Math.max(18, categorySize * 1.8));
|
|
19946
21062
|
const angle = (i) => i / count * Math.PI * 2;
|
|
19947
|
-
const r = (v) => (v
|
|
21063
|
+
const r = (v) => chartAxisRatio(v, scale, model.axes?.value) * radius;
|
|
19948
21064
|
const labelEvery = Math.max(
|
|
19949
21065
|
1,
|
|
19950
21066
|
Math.ceil(12 / Math.max(1, radius / Math.max(1, scale.ticks.length - 1)))
|
|
19951
21067
|
);
|
|
19952
21068
|
for (const [k, t] of scale.ticks.entries()) {
|
|
19953
21069
|
const ring = Array.from({ length: count }, (_, i) => polar(cx2, cy, r(t), angle(i))).map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
|
|
19954
|
-
|
|
19955
|
-
|
|
19956
|
-
|
|
19957
|
-
|
|
21070
|
+
if (!model.axes?.value || model.axes.value.source.majorGridlines)
|
|
21071
|
+
out.push(
|
|
21072
|
+
`<polygon points="${ring}" fill="none" stroke="${grid.color}" stroke-width="${n(grid.width)}"/>`
|
|
21073
|
+
);
|
|
21074
|
+
if (chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false && k % labelEvery === 0)
|
|
19958
21075
|
out.push(
|
|
19959
|
-
text2(
|
|
21076
|
+
text2(
|
|
21077
|
+
cx2 + 3,
|
|
21078
|
+
cy - r(t) + valueSize * 0.3,
|
|
21079
|
+
axisTickText(t, model.axes?.value, scale.percent),
|
|
21080
|
+
valueAttrs
|
|
21081
|
+
)
|
|
19960
21082
|
);
|
|
19961
21083
|
}
|
|
19962
21084
|
model.categories.forEach((c2, i) => {
|
|
19963
21085
|
const [x, y] = polar(cx2, cy, radius, angle(i));
|
|
19964
|
-
out.push(
|
|
21086
|
+
out.push(axisLine(model, model.axes?.category, "categoryAxis", cx2, cy, x, y));
|
|
19965
21087
|
const [lx, ly] = polar(cx2, cy, radius + 10, angle(i));
|
|
19966
21088
|
const anchor = Math.abs(lx - cx2) < 2 ? "middle" : lx > cx2 ? "start" : "end";
|
|
19967
|
-
if (model.appearance?.categoryAxis?.labelsVisible !== false)
|
|
21089
|
+
if (chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false)
|
|
19968
21090
|
out.push(
|
|
19969
21091
|
text2(lx, ly + categorySize * 0.3, fit(c2, area.w / 4, categorySize), {
|
|
19970
21092
|
anchor,
|
|
@@ -19972,12 +21094,22 @@ function radarSvg(model, area) {
|
|
|
19972
21094
|
})
|
|
19973
21095
|
);
|
|
19974
21096
|
});
|
|
21097
|
+
const marks = [];
|
|
19975
21098
|
for (const s of model.series) {
|
|
19976
|
-
const
|
|
21099
|
+
const vertices = s.values.slice(0, count).map((v, i) => polar(cx2, cy, r(v ?? scale.min), angle(i)));
|
|
21100
|
+
vertices.forEach(([x, y], i) => {
|
|
21101
|
+
if (s.values[i] === null) return;
|
|
21102
|
+
const markerSeries = s;
|
|
21103
|
+
if (markerSeries.marker || markerSeries.pointMarkers)
|
|
21104
|
+
out.push(chartSeriesMarkerSvg(s, i, x, y));
|
|
21105
|
+
marks.push({ series: s, index: i, x, y, radius: chartMarkerRadius(s, i) });
|
|
21106
|
+
});
|
|
21107
|
+
const points = vertices.map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
|
|
19977
21108
|
out.push(
|
|
19978
21109
|
`<polygon points="${points}" fill="none" stroke="${s.color}" stroke-width="2"${s.shadowFilter ? ` filter="${s.shadowFilter}"` : ""}/>`
|
|
19979
21110
|
);
|
|
19980
21111
|
}
|
|
21112
|
+
pointLabels(model, marks, out);
|
|
19981
21113
|
return out.join("");
|
|
19982
21114
|
}
|
|
19983
21115
|
|
|
@@ -20068,33 +21200,33 @@ var CHART_FONT_FAMILY = "Calibri, Carlito, Arial, sans-serif";
|
|
|
20068
21200
|
function cssFont(attrs2) {
|
|
20069
21201
|
return `${attrs2.italic ? "italic" : "normal"} ${attrs2.weight ?? "normal"} ${attrs2.size ?? 10}px ${attrs2.family ?? CHART_FONT_FAMILY}`;
|
|
20070
21202
|
}
|
|
20071
|
-
function chartFontMetrics(attrs2,
|
|
20072
|
-
const metrics =
|
|
21203
|
+
function chartFontMetrics(attrs2, options2) {
|
|
21204
|
+
const metrics = options2.measureFont?.(cssFont(attrs2));
|
|
20073
21205
|
return metrics && Number.isFinite(metrics.ascent) && Number.isFinite(metrics.descent) && metrics.ascent >= 0 && metrics.descent >= 0 && metrics.ascent + metrics.descent > 0 ? metrics : void 0;
|
|
20074
21206
|
}
|
|
20075
|
-
function chartTextWidth(content, attrs2,
|
|
20076
|
-
const width =
|
|
21207
|
+
function chartTextWidth(content, attrs2, options2) {
|
|
21208
|
+
const width = options2.measureText?.(content, cssFont(attrs2));
|
|
20077
21209
|
return width !== void 0 && Number.isFinite(width) && width >= 0 ? width : textWidth(content, attrs2.size);
|
|
20078
21210
|
}
|
|
20079
|
-
function fitChartText(content, maxWidth, attrs2,
|
|
20080
|
-
if (!
|
|
20081
|
-
if (chartTextWidth(content, attrs2,
|
|
21211
|
+
function fitChartText(content, maxWidth, attrs2, options2) {
|
|
21212
|
+
if (!options2.measureText) return fit(content, maxWidth, attrs2.size);
|
|
21213
|
+
if (chartTextWidth(content, attrs2, options2) <= maxWidth) return content;
|
|
20082
21214
|
const points = [...content];
|
|
20083
21215
|
let low = 0;
|
|
20084
21216
|
let high = points.length;
|
|
20085
21217
|
while (low < high) {
|
|
20086
21218
|
const mid = Math.ceil((low + high) / 2);
|
|
20087
|
-
if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`, attrs2,
|
|
21219
|
+
if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`, attrs2, options2) <= maxWidth) low = mid;
|
|
20088
21220
|
else high = mid - 1;
|
|
20089
21221
|
}
|
|
20090
21222
|
return `${points.slice(0, low).join("")}\u2026`;
|
|
20091
21223
|
}
|
|
20092
21224
|
|
|
20093
21225
|
// chart/render/chart-svg-legend.ts
|
|
20094
|
-
function chartLegendSvg(model, area, frame2,
|
|
21226
|
+
function chartLegendSvg(model, area, frame2, options2) {
|
|
20095
21227
|
const automatic = [];
|
|
20096
21228
|
const bounds = {};
|
|
20097
|
-
const reserved = automaticLegend(model, area, automatic,
|
|
21229
|
+
const reserved = automaticLegend(model, area, automatic, options2, bounds);
|
|
20098
21230
|
const plot = model.legendOverlay ? area : reserved;
|
|
20099
21231
|
const box = bounds.box;
|
|
20100
21232
|
if (!box) return { plot, markup: "", foreground: false };
|
|
@@ -20108,11 +21240,11 @@ function chartLegendSvg(model, area, frame2, options) {
|
|
|
20108
21240
|
const entries = legendEntries(model);
|
|
20109
21241
|
const attrs2 = chartTextAttributes(model, "legend");
|
|
20110
21242
|
const size = attrs2.size ?? 10;
|
|
20111
|
-
const font = chartFontMetrics(attrs2,
|
|
21243
|
+
const font = chartFontMetrics(attrs2, options2);
|
|
20112
21244
|
const keySize = size / 2;
|
|
20113
21245
|
const keyGap = size / 4;
|
|
20114
21246
|
const widths = entries.map(
|
|
20115
|
-
(entry2) => chartTextWidth(entry2.label, attrs2,
|
|
21247
|
+
(entry2) => chartTextWidth(entry2.label, attrs2, options2) + keySize + keyGap
|
|
20116
21248
|
);
|
|
20117
21249
|
const horizontal = manual.width > manual.height && widths.reduce((sum, width) => sum + width, 0) + size <= manual.width;
|
|
20118
21250
|
const rowWidth = horizontal ? manual.width / entries.length : manual.width;
|
|
@@ -20127,8 +21259,8 @@ function chartLegendSvg(model, area, frame2, options) {
|
|
|
20127
21259
|
];
|
|
20128
21260
|
const baselineOffset = font ? (font.ascent - font.descent) / 2 : size * 0.35;
|
|
20129
21261
|
entries.forEach((entry2, i) => {
|
|
20130
|
-
const available = horizontal ? chartTextWidth(entry2.label, attrs2,
|
|
20131
|
-
const label = fitChartText(entry2.label, available, attrs2,
|
|
21262
|
+
const available = horizontal ? chartTextWidth(entry2.label, attrs2, options2) : Math.max(0, rowWidth - size / 2 - keySize - keyGap);
|
|
21263
|
+
const label = fitChartText(entry2.label, available, attrs2, options2);
|
|
20132
21264
|
const contentWidth = Math.min(
|
|
20133
21265
|
horizontal ? widths[i] ?? 0 : Math.max(...widths),
|
|
20134
21266
|
rowWidth - size / 2
|
|
@@ -20171,7 +21303,7 @@ function legendEntries(model) {
|
|
|
20171
21303
|
color: s.color
|
|
20172
21304
|
}));
|
|
20173
21305
|
}
|
|
20174
|
-
function automaticLegend(model, area, out,
|
|
21306
|
+
function automaticLegend(model, area, out, options2, bounds) {
|
|
20175
21307
|
const entries = legendEntries(model);
|
|
20176
21308
|
if (!model.showLegend || entries.length === 0) return area;
|
|
20177
21309
|
const pos = model.legendPosition;
|
|
@@ -20180,7 +21312,7 @@ function automaticLegend(model, area, out, options, bounds) {
|
|
|
20180
21312
|
const rowH = Math.max(16, size * 1.4);
|
|
20181
21313
|
if (pos === "t" || pos === "b") {
|
|
20182
21314
|
const widths = entries.map(
|
|
20183
|
-
(e) => Math.min(chartTextWidth(e.label, attrs2,
|
|
21315
|
+
(e) => Math.min(chartTextWidth(e.label, attrs2, options2) + 20, area.w / 2)
|
|
20184
21316
|
);
|
|
20185
21317
|
const total = widths.reduce((a2, b) => a2 + b, 0);
|
|
20186
21318
|
let x2 = area.x + Math.max(0, (area.w - total) / 2);
|
|
@@ -20197,14 +21329,14 @@ function automaticLegend(model, area, out, options, bounds) {
|
|
|
20197
21329
|
entries.forEach((e, i) => {
|
|
20198
21330
|
const w = widths[i] ?? 0;
|
|
20199
21331
|
out.push(rect2(x2, y, 8, 8, e.color));
|
|
20200
|
-
out.push(text2(x2 + 12, y + 8, fitChartText(e.label, w - 16, attrs2,
|
|
21332
|
+
out.push(text2(x2 + 12, y + 8, fitChartText(e.label, w - 16, attrs2, options2), attrs2));
|
|
20201
21333
|
x2 += w;
|
|
20202
21334
|
});
|
|
20203
21335
|
return pos === "t" ? { x: area.x, y: area.y + rowH + 4, w: area.w, h: area.h - rowH - 4 } : { x: area.x, y: area.y, w: area.w, h: area.h - rowH - 4 };
|
|
20204
21336
|
}
|
|
20205
21337
|
const width = Math.min(
|
|
20206
21338
|
area.w * 0.35,
|
|
20207
|
-
Math.max(...entries.map((e) => chartTextWidth(e.label, attrs2,
|
|
21339
|
+
Math.max(...entries.map((e) => chartTextWidth(e.label, attrs2, options2))) + 22
|
|
20208
21340
|
);
|
|
20209
21341
|
const height = entries.length * rowH;
|
|
20210
21342
|
const x = pos === "l" ? area.x + 4 : area.x + area.w - width;
|
|
@@ -20222,24 +21354,24 @@ function automaticLegend(model, area, out, options, bounds) {
|
|
|
20222
21354
|
const y = y0 + i * rowH;
|
|
20223
21355
|
if (y + rowH > area.y + area.h + 2) return;
|
|
20224
21356
|
out.push(rect2(x, y + 3, 8, 8, e.color));
|
|
20225
|
-
out.push(text2(x + 12, y + 11, fitChartText(e.label, width - 16, attrs2,
|
|
21357
|
+
out.push(text2(x + 12, y + 11, fitChartText(e.label, width - 16, attrs2, options2), attrs2));
|
|
20226
21358
|
});
|
|
20227
21359
|
return pos === "l" ? { x: area.x + width + 8, y: area.y, w: area.w - width - 8, h: area.h } : { x: area.x, y: area.y, w: area.w - width - 8, h: area.h };
|
|
20228
21360
|
}
|
|
20229
21361
|
|
|
20230
21362
|
// text/wrap-styled-runs.ts
|
|
20231
21363
|
var graphemes = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
20232
|
-
function wrapStyledRuns(runs, maxWidth,
|
|
21364
|
+
function wrapStyledRuns(runs, maxWidth, measure2, options2 = {}) {
|
|
20233
21365
|
const groups = [];
|
|
20234
21366
|
for (const [source, run] of runs.entries()) {
|
|
20235
21367
|
for (const token of run.text.split(/(\r\n|[\r\n]|[ \t]+)/u).filter(Boolean)) {
|
|
20236
21368
|
const kind = /^[\r\n]+$/u.test(token) ? "break" : /^[ \t]+$/u.test(token) ? "space" : "word";
|
|
20237
|
-
let
|
|
20238
|
-
if (!
|
|
20239
|
-
|
|
20240
|
-
groups.push(
|
|
21369
|
+
let group2 = groups.at(-1);
|
|
21370
|
+
if (!group2 || group2.kind !== kind || kind === "break") {
|
|
21371
|
+
group2 = { kind, pieces: [] };
|
|
21372
|
+
groups.push(group2);
|
|
20241
21373
|
}
|
|
20242
|
-
if (kind !== "break")
|
|
21374
|
+
if (kind !== "break") group2.pieces.push({ run, source, text: token });
|
|
20243
21375
|
}
|
|
20244
21376
|
}
|
|
20245
21377
|
const merged = (left, right) => {
|
|
@@ -20252,7 +21384,7 @@ function wrapStyledRuns(runs, maxWidth, measure, options = {}) {
|
|
|
20252
21384
|
return result2;
|
|
20253
21385
|
};
|
|
20254
21386
|
const width = (pieces) => pieces.reduce((sum, piece) => {
|
|
20255
|
-
const advance =
|
|
21387
|
+
const advance = measure2(piece.text, piece.run);
|
|
20256
21388
|
return sum + (Number.isFinite(advance) && advance >= 0 ? advance : 0);
|
|
20257
21389
|
}, 0);
|
|
20258
21390
|
const result = [];
|
|
@@ -20263,29 +21395,29 @@ function wrapStyledRuns(runs, maxWidth, measure, options = {}) {
|
|
|
20263
21395
|
line3 = [];
|
|
20264
21396
|
spaces = [];
|
|
20265
21397
|
};
|
|
20266
|
-
for (const
|
|
20267
|
-
if (
|
|
21398
|
+
for (const group2 of groups) {
|
|
21399
|
+
if (group2.kind === "break") {
|
|
20268
21400
|
flush();
|
|
20269
21401
|
continue;
|
|
20270
21402
|
}
|
|
20271
|
-
if (
|
|
20272
|
-
spaces =
|
|
21403
|
+
if (group2.kind === "space") {
|
|
21404
|
+
spaces = group2.pieces;
|
|
20273
21405
|
continue;
|
|
20274
21406
|
}
|
|
20275
21407
|
const separator = line3.length ? spaces : [];
|
|
20276
|
-
const wordWidth = width(
|
|
20277
|
-
if (line3.length && width(merged(line3, [...separator, ...
|
|
21408
|
+
const wordWidth = width(group2.pieces);
|
|
21409
|
+
if (line3.length && width(merged(line3, [...separator, ...group2.pieces])) > maxWidth) flush();
|
|
20278
21410
|
else line3 = merged(line3, separator);
|
|
20279
21411
|
spaces = [];
|
|
20280
|
-
if (
|
|
20281
|
-
for (const piece of
|
|
21412
|
+
if (options2.breakWords && wordWidth > maxWidth) {
|
|
21413
|
+
for (const piece of group2.pieces) {
|
|
20282
21414
|
for (const { segment: segment2 } of graphemes.segment(piece.text)) {
|
|
20283
21415
|
const next = { ...piece, text: segment2 };
|
|
20284
21416
|
if (line3.length && width(merged(line3, [next])) > maxWidth) flush();
|
|
20285
21417
|
line3 = merged(line3, [next]);
|
|
20286
21418
|
}
|
|
20287
21419
|
}
|
|
20288
|
-
} else line3 = merged(line3,
|
|
21420
|
+
} else line3 = merged(line3, group2.pieces);
|
|
20289
21421
|
}
|
|
20290
21422
|
flush();
|
|
20291
21423
|
return result;
|
|
@@ -20295,11 +21427,11 @@ function wrapStyledRuns(runs, maxWidth, measure, options = {}) {
|
|
|
20295
21427
|
function spacing(value, naturalHeight, fallback) {
|
|
20296
21428
|
return value ? value.unit === "points" ? chartPointsToPixels(value.value) : naturalHeight * value.value : fallback;
|
|
20297
21429
|
}
|
|
20298
|
-
function chartRichTitleSvg(model, width,
|
|
21430
|
+
function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
|
|
20299
21431
|
if (!model.title) return void 0;
|
|
20300
21432
|
const base = chartTextAttributes(model, "title", 14);
|
|
20301
21433
|
const capacity = Math.max(1, width * 0.8 - 8);
|
|
20302
|
-
if (!model.titleText && !hasManualLayoutFields(model.titleLayout) && !model.titleOverlay && !model.title.includes("\n") && chartTextWidth(model.title, base,
|
|
21434
|
+
if (!model.titleText && !hasManualLayoutFields(model.titleLayout) && !model.titleOverlay && !model.title.includes("\n") && chartTextWidth(model.title, base, options2) <= capacity)
|
|
20303
21435
|
return void 0;
|
|
20304
21436
|
const paragraphs = model.titleText?.paragraphs ?? [
|
|
20305
21437
|
{
|
|
@@ -20335,7 +21467,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
20335
21467
|
"title",
|
|
20336
21468
|
base.size
|
|
20337
21469
|
),
|
|
20338
|
-
|
|
21470
|
+
options2
|
|
20339
21471
|
),
|
|
20340
21472
|
{ breakWords: true }
|
|
20341
21473
|
);
|
|
@@ -20359,10 +21491,10 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
20359
21491
|
return {
|
|
20360
21492
|
...line3,
|
|
20361
21493
|
runs,
|
|
20362
|
-
width: runs.reduce((sum, run) => sum + chartTextWidth(run.text, run.attrs,
|
|
21494
|
+
width: runs.reduce((sum, run) => sum + chartTextWidth(run.text, run.attrs, options2), 0),
|
|
20363
21495
|
size: runs.length ? Math.max(...runs.map((run) => run.attrs.size ?? 14)) : base.size ?? 14,
|
|
20364
21496
|
fontMetrics: (runs.length ? runs.map((run) => run.attrs) : [base]).map(
|
|
20365
|
-
(attrs2) => chartFontMetrics(attrs2,
|
|
21497
|
+
(attrs2) => chartFontMetrics(attrs2, options2)
|
|
20366
21498
|
)
|
|
20367
21499
|
};
|
|
20368
21500
|
});
|
|
@@ -20400,7 +21532,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
20400
21532
|
anchor: "start"
|
|
20401
21533
|
}).replace("<text ", '<tspan data-chart-title-run="true" ').replace("</text>", "</tspan>")
|
|
20402
21534
|
);
|
|
20403
|
-
x += chartTextWidth(run.text, run.attrs,
|
|
21535
|
+
x += chartTextWidth(run.text, run.attrs, options2);
|
|
20404
21536
|
}
|
|
20405
21537
|
}
|
|
20406
21538
|
const parent = text2(0, 0, "", { ...base, underline: false }).replace(
|
|
@@ -20426,7 +21558,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
20426
21558
|
}
|
|
20427
21559
|
|
|
20428
21560
|
// chart/render/chart-svg.ts
|
|
20429
|
-
function renderChartSvg(model, width, height,
|
|
21561
|
+
function renderChartSvg(model, width, height, options2 = {}) {
|
|
20430
21562
|
const paint2 = chartGradientPaint(model, Math.max(1, width), Math.max(1, height));
|
|
20431
21563
|
model = paint2.model;
|
|
20432
21564
|
const w = Math.max(1, width);
|
|
@@ -20440,7 +21572,7 @@ function renderChartSvg(model, width, height, options = {}) {
|
|
|
20440
21572
|
if (paint2.defs) out.push(paint2.defs);
|
|
20441
21573
|
out.push(chartAreaRect(model, "chartArea", { x: 0, y: 0, w, h }));
|
|
20442
21574
|
let area = { x: 8, y: 8, w: w - 16, h: h - 16 };
|
|
20443
|
-
const richTitle = chartRichTitleSvg(model, w,
|
|
21575
|
+
const richTitle = chartRichTitleSvg(model, w, options2, h);
|
|
20444
21576
|
if (richTitle) {
|
|
20445
21577
|
if (model.titleLayout || model.titleOverlay) foregroundTitle = richTitle.markup;
|
|
20446
21578
|
else out.push(richTitle.markup);
|
|
@@ -20449,9 +21581,9 @@ function renderChartSvg(model, width, height, options = {}) {
|
|
|
20449
21581
|
} else if (model.title) {
|
|
20450
21582
|
const attrs2 = chartTextAttributes(model, "title", 14);
|
|
20451
21583
|
const size = attrs2.size ?? 14;
|
|
20452
|
-
const label = fitChartText(model.title, w - 16, attrs2,
|
|
20453
|
-
const titleWidth = Math.min(w - 16, chartTextWidth(label, attrs2,
|
|
20454
|
-
const font = chartFontMetrics(attrs2,
|
|
21584
|
+
const label = fitChartText(model.title, w - 16, attrs2, options2);
|
|
21585
|
+
const titleWidth = Math.min(w - 16, chartTextWidth(label, attrs2, options2) + 8);
|
|
21586
|
+
const font = chartFontMetrics(attrs2, options2);
|
|
20455
21587
|
const titleHeight = Math.max(24, font ? font.ascent + font.descent + 4 : size * 1.4 + 4);
|
|
20456
21588
|
out.push(
|
|
20457
21589
|
chartAreaRect(model, "title", {
|
|
@@ -20479,7 +21611,7 @@ function renderChartSvg(model, width, height, options = {}) {
|
|
|
20479
21611
|
out.push("</svg>");
|
|
20480
21612
|
return out.join("");
|
|
20481
21613
|
}
|
|
20482
|
-
const legend = chartLegendSvg(model, area, { width: w, height: h },
|
|
21614
|
+
const legend = chartLegendSvg(model, area, { width: w, height: h }, options2);
|
|
20483
21615
|
area = legend.plot;
|
|
20484
21616
|
if (!legend.foreground) out.push(legend.markup);
|
|
20485
21617
|
if (area.w > 4 && area.h > 4) {
|
|
@@ -20526,8 +21658,8 @@ function chartSpaceKind(space) {
|
|
|
20526
21658
|
const type = chartSummaryFromSpace(space).chartType;
|
|
20527
21659
|
return { type, drawn: DRAWN_CHART_TYPES.has(type) };
|
|
20528
21660
|
}
|
|
20529
|
-
function renderChartSpaceSvg(space,
|
|
20530
|
-
const { width, height, theme, fonts, formatting, colorPalette, styleDefinition, ...svg } =
|
|
21661
|
+
function renderChartSpaceSvg(space, options2) {
|
|
21662
|
+
const { width, height, theme, fonts, formatting, colorPalette, styleDefinition, ...svg } = options2;
|
|
20531
21663
|
const summary = chartSummaryFromSpace(space, {
|
|
20532
21664
|
...formatting ? { formatting } : {},
|
|
20533
21665
|
...colorPalette !== void 0 ? { colorPalette } : {},
|
|
@@ -20536,8 +21668,8 @@ function renderChartSpaceSvg(space, options) {
|
|
|
20536
21668
|
const view = chartSummaryView(summary, chartThemePalette(theme, fonts));
|
|
20537
21669
|
return renderChartSvg(view, width, height, svg);
|
|
20538
21670
|
}
|
|
20539
|
-
function renderChartSummarySvg(summary,
|
|
20540
|
-
const { width, height, theme, fonts, ...svg } =
|
|
21671
|
+
function renderChartSummarySvg(summary, options2) {
|
|
21672
|
+
const { width, height, theme, fonts, ...svg } = options2;
|
|
20541
21673
|
const view = chartSummaryView(summary, chartThemePalette(theme, fonts));
|
|
20542
21674
|
return renderChartSvg(view, width, height, svg);
|
|
20543
21675
|
}
|
|
@@ -21980,36 +23112,36 @@ function buildInlineContent(doc, runs, base, slots, allocator, ranges) {
|
|
|
21980
23112
|
const output = [];
|
|
21981
23113
|
let index = 0;
|
|
21982
23114
|
while (index < runs.length) {
|
|
21983
|
-
const
|
|
21984
|
-
if (!
|
|
23115
|
+
const group2 = containerGroup(runAt(index));
|
|
23116
|
+
if (!group2) {
|
|
21985
23117
|
output.push(...nodesFor(index));
|
|
21986
23118
|
index++;
|
|
21987
23119
|
continue;
|
|
21988
23120
|
}
|
|
21989
23121
|
const start = index;
|
|
21990
|
-
while (index < runs.length && sameGroup(containerGroup(runAt(index)),
|
|
23122
|
+
while (index < runs.length && sameGroup(containerGroup(runAt(index)), group2)) index++;
|
|
21991
23123
|
const oldContainers = new Set(slots.slice(start, index).map((slot2) => slot2?.container));
|
|
21992
23124
|
const [onlyContainer] = oldContainers;
|
|
21993
|
-
const reusable = oldContainers.size === 1 && onlyContainer !== void 0 && onlyContainer.localName === (
|
|
23125
|
+
const reusable = oldContainers.size === 1 && onlyContainer !== void 0 && onlyContainer.localName === (group2.kind === "link" ? "hyperlink" : group2.kind === "control" ? "sdt" : "fldSimple") && base?.slice(start, index).every((run) => sameGroup(run && containerGroup(run), group2)) === true;
|
|
21994
23126
|
let container;
|
|
21995
23127
|
let target;
|
|
21996
|
-
if (reusable &&
|
|
23128
|
+
if (reusable && group2.kind === "control") {
|
|
21997
23129
|
container = onlyContainer;
|
|
21998
|
-
target = resetContentControl(doc, container,
|
|
23130
|
+
target = resetContentControl(doc, container, group2.control);
|
|
21999
23131
|
} else if (reusable) {
|
|
22000
23132
|
container = onlyContainer;
|
|
22001
23133
|
for (const child4 of Array.from(container.childNodes)) container.removeChild(child4);
|
|
22002
|
-
} else if (
|
|
22003
|
-
const created = createContentControl(doc,
|
|
23134
|
+
} else if (group2.kind === "control") {
|
|
23135
|
+
const created = createContentControl(doc, group2.control);
|
|
22004
23136
|
container = created.sdt;
|
|
22005
23137
|
target = created.content;
|
|
22006
|
-
} else if (
|
|
23138
|
+
} else if (group2.kind === "link") container = newHyperlink(doc, group2.link, allocator);
|
|
22007
23139
|
else {
|
|
22008
23140
|
container = makeW(doc, "fldSimple");
|
|
22009
|
-
setW6(container, "instr", ` ${
|
|
23141
|
+
setW6(container, "instr", ` ${group2.instr} `);
|
|
22010
23142
|
}
|
|
22011
|
-
if (
|
|
22012
|
-
const edges =
|
|
23143
|
+
if (group2.kind === "simpleField") writeFieldFlags(container, runAt(start).fieldFlags);
|
|
23144
|
+
const edges = group2.kind === "simpleField" ? takeSimpleFieldCommentEdges(doc, runs, start, index, opens, closes) : { before: [], after: [] };
|
|
22013
23145
|
for (let item = start; item < index; item++)
|
|
22014
23146
|
for (const node of nodesFor(item)) (target ?? container).appendChild(node);
|
|
22015
23147
|
output.push(...edges.before, container, ...edges.after);
|
|
@@ -22818,37 +23950,37 @@ function validateSection(c2, section) {
|
|
|
22818
23950
|
}
|
|
22819
23951
|
}
|
|
22820
23952
|
function validateNumberingCatalog(c2, catalog) {
|
|
22821
|
-
const levelOf = (at,
|
|
22822
|
-
at.enum("numFmt",
|
|
22823
|
-
at.signed("start",
|
|
22824
|
-
at.unsigned("level",
|
|
23953
|
+
const levelOf = (at, level2) => {
|
|
23954
|
+
at.enum("numFmt", level2.numFmt, isStNumberFormat, "ST_NumberFormat");
|
|
23955
|
+
at.signed("start", level2.start, "ST_DecimalNumber");
|
|
23956
|
+
at.unsigned("level", level2.level, "ST_DecimalNumber");
|
|
22825
23957
|
at.check(
|
|
22826
23958
|
"lvlJc",
|
|
22827
|
-
|
|
23959
|
+
level2.lvlJc,
|
|
22828
23960
|
(v) => v === "left" || v === "center" || v === "right",
|
|
22829
23961
|
'must be "left", "center" or "right"'
|
|
22830
23962
|
);
|
|
22831
23963
|
at.check(
|
|
22832
23964
|
"suffix",
|
|
22833
|
-
|
|
23965
|
+
level2.suffix,
|
|
22834
23966
|
(v) => v === "tab" || v === "space" || v === "none",
|
|
22835
23967
|
'must be "tab", "space" or "none"'
|
|
22836
23968
|
);
|
|
22837
|
-
at.check("lvlText",
|
|
23969
|
+
at.check("lvlText", level2.lvlText, (v) => typeof v === "string", "must be a string");
|
|
22838
23970
|
at.check(
|
|
22839
23971
|
"paragraphStyleId",
|
|
22840
|
-
|
|
23972
|
+
level2.paragraphStyleId,
|
|
22841
23973
|
(v) => typeof v === "string" && v.length > 0,
|
|
22842
23974
|
"must be a nonempty style ID"
|
|
22843
23975
|
);
|
|
22844
|
-
at.signed("indentLeftTwips",
|
|
22845
|
-
at.unsigned("hangingTwips",
|
|
22846
|
-
at.unsigned("firstLineTwips",
|
|
22847
|
-
at.unsigned("lvlRestart",
|
|
23976
|
+
at.signed("indentLeftTwips", level2.indentLeftTwips, "ST_SignedTwipsMeasure");
|
|
23977
|
+
at.unsigned("hangingTwips", level2.hangingTwips, "ST_TwipsMeasure");
|
|
23978
|
+
at.unsigned("firstLineTwips", level2.firstLineTwips, "ST_TwipsMeasure");
|
|
23979
|
+
at.unsigned("lvlRestart", level2.lvlRestart, "ST_DecimalNumber");
|
|
22848
23980
|
};
|
|
22849
23981
|
for (const [id, abstract] of Object.entries(catalog.abstractNums))
|
|
22850
|
-
for (const [key,
|
|
22851
|
-
levelOf(new Checker(c2.issues, `${c2.path}.abstractNums[${id}].levels[${key}]`),
|
|
23982
|
+
for (const [key, level2] of Object.entries(abstract.levels))
|
|
23983
|
+
levelOf(new Checker(c2.issues, `${c2.path}.abstractNums[${id}].levels[${key}]`), level2);
|
|
22852
23984
|
for (const [id, num] of Object.entries(catalog.nums))
|
|
22853
23985
|
for (const [key, override] of Object.entries(num.levelOverrides ?? {})) {
|
|
22854
23986
|
const at = new Checker(c2.issues, `${c2.path}.nums[${id}].levelOverrides[${key}]`);
|
|
@@ -22983,14 +24115,14 @@ function parseMarkerFormat(rPr) {
|
|
|
22983
24115
|
return Object.keys(format).length ? format : void 0;
|
|
22984
24116
|
}
|
|
22985
24117
|
function parseNumberingLevel(lvl) {
|
|
22986
|
-
const
|
|
24118
|
+
const level2 = integer2(getW(lvl, "ilvl"), 0);
|
|
22987
24119
|
const start = clampStart(integer2(getW(first2(lvl, "start"), "val"), 1));
|
|
22988
24120
|
const numFmt = enumValue(isStNumberFormat, getW(first2(lvl, "numFmt"), "val"), "w:numFmt") ?? "decimal";
|
|
22989
24121
|
const lvlText = getW(first2(lvl, "lvlText"), "val") ?? "";
|
|
22990
24122
|
const jc = getW(first2(lvl, "lvlJc"), "val");
|
|
22991
24123
|
const ind = first2(first2(lvl, "pPr"), "ind");
|
|
22992
24124
|
const suffRaw = getW(first2(lvl, "suff"), "val");
|
|
22993
|
-
const result = { level, start, numFmt, lvlText };
|
|
24125
|
+
const result = { level: level2, start, numFmt, lvlText };
|
|
22994
24126
|
if (!first2(lvl, "start")) result.startWasOmitted = true;
|
|
22995
24127
|
const paragraphStyleId = getW(first2(lvl, "pStyle"), "val");
|
|
22996
24128
|
if (paragraphStyleId) result.paragraphStyleId = paragraphStyleId;
|
|
@@ -23029,13 +24161,13 @@ function parseNum(element) {
|
|
|
23029
24161
|
const abstractNumId = getW(first2(element, "abstractNumId"), "val") ?? "";
|
|
23030
24162
|
const levelOverrides = dictionary();
|
|
23031
24163
|
for (const override of children2(element, "lvlOverride")) {
|
|
23032
|
-
const
|
|
24164
|
+
const level2 = integer2(getW(override, "ilvl"), 0);
|
|
23033
24165
|
const entry2 = {};
|
|
23034
24166
|
const startOverride = getW(first2(override, "startOverride"), "val");
|
|
23035
24167
|
if (startOverride !== void 0) entry2.startOverride = clampStart(integer2(startOverride, 1));
|
|
23036
24168
|
const lvl = first2(override, "lvl");
|
|
23037
24169
|
if (lvl) entry2.lvl = parseNumberingLevel(lvl);
|
|
23038
|
-
if (Object.keys(entry2).length) levelOverrides[
|
|
24170
|
+
if (Object.keys(entry2).length) levelOverrides[level2] = entry2;
|
|
23039
24171
|
}
|
|
23040
24172
|
return {
|
|
23041
24173
|
id,
|
|
@@ -23069,11 +24201,11 @@ function parseNumberingCatalog(xml) {
|
|
|
23069
24201
|
}
|
|
23070
24202
|
return { abstractNums, nums, warnings: [...new Set(warnings)] };
|
|
23071
24203
|
}
|
|
23072
|
-
function resolveNumberingLevel(catalog, numId,
|
|
24204
|
+
function resolveNumberingLevel(catalog, numId, level2) {
|
|
23073
24205
|
const num = own(catalog.nums, numId);
|
|
23074
24206
|
if (!num) return void 0;
|
|
23075
|
-
const override = num.levelOverrides?.[
|
|
23076
|
-
const sourceAbstract = own(catalog.abstractNums, num.abstractNumId)?.levels[
|
|
24207
|
+
const override = num.levelOverrides?.[level2];
|
|
24208
|
+
const sourceAbstract = own(catalog.abstractNums, num.abstractNumId)?.levels[level2];
|
|
23077
24209
|
const abstract = sourceAbstract?.startWasOmitted && sourceAbstract.start === 1 ? { ...sourceAbstract, start: 0 } : sourceAbstract;
|
|
23078
24210
|
let base = override?.lvl ?? abstract;
|
|
23079
24211
|
if (!base) return void 0;
|
|
@@ -23094,20 +24226,20 @@ function resolveNumberingLevel(catalog, numId, level) {
|
|
|
23094
24226
|
}
|
|
23095
24227
|
|
|
23096
24228
|
// docx/numbering-start-edit.ts
|
|
23097
|
-
function assertListStartValue(
|
|
23098
|
-
if (!Number.isInteger(
|
|
24229
|
+
function assertListStartValue(level2, start) {
|
|
24230
|
+
if (!Number.isInteger(level2) || level2 < 0 || level2 > 8)
|
|
23099
24231
|
throw new Error("List level must be an integer from 0 through 8.");
|
|
23100
24232
|
if (!Number.isInteger(start) || start < 0 || start > 2147483647)
|
|
23101
24233
|
throw new Error("List start must be an integer from 0 through 2147483647.");
|
|
23102
24234
|
}
|
|
23103
|
-
function setListStartOverride(catalog, numId,
|
|
23104
|
-
assertListStartValue(
|
|
24235
|
+
function setListStartOverride(catalog, numId, level2, start) {
|
|
24236
|
+
assertListStartValue(level2, start);
|
|
23105
24237
|
if (!Number.isSafeInteger(numId) || numId <= 0) throw new Error("Invalid list instance id.");
|
|
23106
24238
|
const id = String(numId);
|
|
23107
24239
|
const num = catalog.nums[id];
|
|
23108
|
-
if (!num || !resolveNumberingLevel(catalog, id,
|
|
24240
|
+
if (!num || !resolveNumberingLevel(catalog, id, level2))
|
|
23109
24241
|
throw new Error("List instance or level does not exist.");
|
|
23110
|
-
const override = num.levelOverrides?.[
|
|
24242
|
+
const override = num.levelOverrides?.[level2];
|
|
23111
24243
|
if (override?.lvl) throw new Error("Changing starts with a full level override is unsupported.");
|
|
23112
24244
|
if (override?.startOverride === start) return catalog;
|
|
23113
24245
|
return {
|
|
@@ -23118,7 +24250,7 @@ function setListStartOverride(catalog, numId, level, start) {
|
|
|
23118
24250
|
...num,
|
|
23119
24251
|
levelOverrides: {
|
|
23120
24252
|
...num.levelOverrides,
|
|
23121
|
-
[
|
|
24253
|
+
[level2]: { ...override, startOverride: start }
|
|
23122
24254
|
}
|
|
23123
24255
|
}
|
|
23124
24256
|
}
|
|
@@ -23129,9 +24261,9 @@ function setListStartOverride(catalog, numId, level, start) {
|
|
|
23129
24261
|
function withoutStarts(num) {
|
|
23130
24262
|
const { levelOverrides, ...properties2 } = num;
|
|
23131
24263
|
const kept = {};
|
|
23132
|
-
for (const [
|
|
24264
|
+
for (const [level2, override] of Object.entries(levelOverrides ?? {})) {
|
|
23133
24265
|
const { startOverride: _start, ...rest } = override;
|
|
23134
|
-
if (Object.keys(rest).length) kept[
|
|
24266
|
+
if (Object.keys(rest).length) kept[level2] = rest;
|
|
23135
24267
|
}
|
|
23136
24268
|
return { ...properties2, ...Object.keys(kept).length ? { levelOverrides: kept } : {} };
|
|
23137
24269
|
}
|
|
@@ -23147,18 +24279,18 @@ function numberingStartChanges(prior, next) {
|
|
|
23147
24279
|
...Object.keys(previous.levelOverrides ?? {}),
|
|
23148
24280
|
...Object.keys(current.levelOverrides ?? {})
|
|
23149
24281
|
])) {
|
|
23150
|
-
const
|
|
23151
|
-
const old = previous.levelOverrides?.[
|
|
23152
|
-
const value = current.levelOverrides?.[
|
|
24282
|
+
const level2 = Number(key);
|
|
24283
|
+
const old = previous.levelOverrides?.[level2];
|
|
24284
|
+
const value = current.levelOverrides?.[level2];
|
|
23153
24285
|
if (old?.startOverride === value?.startOverride) continue;
|
|
23154
24286
|
if (value?.startOverride === void 0)
|
|
23155
24287
|
throw new Error("Removing a list start override is unsupported.");
|
|
23156
|
-
assertListStartValue(
|
|
23157
|
-
if (String(
|
|
24288
|
+
assertListStartValue(level2, value.startOverride);
|
|
24289
|
+
if (String(level2) !== key || !prior || !resolveNumberingLevel(prior, id, level2))
|
|
23158
24290
|
throw new Error("List instance or level does not exist.");
|
|
23159
24291
|
if (old?.lvl || value.lvl)
|
|
23160
24292
|
throw new Error("Changing starts with a full level override is unsupported.");
|
|
23161
|
-
changes.push({ numId: id, level, start: value.startOverride });
|
|
24293
|
+
changes.push({ numId: id, level: level2, start: value.startOverride });
|
|
23162
24294
|
}
|
|
23163
24295
|
}
|
|
23164
24296
|
return changes;
|
|
@@ -23265,17 +24397,17 @@ function buildAbstractNumElement(doc, def) {
|
|
|
23265
24397
|
const element = makeW(doc, "abstractNum");
|
|
23266
24398
|
setAttribute8(element, "abstractNumId", def.id);
|
|
23267
24399
|
element.appendChild(valueElement(doc, "multiLevelType", "hybridMultilevel"));
|
|
23268
|
-
for (const
|
|
23269
|
-
element.appendChild(buildLevelElement(doc,
|
|
24400
|
+
for (const level2 of Object.values(def.levels).sort((a2, b) => a2.level - b.level))
|
|
24401
|
+
element.appendChild(buildLevelElement(doc, level2));
|
|
23270
24402
|
return element;
|
|
23271
24403
|
}
|
|
23272
24404
|
function buildNumElement(doc, def) {
|
|
23273
24405
|
const element = makeW(doc, "num");
|
|
23274
24406
|
setAttribute8(element, "numId", def.id);
|
|
23275
24407
|
element.appendChild(valueElement(doc, "abstractNumId", def.abstractNumId));
|
|
23276
|
-
for (const [
|
|
24408
|
+
for (const [level2, override] of Object.entries(def.levelOverrides ?? {})) {
|
|
23277
24409
|
const lvlOverride = makeW(doc, "lvlOverride");
|
|
23278
|
-
setAttribute8(lvlOverride, "ilvl",
|
|
24410
|
+
setAttribute8(lvlOverride, "ilvl", level2);
|
|
23279
24411
|
if (override.startOverride !== void 0)
|
|
23280
24412
|
lvlOverride.appendChild(valueElement(doc, "startOverride", String(override.startOverride)));
|
|
23281
24413
|
if (override.lvl) lvlOverride.appendChild(buildLevelElement(doc, override.lvl));
|
|
@@ -23349,11 +24481,11 @@ function setNumPr(style, numbering) {
|
|
|
23349
24481
|
for (const existing of children2(pPr, "numPr")) pPr.removeChild(existing);
|
|
23350
24482
|
if (numbering) {
|
|
23351
24483
|
const numPr = makeW(doc, "numPr");
|
|
23352
|
-
const
|
|
23353
|
-
|
|
24484
|
+
const level2 = makeW(doc, "ilvl");
|
|
24485
|
+
level2.setAttributeNS(WORD_NS, "w:val", String(numbering.level));
|
|
23354
24486
|
const id = makeW(doc, "numId");
|
|
23355
24487
|
id.setAttributeNS(WORD_NS, "w:val", String(numbering.numId));
|
|
23356
|
-
numPr.appendChild(
|
|
24488
|
+
numPr.appendChild(level2);
|
|
23357
24489
|
numPr.appendChild(id);
|
|
23358
24490
|
pPr.appendChild(numPr);
|
|
23359
24491
|
}
|
|
@@ -23434,9 +24566,9 @@ var PART_KINDS = {
|
|
|
23434
24566
|
headers: { root: "hdr", relation: "header", contentType: "header" },
|
|
23435
24567
|
footers: { root: "ftr", relation: "footer", contentType: "footer" }
|
|
23436
24568
|
};
|
|
23437
|
-
function partContents(
|
|
24569
|
+
function partContents(sections2) {
|
|
23438
24570
|
const parts = /* @__PURE__ */ new Map();
|
|
23439
|
-
for (const section of
|
|
24571
|
+
for (const section of sections2 ?? [])
|
|
23440
24572
|
for (const kind of KINDS)
|
|
23441
24573
|
for (const content of Object.values(
|
|
23442
24574
|
section[kind] ?? {}
|
|
@@ -24645,14 +25777,14 @@ function parseOneSection(section, endsAtBlockId) {
|
|
|
24645
25777
|
};
|
|
24646
25778
|
}
|
|
24647
25779
|
function parseRawSections(body, blocks) {
|
|
24648
|
-
const
|
|
25780
|
+
const sections2 = [];
|
|
24649
25781
|
let position2 = 0;
|
|
24650
25782
|
for (const node of Array.from(body.childNodes).filter(isElement)) {
|
|
24651
25783
|
if (named2(node, "p")) {
|
|
24652
25784
|
const sectPr = first2(first2(node, "pPr"), "sectPr");
|
|
24653
25785
|
if (sectPr) {
|
|
24654
25786
|
const blockId = blocks[position2]?.id;
|
|
24655
|
-
if (blockId)
|
|
25787
|
+
if (blockId) sections2.push(parseOneSection(sectPr, blockId));
|
|
24656
25788
|
}
|
|
24657
25789
|
position2++;
|
|
24658
25790
|
} else if (named2(node, "tbl")) {
|
|
@@ -24662,9 +25794,9 @@ function parseRawSections(body, blocks) {
|
|
|
24662
25794
|
const finalSectPr = children2(body, "sectPr").at(-1);
|
|
24663
25795
|
if (finalSectPr) {
|
|
24664
25796
|
const lastBlockId = blocks.at(-1)?.id;
|
|
24665
|
-
if (lastBlockId)
|
|
25797
|
+
if (lastBlockId) sections2.push(parseOneSection(finalSectPr, lastBlockId));
|
|
24666
25798
|
}
|
|
24667
|
-
return
|
|
25799
|
+
return sections2;
|
|
24668
25800
|
}
|
|
24669
25801
|
|
|
24670
25802
|
// docx/cell-blocks.ts
|
|
@@ -24872,7 +26004,7 @@ async function parseDocumentParts(zip, body, blocks, drawings) {
|
|
|
24872
26004
|
const settings = withParseWarnings(warnings, () => parseSettings(settingsXml));
|
|
24873
26005
|
const cache = /* @__PURE__ */ new Map();
|
|
24874
26006
|
const fieldMarkup = { seen: false };
|
|
24875
|
-
const
|
|
26007
|
+
const sections2 = [];
|
|
24876
26008
|
for (const { headerRefs, footerRefs, ...rest } of raw) {
|
|
24877
26009
|
const headers = await resolveSlots(
|
|
24878
26010
|
zip,
|
|
@@ -24892,7 +26024,7 @@ async function parseDocumentParts(zip, body, blocks, drawings) {
|
|
|
24892
26024
|
drawings,
|
|
24893
26025
|
warnings
|
|
24894
26026
|
);
|
|
24895
|
-
|
|
26027
|
+
sections2.push({ ...rest, ...headers ? { headers } : {}, ...footers ? { footers } : {} });
|
|
24896
26028
|
}
|
|
24897
26029
|
const footnotesXml = await readPart(zip, "word/footnotes.xml");
|
|
24898
26030
|
const endnotesXml = await readPart(zip, "word/endnotes.xml");
|
|
@@ -24903,7 +26035,7 @@ async function parseDocumentParts(zip, body, blocks, drawings) {
|
|
|
24903
26035
|
const footnotes = footnotesXml ? parseNotesPart(footnotesXml, "footnote", await notesParser("word/footnotes.xml")) : void 0;
|
|
24904
26036
|
const footnoteSeparators = footnotesXml ? parseFootnoteSeparators(footnotesXml, await notesParser("word/footnotes.xml")) : void 0;
|
|
24905
26037
|
const endnotes = endnotesXml ? parseNotesPart(endnotesXml, "endnote", await notesParser("word/endnotes.xml")) : void 0;
|
|
24906
|
-
if (
|
|
26038
|
+
if (sections2.some((section) => section.columns.count > 1))
|
|
24907
26039
|
warnings.push(
|
|
24908
26040
|
"Columns render in Print Layout and, for single-section documents, on the editing surface; column breaks balance approximately."
|
|
24909
26041
|
);
|
|
@@ -24912,7 +26044,7 @@ async function parseDocumentParts(zip, body, blocks, drawings) {
|
|
|
24912
26044
|
"PAGE, NUMPAGES, SECTIONPAGES, DATE and TIME fields are recalculated in Print Layout; other fields show the result Word last saved. Field results are editable and field codes are preserved."
|
|
24913
26045
|
);
|
|
24914
26046
|
return {
|
|
24915
|
-
sections,
|
|
26047
|
+
sections: sections2,
|
|
24916
26048
|
...settings.compatibilityMode !== void 0 ? { compatibilityMode: settings.compatibilityMode } : {},
|
|
24917
26049
|
...footnotes ? { footnotes } : {},
|
|
24918
26050
|
...footnoteSeparators ? { footnoteSeparators } : {},
|
|
@@ -25410,10 +26542,10 @@ function resolveParagraphNumbering(paragraph, styleCatalog, numberingCatalog) {
|
|
|
25410
26542
|
const inherited = resolveStyleNumbering(paragraph.style, styleCatalog);
|
|
25411
26543
|
if (!inherited || inherited.numId <= 0) return void 0;
|
|
25412
26544
|
if (numberingCatalog && paragraph.style && styleCatalog.styles[paragraph.style]) {
|
|
25413
|
-
for (let
|
|
25414
|
-
const definition = resolveNumberingLevel(numberingCatalog, String(inherited.numId),
|
|
26545
|
+
for (let level2 = 0; level2 < 9; level2++) {
|
|
26546
|
+
const definition = resolveNumberingLevel(numberingCatalog, String(inherited.numId), level2);
|
|
25415
26547
|
if (definition?.paragraphStyleId === paragraph.style)
|
|
25416
|
-
return { numId: inherited.numId, level };
|
|
26548
|
+
return { numId: inherited.numId, level: level2 };
|
|
25417
26549
|
}
|
|
25418
26550
|
}
|
|
25419
26551
|
return inherited;
|
|
@@ -25446,23 +26578,23 @@ var NumberingCounters = class {
|
|
|
25446
26578
|
return started;
|
|
25447
26579
|
}
|
|
25448
26580
|
/** Advances one level and resets deeper counters according to their resolved restart rules. */
|
|
25449
|
-
advance(numId,
|
|
26581
|
+
advance(numId, level2, def, catalog) {
|
|
25450
26582
|
const counts = this.forNum(numId);
|
|
25451
26583
|
const started = this.startedLevels(numId);
|
|
25452
|
-
const next = started.has(
|
|
25453
|
-
counts.set(
|
|
25454
|
-
started.add(
|
|
26584
|
+
const next = started.has(level2) ? (counts.get(level2) ?? def.start) + 1 : def.start;
|
|
26585
|
+
counts.set(level2, next);
|
|
26586
|
+
started.add(level2);
|
|
25455
26587
|
for (const deeper of [...started]) {
|
|
25456
|
-
if (deeper <=
|
|
26588
|
+
if (deeper <= level2) continue;
|
|
25457
26589
|
const deeperDef = resolveNumberingLevel(catalog, numId, deeper);
|
|
25458
26590
|
const restart = deeperDef?.lvlRestart;
|
|
25459
26591
|
if (restart === 0) continue;
|
|
25460
26592
|
const trigger = restart !== void 0 && restart > 0 && restart <= deeper ? restart - 1 : deeper - 1;
|
|
25461
|
-
if (
|
|
26593
|
+
if (level2 > trigger) continue;
|
|
25462
26594
|
counts.delete(deeper);
|
|
25463
26595
|
started.delete(deeper);
|
|
25464
26596
|
}
|
|
25465
|
-
for (let ancestor = 0; ancestor <
|
|
26597
|
+
for (let ancestor = 0; ancestor < level2; ancestor++) {
|
|
25466
26598
|
if (started.has(ancestor)) continue;
|
|
25467
26599
|
const ancestorDef = resolveNumberingLevel(catalog, numId, ancestor);
|
|
25468
26600
|
if (!ancestorDef) continue;
|
|
@@ -25472,14 +26604,14 @@ var NumberingCounters = class {
|
|
|
25472
26604
|
return next;
|
|
25473
26605
|
}
|
|
25474
26606
|
/** Current value for an ancestor placeholder, defaulting to its own start when never instantiated. */
|
|
25475
|
-
current(numId,
|
|
25476
|
-
return this.forNum(numId).get(
|
|
26607
|
+
current(numId, level2, start) {
|
|
26608
|
+
return this.forNum(numId).get(level2) ?? start;
|
|
25477
26609
|
}
|
|
25478
26610
|
};
|
|
25479
|
-
function substituteLvlText(lvlText, numId,
|
|
26611
|
+
function substituteLvlText(lvlText, numId, level2, catalog, counters, forceDecimal) {
|
|
25480
26612
|
return lvlText.replace(/%([1-9])/g, (match, digit) => {
|
|
25481
26613
|
const ancestorLevel = Number(digit) - 1;
|
|
25482
|
-
if (ancestorLevel >
|
|
26614
|
+
if (ancestorLevel > level2) return match;
|
|
25483
26615
|
const ancestorDef = resolveNumberingLevel(catalog, numId, ancestorLevel);
|
|
25484
26616
|
const start = ancestorDef?.start ?? 1;
|
|
25485
26617
|
const value = counters.current(numId, ancestorLevel, start);
|
|
@@ -25496,15 +26628,15 @@ function computeListLabels(model) {
|
|
|
25496
26628
|
const numbering = resolveParagraphNumbering(paragraph, model.paragraphStyles, catalog);
|
|
25497
26629
|
if (!numbering) continue;
|
|
25498
26630
|
const numId = String(numbering.numId);
|
|
25499
|
-
const
|
|
25500
|
-
const def = resolveNumberingLevel(catalog, numId,
|
|
26631
|
+
const level2 = Math.min(8, Math.max(0, numbering.level));
|
|
26632
|
+
const def = resolveNumberingLevel(catalog, numId, level2);
|
|
25501
26633
|
if (!def) continue;
|
|
25502
26634
|
if (def.numFmt === "none") continue;
|
|
25503
|
-
counters.advance(numId,
|
|
25504
|
-
const text3 = def.numFmt === "bullet" ? def.lvlText : substituteLvlText(def.lvlText, numId,
|
|
26635
|
+
counters.advance(numId, level2, def, catalog);
|
|
26636
|
+
const text3 = def.numFmt === "bullet" ? def.lvlText : substituteLvlText(def.lvlText, numId, level2, catalog, counters, Boolean(def.isLgl));
|
|
25505
26637
|
labels.set(paragraph.id, {
|
|
25506
26638
|
numId,
|
|
25507
|
-
level,
|
|
26639
|
+
level: level2,
|
|
25508
26640
|
text: text3,
|
|
25509
26641
|
suffix: def.suffix ?? "tab",
|
|
25510
26642
|
...definedProps({
|
|
@@ -25537,9 +26669,9 @@ function displayListLabel(text3) {
|
|
|
25537
26669
|
// docx/heading-list-kinds.ts
|
|
25538
26670
|
var SPECS = {
|
|
25539
26671
|
// 1 Heading 1 / 1.1 Heading 2 / 1.1.1 Heading 3 ...
|
|
25540
|
-
headings: Array.from({ length: 9 }, (_,
|
|
26672
|
+
headings: Array.from({ length: 9 }, (_, level2) => [
|
|
25541
26673
|
"decimal",
|
|
25542
|
-
Array.from({ length:
|
|
26674
|
+
Array.from({ length: level2 + 1 }, (_2, i) => `%${i + 1}`).join(".")
|
|
25543
26675
|
]),
|
|
25544
26676
|
// Article I. / Section 1.1 (Arabic) / (a) / (i)
|
|
25545
26677
|
article: [
|
|
@@ -25568,15 +26700,15 @@ var SPECS = {
|
|
|
25568
26700
|
};
|
|
25569
26701
|
var isHeadingListKind = (value) => value in SPECS;
|
|
25570
26702
|
function headingListLevels(kind) {
|
|
25571
|
-
return SPECS[kind].map(([numFmt, lvlText, legal],
|
|
25572
|
-
const indent = 432 + 144 *
|
|
26703
|
+
return SPECS[kind].map(([numFmt, lvlText, legal], level2) => {
|
|
26704
|
+
const indent = 432 + 144 * level2;
|
|
25573
26705
|
return {
|
|
25574
|
-
level,
|
|
26706
|
+
level: level2,
|
|
25575
26707
|
start: 1,
|
|
25576
26708
|
numFmt,
|
|
25577
26709
|
lvlText,
|
|
25578
26710
|
...legal ? { isLgl: true } : {},
|
|
25579
|
-
paragraphStyleId: `Heading${
|
|
26711
|
+
paragraphStyleId: `Heading${level2 + 1}`,
|
|
25580
26712
|
indentLeftTwips: signedTwips(indent),
|
|
25581
26713
|
hangingTwips: twips(indent),
|
|
25582
26714
|
suffix: "tab"
|
|
@@ -25590,19 +26722,19 @@ var OUTLINE_FORMATS = [
|
|
|
25590
26722
|
["lowerLetter", ")"],
|
|
25591
26723
|
["lowerRoman", "."]
|
|
25592
26724
|
];
|
|
25593
|
-
function levelText(kind,
|
|
26725
|
+
function levelText(kind, level2) {
|
|
25594
26726
|
if (kind === "bullet")
|
|
25595
|
-
return expectDefined(BULLET_GLYPHS[
|
|
26727
|
+
return expectDefined(BULLET_GLYPHS[level2 % BULLET_GLYPHS.length], "bullet glyph");
|
|
25596
26728
|
if (kind === "multilevel")
|
|
25597
|
-
return `${Array.from({ length:
|
|
25598
|
-
const [, close] = expectDefined(OUTLINE_FORMATS[
|
|
25599
|
-
return `%${
|
|
26729
|
+
return `${Array.from({ length: level2 + 1 }, (_, i) => `%${i + 1}`).join(".")}.`;
|
|
26730
|
+
const [, close] = expectDefined(OUTLINE_FORMATS[level2 % 3], "outline format");
|
|
26731
|
+
return `%${level2 + 1}${close}`;
|
|
25600
26732
|
}
|
|
25601
|
-
function levelFormat(kind,
|
|
26733
|
+
function levelFormat(kind, level2) {
|
|
25602
26734
|
if (kind === "bullet") return "bullet";
|
|
25603
26735
|
if (kind === "decimal")
|
|
25604
|
-
return expectDefined(DECIMAL_FORMATS[
|
|
25605
|
-
return kind === "multilevel" ? "decimal" : expectDefined(OUTLINE_FORMATS[
|
|
26736
|
+
return expectDefined(DECIMAL_FORMATS[level2 % DECIMAL_FORMATS.length], "decimal format");
|
|
26737
|
+
return kind === "multilevel" ? "decimal" : expectDefined(OUTLINE_FORMATS[level2 % 3], "outline format")[0];
|
|
25606
26738
|
}
|
|
25607
26739
|
var BULLET_GLYPHS = ["\u2022", "\u25E6", "\u25AA"];
|
|
25608
26740
|
var DECIMAL_FORMATS = ["decimal", "lowerLetter", "lowerRoman"];
|
|
@@ -25615,17 +26747,17 @@ function nextId(ids, floor) {
|
|
|
25615
26747
|
}
|
|
25616
26748
|
function buildLevels(kind) {
|
|
25617
26749
|
const levels = {};
|
|
25618
|
-
for (let
|
|
26750
|
+
for (let level2 = 0; level2 < 9; level2++) {
|
|
25619
26751
|
const base = {
|
|
25620
|
-
level,
|
|
26752
|
+
level: level2,
|
|
25621
26753
|
start: 1,
|
|
25622
|
-
numFmt: levelFormat(kind,
|
|
25623
|
-
lvlText: kind === "decimal" ? `%${
|
|
25624
|
-
indentLeftTwips: signedTwips(720 * (
|
|
26754
|
+
numFmt: levelFormat(kind, level2),
|
|
26755
|
+
lvlText: kind === "decimal" ? `%${level2 + 1}.` : levelText(kind, level2),
|
|
26756
|
+
indentLeftTwips: signedTwips(720 * (level2 + 1)),
|
|
25625
26757
|
hangingTwips: twips(kind === "multilevel" ? 720 : 360),
|
|
25626
26758
|
suffix: "tab"
|
|
25627
26759
|
};
|
|
25628
|
-
levels[
|
|
26760
|
+
levels[level2] = base;
|
|
25629
26761
|
}
|
|
25630
26762
|
return levels;
|
|
25631
26763
|
}
|
|
@@ -25633,9 +26765,9 @@ function ensureListDefinition(catalog, kind) {
|
|
|
25633
26765
|
return createListDefinition(catalog, Object.values(buildLevels(kind)));
|
|
25634
26766
|
}
|
|
25635
26767
|
function createListDefinition(catalog, levels) {
|
|
25636
|
-
if (!levels.length || levels.length > 9 || new Set(levels.map((
|
|
26768
|
+
if (!levels.length || levels.length > 9 || new Set(levels.map((level2) => level2.level)).size !== levels.length || levels.some((level2) => !Number.isInteger(level2.level) || level2.level < 0 || level2.level > 8))
|
|
25637
26769
|
throw new Error("A list must have 1 to 9 distinct levels numbered 0 through 8.");
|
|
25638
|
-
const copied = Object.fromEntries(levels.map((
|
|
26770
|
+
const copied = Object.fromEntries(levels.map((level2) => [level2.level, { ...level2 }]));
|
|
25639
26771
|
const issues = [];
|
|
25640
26772
|
validateNumberingCatalog(new Checker(issues, "numberingCatalog"), {
|
|
25641
26773
|
abstractNums: { "0": { id: "0", levels: copied } },
|
|
@@ -25655,9 +26787,9 @@ function createListDefinition(catalog, levels) {
|
|
|
25655
26787
|
function linkStylesToList(styles, levels, numId) {
|
|
25656
26788
|
if (!styles) return styles;
|
|
25657
26789
|
const next = { ...styles, styles: { ...styles.styles } };
|
|
25658
|
-
for (const
|
|
25659
|
-
const style =
|
|
25660
|
-
if (style) next.styles[style.id] = { ...style, numbering: { numId, level:
|
|
26790
|
+
for (const level2 of levels) {
|
|
26791
|
+
const style = level2.paragraphStyleId ? next.styles[level2.paragraphStyleId] : void 0;
|
|
26792
|
+
if (style) next.styles[style.id] = { ...style, numbering: { numId, level: level2.level } };
|
|
25661
26793
|
}
|
|
25662
26794
|
return next;
|
|
25663
26795
|
}
|
|
@@ -25929,7 +27061,7 @@ function datePicture(instr) {
|
|
|
25929
27061
|
}
|
|
25930
27062
|
var TOKENS = /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|am\/pm|AM\/PM|'[^']*'/g;
|
|
25931
27063
|
function formatWordDate(date, picture, locale = "en-US") {
|
|
25932
|
-
const name = (
|
|
27064
|
+
const name = (options2) => new Intl.DateTimeFormat(locale, options2).format(date);
|
|
25933
27065
|
const pad = (value) => String(value).padStart(2, "0");
|
|
25934
27066
|
const hours12 = date.getHours() % 12 || 12;
|
|
25935
27067
|
return picture.replace(TOKENS, (token) => {
|
|
@@ -25987,9 +27119,9 @@ function styleMap(instruction) {
|
|
|
25987
27119
|
const parts = (match?.[1] ?? match?.[2] ?? "").split(/[,;]/).map((part) => part.trim());
|
|
25988
27120
|
for (let i = 0; i + 1 < parts.length; i += 2) {
|
|
25989
27121
|
const name = parts[i];
|
|
25990
|
-
const
|
|
25991
|
-
if (name && Number.isInteger(
|
|
25992
|
-
map.set(name.toLowerCase(),
|
|
27122
|
+
const level2 = Number(parts[i + 1]);
|
|
27123
|
+
if (name && Number.isInteger(level2) && level2 >= 1 && level2 <= 9)
|
|
27124
|
+
map.set(name.toLowerCase(), level2);
|
|
25993
27125
|
}
|
|
25994
27126
|
return map;
|
|
25995
27127
|
}
|
|
@@ -26055,14 +27187,14 @@ function tocEntries(model, instruction = DEFAULT_TOC_INSTRUCTION) {
|
|
|
26055
27187
|
const entries = [];
|
|
26056
27188
|
for (const block of model.blocks) {
|
|
26057
27189
|
if (block.type !== "paragraph") continue;
|
|
26058
|
-
const
|
|
27190
|
+
const level2 = entryLevel(block, model.paragraphStyles, switches);
|
|
26059
27191
|
const text3 = plainText(block);
|
|
26060
|
-
if (
|
|
27192
|
+
if (level2 !== void 0 && text3) entries.push({ level: level2, text: text3, blockId: block.id });
|
|
26061
27193
|
}
|
|
26062
27194
|
return entries;
|
|
26063
27195
|
}
|
|
26064
27196
|
function entryLevel(paragraph, catalog, switches) {
|
|
26065
|
-
const inRange = (
|
|
27197
|
+
const inRange = (level2) => level2 !== void 0 && level2 >= switches.from && level2 <= switches.to ? level2 : void 0;
|
|
26066
27198
|
if (switches.styles.size > 0 && paragraph.style) {
|
|
26067
27199
|
const name = catalog?.styles[paragraph.style]?.name;
|
|
26068
27200
|
const mapped = switches.styles.get(paragraph.style.toLowerCase()) ?? (name ? switches.styles.get(name.toLowerCase()) : void 0);
|
|
@@ -26136,25 +27268,25 @@ function withTocBookmarks(model, added) {
|
|
|
26136
27268
|
)
|
|
26137
27269
|
};
|
|
26138
27270
|
}
|
|
26139
|
-
function buildTableOfContents(model,
|
|
26140
|
-
const instruction =
|
|
27271
|
+
function buildTableOfContents(model, options2) {
|
|
27272
|
+
const instruction = options2.instruction ?? DEFAULT_TOC_INSTRUCTION;
|
|
26141
27273
|
const field = { instr: instruction.trim() };
|
|
26142
|
-
const width =
|
|
27274
|
+
const width = options2.contentWidthTwips ?? twips(9360);
|
|
26143
27275
|
const styles = model.paragraphStyles?.styles ?? {};
|
|
26144
27276
|
const entries = tocEntries(model, instruction);
|
|
26145
27277
|
const figures = tocCaptionLabel(instruction) !== void 0;
|
|
26146
27278
|
const paragraphs = (entries.length ? entries : [void 0]).map((entry2) => {
|
|
26147
|
-
const
|
|
26148
|
-
const style = figures ? "TableofFigures" : `TOC${
|
|
26149
|
-
const page = entry2 ?
|
|
26150
|
-
const bookmark = entry2 ?
|
|
27279
|
+
const level2 = entry2?.level ?? 1;
|
|
27280
|
+
const style = figures ? "TableofFigures" : `TOC${level2}`;
|
|
27281
|
+
const page = entry2 ? options2.pageNumbers?.get(entry2.blockId) : void 0;
|
|
27282
|
+
const bookmark = entry2 ? options2.bookmarks?.get(entry2.blockId) : void 0;
|
|
26151
27283
|
const runs = !entry2 ? [{ text: figures ? EMPTY_FIGURES_TEXT : EMPTY_TOC_TEXT, bold: true, field }] : bookmark ? linkedEntry(entry2.text, bookmark, page) : [{ text: page ? `${entry2.text} ${page}` : entry2.text, field }];
|
|
26152
27284
|
return {
|
|
26153
27285
|
type: "paragraph",
|
|
26154
|
-
id:
|
|
27286
|
+
id: options2.newId(),
|
|
26155
27287
|
runs,
|
|
26156
27288
|
...styles[style] ? { style } : {
|
|
26157
|
-
...
|
|
27289
|
+
...level2 > 1 ? { indentLeftTwips: signedTwips((level2 - 1) * 220) } : {},
|
|
26158
27290
|
spacingAfterTwips: twips(100)
|
|
26159
27291
|
},
|
|
26160
27292
|
tabStops: [{ posTwips: width, align: "right", leader: "dot" }]
|
|
@@ -26193,12 +27325,12 @@ function findTableOfContents(blocks, accepts = (instruction) => tocCaptionLabel(
|
|
|
26193
27325
|
}
|
|
26194
27326
|
return void 0;
|
|
26195
27327
|
}
|
|
26196
|
-
function updateTableOfContents(model,
|
|
27328
|
+
function updateTableOfContents(model, options2) {
|
|
26197
27329
|
const found = findTableOfContents(model.blocks);
|
|
26198
27330
|
if (!found) return void 0;
|
|
26199
27331
|
const linked = tocHyperlinks(found.instruction) ? tocBookmarks(model, tocEntries(model, found.instruction)) : void 0;
|
|
26200
27332
|
const rebuilt = buildTableOfContents(model, {
|
|
26201
|
-
...
|
|
27333
|
+
...options2,
|
|
26202
27334
|
instruction: found.instruction,
|
|
26203
27335
|
...linked ? { bookmarks: linked.bookmarks } : {}
|
|
26204
27336
|
});
|
|
@@ -26385,9 +27517,9 @@ function parseLineSpacingValue(value) {
|
|
|
26385
27517
|
}
|
|
26386
27518
|
|
|
26387
27519
|
// docx/section-layout.ts
|
|
26388
|
-
function sectionLayoutJson(
|
|
27520
|
+
function sectionLayoutJson(sections2) {
|
|
26389
27521
|
return JSON.stringify(
|
|
26390
|
-
|
|
27522
|
+
sections2.map(({ headers: _headers, footers: _footers, ...layout2 }) => layout2)
|
|
26391
27523
|
);
|
|
26392
27524
|
}
|
|
26393
27525
|
function sectionsFromLayout(json, prior, blocks) {
|
|
@@ -26495,13 +27627,13 @@ function transformCase(text3, mode, atSentenceStart = true) {
|
|
|
26495
27627
|
// docx/section-edit.ts
|
|
26496
27628
|
var px2 = twipsToPixels;
|
|
26497
27629
|
function withSection(model, index, change) {
|
|
26498
|
-
const
|
|
27630
|
+
const sections2 = sectionsOf(model).map(
|
|
26499
27631
|
(section, position2) => position2 === index ? change(structuredClone(section)) : section
|
|
26500
27632
|
);
|
|
26501
|
-
const last =
|
|
27633
|
+
const last = sections2.at(-1);
|
|
26502
27634
|
return {
|
|
26503
27635
|
...model,
|
|
26504
|
-
sections,
|
|
27636
|
+
sections: sections2,
|
|
26505
27637
|
page: {
|
|
26506
27638
|
width: px2(last.pageWidthTwips),
|
|
26507
27639
|
height: px2(last.pageHeightTwips),
|
|
@@ -26859,9 +27991,9 @@ var SHAPE_PALETTE = [
|
|
|
26859
27991
|
]
|
|
26860
27992
|
}
|
|
26861
27993
|
];
|
|
26862
|
-
var SHAPE_PALETTE_NAMES = SHAPE_PALETTE.flatMap((
|
|
26863
|
-
|
|
26864
|
-
...
|
|
27994
|
+
var SHAPE_PALETTE_NAMES = SHAPE_PALETTE.flatMap((group2) => [
|
|
27995
|
+
group2.name,
|
|
27996
|
+
...group2.shapes.map((item) => item.name)
|
|
26865
27997
|
]);
|
|
26866
27998
|
var DEFAULT_DRAWN_SHAPE = { widthPx: 96, heightPx: 64 };
|
|
26867
27999
|
var isDirectionalPreset = (preset) => /^(line|straightConnector1|bentConnector\d|curvedConnector\d)$/.test(preset);
|