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
|
@@ -50,17 +50,17 @@ function checkXmlLimits(xml, label, limits = {}) {
|
|
|
50
50
|
throw new Error(`${label} XML exceeds the nesting depth limit of ${maxDepth}`);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
function parseXml(xml,
|
|
54
|
-
const label =
|
|
53
|
+
function parseXml(xml, options2 = {}) {
|
|
54
|
+
const label = options2.label ?? "OOXML";
|
|
55
55
|
if (/<!DOCTYPE|<!ENTITY/i.test(xml))
|
|
56
56
|
throw new Error(`${label} XML with DTD or entity declarations is not supported`);
|
|
57
|
-
checkXmlLimits(xml, label,
|
|
57
|
+
checkXmlLimits(xml, label, options2.limits);
|
|
58
58
|
let parseError = "";
|
|
59
59
|
let parsed;
|
|
60
60
|
try {
|
|
61
61
|
parsed = new xmldom.DOMParser({
|
|
62
|
-
onError: (
|
|
63
|
-
if (
|
|
62
|
+
onError: (level2, message) => {
|
|
63
|
+
if (level2 !== "warning") parseError = message;
|
|
64
64
|
}
|
|
65
65
|
}).parseFromString(xml, "application/xml");
|
|
66
66
|
} catch (error) {
|
|
@@ -730,8 +730,8 @@ function resolveRunFormatting(run, context = {}) {
|
|
|
730
730
|
if (state) result[key] = true;
|
|
731
731
|
}
|
|
732
732
|
for (const key of OVERRIDE_KEYS) {
|
|
733
|
-
for (const
|
|
734
|
-
const value =
|
|
733
|
+
for (const level2 of levels) {
|
|
734
|
+
const value = level2[key];
|
|
735
735
|
if (value !== void 0) result[key] = value;
|
|
736
736
|
}
|
|
737
737
|
}
|
|
@@ -804,8 +804,8 @@ function rgbToHsl(r, g, b) {
|
|
|
804
804
|
}
|
|
805
805
|
return { h, s: clampUnitInterval(s), l: clampUnitInterval(l) };
|
|
806
806
|
}
|
|
807
|
-
function hslToRgb(h, s, l, roundChannel = Math.round,
|
|
808
|
-
const sC =
|
|
807
|
+
function hslToRgb(h, s, l, roundChannel = Math.round, options2) {
|
|
808
|
+
const sC = options2?.clampSaturation === false ? s : clampUnitInterval(s);
|
|
809
809
|
const lC = clampUnitInterval(l);
|
|
810
810
|
const hN = (h % 360 + 360) % 360;
|
|
811
811
|
const c = (1 - Math.abs(2 * lC - 1)) * sC;
|
|
@@ -1294,13 +1294,13 @@ var APPLIED = /* @__PURE__ */ new Set([
|
|
|
1294
1294
|
"lumMod",
|
|
1295
1295
|
"lumOff"
|
|
1296
1296
|
]);
|
|
1297
|
-
function resolveDrawingColor(color, theme,
|
|
1297
|
+
function resolveDrawingColor(color, theme, options2) {
|
|
1298
1298
|
const base = baseHex(color, theme);
|
|
1299
1299
|
const rgb = base ? hexToRgbChannels(base) : null;
|
|
1300
1300
|
if (!rgb) return void 0;
|
|
1301
|
-
if (
|
|
1301
|
+
if (options2?.transformOrder === "document") {
|
|
1302
1302
|
const value = orderedColorTransforms(rgb, color.transforms);
|
|
1303
|
-
const round3 =
|
|
1303
|
+
const round3 = options2.hslRounding === "halfDown" ? (channel) => Math.ceil(channel - 0.5) : Math.round;
|
|
1304
1304
|
return {
|
|
1305
1305
|
hex: `#${toHex(round3(value.r))}${toHex(round3(value.g))}${toHex(round3(value.b))}`,
|
|
1306
1306
|
alpha: value.alpha,
|
|
@@ -1351,7 +1351,7 @@ function resolveDrawingColor(color, theme, options) {
|
|
|
1351
1351
|
if (lumMod !== void 0) hsl.l = clampUnitInterval(hsl.l * lumMod);
|
|
1352
1352
|
const lumOff = parseDrawingFraction(find("lumOff"));
|
|
1353
1353
|
if (lumOff !== void 0) hsl.l = clampUnitInterval(hsl.l + lumOff);
|
|
1354
|
-
const round3 =
|
|
1354
|
+
const round3 = options2?.hslRounding === "halfDown" ? (value) => Math.ceil(value - 0.5) : Math.round;
|
|
1355
1355
|
({ r, g, b } = hslToRgb(hsl.h, hsl.s, hsl.l, round3));
|
|
1356
1356
|
}
|
|
1357
1357
|
let alpha = parseDrawingPercent(find("alpha")) ?? 1;
|
|
@@ -1808,7 +1808,7 @@ function resolveInnerRect(fillToRect, focalPoint) {
|
|
|
1808
1808
|
function lerpEdge(inner, outer, t) {
|
|
1809
1809
|
return inner + (outer - inner) * t;
|
|
1810
1810
|
}
|
|
1811
|
-
function buildRectPathGradientSvg(stops, focalPoint, fillToRect,
|
|
1811
|
+
function buildRectPathGradientSvg(stops, focalPoint, fillToRect, options2) {
|
|
1812
1812
|
if (stops.length === 0) {
|
|
1813
1813
|
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"/>';
|
|
1814
1814
|
}
|
|
@@ -1817,7 +1817,7 @@ function buildRectPathGradientSvg(stops, focalPoint, fillToRect, options) {
|
|
|
1817
1817
|
const rects = [];
|
|
1818
1818
|
const alphaRects = [];
|
|
1819
1819
|
const masked = sorted.some((stop) => (stop.opacity ?? 1) < 1);
|
|
1820
|
-
const bands =
|
|
1820
|
+
const bands = options2?.bands;
|
|
1821
1821
|
if (!Number.isInteger(bands) || bands < 1) throw new RangeError("Invalid gradient band count");
|
|
1822
1822
|
for (let i = bands; i >= 0; i -= 1) {
|
|
1823
1823
|
const t = i / bands;
|
|
@@ -11341,13 +11341,297 @@ function groupRowsByCategory(rawCategories) {
|
|
|
11341
11341
|
return { uniqueCategories, rowIndexesByCategory };
|
|
11342
11342
|
}
|
|
11343
11343
|
|
|
11344
|
+
// chart/number-format-pattern.ts
|
|
11345
|
+
var NAMED_FORMAT_COLORS = {
|
|
11346
|
+
black: "#000000",
|
|
11347
|
+
blue: "#0000FF",
|
|
11348
|
+
cyan: "#00FFFF",
|
|
11349
|
+
green: "#00FF00",
|
|
11350
|
+
magenta: "#FF00FF",
|
|
11351
|
+
red: "#FF0000",
|
|
11352
|
+
white: "#FFFFFF",
|
|
11353
|
+
yellow: "#FFFF00"
|
|
11354
|
+
};
|
|
11355
|
+
var PLACEHOLDER = /[0#?]/u;
|
|
11356
|
+
function parsePattern(code) {
|
|
11357
|
+
let scale = 1;
|
|
11358
|
+
let scientific = false;
|
|
11359
|
+
let color;
|
|
11360
|
+
const chars = [];
|
|
11361
|
+
let inQuotes = false;
|
|
11362
|
+
for (let i = 0; i < code.length; i += 1) {
|
|
11363
|
+
const ch = code[i] ?? "";
|
|
11364
|
+
if (ch === '"') {
|
|
11365
|
+
inQuotes = !inQuotes;
|
|
11366
|
+
continue;
|
|
11367
|
+
}
|
|
11368
|
+
if (inQuotes) {
|
|
11369
|
+
chars.push({ ch, literal: true });
|
|
11370
|
+
continue;
|
|
11371
|
+
}
|
|
11372
|
+
if (ch === "\\" || ch === "*" || ch === "_") {
|
|
11373
|
+
const next = code[i + 1];
|
|
11374
|
+
i += 1;
|
|
11375
|
+
if (ch === "\\" && next !== void 0) {
|
|
11376
|
+
chars.push({ ch: next, literal: true });
|
|
11377
|
+
}
|
|
11378
|
+
continue;
|
|
11379
|
+
}
|
|
11380
|
+
if (ch === "%") {
|
|
11381
|
+
scale *= 100;
|
|
11382
|
+
chars.push({ ch, literal: true });
|
|
11383
|
+
continue;
|
|
11384
|
+
}
|
|
11385
|
+
if (ch === "E" && (code[i + 1] === "+" || code[i + 1] === "-")) {
|
|
11386
|
+
scientific = true;
|
|
11387
|
+
chars.push({ ch: "E", literal: false });
|
|
11388
|
+
i += 1;
|
|
11389
|
+
continue;
|
|
11390
|
+
}
|
|
11391
|
+
if (ch === "[") {
|
|
11392
|
+
const close = code.indexOf("]", i);
|
|
11393
|
+
const token = code.slice(i + 1, close === -1 ? code.length : close);
|
|
11394
|
+
const named3 = NAMED_FORMAT_COLORS[token.trim().toLowerCase()];
|
|
11395
|
+
if (named3 && color === void 0) {
|
|
11396
|
+
color = named3;
|
|
11397
|
+
}
|
|
11398
|
+
i = close === -1 ? code.length : close;
|
|
11399
|
+
continue;
|
|
11400
|
+
}
|
|
11401
|
+
chars.push({ ch, literal: false });
|
|
11402
|
+
}
|
|
11403
|
+
const firstDigit = chars.findIndex((c) => !c.literal && PLACEHOLDER.test(c.ch));
|
|
11404
|
+
if (firstDigit === -1) {
|
|
11405
|
+
return void 0;
|
|
11406
|
+
}
|
|
11407
|
+
let lastDigit = firstDigit;
|
|
11408
|
+
for (let i = chars.length - 1; i >= firstDigit; i -= 1) {
|
|
11409
|
+
const c = chars[i];
|
|
11410
|
+
if (c && !c.literal && (PLACEHOLDER.test(c.ch) || c.ch === "." || c.ch === "," || c.ch === "E")) {
|
|
11411
|
+
lastDigit = i;
|
|
11412
|
+
break;
|
|
11413
|
+
}
|
|
11414
|
+
}
|
|
11415
|
+
const numeric = chars.slice(firstDigit, lastDigit + 1);
|
|
11416
|
+
const prefix2 = chars.slice(0, firstDigit).map((c) => c.ch).join("");
|
|
11417
|
+
const suffix = chars.slice(lastDigit + 1).map((c) => c.ch).join("");
|
|
11418
|
+
let grouped = false;
|
|
11419
|
+
let intDigits = 0;
|
|
11420
|
+
let required = 0;
|
|
11421
|
+
let optional = 0;
|
|
11422
|
+
let afterPoint = false;
|
|
11423
|
+
let inExponent = false;
|
|
11424
|
+
for (let i = 0; i < numeric.length; i += 1) {
|
|
11425
|
+
const { ch, literal } = numeric[i] ?? { ch: "", literal: true };
|
|
11426
|
+
if (literal) {
|
|
11427
|
+
continue;
|
|
11428
|
+
}
|
|
11429
|
+
if (ch === "E") {
|
|
11430
|
+
inExponent = true;
|
|
11431
|
+
continue;
|
|
11432
|
+
}
|
|
11433
|
+
if (inExponent) {
|
|
11434
|
+
continue;
|
|
11435
|
+
}
|
|
11436
|
+
if (ch === ".") {
|
|
11437
|
+
afterPoint = true;
|
|
11438
|
+
continue;
|
|
11439
|
+
}
|
|
11440
|
+
if (ch === ",") {
|
|
11441
|
+
const next = numeric.slice(i + 1).find((c) => !c.literal);
|
|
11442
|
+
if (!next || next.ch === "." || !PLACEHOLDER.test(next.ch)) {
|
|
11443
|
+
scale /= 1e3;
|
|
11444
|
+
} else {
|
|
11445
|
+
grouped = true;
|
|
11446
|
+
}
|
|
11447
|
+
continue;
|
|
11448
|
+
}
|
|
11449
|
+
if (!PLACEHOLDER.test(ch)) {
|
|
11450
|
+
continue;
|
|
11451
|
+
}
|
|
11452
|
+
if (afterPoint) {
|
|
11453
|
+
if (ch === "0") {
|
|
11454
|
+
required += 1;
|
|
11455
|
+
} else {
|
|
11456
|
+
optional += 1;
|
|
11457
|
+
}
|
|
11458
|
+
} else if (ch === "0") {
|
|
11459
|
+
intDigits += 1;
|
|
11460
|
+
}
|
|
11461
|
+
}
|
|
11462
|
+
return {
|
|
11463
|
+
prefix: prefix2,
|
|
11464
|
+
suffix,
|
|
11465
|
+
intDigits,
|
|
11466
|
+
decimals: { required, optional },
|
|
11467
|
+
grouped,
|
|
11468
|
+
scale,
|
|
11469
|
+
scientific,
|
|
11470
|
+
color
|
|
11471
|
+
};
|
|
11472
|
+
}
|
|
11473
|
+
function group(intPart) {
|
|
11474
|
+
return intPart.replace(/\B(?=(\d{3})+(?!\d))/gu, ",");
|
|
11475
|
+
}
|
|
11476
|
+
function applyPattern(value, pattern, forcePositive) {
|
|
11477
|
+
const scaled = value * pattern.scale;
|
|
11478
|
+
const magnitude = forcePositive ? Math.abs(scaled) : scaled;
|
|
11479
|
+
if (pattern.scientific) {
|
|
11480
|
+
const digits = pattern.decimals.required + pattern.decimals.optional;
|
|
11481
|
+
const exponential = magnitude.toExponential(digits);
|
|
11482
|
+
const [mantissa = "", exponent = "0"] = exponential.split("e");
|
|
11483
|
+
const sign = exponent.startsWith("-") ? "-" : "+";
|
|
11484
|
+
const power = Math.abs(Number(exponent)).toString().padStart(2, "0");
|
|
11485
|
+
return `${pattern.prefix}${mantissa}E${sign}${power}${pattern.suffix}`;
|
|
11486
|
+
}
|
|
11487
|
+
const maxDecimals = pattern.decimals.required + pattern.decimals.optional;
|
|
11488
|
+
let body = magnitude.toFixed(maxDecimals);
|
|
11489
|
+
if (pattern.decimals.optional > 0) {
|
|
11490
|
+
body = body.replace(/(\.\d*?)0+$/u, "$1").replace(/\.$/u, "");
|
|
11491
|
+
const [, frac = ""] = body.split(".");
|
|
11492
|
+
if (frac.length < pattern.decimals.required) {
|
|
11493
|
+
body = Number(body).toFixed(pattern.decimals.required);
|
|
11494
|
+
}
|
|
11495
|
+
}
|
|
11496
|
+
const [rawIntPart = "", fracPart] = body.split(".");
|
|
11497
|
+
let intPart = rawIntPart;
|
|
11498
|
+
const hasMinusChar = intPart.startsWith("-");
|
|
11499
|
+
const negative = hasMinusChar && Number(body) !== 0;
|
|
11500
|
+
if (hasMinusChar) {
|
|
11501
|
+
intPart = intPart.slice(1);
|
|
11502
|
+
}
|
|
11503
|
+
if (intPart.length < pattern.intDigits) {
|
|
11504
|
+
intPart = intPart.padStart(pattern.intDigits, "0");
|
|
11505
|
+
}
|
|
11506
|
+
if (pattern.intDigits === 0 && intPart === "0" && fracPart !== void 0) {
|
|
11507
|
+
intPart = "";
|
|
11508
|
+
}
|
|
11509
|
+
if (pattern.grouped) {
|
|
11510
|
+
intPart = group(intPart);
|
|
11511
|
+
}
|
|
11512
|
+
const number = fracPart === void 0 ? intPart : `${intPart}.${fracPart}`;
|
|
11513
|
+
return `${negative ? "-" : ""}${pattern.prefix}${number}${pattern.suffix}`;
|
|
11514
|
+
}
|
|
11515
|
+
|
|
11516
|
+
// chart/number-format.ts
|
|
11517
|
+
var GENERAL = /* @__PURE__ */ new Set(["", "general", "@"]);
|
|
11518
|
+
function sections(code) {
|
|
11519
|
+
const out = [];
|
|
11520
|
+
let current = "";
|
|
11521
|
+
let inQuotes = false;
|
|
11522
|
+
for (let i = 0; i < code.length; i += 1) {
|
|
11523
|
+
const ch = code[i];
|
|
11524
|
+
if (ch === '"') {
|
|
11525
|
+
inQuotes = !inQuotes;
|
|
11526
|
+
current += ch;
|
|
11527
|
+
continue;
|
|
11528
|
+
}
|
|
11529
|
+
if (ch === "\\") {
|
|
11530
|
+
current += ch + (code[i + 1] ?? "");
|
|
11531
|
+
i += 1;
|
|
11532
|
+
continue;
|
|
11533
|
+
}
|
|
11534
|
+
if (ch === ";" && !inQuotes) {
|
|
11535
|
+
out.push(current);
|
|
11536
|
+
current = "";
|
|
11537
|
+
continue;
|
|
11538
|
+
}
|
|
11539
|
+
current += ch;
|
|
11540
|
+
}
|
|
11541
|
+
out.push(current);
|
|
11542
|
+
return out;
|
|
11543
|
+
}
|
|
11544
|
+
function sectionFor(value, parts) {
|
|
11545
|
+
if (parts.length === 1) {
|
|
11546
|
+
return { code: parts[0] ?? "", forcePositive: false };
|
|
11547
|
+
}
|
|
11548
|
+
if (value < 0 && parts[1] !== void 0) {
|
|
11549
|
+
return { code: parts[1] ?? "", forcePositive: true };
|
|
11550
|
+
}
|
|
11551
|
+
if (value === 0 && parts[2] !== void 0) {
|
|
11552
|
+
return { code: parts[2] ?? "", forcePositive: false };
|
|
11553
|
+
}
|
|
11554
|
+
return { code: parts[0] ?? "", forcePositive: false };
|
|
11555
|
+
}
|
|
11556
|
+
function formatChartNumberWithColor(value, formatCode) {
|
|
11557
|
+
if (!Number.isFinite(value)) {
|
|
11558
|
+
return void 0;
|
|
11559
|
+
}
|
|
11560
|
+
const code = (formatCode ?? "").trim();
|
|
11561
|
+
if (GENERAL.has(code.toLowerCase())) {
|
|
11562
|
+
return void 0;
|
|
11563
|
+
}
|
|
11564
|
+
if (/(?:^|[^\\"])(?:yy|mm?m|dd?|hh|ss)/iu.test(code) && !/[0#?]/u.test(code)) {
|
|
11565
|
+
return void 0;
|
|
11566
|
+
}
|
|
11567
|
+
const { code: section, forcePositive } = sectionFor(value, sections(code));
|
|
11568
|
+
const pattern = parsePattern(section);
|
|
11569
|
+
if (!pattern) {
|
|
11570
|
+
return void 0;
|
|
11571
|
+
}
|
|
11572
|
+
try {
|
|
11573
|
+
return { text: applyPattern(value, pattern, forcePositive), color: pattern.color };
|
|
11574
|
+
} catch {
|
|
11575
|
+
return void 0;
|
|
11576
|
+
}
|
|
11577
|
+
}
|
|
11578
|
+
function formatChartNumber(value, formatCode) {
|
|
11579
|
+
return formatChartNumberWithColor(value, formatCode)?.text;
|
|
11580
|
+
}
|
|
11581
|
+
|
|
11582
|
+
// chart/data-label-text.ts
|
|
11583
|
+
var DATA_LABEL_SEPARATOR = ", ";
|
|
11584
|
+
var DATA_LABEL_CATEGORY_PERCENT_SEPARATOR = "\n";
|
|
11585
|
+
var FLAG_KEYS = [
|
|
11586
|
+
"showValue",
|
|
11587
|
+
"showCategory",
|
|
11588
|
+
"showSeriesName",
|
|
11589
|
+
"showPercent",
|
|
11590
|
+
"showBubbleSize"
|
|
11591
|
+
];
|
|
11592
|
+
function resolveDataLabelFlags(levels) {
|
|
11593
|
+
const { point, series, chart } = levels;
|
|
11594
|
+
const picked = {};
|
|
11595
|
+
for (const key of FLAG_KEYS) picked[key] = point?.[key] ?? series?.[key] ?? chart?.[key];
|
|
11596
|
+
const anyDeclared = FLAG_KEYS.some((key) => picked[key] !== void 0);
|
|
11597
|
+
return {
|
|
11598
|
+
showValue: anyDeclared ? picked.showValue === true : levels.siblingOwnsLabels !== true,
|
|
11599
|
+
showCategory: picked.showCategory === true,
|
|
11600
|
+
showSeriesName: picked.showSeriesName === true,
|
|
11601
|
+
showPercent: picked.showPercent === true,
|
|
11602
|
+
showBubbleSize: picked.showBubbleSize === true,
|
|
11603
|
+
separator: point?.separator ?? series?.separator ?? chart?.separator ?? (picked.showCategory === true && picked.showPercent === true ? DATA_LABEL_CATEGORY_PERCENT_SEPARATOR : DATA_LABEL_SEPARATOR)
|
|
11604
|
+
};
|
|
11605
|
+
}
|
|
11606
|
+
function composeDataLabelText(input) {
|
|
11607
|
+
const { flags, value, numberFormat } = input;
|
|
11608
|
+
const parts = [];
|
|
11609
|
+
let valueColor;
|
|
11610
|
+
if (flags.showSeriesName && input.seriesName) parts.push(input.seriesName);
|
|
11611
|
+
if (flags.showCategory && input.category) parts.push(input.category);
|
|
11612
|
+
if (flags.showValue) {
|
|
11613
|
+
const formatted = formatChartNumberWithColor(value, numberFormat);
|
|
11614
|
+
parts.push(formatted?.text ?? (input.formatValue ?? String)(value, numberFormat));
|
|
11615
|
+
valueColor = formatted?.color;
|
|
11616
|
+
}
|
|
11617
|
+
if (flags.showPercent) {
|
|
11618
|
+
const base = input.percentBase;
|
|
11619
|
+
parts.push(base > 0 ? `${Math.round(Math.abs(value) / base * 100)}%` : "0%");
|
|
11620
|
+
}
|
|
11621
|
+
if (flags.showBubbleSize && input.bubbleSize !== void 0)
|
|
11622
|
+
parts.push((input.formatBubbleSize ?? String)(input.bubbleSize));
|
|
11623
|
+
const text2 = parts.join(flags.separator);
|
|
11624
|
+
if (text2.length === 0) return void 0;
|
|
11625
|
+
return { text: text2, color: parts.length === 1 && flags.showValue ? valueColor : void 0 };
|
|
11626
|
+
}
|
|
11627
|
+
|
|
11344
11628
|
// chart/bubble-radius.ts
|
|
11345
|
-
function computeBubbleRadius(sizeVal, maxBubble, medianRadius,
|
|
11346
|
-
const scale = (
|
|
11629
|
+
function computeBubbleRadius(sizeVal, maxBubble, medianRadius, options2) {
|
|
11630
|
+
const scale = (options2?.bubbleScale ?? 100) / 100;
|
|
11347
11631
|
if (sizeVal === void 0) return medianRadius * scale;
|
|
11348
11632
|
const denom = maxBubble > 0 ? maxBubble : 1;
|
|
11349
11633
|
const magnitude = Math.abs(sizeVal);
|
|
11350
|
-
const ratio = (
|
|
11634
|
+
const ratio = (options2?.sizeRepresents ?? "w") === "area" ? Math.sqrt(magnitude) / Math.sqrt(denom) : magnitude / denom;
|
|
11351
11635
|
return medianRadius * scale * 0.5 + ratio * medianRadius * scale * 1.5;
|
|
11352
11636
|
}
|
|
11353
11637
|
function maxBubbleSize(sizes) {
|
|
@@ -11453,10 +11737,10 @@ function squarify(nodes, box) {
|
|
|
11453
11737
|
|
|
11454
11738
|
// chart/hierarchy.ts
|
|
11455
11739
|
function normalizeLevels(levels, pointCount) {
|
|
11456
|
-
return levels.map((
|
|
11740
|
+
return levels.map((level2) => {
|
|
11457
11741
|
let previous = "";
|
|
11458
11742
|
return Array.from({ length: pointCount }, (_, index) => {
|
|
11459
|
-
const label =
|
|
11743
|
+
const label = level2[index]?.trim() ?? "";
|
|
11460
11744
|
if (label) previous = label;
|
|
11461
11745
|
return label || previous;
|
|
11462
11746
|
});
|
|
@@ -11614,12 +11898,12 @@ function computeSunburstArcs(series, cx, cy, maxR) {
|
|
|
11614
11898
|
});
|
|
11615
11899
|
return out;
|
|
11616
11900
|
}
|
|
11617
|
-
function hierarchyKey(levels,
|
|
11618
|
-
return levels.slice(
|
|
11901
|
+
function hierarchyKey(levels, level2, index) {
|
|
11902
|
+
return levels.slice(level2).map((labels) => labels[index] ?? "").join("\0");
|
|
11619
11903
|
}
|
|
11620
11904
|
function computeHierarchicalSunburstArcs(categoryLevels, values, cx, cy, maxR) {
|
|
11621
|
-
const levels = categoryLevels.filter((
|
|
11622
|
-
const leafCount = Math.max(values.length, ...levels.map((
|
|
11905
|
+
const levels = categoryLevels.filter((level2) => level2.length > 0);
|
|
11906
|
+
const leafCount = Math.max(values.length, ...levels.map((level2) => level2.length), 0);
|
|
11623
11907
|
if (levels.length === 0 || leafCount === 0) return [];
|
|
11624
11908
|
const rawWeights = Array.from({ length: leafCount }, (_, index) => Math.abs(values[index] ?? 0));
|
|
11625
11909
|
const weights = rawWeights.some((value) => value !== 0) ? rawWeights : rawWeights.map(() => 1);
|
|
@@ -11630,15 +11914,15 @@ function computeHierarchicalSunburstArcs(categoryLevels, values, cx, cy, maxR) {
|
|
|
11630
11914
|
const rootLabels = levels[levels.length - 1] ?? [];
|
|
11631
11915
|
const rootColors = /* @__PURE__ */ new Map();
|
|
11632
11916
|
const out = [];
|
|
11633
|
-
for (let
|
|
11634
|
-
const ringIndex = levels.length - 1 -
|
|
11917
|
+
for (let level2 = levels.length - 1; level2 >= 0; level2--) {
|
|
11918
|
+
const ringIndex = levels.length - 1 - level2;
|
|
11635
11919
|
const innerRadius = ringWidth * (ringIndex + 0.5);
|
|
11636
11920
|
const outerRadius = ringWidth * (ringIndex + 1.5);
|
|
11637
11921
|
let start = 0;
|
|
11638
11922
|
while (start < leafCount) {
|
|
11639
|
-
const key = hierarchyKey(levels,
|
|
11923
|
+
const key = hierarchyKey(levels, level2, start);
|
|
11640
11924
|
let end = start + 1;
|
|
11641
|
-
while (end < leafCount && hierarchyKey(levels,
|
|
11925
|
+
while (end < leafCount && hierarchyKey(levels, level2, end) === key) end++;
|
|
11642
11926
|
const startAngle = -Math.PI / 2 + (prefix2[start] ?? 0) / total * Math.PI * 2;
|
|
11643
11927
|
const endAngle = -Math.PI / 2 + (prefix2[end] ?? 0) / total * Math.PI * 2;
|
|
11644
11928
|
const rootLabel = rootLabels[start] ?? "";
|
|
@@ -11648,8 +11932,8 @@ function computeHierarchicalSunburstArcs(categoryLevels, values, cx, cy, maxR) {
|
|
|
11648
11932
|
colorIndex: rootColors.get(rootLabel) ?? start,
|
|
11649
11933
|
opacity: Math.max(0.1, 0.9 - ringIndex * 0.1),
|
|
11650
11934
|
level: ringIndex,
|
|
11651
|
-
label: levels[
|
|
11652
|
-
...
|
|
11935
|
+
label: levels[level2]?.[start] ?? "",
|
|
11936
|
+
...level2 === 0 && end === start + 1 ? { pointIndex: start } : {},
|
|
11653
11937
|
...arcLabelPlacement(cx, cy, (innerRadius + outerRadius) / 2, startAngle, endAngle)
|
|
11654
11938
|
});
|
|
11655
11939
|
start = end;
|
|
@@ -11675,14 +11959,14 @@ function scottBinCount(values, min, max) {
|
|
|
11675
11959
|
const width = 3.49 * sd * values.length ** (-1 / 3);
|
|
11676
11960
|
return Math.max(1, Math.ceil((max - min) / width));
|
|
11677
11961
|
}
|
|
11678
|
-
function computeHistogramBins(values,
|
|
11679
|
-
const closed =
|
|
11962
|
+
function computeHistogramBins(values, options2, format = String) {
|
|
11963
|
+
const closed = options2.intervalClosed ?? "l";
|
|
11680
11964
|
const finite2 = values.map((value, sourceIndex) => ({ value, sourceIndex })).filter((item) => Number.isFinite(item.value));
|
|
11681
11965
|
if (finite2.length === 0) {
|
|
11682
11966
|
return [];
|
|
11683
11967
|
}
|
|
11684
|
-
const underflow = typeof
|
|
11685
|
-
const overflow = typeof
|
|
11968
|
+
const underflow = typeof options2.underflow === "number" ? options2.underflow : void 0;
|
|
11969
|
+
const overflow = typeof options2.overflow === "number" ? options2.overflow : void 0;
|
|
11686
11970
|
const under = underflow === void 0 ? [] : finite2.filter(
|
|
11687
11971
|
(item) => closed === "r" ? item.value <= underflow : item.value < underflow
|
|
11688
11972
|
);
|
|
@@ -11699,8 +11983,8 @@ function computeHistogramBins(values, options, format = String) {
|
|
|
11699
11983
|
if (regular.length > 0) {
|
|
11700
11984
|
const min = Math.min(...regular.map((item) => item.value));
|
|
11701
11985
|
const max = Math.max(...regular.map((item) => item.value));
|
|
11702
|
-
const requestedSize =
|
|
11703
|
-
const requestedCount =
|
|
11986
|
+
const requestedSize = options2.binSize && options2.binSize > 0 ? options2.binSize : void 0;
|
|
11987
|
+
const requestedCount = options2.binCount && options2.binCount > 0 ? options2.binCount : void 0;
|
|
11704
11988
|
const start = requestedSize ? Math.floor(min / requestedSize) * requestedSize : min;
|
|
11705
11989
|
const count = requestedSize ? Math.max(
|
|
11706
11990
|
closed === "l" ? Math.floor((max - start) / requestedSize) + 1 : Math.ceil((max - start) / requestedSize),
|
|
@@ -11751,9 +12035,9 @@ function aggregateByCategory(values, rawCategories) {
|
|
|
11751
12035
|
}
|
|
11752
12036
|
|
|
11753
12037
|
// chart/waterfall.ts
|
|
11754
|
-
function buildWaterfallSteps(values,
|
|
12038
|
+
function buildWaterfallSteps(values, options2) {
|
|
11755
12039
|
const subtotalIndices = new Set(
|
|
11756
|
-
|
|
12040
|
+
options2?.subtotalIndices ?? (values.length > 0 ? [values.length - 1] : [])
|
|
11757
12041
|
);
|
|
11758
12042
|
const steps = [];
|
|
11759
12043
|
let runningTotal = 0;
|
|
@@ -11813,13 +12097,13 @@ var noFit = () => ({
|
|
|
11813
12097
|
rSquared: 0,
|
|
11814
12098
|
coefficients: []
|
|
11815
12099
|
});
|
|
11816
|
-
function fitModel(
|
|
12100
|
+
function fitModel(options2, xVals, yVals) {
|
|
11817
12101
|
const xs = [...xVals];
|
|
11818
12102
|
const ys = [...yVals];
|
|
11819
|
-
switch (
|
|
12103
|
+
switch (options2.kind) {
|
|
11820
12104
|
case "linear": {
|
|
11821
12105
|
const reg = computeLinearRegression(xs, ys);
|
|
11822
|
-
const fixed =
|
|
12106
|
+
const fixed = options2.intercept;
|
|
11823
12107
|
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;
|
|
11824
12108
|
const b = fixed ?? reg.intercept;
|
|
11825
12109
|
return {
|
|
@@ -11869,7 +12153,7 @@ function fitModel(options, xVals, yVals) {
|
|
|
11869
12153
|
};
|
|
11870
12154
|
}
|
|
11871
12155
|
case "polynomial": {
|
|
11872
|
-
const order = Math.min(
|
|
12156
|
+
const order = Math.min(options2.order ?? 2, 6);
|
|
11873
12157
|
const coeffs = fitPolynomial(xs, ys, order);
|
|
11874
12158
|
const evaluate = (x) => coeffs.reduce((s, c, i) => s + c * x ** i, 0);
|
|
11875
12159
|
return {
|
|
@@ -11883,11 +12167,11 @@ function fitModel(options, xVals, yVals) {
|
|
|
11883
12167
|
return void 0;
|
|
11884
12168
|
}
|
|
11885
12169
|
}
|
|
11886
|
-
function fitChartTrendline(
|
|
12170
|
+
function fitChartTrendline(options2, xVals, yVals) {
|
|
11887
12171
|
const count = yVals.length;
|
|
11888
12172
|
if (count < 2) return noFit();
|
|
11889
|
-
if (
|
|
11890
|
-
const period =
|
|
12173
|
+
if (options2.kind === "movingAvg") {
|
|
12174
|
+
const period = options2.period ?? 2;
|
|
11891
12175
|
const points2 = [];
|
|
11892
12176
|
for (let i = period - 1; i < count; i++) {
|
|
11893
12177
|
let sum = 0;
|
|
@@ -11896,10 +12180,10 @@ function fitChartTrendline(options, xVals, yVals) {
|
|
|
11896
12180
|
}
|
|
11897
12181
|
return { points: points2, equation: `${period}-period moving average`, rSquared: 0, coefficients: [] };
|
|
11898
12182
|
}
|
|
11899
|
-
const model = fitModel(
|
|
12183
|
+
const model = fitModel(options2, xVals, yVals);
|
|
11900
12184
|
if (!model) return noFit();
|
|
11901
|
-
const startX = Math.min(...xVals) - (
|
|
11902
|
-
const endX = Math.max(...xVals) + (
|
|
12185
|
+
const startX = Math.min(...xVals) - (options2.backward ?? 0);
|
|
12186
|
+
const endX = Math.max(...xVals) + (options2.forward ?? 0);
|
|
11903
12187
|
const steps = Math.max(Math.ceil((endX - startX) * 4), 20);
|
|
11904
12188
|
const points = [];
|
|
11905
12189
|
for (let step = 0; step <= steps; step++) {
|
|
@@ -11922,19 +12206,78 @@ function chartSampleVariance(values) {
|
|
|
11922
12206
|
const mean = values.reduce((sum, value) => sum + value, 0) / count;
|
|
11923
12207
|
return values.reduce((sum, value) => sum + (value - mean) ** 2, 0) / Math.max(count - 1, 1);
|
|
11924
12208
|
}
|
|
11925
|
-
function chartErrorBarAmount(
|
|
11926
|
-
switch (
|
|
12209
|
+
function chartErrorBarAmount(options2, values, displayIndex, sourceIndex, side) {
|
|
12210
|
+
switch (options2.valueType) {
|
|
11927
12211
|
case "fixedVal":
|
|
11928
|
-
return
|
|
12212
|
+
return options2.value ?? 0;
|
|
11929
12213
|
case "percentage":
|
|
11930
|
-
return Math.abs(values[displayIndex] ?? 0) * ((
|
|
12214
|
+
return Math.abs(values[displayIndex] ?? 0) * ((options2.value ?? 0) / 100);
|
|
11931
12215
|
case "stdDev":
|
|
11932
|
-
return Math.sqrt(chartSampleVariance(values)) * (
|
|
12216
|
+
return Math.sqrt(chartSampleVariance(values)) * (options2.value ?? 1);
|
|
11933
12217
|
case "stdErr":
|
|
11934
12218
|
return Math.sqrt(chartSampleVariance(values) / Math.max(values.length, 1));
|
|
11935
12219
|
case "cust":
|
|
11936
|
-
return side === "plus" ?
|
|
12220
|
+
return side === "plus" ? options2.customPlus?.[sourceIndex] ?? 0 : options2.customMinus?.[sourceIndex] ?? 0;
|
|
12221
|
+
}
|
|
12222
|
+
}
|
|
12223
|
+
|
|
12224
|
+
// chart/pie-best-fit.ts
|
|
12225
|
+
var PX_PER_PT = 4 / 3;
|
|
12226
|
+
var BEST_FIT_RIM_INSET = 4 * PX_PER_PT;
|
|
12227
|
+
var BEST_FIT_EDGE_TOLERANCE = 1.5 * PX_PER_PT;
|
|
12228
|
+
var BEST_FIT_OUTSIDE_GAP = 2 * PX_PER_PT;
|
|
12229
|
+
function farCorner(x, y, w, h) {
|
|
12230
|
+
return Math.hypot(Math.abs(x) + w / 2, Math.abs(y) + h / 2);
|
|
12231
|
+
}
|
|
12232
|
+
function insideDistance(ux, uy, w, h, limit) {
|
|
12233
|
+
if (farCorner(0, 0, w, h) > limit) {
|
|
12234
|
+
return void 0;
|
|
11937
12235
|
}
|
|
12236
|
+
let lo = 0;
|
|
12237
|
+
let hi = limit;
|
|
12238
|
+
for (let i = 0; i < 40; i++) {
|
|
12239
|
+
const mid = (lo + hi) / 2;
|
|
12240
|
+
if (farCorner(mid * ux, mid * uy, w, h) > limit) {
|
|
12241
|
+
hi = mid;
|
|
12242
|
+
} else {
|
|
12243
|
+
lo = mid;
|
|
12244
|
+
}
|
|
12245
|
+
}
|
|
12246
|
+
return lo;
|
|
12247
|
+
}
|
|
12248
|
+
function edgeOverhang(x, y, w, h, slice) {
|
|
12249
|
+
let worst = Number.NEGATIVE_INFINITY;
|
|
12250
|
+
const corners = [
|
|
12251
|
+
[-w / 2, -h / 2],
|
|
12252
|
+
[w / 2, -h / 2],
|
|
12253
|
+
[-w / 2, h / 2],
|
|
12254
|
+
[w / 2, h / 2]
|
|
12255
|
+
];
|
|
12256
|
+
for (const [dx, dy] of corners) {
|
|
12257
|
+
const px = x + dx;
|
|
12258
|
+
const py = y + dy;
|
|
12259
|
+
const fromStart = Math.cos(slice.startAngle) * py - Math.sin(slice.startAngle) * px;
|
|
12260
|
+
const fromEnd = Math.sin(slice.endAngle) * px - Math.cos(slice.endAngle) * py;
|
|
12261
|
+
worst = Math.max(worst, -fromStart, -fromEnd);
|
|
12262
|
+
}
|
|
12263
|
+
return worst;
|
|
12264
|
+
}
|
|
12265
|
+
function placeBestFitLabel(slice, w, h) {
|
|
12266
|
+
const mid = (slice.startAngle + slice.endAngle) / 2;
|
|
12267
|
+
const ux = Math.cos(mid);
|
|
12268
|
+
const uy = Math.sin(mid);
|
|
12269
|
+
const distance = insideDistance(ux, uy, w, h, slice.outerR - BEST_FIT_RIM_INSET);
|
|
12270
|
+
if (distance !== void 0) {
|
|
12271
|
+
const x = distance * ux;
|
|
12272
|
+
const y = distance * uy;
|
|
12273
|
+
const reflex = slice.endAngle - slice.startAngle >= Math.PI;
|
|
12274
|
+
if (reflex || edgeOverhang(x, y, w, h, slice) <= BEST_FIT_EDGE_TOLERANCE) {
|
|
12275
|
+
return { x: slice.cx + x, y: slice.cy + y, inside: true };
|
|
12276
|
+
}
|
|
12277
|
+
}
|
|
12278
|
+
const extent = Math.abs(ux) * w / 2 + Math.abs(uy) * h / 2;
|
|
12279
|
+
const outside = slice.outerR + BEST_FIT_OUTSIDE_GAP + extent;
|
|
12280
|
+
return { x: slice.cx + outside * ux, y: slice.cy + outside * uy, inside: false };
|
|
11938
12281
|
}
|
|
11939
12282
|
|
|
11940
12283
|
// chart/color-palettes.ts
|
|
@@ -12250,6 +12593,191 @@ function chartCacheValues(cache2) {
|
|
|
12250
12593
|
}
|
|
12251
12594
|
var chartSourceValues = (source) => chartCacheValues(source?.cache ?? source?.levels?.[0]);
|
|
12252
12595
|
|
|
12596
|
+
// chart/marker-shape.ts
|
|
12597
|
+
var CHART_PX_PER_PT = 4 / 3;
|
|
12598
|
+
var DEFAULT_MARKER_OUTLINE_PT = 0.75;
|
|
12599
|
+
var AUTOMATIC_MARKER_CYCLE = [
|
|
12600
|
+
"diamond",
|
|
12601
|
+
"square",
|
|
12602
|
+
"triangle",
|
|
12603
|
+
"x",
|
|
12604
|
+
"star",
|
|
12605
|
+
"circle",
|
|
12606
|
+
"plus",
|
|
12607
|
+
"dot",
|
|
12608
|
+
"dash"
|
|
12609
|
+
];
|
|
12610
|
+
function automaticMarkerSymbol(seriesIdx) {
|
|
12611
|
+
const length = AUTOMATIC_MARKER_CYCLE.length;
|
|
12612
|
+
const normalized = (Math.trunc(seriesIdx) % length + length) % length;
|
|
12613
|
+
return AUTOMATIC_MARKER_CYCLE[Number.isFinite(normalized) ? normalized : 0];
|
|
12614
|
+
}
|
|
12615
|
+
function markerRadius(size, defaultRadius) {
|
|
12616
|
+
if (size === void 0 || !Number.isFinite(size) || size <= 0) {
|
|
12617
|
+
return defaultRadius;
|
|
12618
|
+
}
|
|
12619
|
+
return size / 2;
|
|
12620
|
+
}
|
|
12621
|
+
function polygonPoints(vertices) {
|
|
12622
|
+
return vertices.map(([x, y]) => `${x.toFixed(2)},${y.toFixed(2)}`).join(" ");
|
|
12623
|
+
}
|
|
12624
|
+
function starVertices(cx, cy, r) {
|
|
12625
|
+
const inner = r * 0.5;
|
|
12626
|
+
const out = [];
|
|
12627
|
+
for (let i = 0; i < 10; i++) {
|
|
12628
|
+
const radius = i % 2 === 0 ? r : inner;
|
|
12629
|
+
const angle = -Math.PI / 2 + Math.PI * i / 5;
|
|
12630
|
+
out.push([cx + radius * Math.cos(angle), cy + radius * Math.sin(angle)]);
|
|
12631
|
+
}
|
|
12632
|
+
return out;
|
|
12633
|
+
}
|
|
12634
|
+
function rectPolygon(x, y, w, h) {
|
|
12635
|
+
return polygonPoints([
|
|
12636
|
+
[x, y],
|
|
12637
|
+
[x + w, y],
|
|
12638
|
+
[x + w, y + h],
|
|
12639
|
+
[x, y + h]
|
|
12640
|
+
]);
|
|
12641
|
+
}
|
|
12642
|
+
function buildMarkerPrimitive(input) {
|
|
12643
|
+
const { symbol, cx, cy, fill } = input;
|
|
12644
|
+
const part = input.part === void 0 ? {} : { part: input.part };
|
|
12645
|
+
if (symbol === "none") {
|
|
12646
|
+
return null;
|
|
12647
|
+
}
|
|
12648
|
+
const r = markerRadius(input.size, input.defaultRadius);
|
|
12649
|
+
const outline = input.stroke ? {
|
|
12650
|
+
stroke: input.stroke,
|
|
12651
|
+
strokeWidth: input.strokeWidth ?? DEFAULT_MARKER_OUTLINE_PT * CHART_PX_PER_PT
|
|
12652
|
+
} : void 0;
|
|
12653
|
+
const polygonStroke = outline ?? { stroke: fill, strokeWidth: 0 };
|
|
12654
|
+
const lineStroke = input.stroke ?? fill;
|
|
12655
|
+
switch (symbol) {
|
|
12656
|
+
case "square":
|
|
12657
|
+
case "dash": {
|
|
12658
|
+
const h = symbol === "dash" ? r * 0.64 : r * 2;
|
|
12659
|
+
const y = cy - h / 2;
|
|
12660
|
+
if (outline) {
|
|
12661
|
+
return {
|
|
12662
|
+
kind: "polygon",
|
|
12663
|
+
points: rectPolygon(cx - r, y, r * 2, h),
|
|
12664
|
+
fill,
|
|
12665
|
+
...outline,
|
|
12666
|
+
...part
|
|
12667
|
+
};
|
|
12668
|
+
}
|
|
12669
|
+
return { kind: "rect", x: cx - r, y, w: r * 2, h, fill, ...part };
|
|
12670
|
+
}
|
|
12671
|
+
case "diamond":
|
|
12672
|
+
return {
|
|
12673
|
+
kind: "polygon",
|
|
12674
|
+
points: polygonPoints([
|
|
12675
|
+
[cx, cy - r],
|
|
12676
|
+
[cx + r, cy],
|
|
12677
|
+
[cx, cy + r],
|
|
12678
|
+
[cx - r, cy]
|
|
12679
|
+
]),
|
|
12680
|
+
fill,
|
|
12681
|
+
...polygonStroke,
|
|
12682
|
+
...part
|
|
12683
|
+
};
|
|
12684
|
+
case "triangle":
|
|
12685
|
+
return {
|
|
12686
|
+
kind: "polygon",
|
|
12687
|
+
points: polygonPoints([
|
|
12688
|
+
[cx, cy - r],
|
|
12689
|
+
[cx + r * 0.9, cy + r * 0.75],
|
|
12690
|
+
[cx - r * 0.9, cy + r * 0.75]
|
|
12691
|
+
]),
|
|
12692
|
+
fill,
|
|
12693
|
+
...polygonStroke,
|
|
12694
|
+
...part
|
|
12695
|
+
};
|
|
12696
|
+
case "star":
|
|
12697
|
+
return {
|
|
12698
|
+
kind: "polygon",
|
|
12699
|
+
points: polygonPoints(starVertices(cx, cy, r)),
|
|
12700
|
+
fill,
|
|
12701
|
+
...polygonStroke,
|
|
12702
|
+
...part
|
|
12703
|
+
};
|
|
12704
|
+
case "plus":
|
|
12705
|
+
return {
|
|
12706
|
+
kind: "path",
|
|
12707
|
+
d: `M${(cx - r).toFixed(2)},${cy.toFixed(2)} L${(cx + r).toFixed(2)},${cy.toFixed(2)} M${cx.toFixed(2)},${(cy - r).toFixed(2)} L${cx.toFixed(2)},${(cy + r).toFixed(2)}`,
|
|
12708
|
+
fill: "none",
|
|
12709
|
+
stroke: lineStroke,
|
|
12710
|
+
strokeWidth: Math.max(1, r * 0.4),
|
|
12711
|
+
...part
|
|
12712
|
+
};
|
|
12713
|
+
case "x":
|
|
12714
|
+
return {
|
|
12715
|
+
kind: "path",
|
|
12716
|
+
d: `M${(cx - r).toFixed(2)},${(cy - r).toFixed(2)} L${(cx + r).toFixed(2)},${(cy + r).toFixed(2)} M${(cx + r).toFixed(2)},${(cy - r).toFixed(2)} L${(cx - r).toFixed(2)},${(cy + r).toFixed(2)}`,
|
|
12717
|
+
fill: "none",
|
|
12718
|
+
stroke: lineStroke,
|
|
12719
|
+
strokeWidth: Math.max(1, r * 0.4),
|
|
12720
|
+
...part
|
|
12721
|
+
};
|
|
12722
|
+
case "dot":
|
|
12723
|
+
return { kind: "circle", cx, cy, r: Math.max(r * 0.6, 1), fill, ...part, ...outline };
|
|
12724
|
+
default:
|
|
12725
|
+
return { kind: "circle", cx, cy, r, fill, ...part, ...outline };
|
|
12726
|
+
}
|
|
12727
|
+
}
|
|
12728
|
+
|
|
12729
|
+
// chart/render/chart-view-markers.ts
|
|
12730
|
+
function summaryMarkers(source, group2, seriesPosition) {
|
|
12731
|
+
if (!["line", "scatter", "radar"].includes(group2.kind)) return {};
|
|
12732
|
+
const enabled = group2.kind === "line" ? group2.marker === true : group2.kind === "radar" ? group2.radarStyle === "marker" : !["line", "smooth", "none"].includes(group2.scatterStyle ?? "marker");
|
|
12733
|
+
const symbol = source.marker?.symbol;
|
|
12734
|
+
const marker = {
|
|
12735
|
+
...source.marker,
|
|
12736
|
+
symbol: symbol && symbol !== "auto" ? symbol : source.marker || enabled ? automaticMarkerSymbol(source.index ?? seriesPosition) : "none"
|
|
12737
|
+
};
|
|
12738
|
+
const pointMarkers = {};
|
|
12739
|
+
for (const point of source.dataPoints) {
|
|
12740
|
+
if (point.index === void 0 || !point.marker) continue;
|
|
12741
|
+
const override = point.marker;
|
|
12742
|
+
pointMarkers[point.index] = {
|
|
12743
|
+
...marker,
|
|
12744
|
+
...override,
|
|
12745
|
+
...override.symbol === "auto" || !source.marker && override.symbol === void 0 ? { symbol: automaticMarkerSymbol(source.index ?? seriesPosition) } : {},
|
|
12746
|
+
...marker.spPr || override.spPr ? {
|
|
12747
|
+
spPr: {
|
|
12748
|
+
...marker.spPr,
|
|
12749
|
+
...override.spPr,
|
|
12750
|
+
...marker.spPr?.line || override.spPr?.line ? { line: { ...marker.spPr?.line, ...override.spPr?.line } } : {}
|
|
12751
|
+
}
|
|
12752
|
+
} : {}
|
|
12753
|
+
};
|
|
12754
|
+
}
|
|
12755
|
+
return { marker, ...Object.keys(pointMarkers).length ? { pointMarkers } : {} };
|
|
12756
|
+
}
|
|
12757
|
+
function seriesMarkerViews(source, drawingColor) {
|
|
12758
|
+
const fillColor = (fill) => fill?.kind === "none" ? "none" : fill?.kind === "solid" ? drawingColor(fill.color) : void 0;
|
|
12759
|
+
const resolve = (marker) => {
|
|
12760
|
+
const fill = fillColor(marker.spPr?.fill);
|
|
12761
|
+
const stroke = fillColor(marker.spPr?.line?.fill);
|
|
12762
|
+
const width = marker.spPr?.line?.widthEmu;
|
|
12763
|
+
return {
|
|
12764
|
+
...marker.symbol !== void 0 ? { symbol: marker.symbol } : {},
|
|
12765
|
+
...marker.size !== void 0 ? { size: marker.size } : {},
|
|
12766
|
+
...fill !== void 0 ? { fill } : {},
|
|
12767
|
+
...stroke !== void 0 ? { stroke } : {},
|
|
12768
|
+
...width !== void 0 ? { strokeWidth: width / 9525 } : {}
|
|
12769
|
+
};
|
|
12770
|
+
};
|
|
12771
|
+
return {
|
|
12772
|
+
...source.marker ? { marker: resolve(source.marker) } : {},
|
|
12773
|
+
...source.pointMarkers ? {
|
|
12774
|
+
pointMarkers: Object.fromEntries(
|
|
12775
|
+
Object.entries(source.pointMarkers).map(([i, marker]) => [i, resolve(marker)])
|
|
12776
|
+
)
|
|
12777
|
+
} : {}
|
|
12778
|
+
};
|
|
12779
|
+
}
|
|
12780
|
+
|
|
12253
12781
|
// chart/render/summary-analysis.ts
|
|
12254
12782
|
function summaryTrendline(source) {
|
|
12255
12783
|
const kind = chartTrendlineKind(source.trendlineType);
|
|
@@ -12290,6 +12818,41 @@ function summaryAnalysis(series) {
|
|
|
12290
12818
|
};
|
|
12291
12819
|
}
|
|
12292
12820
|
|
|
12821
|
+
// chart/render/summary-labels.ts
|
|
12822
|
+
function level(options2, custom) {
|
|
12823
|
+
const out = {};
|
|
12824
|
+
if (options2.deleted !== void 0) out.deleted = options2.deleted;
|
|
12825
|
+
if (options2.showValue !== void 0) out.showValue = options2.showValue;
|
|
12826
|
+
if (options2.showCategoryName !== void 0) out.showCategory = options2.showCategoryName;
|
|
12827
|
+
if (options2.showSeriesName !== void 0) out.showSeriesName = options2.showSeriesName;
|
|
12828
|
+
if (options2.showPercent !== void 0) out.showPercent = options2.showPercent;
|
|
12829
|
+
if (options2.showBubbleSize !== void 0) out.showBubbleSize = options2.showBubbleSize;
|
|
12830
|
+
if (options2.separator !== void 0) out.separator = options2.separator;
|
|
12831
|
+
if (options2.position) out.position = options2.position;
|
|
12832
|
+
if (options2.numberFormat?.formatCode) out.numberFormat = options2.numberFormat.formatCode;
|
|
12833
|
+
if (custom?.text !== void 0) out.text = custom.text;
|
|
12834
|
+
return out;
|
|
12835
|
+
}
|
|
12836
|
+
function shows(levels, point) {
|
|
12837
|
+
const flags = resolveDataLabelFlags({ ...levels, ...point ? { point } : {} });
|
|
12838
|
+
return point?.text !== void 0 || Object.values(flags).some((value) => value === true);
|
|
12839
|
+
}
|
|
12840
|
+
function summaryDataLabels(series, group2) {
|
|
12841
|
+
const own2 = series.dataLabels;
|
|
12842
|
+
if (!own2 && !group2) return void 0;
|
|
12843
|
+
const out = {};
|
|
12844
|
+
if (group2) out.chart = level(group2);
|
|
12845
|
+
if (own2) out.series = level(own2);
|
|
12846
|
+
const points = {};
|
|
12847
|
+
for (const labels of [group2, own2])
|
|
12848
|
+
for (const label of labels?.labels ?? [])
|
|
12849
|
+
if (label.index !== void 0)
|
|
12850
|
+
points[label.index] = { ...points[label.index], ...level(label, label.tx) };
|
|
12851
|
+
if (Object.keys(points).length) out.points = points;
|
|
12852
|
+
if (!shows(out) && !Object.values(points).some((point) => shows(out, point))) return void 0;
|
|
12853
|
+
return out;
|
|
12854
|
+
}
|
|
12855
|
+
|
|
12293
12856
|
// chart/render/summary-from-space.ts
|
|
12294
12857
|
var solidColor = (fill) => fill?.kind === "solid" ? fill.color : void 0;
|
|
12295
12858
|
var isSolidFill = (fill) => fill?.kind === "solid" || fill?.kind === "unsupported" && fill.element === "solidFill";
|
|
@@ -12307,7 +12870,7 @@ var GROUP_TYPES = {
|
|
|
12307
12870
|
surface: "surface"
|
|
12308
12871
|
};
|
|
12309
12872
|
var GROUPINGS = /* @__PURE__ */ new Set(["clustered", "stacked", "percentStacked", "standard"]);
|
|
12310
|
-
function chartSummarySeries(source, chartType) {
|
|
12873
|
+
function chartSummarySeries(source, chartType, groupLabels) {
|
|
12311
12874
|
const categories = source.categories ?? source.xValues;
|
|
12312
12875
|
const values = source.values ?? source.yValues;
|
|
12313
12876
|
const numeric = (v) => typeof v === "number" ? v : v === "" ? null : Number.isFinite(Number(v)) ? Number(v) : null;
|
|
@@ -12315,6 +12878,7 @@ function chartSummarySeries(source, chartType) {
|
|
|
12315
12878
|
categories: chartSourceValues(categories),
|
|
12316
12879
|
values: chartSourceValues(values).map(numeric)
|
|
12317
12880
|
};
|
|
12881
|
+
if (values?.cache?.formatCode !== void 0) out.numberFormat = values.cache.formatCode;
|
|
12318
12882
|
if (source.bubbleSizes) {
|
|
12319
12883
|
out.bubbleSizes = chartSourceValues(source.bubbleSizes).map(numeric);
|
|
12320
12884
|
if (source.bubbleSizes.formula) out.bubbleSizesRef = source.bubbleSizes.formula;
|
|
@@ -12343,6 +12907,8 @@ function chartSummarySeries(source, chartType) {
|
|
|
12343
12907
|
}
|
|
12344
12908
|
if (Object.keys(points).length) out.pointColors = points;
|
|
12345
12909
|
if (Object.keys(pointFills).length) out.pointFills = pointFills;
|
|
12910
|
+
const dataLabels = summaryDataLabels(source, groupLabels);
|
|
12911
|
+
if (dataLabels) out.dataLabels = dataLabels;
|
|
12346
12912
|
Object.assign(out, summaryAnalysis(source));
|
|
12347
12913
|
return out;
|
|
12348
12914
|
}
|
|
@@ -12351,12 +12917,12 @@ function valueAxisId(chartSpace, axisIds) {
|
|
|
12351
12917
|
(id) => chartSpace.plotArea.axes.some((a) => a.id === id && a.kind === "val")
|
|
12352
12918
|
);
|
|
12353
12919
|
}
|
|
12354
|
-
function stockStyle(
|
|
12920
|
+
function stockStyle(group2) {
|
|
12355
12921
|
return {
|
|
12356
|
-
...
|
|
12357
|
-
...
|
|
12358
|
-
...
|
|
12359
|
-
...
|
|
12922
|
+
...group2.hiLowLinesSpPr ? { hiLowLines: group2.hiLowLinesSpPr } : {},
|
|
12923
|
+
...group2.upBars?.spPr ? { upBars: group2.upBars.spPr } : {},
|
|
12924
|
+
...group2.downBars?.spPr ? { downBars: group2.downBars.spPr } : {},
|
|
12925
|
+
...group2.upDownBarsGapWidth === void 0 ? {} : { gapWidth: group2.upDownBarsGapWidth }
|
|
12360
12926
|
};
|
|
12361
12927
|
}
|
|
12362
12928
|
function extraGroups(chartSpace, firstType) {
|
|
@@ -12364,54 +12930,62 @@ function extraGroups(chartSpace, firstType) {
|
|
|
12364
12930
|
if (!first3 || !["column", "line", "area"].includes(firstType)) return [];
|
|
12365
12931
|
const primary = valueAxisId(chartSpace, first3.axisIds);
|
|
12366
12932
|
const out = [];
|
|
12367
|
-
for (const
|
|
12368
|
-
const stockOverColumns =
|
|
12369
|
-
if (
|
|
12370
|
-
const type =
|
|
12933
|
+
for (const group2 of rest) {
|
|
12934
|
+
const stockOverColumns = group2.kind === "stock" && firstType === "column";
|
|
12935
|
+
if (group2.is3D || !(["bar", "line", "area"].includes(group2.kind) || stockOverColumns)) continue;
|
|
12936
|
+
const type = group2.kind === "bar" ? "column" : group2.kind;
|
|
12371
12937
|
const entry = {
|
|
12372
12938
|
chartType: type,
|
|
12373
|
-
series:
|
|
12374
|
-
|
|
12939
|
+
series: group2.series.map((source, index) => ({
|
|
12940
|
+
...chartSummarySeries(source, type, group2.dataLabels),
|
|
12941
|
+
...summaryMarkers(source, group2, index)
|
|
12942
|
+
})),
|
|
12943
|
+
secondary: valueAxisId(chartSpace, group2.axisIds) !== primary
|
|
12375
12944
|
};
|
|
12376
|
-
if (
|
|
12377
|
-
entry.grouping =
|
|
12378
|
-
if (type === "stock") entry.stock = stockStyle(
|
|
12945
|
+
if (group2.grouping && GROUPINGS.has(group2.grouping))
|
|
12946
|
+
entry.grouping = group2.grouping;
|
|
12947
|
+
if (type === "stock") entry.stock = stockStyle(group2);
|
|
12379
12948
|
if (type === "column") {
|
|
12380
|
-
if (
|
|
12381
|
-
if (
|
|
12949
|
+
if (group2.gapWidth !== void 0) entry.barGapWidth = group2.gapWidth;
|
|
12950
|
+
if (group2.overlap !== void 0) entry.barOverlap = group2.overlap;
|
|
12382
12951
|
}
|
|
12383
12952
|
if (entry.series.length) out.push(entry);
|
|
12384
12953
|
}
|
|
12385
12954
|
return out;
|
|
12386
12955
|
}
|
|
12387
12956
|
function chartSummaryFromSpace(chartSpace, extras = {}) {
|
|
12388
|
-
const
|
|
12389
|
-
let chartType =
|
|
12390
|
-
if (chartType === "bar" &&
|
|
12391
|
-
const series = (
|
|
12957
|
+
const group2 = chartSpace.plotArea.groups[0];
|
|
12958
|
+
let chartType = group2 ? GROUP_TYPES[group2.kind] : "column";
|
|
12959
|
+
if (chartType === "bar" && group2?.barDirection !== "bar") chartType = "column";
|
|
12960
|
+
const series = (group2?.series ?? []).map((source, index) => ({
|
|
12961
|
+
...chartSummarySeries(source, chartType, group2?.dataLabels),
|
|
12962
|
+
...group2 ? summaryMarkers(source, group2, index) : {}
|
|
12963
|
+
}));
|
|
12392
12964
|
const summary = {
|
|
12393
12965
|
chartType,
|
|
12394
12966
|
series,
|
|
12395
|
-
showLegend: chartSpace.legend !== void 0
|
|
12967
|
+
showLegend: chartSpace.legend !== void 0,
|
|
12968
|
+
axes: chartSpace.plotArea.axes,
|
|
12969
|
+
axisIds: group2?.axisIds ?? []
|
|
12396
12970
|
};
|
|
12397
12971
|
const combined = extraGroups(chartSpace, chartType);
|
|
12398
12972
|
if (combined.length) summary.extraGroups = combined;
|
|
12399
|
-
if (chartType === "stock" &&
|
|
12400
|
-
if (chartType === "bubble" &&
|
|
12401
|
-
const sizeRepresents =
|
|
12973
|
+
if (chartType === "stock" && group2) summary.stock = stockStyle(group2);
|
|
12974
|
+
if (chartType === "bubble" && group2) {
|
|
12975
|
+
const sizeRepresents = group2.sizeRepresents === "w" ? "w" : "area";
|
|
12402
12976
|
summary.bubble = {
|
|
12403
12977
|
sizeRepresents,
|
|
12404
|
-
...
|
|
12405
|
-
showNegativeBubbles:
|
|
12978
|
+
...group2.bubbleScale === void 0 ? {} : { bubbleScale: group2.bubbleScale },
|
|
12979
|
+
showNegativeBubbles: group2.showNegativeBubbles === true
|
|
12406
12980
|
};
|
|
12407
12981
|
}
|
|
12408
|
-
const grouping =
|
|
12982
|
+
const grouping = group2?.grouping;
|
|
12409
12983
|
if (grouping && GROUPINGS.has(grouping))
|
|
12410
12984
|
summary.grouping = grouping;
|
|
12411
12985
|
if (chartType === "bar" || chartType === "column") {
|
|
12412
12986
|
for (const [value, field, fallback, min, max] of [
|
|
12413
|
-
[
|
|
12414
|
-
[
|
|
12987
|
+
[group2?.gapWidth, "barGapWidth", 150, 0, 500],
|
|
12988
|
+
[group2?.overlap, "barOverlap", 0, -100, 100]
|
|
12415
12989
|
]) {
|
|
12416
12990
|
const resolved = value ?? fallback;
|
|
12417
12991
|
if (Number.isInteger(resolved) && resolved >= min && resolved <= max)
|
|
@@ -12473,72 +13047,438 @@ function chartBarSpacing(chart) {
|
|
|
12473
13047
|
};
|
|
12474
13048
|
}
|
|
12475
13049
|
|
|
12476
|
-
// chart/render/
|
|
12477
|
-
|
|
12478
|
-
|
|
12479
|
-
|
|
12480
|
-
|
|
12481
|
-
|
|
12482
|
-
|
|
12483
|
-
|
|
12484
|
-
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12488
|
-
|
|
12489
|
-
|
|
12490
|
-
|
|
12491
|
-
|
|
12492
|
-
|
|
12493
|
-
|
|
12494
|
-
|
|
12495
|
-
|
|
12496
|
-
|
|
12497
|
-
|
|
12498
|
-
|
|
12499
|
-
|
|
12500
|
-
|
|
12501
|
-
|
|
12502
|
-
|
|
12503
|
-
|
|
12504
|
-
|
|
12505
|
-
|
|
12506
|
-
|
|
12507
|
-
|
|
12508
|
-
const gradient = s.pointGradients?.[i] ?? (s.pointColors?.[i] === void 0 ? s.gradient : void 0);
|
|
12509
|
-
if (gradient && (gradient.path === "circle" || gradient.path === "shape")) {
|
|
12510
|
-
const baseId = color.match(/^url\(#(.+)\)$/)?.[1];
|
|
12511
|
-
if (baseId) {
|
|
12512
|
-
const id = baseId.replace(/(-s\d+(?:-p\d+)?)$/, `-mark${i}$1`);
|
|
12513
|
-
const def = buildChartGradientDef(id, gradient, {
|
|
12514
|
-
width: Number(n(width)),
|
|
12515
|
-
height: Number(n(height)),
|
|
12516
|
-
shape: "rect"
|
|
12517
|
-
});
|
|
12518
|
-
out.push(`<defs>${chartGradientMarkup(def)}</defs>`);
|
|
12519
|
-
color = `url(#${id})`;
|
|
12520
|
-
}
|
|
12521
|
-
}
|
|
12522
|
-
out.push(`<g data-chart-series="${si}" data-chart-point="${i}">`);
|
|
12523
|
-
if (model.horizontal)
|
|
12524
|
-
out.push(
|
|
12525
|
-
rect2(Math.min(a, b), center + offset, Math.abs(b - a), barSize, color, s.shadowFilter)
|
|
12526
|
-
);
|
|
12527
|
-
else
|
|
12528
|
-
out.push(
|
|
12529
|
-
rect2(center + offset, Math.min(a, b), barSize, Math.abs(b - a), color, s.shadowFilter)
|
|
12530
|
-
);
|
|
12531
|
-
out.push("</g>");
|
|
12532
|
-
});
|
|
12533
|
-
});
|
|
13050
|
+
// chart/render/theme-palette.ts
|
|
13051
|
+
var THEME_SLOTS = [
|
|
13052
|
+
"lt1",
|
|
13053
|
+
"dk1",
|
|
13054
|
+
"lt2",
|
|
13055
|
+
"dk2",
|
|
13056
|
+
"accent1",
|
|
13057
|
+
"accent2",
|
|
13058
|
+
"accent3",
|
|
13059
|
+
"accent4",
|
|
13060
|
+
"accent5",
|
|
13061
|
+
"accent6",
|
|
13062
|
+
"hlink",
|
|
13063
|
+
"folHlink"
|
|
13064
|
+
];
|
|
13065
|
+
var DEFAULT_THEME_COLORS = [
|
|
13066
|
+
"FFFFFF",
|
|
13067
|
+
"000000",
|
|
13068
|
+
"E7E6E6",
|
|
13069
|
+
"44546A",
|
|
13070
|
+
"4472C4",
|
|
13071
|
+
"ED7D31",
|
|
13072
|
+
"A5A5A5",
|
|
13073
|
+
"FFC000",
|
|
13074
|
+
"5B9BD5",
|
|
13075
|
+
"70AD47",
|
|
13076
|
+
"0563C1",
|
|
13077
|
+
"954F72"
|
|
13078
|
+
];
|
|
13079
|
+
function themeColor(theme, index) {
|
|
13080
|
+
const hex = theme.colors[index] ?? DEFAULT_THEME_COLORS[index];
|
|
13081
|
+
return hex && parseArgbHex(hex) ? hex.replace(/^#/, "") : void 0;
|
|
12534
13082
|
}
|
|
12535
13083
|
|
|
12536
|
-
// chart/render/chart-
|
|
12537
|
-
|
|
12538
|
-
|
|
12539
|
-
|
|
12540
|
-
|
|
12541
|
-
|
|
13084
|
+
// chart/render/chart-colors.ts
|
|
13085
|
+
function chartColorScheme(theme) {
|
|
13086
|
+
const slots = Object.fromEntries(
|
|
13087
|
+
THEME_SLOTS.map((slot, index) => [slot, `#${themeColor(theme, index) ?? "000000"}`])
|
|
13088
|
+
);
|
|
13089
|
+
return {
|
|
13090
|
+
...slots,
|
|
13091
|
+
bg1: slots.lt1,
|
|
13092
|
+
tx1: slots.dk1,
|
|
13093
|
+
bg2: slots.lt2,
|
|
13094
|
+
tx2: slots.dk2
|
|
13095
|
+
};
|
|
13096
|
+
}
|
|
13097
|
+
function autoSeriesColor(theme, index) {
|
|
13098
|
+
const i = Math.max(0, Math.floor(index));
|
|
13099
|
+
return chartPaletteSeriesColor(findChartColorPalette(10), i, i + 1, chartColorScheme(theme));
|
|
13100
|
+
}
|
|
13101
|
+
|
|
13102
|
+
// chart/text-inheritance.ts
|
|
13103
|
+
var TEXT_KEYS = [
|
|
13104
|
+
"fontSize",
|
|
13105
|
+
"bold",
|
|
13106
|
+
"italic",
|
|
13107
|
+
"underline",
|
|
13108
|
+
"typeface",
|
|
13109
|
+
"textColor",
|
|
13110
|
+
"fontRef"
|
|
13111
|
+
];
|
|
13112
|
+
var TEXT_PARTS = [
|
|
13113
|
+
"title",
|
|
13114
|
+
"axisTitle",
|
|
13115
|
+
"categoryAxis",
|
|
13116
|
+
"valueAxis",
|
|
13117
|
+
"legend",
|
|
13118
|
+
"dataLabel"
|
|
13119
|
+
];
|
|
13120
|
+
function inheritChartText(part, entry, builtIn, root) {
|
|
13121
|
+
if (!root || !TEXT_PARTS.includes(part)) return entry;
|
|
13122
|
+
const out = { ...entry };
|
|
13123
|
+
for (const key of TEXT_KEYS) {
|
|
13124
|
+
delete out[key];
|
|
13125
|
+
const value = root[key] ?? builtIn?.[key];
|
|
13126
|
+
if (value !== void 0) Object.assign(out, { [key]: value });
|
|
13127
|
+
}
|
|
13128
|
+
if (part === "title" && root.fontSize !== void 0) out.fontSize = root.fontSize * 1.2;
|
|
13129
|
+
if (root.textEffectsXml !== void 0) out.textEffectsXml = root.textEffectsXml;
|
|
13130
|
+
return out;
|
|
13131
|
+
}
|
|
13132
|
+
|
|
13133
|
+
// chart/render/chart-appearance.ts
|
|
13134
|
+
var chartPointsToPixels = (points) => points * EMU_PER_POINT / EMU_PER_PIXEL;
|
|
13135
|
+
function typeface(entry, theme) {
|
|
13136
|
+
const name = entry.typeface;
|
|
13137
|
+
if (name?.startsWith("+mj-")) return theme.majorFont;
|
|
13138
|
+
if (name?.startsWith("+mn-")) return theme.minorFont;
|
|
13139
|
+
return name ?? (entry.fontRef?.index === "major" ? theme.majorFont : entry.fontRef?.index === "minor" ? theme.minorFont : void 0);
|
|
13140
|
+
}
|
|
13141
|
+
function chartAppearance(chart, theme) {
|
|
13142
|
+
const defaults = builtInChartTextStyle(effectiveBuiltInChartStyle(chart.formatting));
|
|
13143
|
+
const entries = {};
|
|
13144
|
+
for (const part of CHART_STYLE_PARTS) {
|
|
13145
|
+
const base = chart.styleDefinition?.entries[part];
|
|
13146
|
+
const direct = chart.formatting?.entries[part];
|
|
13147
|
+
if (!defaults[part] && !base && !direct) continue;
|
|
13148
|
+
const entry = {
|
|
13149
|
+
...inheritChartText(
|
|
13150
|
+
part,
|
|
13151
|
+
{ ...defaults[part], ...base, sourceXml: base?.sourceXml ?? "" },
|
|
13152
|
+
defaults[part],
|
|
13153
|
+
chart.formatting?.textDefaults
|
|
13154
|
+
),
|
|
13155
|
+
...direct,
|
|
13156
|
+
sourceXml: direct?.sourceXml ?? base?.sourceXml ?? ""
|
|
13157
|
+
};
|
|
13158
|
+
if (base?.line || direct?.line) entry.line = { ...base?.line, ...direct?.line };
|
|
13159
|
+
entries[part] = entry;
|
|
13160
|
+
}
|
|
13161
|
+
const scheme = chartColorScheme(theme);
|
|
13162
|
+
const resolve = (color) => resolveDrawingColor(
|
|
13163
|
+
color,
|
|
13164
|
+
{ scheme: (name) => scheme[name] },
|
|
13165
|
+
{ hslRounding: "halfDown", transformOrder: "document" }
|
|
13166
|
+
);
|
|
13167
|
+
const out = resolveChartStyleDefinition(
|
|
13168
|
+
{ entries},
|
|
13169
|
+
(color) => drawingColorCss(resolve(color))
|
|
13170
|
+
) ?? {};
|
|
13171
|
+
for (const part of CHART_STYLE_PARTS) {
|
|
13172
|
+
const entry = entries[part];
|
|
13173
|
+
if (!entry) continue;
|
|
13174
|
+
const family = typeface(entry, theme);
|
|
13175
|
+
const shadow = resolveDrawingShadowXml(entry.textEffectsXml, {
|
|
13176
|
+
scheme: (name) => scheme[name]
|
|
13177
|
+
});
|
|
13178
|
+
if (shadow) (out[part] ??= {}).textShadow = shadow;
|
|
13179
|
+
if (family) (out[part] ??= {}).typeface = family;
|
|
13180
|
+
if (entry.axisVisible !== void 0) (out[part] ??= {}).axisVisible = entry.axisVisible;
|
|
13181
|
+
if (entry.labelsVisible !== void 0) (out[part] ??= {}).labelsVisible = entry.labelsVisible;
|
|
13182
|
+
if (entry.line?.widthEmu === 0) (out[part] ??= {}).lineWidth = 0;
|
|
13183
|
+
if (entry.fill?.kind === "gradient") {
|
|
13184
|
+
(out[part] ??= {}).gradient = resolveChartGradient(entry.fill, resolve);
|
|
13185
|
+
}
|
|
13186
|
+
}
|
|
13187
|
+
return out;
|
|
13188
|
+
}
|
|
13189
|
+
|
|
13190
|
+
// text/css-font-family.ts
|
|
13191
|
+
var FALLBACKS = {
|
|
13192
|
+
calibri: '"Calibri", "Carlito", "Segoe UI", Arial, sans-serif',
|
|
13193
|
+
"calibri light": '"Calibri Light", "Calibri", "Carlito", "Segoe UI", Arial, sans-serif',
|
|
13194
|
+
cambria: '"Cambria", "Caladea", Georgia, serif',
|
|
13195
|
+
arial: 'Arial, "Liberation Sans", Helvetica, sans-serif',
|
|
13196
|
+
"times new roman": '"Times New Roman", "Liberation Serif", Times, serif',
|
|
13197
|
+
"courier new": '"Courier New", "Liberation Mono", monospace',
|
|
13198
|
+
aptos: '"Aptos", "Calibri", "Carlito", "Segoe UI", sans-serif'
|
|
13199
|
+
};
|
|
13200
|
+
function cssFontFamily(name) {
|
|
13201
|
+
const known = FALLBACKS[name.toLowerCase()];
|
|
13202
|
+
if (known) return known;
|
|
13203
|
+
const quoted = `"${name.replace(/["\\]/g, "")}"`;
|
|
13204
|
+
return `${quoted}, "Calibri", "Carlito", "Segoe UI", sans-serif`;
|
|
13205
|
+
}
|
|
13206
|
+
|
|
13207
|
+
// chart/render/chart-svg-appearance.ts
|
|
13208
|
+
var nextPaintId = 0;
|
|
13209
|
+
function chartGradientPaint(model, width = 1024, height = 768) {
|
|
13210
|
+
const prefix2 = `xlsx-chart-${++nextPaintId}`;
|
|
13211
|
+
const appearance = { ...model.appearance };
|
|
13212
|
+
const defs = [];
|
|
13213
|
+
const shadowPaint = (shadow, suffix) => {
|
|
13214
|
+
const id = `${prefix2}-${suffix}`;
|
|
13215
|
+
const pad = Math.max(4, shadow.blur * 3 + Math.abs(shadow.dx) + Math.abs(shadow.dy));
|
|
13216
|
+
defs.push(
|
|
13217
|
+
`<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>`
|
|
13218
|
+
);
|
|
13219
|
+
return `url(#${id})`;
|
|
13220
|
+
};
|
|
13221
|
+
for (const [part, entry] of Object.entries(appearance)) {
|
|
13222
|
+
if (entry?.textShadow)
|
|
13223
|
+
appearance[part] = {
|
|
13224
|
+
...entry,
|
|
13225
|
+
textShadowFilter: shadowPaint(entry.textShadow, `${part}-text-shadow`)
|
|
13226
|
+
};
|
|
13227
|
+
}
|
|
13228
|
+
const paint2 = (gradient, suffix, bounds) => {
|
|
13229
|
+
const def = buildChartGradientDef(`${prefix2}-${suffix}`, gradient, bounds);
|
|
13230
|
+
defs.push(chartGradientMarkup(def));
|
|
13231
|
+
return `url(#${def.id})`;
|
|
13232
|
+
};
|
|
13233
|
+
for (const part of ["chartArea", "plotArea"]) {
|
|
13234
|
+
const entry = appearance[part];
|
|
13235
|
+
if (!entry?.gradient) continue;
|
|
13236
|
+
if (part === "plotArea" && ["circle", "shape"].includes(entry.gradient.path ?? "")) continue;
|
|
13237
|
+
appearance[part] = {
|
|
13238
|
+
...entry,
|
|
13239
|
+
fillColor: paint2(entry.gradient, part, { width, height, shape: "rect" })
|
|
13240
|
+
};
|
|
13241
|
+
}
|
|
13242
|
+
const series = model.series.map((source, index) => {
|
|
13243
|
+
const view = { ...source };
|
|
13244
|
+
if (source.shadow) view.shadowFilter = shadowPaint(source.shadow, `s${index}-shadow`);
|
|
13245
|
+
const bounds = model.type === "bar" || model.type === "column" ? { width: 1, height: 1, shape: "rect" } : void 0;
|
|
13246
|
+
if (source.gradient) view.color = paint2(source.gradient, `s${index}`, bounds);
|
|
13247
|
+
if (source.pointGradients) {
|
|
13248
|
+
view.pointColors = [...source.pointColors ?? []];
|
|
13249
|
+
for (const [key, gradient] of Object.entries(source.pointGradients))
|
|
13250
|
+
view.pointColors[Number(key)] = paint2(gradient, `s${index}-p${key}`, bounds);
|
|
13251
|
+
}
|
|
13252
|
+
return view;
|
|
13253
|
+
});
|
|
13254
|
+
return defs.length ? { model: { ...model, appearance, series }, defs: `<defs>${defs.join("")}</defs>` } : { model, defs: "" };
|
|
13255
|
+
}
|
|
13256
|
+
function chartTextAttributes(model, part, fallbackSize = FONT_SIZE) {
|
|
13257
|
+
const entry = model.appearance?.[part];
|
|
13258
|
+
return {
|
|
13259
|
+
size: entry?.fontSize === void 0 ? fallbackSize : chartPointsToPixels(entry.fontSize),
|
|
13260
|
+
...entry?.color === void 0 ? {} : { fill: entry.color },
|
|
13261
|
+
...entry?.bold === void 0 ? {} : { weight: entry.bold ? "bold" : "normal" },
|
|
13262
|
+
...entry?.italic === void 0 ? {} : { italic: entry.italic },
|
|
13263
|
+
...entry?.underline === void 0 ? {} : { underline: entry.underline },
|
|
13264
|
+
...entry?.typeface === void 0 ? {} : { family: cssFontFamily(entry.typeface) },
|
|
13265
|
+
...entry?.textShadowFilter === void 0 ? {} : { filter: entry.textShadowFilter }
|
|
13266
|
+
};
|
|
13267
|
+
}
|
|
13268
|
+
function chartStroke(model, part) {
|
|
13269
|
+
const entry = model.appearance?.[part];
|
|
13270
|
+
return {
|
|
13271
|
+
color: entry?.axisVisible === false ? "none" : entry?.lineColor ?? (part.startsWith("gridline") ? GRID_COLOR : AXIS_COLOR),
|
|
13272
|
+
width: entry?.lineWidth === void 0 ? 1 : chartPointsToPixels(entry.lineWidth)
|
|
13273
|
+
};
|
|
13274
|
+
}
|
|
13275
|
+
function chartAreaRect(model, part, area) {
|
|
13276
|
+
if (area.w <= 0 || area.h <= 0) return "";
|
|
13277
|
+
const entry = model.appearance?.[part];
|
|
13278
|
+
let fill = entry?.fillColor ?? (part === "chartArea" ? "#FFFFFF" : "none");
|
|
13279
|
+
let defs = "";
|
|
13280
|
+
if (part !== "chartArea" && entry?.gradient && (part !== "plotArea" || ["circle", "shape"].includes(entry.gradient.path ?? ""))) {
|
|
13281
|
+
const def = buildChartGradientDef(`xlsx-chart-${++nextPaintId}-${part}`, entry.gradient, {
|
|
13282
|
+
width: area.w,
|
|
13283
|
+
height: area.h,
|
|
13284
|
+
shape: "rect"
|
|
13285
|
+
});
|
|
13286
|
+
defs = `<defs>${chartGradientMarkup(def)}</defs>`;
|
|
13287
|
+
fill = `url(#${def.id})`;
|
|
13288
|
+
}
|
|
13289
|
+
const stroke = entry?.lineColor ?? "none";
|
|
13290
|
+
if (fill === "none" && stroke === "none") return "";
|
|
13291
|
+
const width = entry?.lineWidth === void 0 ? 1 : chartPointsToPixels(entry.lineWidth);
|
|
13292
|
+
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}"/>`;
|
|
13293
|
+
}
|
|
13294
|
+
|
|
13295
|
+
// chart/render/chart-svg-labels.ts
|
|
13296
|
+
var GAP = 3;
|
|
13297
|
+
var LINE = 1.2;
|
|
13298
|
+
var NAMED_COLORS = /^(black|blue|cyan|green|magenta|red|white|yellow)$/iu;
|
|
13299
|
+
function measure(model, label) {
|
|
13300
|
+
const attrs = chartTextAttributes(model, "dataLabel", 10);
|
|
13301
|
+
const size = attrs.size ?? 10;
|
|
13302
|
+
const lines = label.text.split("\n");
|
|
13303
|
+
return {
|
|
13304
|
+
lines,
|
|
13305
|
+
size,
|
|
13306
|
+
w: Math.max(...lines.map((l) => textWidth(l, size))),
|
|
13307
|
+
h: lines.length * size * LINE,
|
|
13308
|
+
attrs
|
|
13309
|
+
};
|
|
13310
|
+
}
|
|
13311
|
+
function draw(m, label, x, y, anchor, out) {
|
|
13312
|
+
const fill = label.color && NAMED_COLORS.test(label.color) ? label.color.toLowerCase() : void 0;
|
|
13313
|
+
m.lines.forEach((line3, k) => {
|
|
13314
|
+
const lineY = y - m.h / 2 + (k + 0.5) * m.size * LINE + m.size * 0.35;
|
|
13315
|
+
out.push(text(x, lineY, line3, { ...m.attrs, ...fill ? { fill } : {}, anchor }));
|
|
13316
|
+
});
|
|
13317
|
+
}
|
|
13318
|
+
function barLabels(model, marks, out) {
|
|
13319
|
+
const stacked = model.grouping === "stacked" || model.grouping === "percentStacked";
|
|
13320
|
+
for (const mark of marks) {
|
|
13321
|
+
const label = mark.series.labels?.[mark.index];
|
|
13322
|
+
if (!label) continue;
|
|
13323
|
+
const m = measure(model, label);
|
|
13324
|
+
let position = label.position ?? (stacked ? "ctr" : "outEnd");
|
|
13325
|
+
if (stacked && position === "outEnd") position = "ctr";
|
|
13326
|
+
const cx = mark.x + mark.w / 2;
|
|
13327
|
+
const cy = mark.y + mark.h / 2;
|
|
13328
|
+
if (model.horizontal) {
|
|
13329
|
+
const end = mark.negative ? mark.x : mark.x + mark.w;
|
|
13330
|
+
const base = mark.negative ? mark.x + mark.w : mark.x;
|
|
13331
|
+
const dir2 = mark.negative ? -1 : 1;
|
|
13332
|
+
const side = (at, outward) => [
|
|
13333
|
+
at + (outward ? dir2 : -dir2) * GAP,
|
|
13334
|
+
(outward ? dir2 : -dir2) > 0 ? "start" : "end"
|
|
13335
|
+
];
|
|
13336
|
+
const [x, anchor] = position === "ctr" ? [cx, "middle"] : position === "inEnd" ? side(end, false) : position === "inBase" ? side(base, true) : side(end, true);
|
|
13337
|
+
draw(m, label, x, cy, anchor, out);
|
|
13338
|
+
continue;
|
|
13339
|
+
}
|
|
13340
|
+
const top = mark.negative ? mark.y + mark.h : mark.y;
|
|
13341
|
+
const bottom = mark.negative ? mark.y : mark.y + mark.h;
|
|
13342
|
+
const dir = mark.negative ? 1 : -1;
|
|
13343
|
+
const y = position === "ctr" ? cy : position === "inEnd" ? top - dir * (GAP + m.h / 2) : position === "inBase" ? bottom + dir * (GAP + m.h / 2) : top + dir * (GAP + m.h / 2);
|
|
13344
|
+
draw(m, label, cx, y, "middle", out);
|
|
13345
|
+
}
|
|
13346
|
+
}
|
|
13347
|
+
function pointLabels(model, marks, out) {
|
|
13348
|
+
for (const mark of marks) {
|
|
13349
|
+
const label = mark.series.labels?.[mark.index];
|
|
13350
|
+
if (!label) continue;
|
|
13351
|
+
const m = measure(model, label);
|
|
13352
|
+
const reach = mark.radius + GAP;
|
|
13353
|
+
switch (model.type === "area" ? "ctr" : label.position ?? "r") {
|
|
13354
|
+
case "ctr":
|
|
13355
|
+
draw(m, label, mark.x, mark.y, "middle", out);
|
|
13356
|
+
break;
|
|
13357
|
+
case "t":
|
|
13358
|
+
draw(m, label, mark.x, mark.y - reach - m.h / 2, "middle", out);
|
|
13359
|
+
break;
|
|
13360
|
+
case "b":
|
|
13361
|
+
draw(m, label, mark.x, mark.y + reach + m.h / 2, "middle", out);
|
|
13362
|
+
break;
|
|
13363
|
+
case "l":
|
|
13364
|
+
draw(m, label, mark.x - reach, mark.y, "end", out);
|
|
13365
|
+
break;
|
|
13366
|
+
default:
|
|
13367
|
+
draw(m, label, mark.x + reach, mark.y, "start", out);
|
|
13368
|
+
}
|
|
13369
|
+
}
|
|
13370
|
+
}
|
|
13371
|
+
function sliceLabels(model, marks, out) {
|
|
13372
|
+
for (const mark of marks) {
|
|
13373
|
+
const label = mark.series.labels?.[mark.index];
|
|
13374
|
+
if (!label) continue;
|
|
13375
|
+
const m = measure(model, label);
|
|
13376
|
+
const mid = (mark.start + mark.end) / 2;
|
|
13377
|
+
const ux = Math.sin(mid);
|
|
13378
|
+
const uy = -Math.cos(mid);
|
|
13379
|
+
const place2 = (radius) => [
|
|
13380
|
+
mark.cx + radius * ux,
|
|
13381
|
+
mark.cy + radius * uy
|
|
13382
|
+
];
|
|
13383
|
+
const position = model.type === "doughnut" ? "ctr" : label.position ?? "bestFit";
|
|
13384
|
+
let x;
|
|
13385
|
+
let y;
|
|
13386
|
+
if (position === "ctr") [x, y] = place2(mark.inner + (mark.outer - mark.inner) / 2);
|
|
13387
|
+
else if (position === "inEnd") {
|
|
13388
|
+
const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
|
|
13389
|
+
[x, y] = place2(Math.max(0, mark.outer - GAP - extent));
|
|
13390
|
+
} else if (position === "outEnd") {
|
|
13391
|
+
const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
|
|
13392
|
+
[x, y] = place2(mark.outer + GAP + extent);
|
|
13393
|
+
} else {
|
|
13394
|
+
const placed2 = placeBestFitLabel(
|
|
13395
|
+
{
|
|
13396
|
+
cx: mark.cx,
|
|
13397
|
+
cy: mark.cy,
|
|
13398
|
+
outerR: mark.outer,
|
|
13399
|
+
startAngle: mark.start - Math.PI / 2,
|
|
13400
|
+
endAngle: mark.end - Math.PI / 2
|
|
13401
|
+
},
|
|
13402
|
+
m.w,
|
|
13403
|
+
m.h
|
|
13404
|
+
);
|
|
13405
|
+
x = placed2.x;
|
|
13406
|
+
y = placed2.y;
|
|
13407
|
+
}
|
|
13408
|
+
draw(m, label, x, y, "middle", out);
|
|
13409
|
+
}
|
|
13410
|
+
}
|
|
13411
|
+
function hasOutsideLabels(model) {
|
|
13412
|
+
return model.series.some(
|
|
13413
|
+
(s) => s.labels?.some(
|
|
13414
|
+
(l) => l !== void 0 && ["bestFit", "outEnd"].includes(l.position ?? "bestFit")
|
|
13415
|
+
)
|
|
13416
|
+
);
|
|
13417
|
+
}
|
|
13418
|
+
|
|
13419
|
+
// chart/render/chart-svg-bars.ts
|
|
13420
|
+
function barLayout(model, frame2) {
|
|
13421
|
+
const count = Math.max(1, model.series.length);
|
|
13422
|
+
const geometry = clusteredBarGeometry(frame2.bandSize, count, chartBarSpacing(model));
|
|
13423
|
+
const barSize = geometry.singleBarWidth;
|
|
13424
|
+
const offset = (si) => model.horizontal ? geometry.clusterWidth / 2 - barSize - si * geometry.step : -geometry.clusterWidth / 2 + si * geometry.step;
|
|
13425
|
+
return { barSize, offset };
|
|
13426
|
+
}
|
|
13427
|
+
function bars(model, frame2, out, values) {
|
|
13428
|
+
const stacked = model.grouping === "stacked" || model.grouping === "percentStacked";
|
|
13429
|
+
const { barSize, offset: barOffset } = barLayout(model, frame2);
|
|
13430
|
+
const base = frame2.value(0);
|
|
13431
|
+
const pos = new Array(model.categories.length).fill(0);
|
|
13432
|
+
const neg = new Array(model.categories.length).fill(0);
|
|
13433
|
+
const marks = [];
|
|
13434
|
+
model.series.forEach((s, si) => {
|
|
13435
|
+
values[si]?.forEach((v, i) => {
|
|
13436
|
+
if (v === null || i >= model.categories.length) return;
|
|
13437
|
+
let from = 0;
|
|
13438
|
+
let to = v;
|
|
13439
|
+
if (stacked) {
|
|
13440
|
+
const acc = v >= 0 ? pos : neg;
|
|
13441
|
+
from = acc[i] ?? 0;
|
|
13442
|
+
to = from + v;
|
|
13443
|
+
acc[i] = to;
|
|
13444
|
+
}
|
|
13445
|
+
const a = stacked ? frame2.value(from) : base;
|
|
13446
|
+
const b = frame2.value(to);
|
|
13447
|
+
const offset = barOffset(si);
|
|
13448
|
+
const center = frame2.band(i);
|
|
13449
|
+
const width = model.horizontal ? Math.abs(b - a) : barSize;
|
|
13450
|
+
const height = model.horizontal ? barSize : Math.abs(b - a);
|
|
13451
|
+
let color = s.pointColors?.[i] ?? s.color;
|
|
13452
|
+
const gradient = s.pointGradients?.[i] ?? (s.pointColors?.[i] === void 0 ? s.gradient : void 0);
|
|
13453
|
+
if (gradient && (gradient.path === "circle" || gradient.path === "shape")) {
|
|
13454
|
+
const baseId = color.match(/^url\(#(.+)\)$/)?.[1];
|
|
13455
|
+
if (baseId) {
|
|
13456
|
+
const id = baseId.replace(/(-s\d+(?:-p\d+)?)$/, `-mark${i}$1`);
|
|
13457
|
+
const def = buildChartGradientDef(id, gradient, {
|
|
13458
|
+
width: Number(n(width)),
|
|
13459
|
+
height: Number(n(height)),
|
|
13460
|
+
shape: "rect"
|
|
13461
|
+
});
|
|
13462
|
+
out.push(`<defs>${chartGradientMarkup(def)}</defs>`);
|
|
13463
|
+
color = `url(#${id})`;
|
|
13464
|
+
}
|
|
13465
|
+
}
|
|
13466
|
+
out.push(`<g data-chart-series="${si}" data-chart-point="${i}">`);
|
|
13467
|
+
const box = model.horizontal ? { x: Math.min(a, b), y: center + offset, w: Math.abs(b - a), h: barSize } : { x: center + offset, y: Math.min(a, b), w: barSize, h: Math.abs(b - a) };
|
|
13468
|
+
out.push(rect2(box.x, box.y, box.w, box.h, color, s.shadowFilter));
|
|
13469
|
+
out.push("</g>");
|
|
13470
|
+
marks.push({ series: s, index: i, ...box, negative: v < 0 });
|
|
13471
|
+
});
|
|
13472
|
+
});
|
|
13473
|
+
barLabels(model, marks, out);
|
|
13474
|
+
}
|
|
13475
|
+
|
|
13476
|
+
// chart/render/chart-svg-analysis.ts
|
|
13477
|
+
var DASHES = {
|
|
13478
|
+
dot: [1, 3],
|
|
13479
|
+
dash: [4, 3],
|
|
13480
|
+
lgDash: [8, 3],
|
|
13481
|
+
dashDot: [4, 3, 1, 3],
|
|
12542
13482
|
lgDashDot: [8, 3, 1, 3],
|
|
12543
13483
|
lgDashDotDot: [8, 3, 1, 3, 1, 3],
|
|
12544
13484
|
sysDash: [3, 1],
|
|
@@ -12619,6 +13559,60 @@ function scatterAnalysis(model, px, py, out) {
|
|
|
12619
13559
|
});
|
|
12620
13560
|
}
|
|
12621
13561
|
|
|
13562
|
+
// chart/render/chart-svg-markers.ts
|
|
13563
|
+
function chartMarkerRadius(series, index, defaultRadius = 3) {
|
|
13564
|
+
const marker = { ...series.marker, ...series.pointMarkers?.[index] };
|
|
13565
|
+
if (marker.symbol === "none") return 0;
|
|
13566
|
+
const radius = markerRadius(marker.size, defaultRadius);
|
|
13567
|
+
return marker.symbol === "dot" ? Math.max(radius * 0.6, 1) : radius;
|
|
13568
|
+
}
|
|
13569
|
+
function chartSeriesMarkerSvg(series, index, cx, cy, defaultRadius = 3) {
|
|
13570
|
+
const marker = { ...series.marker, ...series.pointMarkers?.[index] };
|
|
13571
|
+
const primitive = buildMarkerPrimitive({
|
|
13572
|
+
...marker,
|
|
13573
|
+
symbol: marker.symbol,
|
|
13574
|
+
size: marker.size,
|
|
13575
|
+
cx,
|
|
13576
|
+
cy,
|
|
13577
|
+
fill: marker.fill ?? series.pointColors?.[index] ?? series.color,
|
|
13578
|
+
defaultRadius
|
|
13579
|
+
});
|
|
13580
|
+
if (!primitive) return "";
|
|
13581
|
+
let geometry;
|
|
13582
|
+
switch (primitive.kind) {
|
|
13583
|
+
case "circle":
|
|
13584
|
+
geometry = `cx="${n(primitive.cx)}" cy="${n(primitive.cy)}" r="${n(primitive.r)}"`;
|
|
13585
|
+
break;
|
|
13586
|
+
case "rect":
|
|
13587
|
+
geometry = `x="${n(primitive.x)}" y="${n(primitive.y)}" width="${n(primitive.w)}" height="${n(primitive.h)}"`;
|
|
13588
|
+
break;
|
|
13589
|
+
case "path":
|
|
13590
|
+
geometry = `d="${esc(primitive.d)}"`;
|
|
13591
|
+
break;
|
|
13592
|
+
case "polygon":
|
|
13593
|
+
geometry = `points="${esc(primitive.points)}"`;
|
|
13594
|
+
break;
|
|
13595
|
+
}
|
|
13596
|
+
const outline = primitive.stroke ? ` stroke="${esc(primitive.stroke)}" stroke-width="${n(primitive.strokeWidth ?? 1)}"` : "";
|
|
13597
|
+
const filter = series.shadowFilter ? ` filter="${esc(series.shadowFilter)}"` : "";
|
|
13598
|
+
return `<${primitive.kind} ${geometry} fill="${esc(primitive.fill)}"${outline}${filter}/>`;
|
|
13599
|
+
}
|
|
13600
|
+
|
|
13601
|
+
// chart/line-dash.ts
|
|
13602
|
+
function chartLineDashArray(style, width) {
|
|
13603
|
+
if (!style || style === "solid") {
|
|
13604
|
+
return void 0;
|
|
13605
|
+
}
|
|
13606
|
+
const unit = Math.max(width, 1);
|
|
13607
|
+
if (style === "dot" || style === "sysDot") {
|
|
13608
|
+
return `${unit} ${unit * 2}`;
|
|
13609
|
+
}
|
|
13610
|
+
if (style === "lgDash") {
|
|
13611
|
+
return `${unit * 6} ${unit * 3}`;
|
|
13612
|
+
}
|
|
13613
|
+
return `${unit * 3} ${unit * 2}`;
|
|
13614
|
+
}
|
|
13615
|
+
|
|
12622
13616
|
// chart/render/chart-scale.ts
|
|
12623
13617
|
var clean = (n2) => Number(n2.toPrecision(12));
|
|
12624
13618
|
function* units(raw) {
|
|
@@ -12629,14 +13623,14 @@ function* units(raw) {
|
|
|
12629
13623
|
exp++;
|
|
12630
13624
|
}
|
|
12631
13625
|
}
|
|
12632
|
-
function niceScale(dataMin, dataMax,
|
|
12633
|
-
const maxIntervals = Math.max(1,
|
|
13626
|
+
function niceScale(dataMin, dataMax, options2 = {}) {
|
|
13627
|
+
const maxIntervals = Math.max(1, options2.maxIntervals ?? 10);
|
|
12634
13628
|
let lo = Number.isFinite(dataMin) ? dataMin : 0;
|
|
12635
13629
|
let hi = Number.isFinite(dataMax) ? dataMax : 0;
|
|
12636
13630
|
if (lo > hi) [lo, hi] = [hi, lo];
|
|
12637
13631
|
if (lo === hi) {
|
|
12638
13632
|
if (lo === 0) hi = 1;
|
|
12639
|
-
else if (
|
|
13633
|
+
else if (options2.noZero) {
|
|
12640
13634
|
const pad = Math.abs(lo) * 0.1 || 1;
|
|
12641
13635
|
lo -= pad;
|
|
12642
13636
|
hi += pad;
|
|
@@ -12645,7 +13639,7 @@ function niceScale(dataMin, dataMax, options = {}) {
|
|
|
12645
13639
|
}
|
|
12646
13640
|
let fixedLo = false;
|
|
12647
13641
|
let fixedHi = false;
|
|
12648
|
-
if (!
|
|
13642
|
+
if (!options2.noZero) {
|
|
12649
13643
|
if (lo >= 0 && hi - lo >= hi / 6) {
|
|
12650
13644
|
lo = 0;
|
|
12651
13645
|
fixedLo = true;
|
|
@@ -12685,144 +13679,231 @@ function formatAxisValue(value, percent = false) {
|
|
|
12685
13679
|
return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
|
|
12686
13680
|
}
|
|
12687
13681
|
|
|
12688
|
-
// chart/render/
|
|
12689
|
-
|
|
12690
|
-
|
|
12691
|
-
|
|
12692
|
-
|
|
12693
|
-
"
|
|
12694
|
-
|
|
12695
|
-
|
|
12696
|
-
|
|
12697
|
-
|
|
12698
|
-
|
|
12699
|
-
"
|
|
12700
|
-
|
|
12701
|
-
|
|
12702
|
-
|
|
12703
|
-
|
|
12704
|
-
|
|
12705
|
-
|
|
12706
|
-
|
|
12707
|
-
|
|
12708
|
-
|
|
12709
|
-
|
|
12710
|
-
|
|
12711
|
-
|
|
12712
|
-
|
|
12713
|
-
|
|
12714
|
-
"
|
|
12715
|
-
"
|
|
12716
|
-
|
|
12717
|
-
function themeColor(theme, index) {
|
|
12718
|
-
const hex = theme.colors[index] ?? DEFAULT_THEME_COLORS[index];
|
|
12719
|
-
return hex && parseArgbHex(hex) ? hex.replace(/^#/, "") : void 0;
|
|
13682
|
+
// chart/render/chart-svg-axes.ts
|
|
13683
|
+
function axisTickText(value, axis, percent = false) {
|
|
13684
|
+
return formatChartNumber(value, axis?.source.numberFormat?.formatCode) ?? formatAxisValue(value, percent);
|
|
13685
|
+
}
|
|
13686
|
+
function axisLine(model, axis, part, x1, y1, x2, y2) {
|
|
13687
|
+
if (axis?.source.deleted) return "";
|
|
13688
|
+
return styledAxisLine(x1, y1, x2, y2, axis?.line, chartStroke(model, part));
|
|
13689
|
+
}
|
|
13690
|
+
function styledAxisLine(x1, y1, x2, y2, paint2, fallback) {
|
|
13691
|
+
const color = paint2?.color ?? fallback.color;
|
|
13692
|
+
const width = paint2?.width ?? fallback.width;
|
|
13693
|
+
if (color === "none" || width === 0) return "";
|
|
13694
|
+
const dash = chartLineDashArray(paint2?.dash, width);
|
|
13695
|
+
return line2(x1, y1, x2, y2, esc(color), width).replace(
|
|
13696
|
+
"/>",
|
|
13697
|
+
dash ? ` stroke-dasharray="${dash}"/>` : "/>"
|
|
13698
|
+
);
|
|
13699
|
+
}
|
|
13700
|
+
function axisGridlines(model, axis, ticks, position, plot, vertical) {
|
|
13701
|
+
const draw2 = (values, paint2, minor2) => {
|
|
13702
|
+
const fallback = chartStroke(model, minor2 ? "gridlineMinor" : "gridlineMajor");
|
|
13703
|
+
return values.map((value) => {
|
|
13704
|
+
const p = position(value);
|
|
13705
|
+
return vertical ? styledAxisLine(p, plot.y, p, plot.y + plot.h, paint2, fallback) : styledAxisLine(plot.x, p, plot.x + plot.w, p, paint2, fallback);
|
|
13706
|
+
}).join("");
|
|
13707
|
+
};
|
|
13708
|
+
const major = !axis || axis.source.majorGridlines ? draw2(ticks, axis?.majorGrid, false) : "";
|
|
13709
|
+
const minor = axis?.source.minorGridlines ? draw2(axis.minorTicks, axis.minorGrid, true) : "";
|
|
13710
|
+
return major + minor;
|
|
12720
13711
|
}
|
|
12721
13712
|
|
|
12722
|
-
// chart/
|
|
12723
|
-
function
|
|
12724
|
-
const
|
|
12725
|
-
|
|
12726
|
-
|
|
13713
|
+
// chart/axis-range.ts
|
|
13714
|
+
function computeLogValueRange(series, logBase) {
|
|
13715
|
+
const allValues = series.flatMap((item) => item.values).filter((value) => value !== null && Number.isFinite(value) && value > 0);
|
|
13716
|
+
if (allValues.length === 0) {
|
|
13717
|
+
return { min: 1, max: logBase, span: 1, logScale: true, logBase };
|
|
13718
|
+
}
|
|
13719
|
+
const dataMin = Math.min(...allValues);
|
|
13720
|
+
const dataMax = Math.max(...allValues);
|
|
13721
|
+
const logMin = Math.floor(Math.log(dataMin) / Math.log(logBase));
|
|
13722
|
+
const logMax = Math.ceil(Math.log(dataMax) / Math.log(logBase));
|
|
13723
|
+
const min = logBase ** logMin;
|
|
13724
|
+
const max = logBase ** Math.max(logMax, logMin + 1);
|
|
12727
13725
|
return {
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
13726
|
+
min,
|
|
13727
|
+
max,
|
|
13728
|
+
span: Math.max(Math.log(max) / Math.log(logBase) - Math.log(min) / Math.log(logBase), 1),
|
|
13729
|
+
logScale: true,
|
|
13730
|
+
logBase
|
|
13731
|
+
};
|
|
13732
|
+
}
|
|
13733
|
+
function withAxisBounds(automatic, axis, logBase) {
|
|
13734
|
+
const validMin = typeof axis?.min === "number" && Number.isFinite(axis.min) && (!logBase || axis.min > 0) ? axis.min : void 0;
|
|
13735
|
+
const validMax = typeof axis?.max === "number" && Number.isFinite(axis.max) && (!logBase || axis.max > 0) ? axis.max : void 0;
|
|
13736
|
+
const min = validMin ?? automatic.min;
|
|
13737
|
+
let max = validMax ?? automatic.max;
|
|
13738
|
+
const majorUnit = validMin === void 0 && validMax === void 0 ? automatic.majorUnit : void 0;
|
|
13739
|
+
if (max <= min) {
|
|
13740
|
+
max = logBase ? min * logBase : min + 1;
|
|
13741
|
+
}
|
|
13742
|
+
const span = logBase ? Math.log(max) / Math.log(logBase) - Math.log(min) / Math.log(logBase) : max - min;
|
|
13743
|
+
return {
|
|
13744
|
+
min,
|
|
13745
|
+
max,
|
|
13746
|
+
span: Math.max(span, Number.EPSILON),
|
|
13747
|
+
...majorUnit !== void 0 ? { majorUnit } : {},
|
|
13748
|
+
...logBase ? { logScale: true, logBase } : {},
|
|
13749
|
+
...axis?.orientation === "maxMin" ? { reverseOrder: true } : {}
|
|
12733
13750
|
};
|
|
12734
13751
|
}
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
13752
|
+
|
|
13753
|
+
// chart/axis-ticks.ts
|
|
13754
|
+
var LOG_EXPONENT_TOLERANCE = 1e-12;
|
|
13755
|
+
function generateLogTicks(range) {
|
|
13756
|
+
if (!range.logScale || !range.logBase) {
|
|
13757
|
+
return [];
|
|
13758
|
+
}
|
|
13759
|
+
const base = range.logBase;
|
|
13760
|
+
const logMin = Math.log(range.min) / Math.log(base);
|
|
13761
|
+
const logMax = Math.log(range.max) / Math.log(base);
|
|
13762
|
+
const firstExponent = Math.ceil(logMin - LOG_EXPONENT_TOLERANCE);
|
|
13763
|
+
const lastExponent = Math.floor(logMax + LOG_EXPONENT_TOLERANCE);
|
|
13764
|
+
if (lastExponent < firstExponent) {
|
|
13765
|
+
return range.min === range.max ? [range.min] : [range.min, range.max];
|
|
13766
|
+
}
|
|
13767
|
+
return Array.from(
|
|
13768
|
+
{ length: lastExponent - firstExponent + 1 },
|
|
13769
|
+
(_unused, index) => base ** (firstExponent + index)
|
|
13770
|
+
);
|
|
13771
|
+
}
|
|
13772
|
+
function generateIntervalTicks(range, unit) {
|
|
13773
|
+
if (!Number.isFinite(unit) || unit <= 0 || range.logScale) {
|
|
13774
|
+
return [];
|
|
13775
|
+
}
|
|
13776
|
+
const tolerance = Math.max(1, Math.abs(range.min), Math.abs(range.max)) * 1e-12;
|
|
13777
|
+
const first3 = Math.ceil((range.min - tolerance) / unit);
|
|
13778
|
+
const last = Math.floor((range.max + tolerance) / unit);
|
|
13779
|
+
const count = Math.min(Math.max(last - first3 + 1, 0), 2e3);
|
|
13780
|
+
return Array.from({ length: count }, (_, index) => (first3 + index) * unit);
|
|
13781
|
+
}
|
|
13782
|
+
function generateAxisTicks(range, axis, defaultIntervals) {
|
|
13783
|
+
if (range.logScale && range.logBase) {
|
|
13784
|
+
return generateLogTicks(range);
|
|
13785
|
+
}
|
|
13786
|
+
const explicit = generateIntervalTicks(range, axis?.majorUnit ?? 0);
|
|
13787
|
+
if (explicit.length > 0) {
|
|
13788
|
+
return explicit;
|
|
13789
|
+
}
|
|
13790
|
+
const automatic = generateIntervalTicks(range, range.majorUnit ?? 0);
|
|
13791
|
+
if (automatic.length > 0) {
|
|
13792
|
+
return automatic;
|
|
13793
|
+
}
|
|
13794
|
+
return Array.from(
|
|
13795
|
+
{ length: defaultIntervals + 1 },
|
|
13796
|
+
(_, index) => range.min + range.span / defaultIntervals * index
|
|
13797
|
+
);
|
|
12738
13798
|
}
|
|
12739
|
-
|
|
12740
|
-
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
"bold",
|
|
12744
|
-
"italic",
|
|
12745
|
-
"underline",
|
|
12746
|
-
"typeface",
|
|
12747
|
-
"textColor",
|
|
12748
|
-
"fontRef"
|
|
12749
|
-
];
|
|
12750
|
-
var TEXT_PARTS = [
|
|
12751
|
-
"title",
|
|
12752
|
-
"axisTitle",
|
|
12753
|
-
"categoryAxis",
|
|
12754
|
-
"valueAxis",
|
|
12755
|
-
"legend",
|
|
12756
|
-
"dataLabel"
|
|
12757
|
-
];
|
|
12758
|
-
function inheritChartText(part, entry, builtIn, root) {
|
|
12759
|
-
if (!root || !TEXT_PARTS.includes(part)) return entry;
|
|
12760
|
-
const out = { ...entry };
|
|
12761
|
-
for (const key of TEXT_KEYS) {
|
|
12762
|
-
delete out[key];
|
|
12763
|
-
const value = root[key] ?? builtIn?.[key];
|
|
12764
|
-
if (value !== void 0) Object.assign(out, { [key]: value });
|
|
13799
|
+
function generateMinorAxisTicks(range, axis) {
|
|
13800
|
+
const minor = generateIntervalTicks(range, axis?.minorUnit ?? 0);
|
|
13801
|
+
if (minor.length === 0) {
|
|
13802
|
+
return [];
|
|
12765
13803
|
}
|
|
12766
|
-
|
|
12767
|
-
if (
|
|
12768
|
-
|
|
13804
|
+
const majorUnit = axis?.majorUnit;
|
|
13805
|
+
if (!majorUnit || !Number.isFinite(majorUnit) || majorUnit <= 0) {
|
|
13806
|
+
return minor;
|
|
13807
|
+
}
|
|
13808
|
+
const tolerance = Math.max(1, Math.abs(range.min), Math.abs(range.max)) * 1e-10;
|
|
13809
|
+
return minor.filter(
|
|
13810
|
+
(value) => Math.abs(value / majorUnit - Math.round(value / majorUnit)) > tolerance
|
|
13811
|
+
);
|
|
12769
13812
|
}
|
|
12770
13813
|
|
|
12771
|
-
// chart/render/chart-
|
|
12772
|
-
|
|
12773
|
-
|
|
12774
|
-
const
|
|
12775
|
-
|
|
12776
|
-
if (name?.startsWith("+mn-")) return theme.minorFont;
|
|
12777
|
-
return name ?? (entry.fontRef?.index === "major" ? theme.majorFont : entry.fontRef?.index === "minor" ? theme.minorFont : void 0);
|
|
13814
|
+
// chart/render/chart-view-axes.ts
|
|
13815
|
+
function chartAxisRatio(value, scale, axis) {
|
|
13816
|
+
const range = axis?.range;
|
|
13817
|
+
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);
|
|
13818
|
+
return range?.reverseOrder ? 1 - ratio : ratio;
|
|
12778
13819
|
}
|
|
12779
|
-
function
|
|
12780
|
-
|
|
12781
|
-
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
|
|
12789
|
-
|
|
12790
|
-
|
|
12791
|
-
|
|
12792
|
-
|
|
12793
|
-
|
|
12794
|
-
|
|
12795
|
-
|
|
12796
|
-
|
|
12797
|
-
|
|
12798
|
-
|
|
12799
|
-
const scheme = chartColorScheme(theme);
|
|
12800
|
-
const resolve = (color) => resolveDrawingColor(
|
|
12801
|
-
color,
|
|
12802
|
-
{ scheme: (name) => scheme[name] },
|
|
12803
|
-
{ hslRounding: "halfDown", transformOrder: "document" }
|
|
13820
|
+
function chartAxisLabels(axis) {
|
|
13821
|
+
return axis?.source.deleted !== true && axis?.source.tickLabelPosition !== "none";
|
|
13822
|
+
}
|
|
13823
|
+
function options(axis) {
|
|
13824
|
+
return {
|
|
13825
|
+
...axis.scaling,
|
|
13826
|
+
...axis.scaling.logBase === void 0 ? {} : { logScale: true },
|
|
13827
|
+
...axis.majorUnit === void 0 ? {} : { majorUnit: axis.majorUnit },
|
|
13828
|
+
...axis.minorUnit === void 0 ? {} : { minorUnit: axis.minorUnit }
|
|
13829
|
+
};
|
|
13830
|
+
}
|
|
13831
|
+
function applyChartAxes(model, chart, color) {
|
|
13832
|
+
if (!chart.axes?.length) return;
|
|
13833
|
+
const axes = chart.axes;
|
|
13834
|
+
const linked = axes.filter((axis) => axis.id !== void 0 && chart.axisIds?.includes(axis.id));
|
|
13835
|
+
const candidates = linked.length ? linked : axes;
|
|
13836
|
+
const xy = model.type === "scatter" || model.type === "bubble";
|
|
13837
|
+
const value = candidates.find((axis) => axis.kind === "val" && !["b", "t"].includes(axis.position ?? "")) ?? candidates.find((axis) => axis.kind === "val");
|
|
13838
|
+
const category = candidates.find(
|
|
13839
|
+
(axis) => xy ? axis.kind === "val" && axis !== value : axis.kind === "cat" || axis.kind === "date"
|
|
12804
13840
|
);
|
|
12805
|
-
const
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
|
|
12812
|
-
|
|
12813
|
-
|
|
12814
|
-
|
|
12815
|
-
|
|
12816
|
-
|
|
12817
|
-
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
|
|
12821
|
-
|
|
12822
|
-
|
|
13841
|
+
const secondary = axes.find((axis) => axis.kind === "val" && axis !== value && axis !== category);
|
|
13842
|
+
const paint2 = (shape) => {
|
|
13843
|
+
const ln = shape?.line;
|
|
13844
|
+
const fill = ln?.fill;
|
|
13845
|
+
const resolved = fill?.kind === "none" ? "none" : color(fill?.kind === "solid" ? fill.color : void 0);
|
|
13846
|
+
return {
|
|
13847
|
+
...resolved === void 0 ? {} : { color: resolved },
|
|
13848
|
+
...ln?.widthEmu === void 0 ? {} : { width: ln.widthEmu / EMU_PER_PIXEL },
|
|
13849
|
+
...ln?.dash === void 0 ? {} : { dash: ln.dash }
|
|
13850
|
+
};
|
|
13851
|
+
};
|
|
13852
|
+
const bind = (axis, scale, values) => {
|
|
13853
|
+
const opts = options(axis);
|
|
13854
|
+
const automatic = opts.logScale ? computeLogValueRange(
|
|
13855
|
+
[{ values: values ?? [] }],
|
|
13856
|
+
opts.logBase && Number.isFinite(opts.logBase) && opts.logBase > 1 ? opts.logBase : 10
|
|
13857
|
+
) : {
|
|
13858
|
+
min: scale?.min ?? 0,
|
|
13859
|
+
max: scale?.max ?? 1,
|
|
13860
|
+
span: (scale?.max ?? 1) - (scale?.min ?? 0),
|
|
13861
|
+
...scale ? { majorUnit: scale.majorUnit } : {}
|
|
13862
|
+
};
|
|
13863
|
+
const logBase = automatic.logBase;
|
|
13864
|
+
const range = withAxisBounds(automatic, opts, logBase);
|
|
13865
|
+
if (scale) {
|
|
13866
|
+
scale.min = range.min;
|
|
13867
|
+
scale.max = range.max;
|
|
13868
|
+
scale.ticks = generateAxisTicks(range, opts, 5);
|
|
12823
13869
|
}
|
|
12824
|
-
|
|
12825
|
-
|
|
13870
|
+
return {
|
|
13871
|
+
source: axis,
|
|
13872
|
+
range,
|
|
13873
|
+
minorTicks: generateMinorAxisTicks(range, opts),
|
|
13874
|
+
line: paint2(axis.spPr),
|
|
13875
|
+
majorGrid: paint2(axis.majorGridlinesSpPr),
|
|
13876
|
+
minorGrid: paint2(axis.minorGridlinesSpPr)
|
|
13877
|
+
};
|
|
13878
|
+
};
|
|
13879
|
+
const out = {};
|
|
13880
|
+
if (value)
|
|
13881
|
+
out.value = bind(
|
|
13882
|
+
value,
|
|
13883
|
+
model.valueAxis,
|
|
13884
|
+
[
|
|
13885
|
+
...model.series,
|
|
13886
|
+
...model.extraGroups?.filter((g) => !g.secondary).flatMap((g) => g.series) ?? []
|
|
13887
|
+
].flatMap((s) => s.values)
|
|
13888
|
+
);
|
|
13889
|
+
if (category)
|
|
13890
|
+
out.category = bind(
|
|
13891
|
+
category,
|
|
13892
|
+
model.xAxis ?? {
|
|
13893
|
+
min: 0,
|
|
13894
|
+
max: Math.max(1, model.categories.length - 1),
|
|
13895
|
+
majorUnit: 1,
|
|
13896
|
+
ticks: []
|
|
13897
|
+
},
|
|
13898
|
+
model.series.flatMap((s) => s.xValues ?? [])
|
|
13899
|
+
);
|
|
13900
|
+
if (secondary)
|
|
13901
|
+
out.secondary = bind(
|
|
13902
|
+
secondary,
|
|
13903
|
+
model.secondaryAxis,
|
|
13904
|
+
model.extraGroups?.filter((g) => g.secondary).flatMap((g) => g.series.flatMap((s) => s.values))
|
|
13905
|
+
);
|
|
13906
|
+
model.axes = out;
|
|
12826
13907
|
}
|
|
12827
13908
|
|
|
12828
13909
|
// chart/render/chart-view-analysis.ts
|
|
@@ -12874,15 +13955,15 @@ function seriesName(series, index, evaluateRef) {
|
|
|
12874
13955
|
const fromRef = resolveRef(series.nameRef, evaluateRef)?.map(toText).filter((t) => t !== "").join(" ");
|
|
12875
13956
|
return fromRef || series.name || `Series${index + 1}`;
|
|
12876
13957
|
}
|
|
12877
|
-
function seriesContext(chart, theme,
|
|
13958
|
+
function seriesContext(chart, theme, options2) {
|
|
12878
13959
|
const scheme = chartColorScheme(theme);
|
|
12879
13960
|
const resolver = { scheme: (name) => scheme[name] };
|
|
12880
13961
|
return {
|
|
12881
13962
|
theme,
|
|
12882
13963
|
scheme,
|
|
12883
13964
|
palette: chart.colorPalette === void 0 ? void 0 : findChartColorPalette(chart.colorPalette),
|
|
12884
|
-
evaluateRef:
|
|
12885
|
-
seriesColor:
|
|
13965
|
+
evaluateRef: options2.evaluateRef ?? (() => []),
|
|
13966
|
+
seriesColor: options2.seriesColor,
|
|
12886
13967
|
drawingColor: (color) => color && drawingColorCss(resolveDrawingColor(color, resolver, { transformOrder: "document" })),
|
|
12887
13968
|
gradient: (fill) => fill?.kind === "gradient" ? resolveChartGradient(
|
|
12888
13969
|
fill,
|
|
@@ -12908,7 +13989,11 @@ function seriesView(ctx, s, index, total, categoriesOf) {
|
|
|
12908
13989
|
})
|
|
12909
13990
|
);
|
|
12910
13991
|
if (Object.keys(points).length) view.pointGradients = points;
|
|
12911
|
-
Object.assign(
|
|
13992
|
+
Object.assign(
|
|
13993
|
+
view,
|
|
13994
|
+
analysisView(s, color, ctx.drawingColor),
|
|
13995
|
+
seriesMarkerViews(s, ctx.drawingColor)
|
|
13996
|
+
);
|
|
12912
13997
|
return view;
|
|
12913
13998
|
}
|
|
12914
13999
|
|
|
@@ -13081,12 +14166,70 @@ function chartTitleText(chart, theme) {
|
|
|
13081
14166
|
};
|
|
13082
14167
|
}
|
|
13083
14168
|
|
|
14169
|
+
// chart/render/chart-view-labels.ts
|
|
14170
|
+
function labelsOf(source, view, categories, numberFormat) {
|
|
14171
|
+
const { chart, series, points } = source;
|
|
14172
|
+
if ((series?.deleted ?? chart?.deleted) === true) return void 0;
|
|
14173
|
+
const percentBase = view.values.reduce(
|
|
14174
|
+
(sum, v) => sum + (v === null ? 0 : Math.abs(v)),
|
|
14175
|
+
0
|
|
14176
|
+
);
|
|
14177
|
+
const out = [];
|
|
14178
|
+
let any = false;
|
|
14179
|
+
view.values.forEach((value, i) => {
|
|
14180
|
+
const point = points?.[i];
|
|
14181
|
+
if (value === null || point?.deleted === true) return;
|
|
14182
|
+
const position = point?.position ?? series?.position ?? chart?.position;
|
|
14183
|
+
const x = view.xValues?.[i];
|
|
14184
|
+
const category = x === void 0 || x === null ? categories[i] : formatAxisValue(x);
|
|
14185
|
+
let built;
|
|
14186
|
+
if (point?.text !== void 0) built = { text: point.text };
|
|
14187
|
+
else {
|
|
14188
|
+
const flags = resolveDataLabelFlags({
|
|
14189
|
+
...point ? { point } : {},
|
|
14190
|
+
...series ? { series } : {},
|
|
14191
|
+
...chart ? { chart } : {}
|
|
14192
|
+
});
|
|
14193
|
+
built = composeDataLabelText({
|
|
14194
|
+
flags,
|
|
14195
|
+
seriesName: view.name,
|
|
14196
|
+
category,
|
|
14197
|
+
value,
|
|
14198
|
+
numberFormat: point?.numberFormat ?? series?.numberFormat ?? chart?.numberFormat ?? numberFormat,
|
|
14199
|
+
percentBase,
|
|
14200
|
+
bubbleSize: view.sizes?.[i] ?? void 0,
|
|
14201
|
+
formatValue: (v) => formatAxisValue(v),
|
|
14202
|
+
formatBubbleSize: (size) => formatAxisValue(size)
|
|
14203
|
+
});
|
|
14204
|
+
}
|
|
14205
|
+
if (!built) return;
|
|
14206
|
+
any = true;
|
|
14207
|
+
out[i] = {
|
|
14208
|
+
text: built.text,
|
|
14209
|
+
...position ? { position } : {},
|
|
14210
|
+
...built.color ? { color: built.color } : {}
|
|
14211
|
+
};
|
|
14212
|
+
});
|
|
14213
|
+
return any ? out : void 0;
|
|
14214
|
+
}
|
|
14215
|
+
function applyDataLabels(model, sources, extra) {
|
|
14216
|
+
const apply = (source, view) => {
|
|
14217
|
+
if (!source?.dataLabels) return;
|
|
14218
|
+
const labels = labelsOf(source.dataLabels, view, model.categories, source.numberFormat);
|
|
14219
|
+
if (labels) view.labels = labels;
|
|
14220
|
+
};
|
|
14221
|
+
model.series.forEach((view, i) => apply(sources[i], view));
|
|
14222
|
+
model.extraGroups?.forEach(
|
|
14223
|
+
(group2, g) => group2.series.forEach((view, i) => apply(extra[g]?.series[i], view))
|
|
14224
|
+
);
|
|
14225
|
+
}
|
|
14226
|
+
|
|
13084
14227
|
// chart/render/chart-view-ex.ts
|
|
13085
14228
|
function groupsAxis(groups, categories) {
|
|
13086
14229
|
let min = Infinity;
|
|
13087
14230
|
let max = -Infinity;
|
|
13088
|
-
for (const
|
|
13089
|
-
const extent = valueExtent(
|
|
14231
|
+
for (const group2 of groups) {
|
|
14232
|
+
const extent = valueExtent(group2.type, group2.grouping, group2.series, categories);
|
|
13090
14233
|
min = Math.min(min, extent.min);
|
|
13091
14234
|
max = Math.max(max, extent.max);
|
|
13092
14235
|
}
|
|
@@ -13095,17 +14238,17 @@ function groupsAxis(groups, categories) {
|
|
|
13095
14238
|
function chartExtraView(chart, model, ctx, total, categoriesOf) {
|
|
13096
14239
|
let index = chart.series.length;
|
|
13097
14240
|
const groups = [];
|
|
13098
|
-
for (const
|
|
13099
|
-
const series =
|
|
14241
|
+
for (const group2 of chart.extraGroups ?? []) {
|
|
14242
|
+
const series = group2.series.map((s) => seriesView(ctx, s, index++, total, categoriesOf));
|
|
13100
14243
|
const view = {
|
|
13101
|
-
type:
|
|
13102
|
-
grouping:
|
|
14244
|
+
type: group2.chartType,
|
|
14245
|
+
grouping: group2.grouping ?? (group2.chartType === "column" ? "clustered" : "standard"),
|
|
13103
14246
|
series,
|
|
13104
|
-
secondary:
|
|
14247
|
+
secondary: group2.secondary
|
|
13105
14248
|
};
|
|
13106
|
-
if (
|
|
13107
|
-
if (
|
|
13108
|
-
if (
|
|
14249
|
+
if (group2.chartType === "stock") view.stock = stockView(group2.stock, ctx);
|
|
14250
|
+
if (group2.barGapWidth !== void 0) view.barGapWidth = group2.barGapWidth;
|
|
14251
|
+
if (group2.barOverlap !== void 0) view.barOverlap = group2.barOverlap;
|
|
13109
14252
|
groups.push(view);
|
|
13110
14253
|
}
|
|
13111
14254
|
if (!groups.length) return;
|
|
@@ -13122,8 +14265,8 @@ function chartExtraAxes(model) {
|
|
|
13122
14265
|
const own2 = valueExtent(model.type, model.grouping, model.series, count);
|
|
13123
14266
|
let min = own2.min;
|
|
13124
14267
|
let max = own2.max;
|
|
13125
|
-
for (const
|
|
13126
|
-
const extent = valueExtent(
|
|
14268
|
+
for (const group2 of shared) {
|
|
14269
|
+
const extent = valueExtent(group2.type, group2.grouping, group2.series, count);
|
|
13127
14270
|
min = Math.min(min, extent.min);
|
|
13128
14271
|
max = Math.max(max, extent.max);
|
|
13129
14272
|
}
|
|
@@ -13150,11 +14293,11 @@ function histogramView(chart, model) {
|
|
|
13150
14293
|
const first3 = model.series[0];
|
|
13151
14294
|
if (!first3) return;
|
|
13152
14295
|
const raw = first3.values.map((v) => v ?? Number.NaN);
|
|
13153
|
-
const
|
|
13154
|
-
const bins =
|
|
14296
|
+
const options2 = chart.histogram ?? {};
|
|
14297
|
+
const bins = options2.aggregateByCategory ? aggregateByCategory(
|
|
13155
14298
|
first3.values.map((v) => v ?? 0),
|
|
13156
14299
|
model.categories
|
|
13157
|
-
) : computeHistogramBins(raw,
|
|
14300
|
+
) : computeHistogramBins(raw, options2, formatAxisValue);
|
|
13158
14301
|
model.categories = bins.map((bin) => bin.label);
|
|
13159
14302
|
first3.values = bins.map((bin) => bin.value);
|
|
13160
14303
|
model.barGapWidth = 0;
|
|
@@ -13178,11 +14321,11 @@ var SUPPORTED = /* @__PURE__ */ new Set([
|
|
|
13178
14321
|
"treemap",
|
|
13179
14322
|
"sunburst"
|
|
13180
14323
|
]);
|
|
13181
|
-
function chartSummaryView(chart, theme,
|
|
14324
|
+
function chartSummaryView(chart, theme, options2 = {}) {
|
|
13182
14325
|
const type = chart.chartType;
|
|
13183
14326
|
const radial = type === "pie" || type === "doughnut";
|
|
13184
14327
|
const byPoint = radial || type === "treemap" || type === "sunburst";
|
|
13185
|
-
const ctx = seriesContext(chart, theme,
|
|
14328
|
+
const ctx = seriesContext(chart, theme, options2);
|
|
13186
14329
|
const { palette, scheme, drawingColor } = ctx;
|
|
13187
14330
|
const grouping = chart.grouping ?? (type === "bar" || type === "column" ? "clustered" : "standard");
|
|
13188
14331
|
const rawCategories = [];
|
|
@@ -13266,128 +14409,23 @@ function chartSummaryView(chart, theme, options = {}) {
|
|
|
13266
14409
|
chartExtraView(chart, model, ctx, total, collect);
|
|
13267
14410
|
if (type === "waterfall") waterfallView(chart, model, ctx);
|
|
13268
14411
|
else if (!byPoint) model.valueAxis = valueAxis(model);
|
|
14412
|
+
applyDataLabels(model, chart.series, extra);
|
|
13269
14413
|
chartExtraAxes(model);
|
|
14414
|
+
applyChartAxes(model, chart, ctx.drawingColor);
|
|
13270
14415
|
return model;
|
|
13271
14416
|
}
|
|
13272
14417
|
|
|
13273
|
-
// text/css-font-family.ts
|
|
13274
|
-
var FALLBACKS = {
|
|
13275
|
-
calibri: '"Calibri", "Carlito", "Segoe UI", Arial, sans-serif',
|
|
13276
|
-
"calibri light": '"Calibri Light", "Calibri", "Carlito", "Segoe UI", Arial, sans-serif',
|
|
13277
|
-
cambria: '"Cambria", "Caladea", Georgia, serif',
|
|
13278
|
-
arial: 'Arial, "Liberation Sans", Helvetica, sans-serif',
|
|
13279
|
-
"times new roman": '"Times New Roman", "Liberation Serif", Times, serif',
|
|
13280
|
-
"courier new": '"Courier New", "Liberation Mono", monospace',
|
|
13281
|
-
aptos: '"Aptos", "Calibri", "Carlito", "Segoe UI", sans-serif'
|
|
13282
|
-
};
|
|
13283
|
-
function cssFontFamily(name) {
|
|
13284
|
-
const known = FALLBACKS[name.toLowerCase()];
|
|
13285
|
-
if (known) return known;
|
|
13286
|
-
const quoted = `"${name.replace(/["\\]/g, "")}"`;
|
|
13287
|
-
return `${quoted}, "Calibri", "Carlito", "Segoe UI", sans-serif`;
|
|
13288
|
-
}
|
|
13289
|
-
|
|
13290
|
-
// chart/render/chart-svg-appearance.ts
|
|
13291
|
-
var nextPaintId = 0;
|
|
13292
|
-
function chartGradientPaint(model, width = 1024, height = 768) {
|
|
13293
|
-
const prefix2 = `xlsx-chart-${++nextPaintId}`;
|
|
13294
|
-
const appearance = { ...model.appearance };
|
|
13295
|
-
const defs = [];
|
|
13296
|
-
const shadowPaint = (shadow, suffix) => {
|
|
13297
|
-
const id = `${prefix2}-${suffix}`;
|
|
13298
|
-
const pad = Math.max(4, shadow.blur * 3 + Math.abs(shadow.dx) + Math.abs(shadow.dy));
|
|
13299
|
-
defs.push(
|
|
13300
|
-
`<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>`
|
|
13301
|
-
);
|
|
13302
|
-
return `url(#${id})`;
|
|
13303
|
-
};
|
|
13304
|
-
for (const [part, entry] of Object.entries(appearance)) {
|
|
13305
|
-
if (entry?.textShadow)
|
|
13306
|
-
appearance[part] = {
|
|
13307
|
-
...entry,
|
|
13308
|
-
textShadowFilter: shadowPaint(entry.textShadow, `${part}-text-shadow`)
|
|
13309
|
-
};
|
|
13310
|
-
}
|
|
13311
|
-
const paint2 = (gradient, suffix, bounds) => {
|
|
13312
|
-
const def = buildChartGradientDef(`${prefix2}-${suffix}`, gradient, bounds);
|
|
13313
|
-
defs.push(chartGradientMarkup(def));
|
|
13314
|
-
return `url(#${def.id})`;
|
|
13315
|
-
};
|
|
13316
|
-
for (const part of ["chartArea", "plotArea"]) {
|
|
13317
|
-
const entry = appearance[part];
|
|
13318
|
-
if (!entry?.gradient) continue;
|
|
13319
|
-
if (part === "plotArea" && ["circle", "shape"].includes(entry.gradient.path ?? "")) continue;
|
|
13320
|
-
appearance[part] = {
|
|
13321
|
-
...entry,
|
|
13322
|
-
fillColor: paint2(entry.gradient, part, { width, height, shape: "rect" })
|
|
13323
|
-
};
|
|
13324
|
-
}
|
|
13325
|
-
const series = model.series.map((source, index) => {
|
|
13326
|
-
const view = { ...source };
|
|
13327
|
-
if (source.shadow) view.shadowFilter = shadowPaint(source.shadow, `s${index}-shadow`);
|
|
13328
|
-
const bounds = model.type === "bar" || model.type === "column" ? { width: 1, height: 1, shape: "rect" } : void 0;
|
|
13329
|
-
if (source.gradient) view.color = paint2(source.gradient, `s${index}`, bounds);
|
|
13330
|
-
if (source.pointGradients) {
|
|
13331
|
-
view.pointColors = [...source.pointColors ?? []];
|
|
13332
|
-
for (const [key, gradient] of Object.entries(source.pointGradients))
|
|
13333
|
-
view.pointColors[Number(key)] = paint2(gradient, `s${index}-p${key}`, bounds);
|
|
13334
|
-
}
|
|
13335
|
-
return view;
|
|
13336
|
-
});
|
|
13337
|
-
return defs.length ? { model: { ...model, appearance, series }, defs: `<defs>${defs.join("")}</defs>` } : { model, defs: "" };
|
|
13338
|
-
}
|
|
13339
|
-
function chartTextAttributes(model, part, fallbackSize = FONT_SIZE) {
|
|
13340
|
-
const entry = model.appearance?.[part];
|
|
13341
|
-
return {
|
|
13342
|
-
size: entry?.fontSize === void 0 ? fallbackSize : chartPointsToPixels(entry.fontSize),
|
|
13343
|
-
...entry?.color === void 0 ? {} : { fill: entry.color },
|
|
13344
|
-
...entry?.bold === void 0 ? {} : { weight: entry.bold ? "bold" : "normal" },
|
|
13345
|
-
...entry?.italic === void 0 ? {} : { italic: entry.italic },
|
|
13346
|
-
...entry?.underline === void 0 ? {} : { underline: entry.underline },
|
|
13347
|
-
...entry?.typeface === void 0 ? {} : { family: cssFontFamily(entry.typeface) },
|
|
13348
|
-
...entry?.textShadowFilter === void 0 ? {} : { filter: entry.textShadowFilter }
|
|
13349
|
-
};
|
|
13350
|
-
}
|
|
13351
|
-
function chartStroke(model, part) {
|
|
13352
|
-
const entry = model.appearance?.[part];
|
|
13353
|
-
return {
|
|
13354
|
-
color: entry?.axisVisible === false ? "none" : entry?.lineColor ?? (part === "gridlineMajor" ? GRID_COLOR : AXIS_COLOR),
|
|
13355
|
-
width: entry?.lineWidth === void 0 ? 1 : chartPointsToPixels(entry.lineWidth)
|
|
13356
|
-
};
|
|
13357
|
-
}
|
|
13358
|
-
function chartAreaRect(model, part, area) {
|
|
13359
|
-
if (area.w <= 0 || area.h <= 0) return "";
|
|
13360
|
-
const entry = model.appearance?.[part];
|
|
13361
|
-
let fill = entry?.fillColor ?? (part === "chartArea" ? "#FFFFFF" : "none");
|
|
13362
|
-
let defs = "";
|
|
13363
|
-
if (part !== "chartArea" && entry?.gradient && (part !== "plotArea" || ["circle", "shape"].includes(entry.gradient.path ?? ""))) {
|
|
13364
|
-
const def = buildChartGradientDef(`xlsx-chart-${++nextPaintId}-${part}`, entry.gradient, {
|
|
13365
|
-
width: area.w,
|
|
13366
|
-
height: area.h,
|
|
13367
|
-
shape: "rect"
|
|
13368
|
-
});
|
|
13369
|
-
defs = `<defs>${chartGradientMarkup(def)}</defs>`;
|
|
13370
|
-
fill = `url(#${def.id})`;
|
|
13371
|
-
}
|
|
13372
|
-
const stroke = entry?.lineColor ?? "none";
|
|
13373
|
-
if (fill === "none" && stroke === "none") return "";
|
|
13374
|
-
const width = entry?.lineWidth === void 0 ? 1 : chartPointsToPixels(entry.lineWidth);
|
|
13375
|
-
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}"/>`;
|
|
13376
|
-
}
|
|
13377
|
-
|
|
13378
14418
|
// chart/render/chart-svg-cartesian.ts
|
|
13379
14419
|
function cartesianAxes(model, area, out) {
|
|
13380
14420
|
const scale = model.valueAxis;
|
|
13381
14421
|
if (!scale) return void 0;
|
|
13382
|
-
const labels = scale.ticks.map((t) =>
|
|
14422
|
+
const labels = scale.ticks.map((t) => axisTickText(t, model.axes?.value, scale.percent));
|
|
13383
14423
|
const valueAttrs = chartTextAttributes(model, "valueAxis");
|
|
13384
14424
|
const categoryAttrs = chartTextAttributes(model, "categoryAxis");
|
|
13385
14425
|
const valueSize = valueAttrs.size ?? 10;
|
|
13386
14426
|
const categorySize = categoryAttrs.size ?? 10;
|
|
13387
|
-
const
|
|
13388
|
-
const
|
|
13389
|
-
const valueLabels = model.appearance?.valueAxis?.labelsVisible !== false;
|
|
13390
|
-
const categoryLabels = model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
14427
|
+
const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
|
|
14428
|
+
const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
13391
14429
|
const labelW = valueLabels ? Math.max(...labels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
|
|
13392
14430
|
const horizontal = model.horizontal;
|
|
13393
14431
|
const cats = Math.max(1, model.categories.length);
|
|
@@ -13396,7 +14434,7 @@ function cartesianAxes(model, area, out) {
|
|
|
13396
14434
|
Math.max(...model.categories.map((c) => textWidth(c, categorySize)), 8) + 6
|
|
13397
14435
|
);
|
|
13398
14436
|
const second = horizontal ? void 0 : model.secondaryAxis;
|
|
13399
|
-
const secondLabels = second?.ticks.map((t) =>
|
|
14437
|
+
const secondLabels = second?.ticks.map((t) => axisTickText(t, model.axes?.secondary, second.percent)) ?? [];
|
|
13400
14438
|
const secondW = second ? valueLabels ? Math.max(...secondLabels.map((l) => textWidth(l, valueSize)), 8) + 8 : 4 : 0;
|
|
13401
14439
|
const plot = horizontal ? {
|
|
13402
14440
|
x: area.x + catW,
|
|
@@ -13409,29 +14447,47 @@ function cartesianAxes(model, area, out) {
|
|
|
13409
14447
|
w: Math.max(1, area.w - labelW - 4 - secondW),
|
|
13410
14448
|
h: Math.max(1, area.h - Math.max(20, categorySize * 1.5))
|
|
13411
14449
|
};
|
|
13412
|
-
const
|
|
13413
|
-
const value = horizontal ? (v) => plot.x + (v - scale.min) / span * plot.w : (v) => plot.y + plot.h - (v - scale.min) / span * plot.h;
|
|
14450
|
+
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;
|
|
13414
14451
|
const bandSize = (horizontal ? plot.h : plot.w) / cats;
|
|
13415
|
-
const
|
|
14452
|
+
const index = (i) => model.axes?.category?.range.reverseOrder ? cats - 1 - i : i;
|
|
14453
|
+
const band = horizontal ? (i) => plot.y + plot.h - bandSize * (index(i) + 0.5) : (i) => plot.x + bandSize * (index(i) + 0.5);
|
|
13416
14454
|
out.push(chartAreaRect(model, "plotArea", plot));
|
|
14455
|
+
out.push(axisGridlines(model, model.axes?.value, scale.ticks, value, plot, horizontal));
|
|
14456
|
+
if (model.axes?.category?.source.majorGridlines || model.axes?.category?.source.minorGridlines)
|
|
14457
|
+
out.push(
|
|
14458
|
+
axisGridlines(
|
|
14459
|
+
model,
|
|
14460
|
+
model.axes.category,
|
|
14461
|
+
model.categories.map((_, i) => i),
|
|
14462
|
+
band,
|
|
14463
|
+
plot,
|
|
14464
|
+
!horizontal
|
|
14465
|
+
)
|
|
14466
|
+
);
|
|
13417
14467
|
scale.ticks.forEach((t, i) => {
|
|
13418
14468
|
const p = value(t);
|
|
13419
14469
|
const label = labels[i] ?? "";
|
|
13420
14470
|
if (horizontal) {
|
|
13421
|
-
out.push(line2(p, plot.y, p, plot.y + plot.h, grid.color, grid.width));
|
|
13422
14471
|
if (valueLabels)
|
|
13423
14472
|
out.push(
|
|
13424
14473
|
text(p, plot.y + plot.h + valueSize + 2, label, { anchor: "middle", ...valueAttrs })
|
|
13425
14474
|
);
|
|
13426
14475
|
} else {
|
|
13427
|
-
out.push(line2(plot.x, p, plot.x + plot.w, p, grid.color, grid.width));
|
|
13428
14476
|
if (valueLabels)
|
|
13429
14477
|
out.push(text(plot.x - 4, p + valueSize * 0.3, label, { anchor: "end", ...valueAttrs }));
|
|
13430
14478
|
}
|
|
13431
14479
|
});
|
|
13432
|
-
const
|
|
13433
|
-
|
|
13434
|
-
|
|
14480
|
+
const source = model.axes?.value?.source;
|
|
14481
|
+
const crossing = source?.crosses === "max" ? scale.max : source?.crosses === "min" ? scale.min : source?.crossesAt ?? 0;
|
|
14482
|
+
const zero = value(Math.min(Math.max(crossing, scale.min), scale.max));
|
|
14483
|
+
if (horizontal)
|
|
14484
|
+
out.push(
|
|
14485
|
+
axisLine(model, model.axes?.category, "categoryAxis", zero, plot.y, zero, plot.y + plot.h)
|
|
14486
|
+
);
|
|
14487
|
+
else
|
|
14488
|
+
out.push(
|
|
14489
|
+
axisLine(model, model.axes?.category, "categoryAxis", plot.x, zero, plot.x + plot.w, zero)
|
|
14490
|
+
);
|
|
13435
14491
|
const step = Math.max(
|
|
13436
14492
|
1,
|
|
13437
14493
|
Math.ceil(cats / Math.max(1, Math.floor((horizontal ? plot.h : plot.w) / 14)))
|
|
@@ -13456,20 +14512,23 @@ function cartesianAxes(model, area, out) {
|
|
|
13456
14512
|
});
|
|
13457
14513
|
const frame2 = { plot, value, band, bandSize };
|
|
13458
14514
|
if (second) {
|
|
13459
|
-
|
|
13460
|
-
frame2.secondary = (v) => plot.y + plot.h - (v - second.min) / secondSpan * plot.h;
|
|
13461
|
-
const secondAxis = chartStroke(model, "valueAxis");
|
|
14515
|
+
frame2.secondary = (v) => plot.y + plot.h - chartAxisRatio(v, second, model.axes?.secondary) * plot.h;
|
|
13462
14516
|
out.push(
|
|
13463
|
-
|
|
14517
|
+
axisLine(
|
|
14518
|
+
model,
|
|
14519
|
+
model.axes?.secondary,
|
|
14520
|
+
"valueAxis",
|
|
13464
14521
|
plot.x + plot.w,
|
|
13465
14522
|
plot.y,
|
|
13466
14523
|
plot.x + plot.w,
|
|
13467
|
-
plot.y + plot.h
|
|
13468
|
-
secondAxis.color,
|
|
13469
|
-
secondAxis.width
|
|
14524
|
+
plot.y + plot.h
|
|
13470
14525
|
)
|
|
13471
14526
|
);
|
|
13472
|
-
if (
|
|
14527
|
+
if (model.axes?.secondary?.source.majorGridlines || model.axes?.secondary?.source.minorGridlines)
|
|
14528
|
+
out.push(
|
|
14529
|
+
axisGridlines(model, model.axes.secondary, second.ticks, frame2.secondary, plot, false)
|
|
14530
|
+
);
|
|
14531
|
+
if (chartAxisLabels(model.axes?.secondary))
|
|
13473
14532
|
second.ticks.forEach(
|
|
13474
14533
|
(t, i) => out.push(
|
|
13475
14534
|
text(plot.x + plot.w + 4, frame2.secondary(t) + valueSize * 0.3, secondLabels[i] ?? "", {
|
|
@@ -13493,6 +14552,7 @@ function linesAndAreas(model, frame2, out) {
|
|
|
13493
14552
|
const stacked = model.grouping === "stacked" || model.grouping === "percentStacked";
|
|
13494
14553
|
const acc = new Array(model.categories.length).fill(0);
|
|
13495
14554
|
const area = model.type === "area";
|
|
14555
|
+
const marks = [];
|
|
13496
14556
|
const layers = [];
|
|
13497
14557
|
model.series.forEach((s, si) => {
|
|
13498
14558
|
const points = [];
|
|
@@ -13507,16 +14567,24 @@ function linesAndAreas(model, frame2, out) {
|
|
|
13507
14567
|
const top = below2 + (v ?? 0);
|
|
13508
14568
|
if (stacked) acc[i] = top;
|
|
13509
14569
|
points.push([frame2.band(i), frame2.value(top)]);
|
|
14570
|
+
marks.push({
|
|
14571
|
+
series: s,
|
|
14572
|
+
index: i,
|
|
14573
|
+
x: frame2.band(i),
|
|
14574
|
+
y: frame2.value(top),
|
|
14575
|
+
radius: area ? 0 : chartMarkerRadius(s, i, 2.5)
|
|
14576
|
+
});
|
|
13510
14577
|
lower.push([frame2.band(i), frame2.value(below2)]);
|
|
13511
14578
|
});
|
|
13512
14579
|
layers.push({
|
|
14580
|
+
series: s,
|
|
13513
14581
|
points,
|
|
13514
14582
|
lower,
|
|
13515
14583
|
color: s.color,
|
|
13516
14584
|
filter: s.shadowFilter ? ` filter="${s.shadowFilter}"` : ""
|
|
13517
14585
|
});
|
|
13518
14586
|
});
|
|
13519
|
-
for (const { points, lower, color, filter } of area ? [...layers].reverse() : layers) {
|
|
14587
|
+
for (const { points, lower, color, filter, series } of area ? [...layers].reverse() : layers) {
|
|
13520
14588
|
if (area) {
|
|
13521
14589
|
const poly = [...points, ...[...lower].reverse()].map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
|
|
13522
14590
|
out.push(`<polygon points="${poly}" fill="${color}" fill-opacity="0.85"${filter}/>`);
|
|
@@ -13535,10 +14603,11 @@ function linesAndAreas(model, frame2, out) {
|
|
|
13535
14603
|
else segment2.push(`${n(x)},${n(y)}`);
|
|
13536
14604
|
}
|
|
13537
14605
|
flush();
|
|
13538
|
-
|
|
13539
|
-
if (!Number.isNaN(x))
|
|
13540
|
-
|
|
14606
|
+
points.forEach(([x, y], index) => {
|
|
14607
|
+
if (!Number.isNaN(x)) out.push(chartSeriesMarkerSvg(series, index, x, y, 2.5));
|
|
14608
|
+
});
|
|
13541
14609
|
}
|
|
14610
|
+
pointLabels(model, marks, out);
|
|
13542
14611
|
}
|
|
13543
14612
|
|
|
13544
14613
|
// chart/render/chart-svg-xy.ts
|
|
@@ -13546,16 +14615,14 @@ function scatter(model, area, out) {
|
|
|
13546
14615
|
const ys = model.valueAxis;
|
|
13547
14616
|
const xs = model.xAxis;
|
|
13548
14617
|
if (!ys || !xs) return;
|
|
13549
|
-
const yLabels = ys.ticks.map((t) =>
|
|
14618
|
+
const yLabels = ys.ticks.map((t) => axisTickText(t, model.axes?.value));
|
|
13550
14619
|
const valueAttrs = chartTextAttributes(model, "valueAxis");
|
|
13551
14620
|
const categoryAttrs = chartTextAttributes(model, "categoryAxis");
|
|
13552
14621
|
const valueSize = valueAttrs.size ?? 10;
|
|
13553
14622
|
const categorySize = categoryAttrs.size ?? 10;
|
|
13554
|
-
const grid = chartStroke(model, "gridlineMajor");
|
|
13555
14623
|
const xAxis = chartStroke(model, "categoryAxis");
|
|
13556
|
-
const
|
|
13557
|
-
const
|
|
13558
|
-
const categoryLabels = model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
14624
|
+
const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
|
|
14625
|
+
const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
13559
14626
|
const labelW = valueLabels ? Math.max(...yLabels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
|
|
13560
14627
|
const plot = {
|
|
13561
14628
|
x: area.x + labelW,
|
|
@@ -13575,17 +14642,24 @@ function scatter(model, area, out) {
|
|
|
13575
14642
|
s.values.forEach((_, i) => {
|
|
13576
14643
|
reach = Math.max(reach, radiusOf(s.sizes?.[i] ?? void 0) ?? 0);
|
|
13577
14644
|
});
|
|
13578
|
-
const widen = (s, length) => {
|
|
14645
|
+
const widen = (s, length, axis) => {
|
|
14646
|
+
if (axis?.range.logScale) return s;
|
|
13579
14647
|
const pad = reach * (s.max - s.min || 1) / Math.max(1, length - 2 * reach);
|
|
13580
|
-
return {
|
|
14648
|
+
return {
|
|
14649
|
+
...s,
|
|
14650
|
+
min: axis?.source.scaling.min === void 0 ? s.min - pad : s.min,
|
|
14651
|
+
max: axis?.source.scaling.max === void 0 ? s.max + pad : s.max
|
|
14652
|
+
};
|
|
13581
14653
|
};
|
|
13582
|
-
const xView = widen(xs, plot.w);
|
|
13583
|
-
const yView = widen(ys, plot.h);
|
|
13584
|
-
const px = (v) => plot.x + (v
|
|
13585
|
-
const py = (v) => plot.y + plot.h - (v
|
|
14654
|
+
const xView = widen(xs, plot.w, model.axes?.category);
|
|
14655
|
+
const yView = widen(ys, plot.h, model.axes?.value);
|
|
14656
|
+
const px = (v) => plot.x + chartAxisRatio(v, xView, model.axes?.category) * plot.w;
|
|
14657
|
+
const py = (v) => plot.y + plot.h - chartAxisRatio(v, yView, model.axes?.value) * plot.h;
|
|
13586
14658
|
out.push(chartAreaRect(model, "plotArea", plot));
|
|
14659
|
+
out.push(axisGridlines(model, model.axes?.value, ys.ticks, py, plot, false));
|
|
14660
|
+
if (model.axes?.category)
|
|
14661
|
+
out.push(axisGridlines(model, model.axes.category, xs.ticks, px, plot, true));
|
|
13587
14662
|
ys.ticks.forEach((t, i) => {
|
|
13588
|
-
out.push(line2(plot.x, py(t), plot.x + plot.w, py(t), grid.color, grid.width));
|
|
13589
14663
|
if (valueLabels)
|
|
13590
14664
|
out.push(
|
|
13591
14665
|
text(plot.x - 4, py(t) + valueSize * 0.3, yLabels[i] ?? "", {
|
|
@@ -13595,19 +14669,31 @@ function scatter(model, area, out) {
|
|
|
13595
14669
|
);
|
|
13596
14670
|
});
|
|
13597
14671
|
for (const t of xs.ticks) {
|
|
13598
|
-
|
|
14672
|
+
if (!model.axes?.category?.source.deleted)
|
|
14673
|
+
out.push(line2(px(t), plot.y + plot.h, px(t), plot.y + plot.h + 3, xAxis.color, xAxis.width));
|
|
13599
14674
|
if (categoryLabels)
|
|
13600
14675
|
out.push(
|
|
13601
|
-
text(px(t), plot.y + plot.h + categorySize + 3,
|
|
14676
|
+
text(px(t), plot.y + plot.h + categorySize + 3, axisTickText(t, model.axes?.category), {
|
|
13602
14677
|
anchor: "middle",
|
|
13603
14678
|
...categoryAttrs
|
|
13604
14679
|
})
|
|
13605
14680
|
);
|
|
13606
14681
|
}
|
|
13607
14682
|
out.push(
|
|
13608
|
-
|
|
14683
|
+
axisLine(
|
|
14684
|
+
model,
|
|
14685
|
+
model.axes?.category,
|
|
14686
|
+
"categoryAxis",
|
|
14687
|
+
plot.x,
|
|
14688
|
+
plot.y + plot.h,
|
|
14689
|
+
plot.x + plot.w,
|
|
14690
|
+
plot.y + plot.h
|
|
14691
|
+
)
|
|
14692
|
+
);
|
|
14693
|
+
out.push(
|
|
14694
|
+
axisLine(model, model.axes?.value, "valueAxis", plot.x, plot.y, plot.x, plot.y + plot.h)
|
|
13609
14695
|
);
|
|
13610
|
-
|
|
14696
|
+
const marks = [];
|
|
13611
14697
|
for (const [si, s] of model.series.entries())
|
|
13612
14698
|
s.values.forEach((v, i) => {
|
|
13613
14699
|
const x = s.xValues?.[i] ?? null;
|
|
@@ -13615,15 +14701,18 @@ function scatter(model, area, out) {
|
|
|
13615
14701
|
const filter = s.shadowFilter ? ` filter="${s.shadowFilter}"` : "";
|
|
13616
14702
|
const fill = s.pointColors?.[i] ?? s.color;
|
|
13617
14703
|
if (!bubble) {
|
|
13618
|
-
out.push(
|
|
14704
|
+
out.push(chartSeriesMarkerSvg(s, i, px(x), py(v)));
|
|
14705
|
+
marks.push({ series: s, index: i, x: px(x), y: py(v), radius: chartMarkerRadius(s, i) });
|
|
13619
14706
|
return;
|
|
13620
14707
|
}
|
|
13621
14708
|
const r = radiusOf(s.sizes?.[i] ?? void 0);
|
|
13622
14709
|
if (r === void 0) return;
|
|
14710
|
+
marks.push({ series: s, index: i, x: px(x), y: py(v), radius: r });
|
|
13623
14711
|
out.push(
|
|
13624
14712
|
`<circle cx="${n(px(x))}" cy="${n(py(v))}" r="${n(r)}" fill="${fill}" fill-opacity="0.6" data-chart-series="${si}" data-chart-point="${i}"${filter}/>`
|
|
13625
14713
|
);
|
|
13626
14714
|
});
|
|
14715
|
+
pointLabels(model, marks, out);
|
|
13627
14716
|
scatterAnalysis(model, px, py, out);
|
|
13628
14717
|
}
|
|
13629
14718
|
|
|
@@ -13740,21 +14829,21 @@ function cartesianSvg(model, area) {
|
|
|
13740
14829
|
return out.join("");
|
|
13741
14830
|
}
|
|
13742
14831
|
const layers = [{ model, frame: frame2 }];
|
|
13743
|
-
for (const
|
|
14832
|
+
for (const group2 of model.extraGroups ?? []) {
|
|
13744
14833
|
const grouped = {
|
|
13745
14834
|
...model,
|
|
13746
|
-
type:
|
|
13747
|
-
grouping:
|
|
13748
|
-
series:
|
|
14835
|
+
type: group2.type,
|
|
14836
|
+
grouping: group2.grouping,
|
|
14837
|
+
series: group2.series,
|
|
13749
14838
|
horizontal: false
|
|
13750
14839
|
};
|
|
13751
|
-
if (
|
|
14840
|
+
if (group2.stock) grouped.stock = group2.stock;
|
|
13752
14841
|
else delete grouped.stock;
|
|
13753
|
-
if (
|
|
14842
|
+
if (group2.barGapWidth !== void 0) grouped.barGapWidth = group2.barGapWidth;
|
|
13754
14843
|
else delete grouped.barGapWidth;
|
|
13755
|
-
if (
|
|
14844
|
+
if (group2.barOverlap !== void 0) grouped.barOverlap = group2.barOverlap;
|
|
13756
14845
|
else delete grouped.barOverlap;
|
|
13757
|
-
const value =
|
|
14846
|
+
const value = group2.secondary && frame2.secondary ? frame2.secondary : frame2.value;
|
|
13758
14847
|
layers.push({ model: grouped, frame: { ...frame2, value } });
|
|
13759
14848
|
}
|
|
13760
14849
|
layers.map((layer, order) => ({ layer, order })).sort(
|
|
@@ -13788,7 +14877,9 @@ function pieSvg(model, area) {
|
|
|
13788
14877
|
const out = [chartAreaRect(model, "plotArea", area)];
|
|
13789
14878
|
const cx = area.x + area.w / 2;
|
|
13790
14879
|
const cy = area.y + area.h / 2;
|
|
13791
|
-
const
|
|
14880
|
+
const margin = hasOutsideLabels(model) ? Math.min(area.w, area.h) * 0.12 : 0;
|
|
14881
|
+
const radius = Math.max(1, Math.min(area.w, area.h) / 2 - 4 - margin);
|
|
14882
|
+
const slices = [];
|
|
13792
14883
|
const rings = model.type === "doughnut" ? model.series : model.series.slice(0, 1);
|
|
13793
14884
|
const hole = model.type === "doughnut" ? radius * 0.5 : 0;
|
|
13794
14885
|
const ringSize = (radius - hole) / Math.max(1, rings.length);
|
|
@@ -13805,9 +14896,20 @@ function pieSvg(model, area) {
|
|
|
13805
14896
|
out.push(
|
|
13806
14897
|
`<path d="${slicePath(cx, cy, outer, inner, angle, angle + sweep)}" fill="${color}" stroke="#FFFFFF" stroke-width="1"${s.shadowFilter ? ` filter="${s.shadowFilter}"` : ""}/>`
|
|
13807
14898
|
);
|
|
14899
|
+
slices.push({
|
|
14900
|
+
series: s,
|
|
14901
|
+
index: i,
|
|
14902
|
+
cx,
|
|
14903
|
+
cy,
|
|
14904
|
+
outer,
|
|
14905
|
+
inner,
|
|
14906
|
+
start: angle,
|
|
14907
|
+
end: angle + sweep
|
|
14908
|
+
});
|
|
13808
14909
|
angle += sweep;
|
|
13809
14910
|
});
|
|
13810
14911
|
});
|
|
14912
|
+
sliceLabels(model, slices, out);
|
|
13811
14913
|
return out.join("");
|
|
13812
14914
|
}
|
|
13813
14915
|
function radarSvg(model, area) {
|
|
@@ -13820,32 +14922,37 @@ function radarSvg(model, area) {
|
|
|
13820
14922
|
const valueSize = valueAttrs.size ?? 9;
|
|
13821
14923
|
const categorySize = categoryAttrs.size ?? 10;
|
|
13822
14924
|
const grid = chartStroke(model, "gridlineMajor");
|
|
13823
|
-
const axis = chartStroke(model, "categoryAxis");
|
|
13824
14925
|
const cx = area.x + area.w / 2;
|
|
13825
14926
|
const cy = area.y + area.h / 2 + 4;
|
|
13826
14927
|
const radius = Math.max(1, Math.min(area.w, area.h) / 2 - Math.max(18, categorySize * 1.8));
|
|
13827
14928
|
const angle = (i) => i / count * Math.PI * 2;
|
|
13828
|
-
const r = (v) => (v
|
|
14929
|
+
const r = (v) => chartAxisRatio(v, scale, model.axes?.value) * radius;
|
|
13829
14930
|
const labelEvery = Math.max(
|
|
13830
14931
|
1,
|
|
13831
14932
|
Math.ceil(12 / Math.max(1, radius / Math.max(1, scale.ticks.length - 1)))
|
|
13832
14933
|
);
|
|
13833
14934
|
for (const [k, t] of scale.ticks.entries()) {
|
|
13834
14935
|
const ring = Array.from({ length: count }, (_, i) => polar(cx, cy, r(t), angle(i))).map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
|
|
13835
|
-
|
|
13836
|
-
|
|
13837
|
-
|
|
13838
|
-
|
|
14936
|
+
if (!model.axes?.value || model.axes.value.source.majorGridlines)
|
|
14937
|
+
out.push(
|
|
14938
|
+
`<polygon points="${ring}" fill="none" stroke="${grid.color}" stroke-width="${n(grid.width)}"/>`
|
|
14939
|
+
);
|
|
14940
|
+
if (chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false && k % labelEvery === 0)
|
|
13839
14941
|
out.push(
|
|
13840
|
-
text(
|
|
14942
|
+
text(
|
|
14943
|
+
cx + 3,
|
|
14944
|
+
cy - r(t) + valueSize * 0.3,
|
|
14945
|
+
axisTickText(t, model.axes?.value, scale.percent),
|
|
14946
|
+
valueAttrs
|
|
14947
|
+
)
|
|
13841
14948
|
);
|
|
13842
14949
|
}
|
|
13843
14950
|
model.categories.forEach((c, i) => {
|
|
13844
14951
|
const [x, y] = polar(cx, cy, radius, angle(i));
|
|
13845
|
-
out.push(
|
|
14952
|
+
out.push(axisLine(model, model.axes?.category, "categoryAxis", cx, cy, x, y));
|
|
13846
14953
|
const [lx, ly] = polar(cx, cy, radius + 10, angle(i));
|
|
13847
14954
|
const anchor = Math.abs(lx - cx) < 2 ? "middle" : lx > cx ? "start" : "end";
|
|
13848
|
-
if (model.appearance?.categoryAxis?.labelsVisible !== false)
|
|
14955
|
+
if (chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false)
|
|
13849
14956
|
out.push(
|
|
13850
14957
|
text(lx, ly + categorySize * 0.3, fit(c, area.w / 4, categorySize), {
|
|
13851
14958
|
anchor,
|
|
@@ -13853,12 +14960,22 @@ function radarSvg(model, area) {
|
|
|
13853
14960
|
})
|
|
13854
14961
|
);
|
|
13855
14962
|
});
|
|
14963
|
+
const marks = [];
|
|
13856
14964
|
for (const s of model.series) {
|
|
13857
|
-
const
|
|
14965
|
+
const vertices = s.values.slice(0, count).map((v, i) => polar(cx, cy, r(v ?? scale.min), angle(i)));
|
|
14966
|
+
vertices.forEach(([x, y], i) => {
|
|
14967
|
+
if (s.values[i] === null) return;
|
|
14968
|
+
const markerSeries = s;
|
|
14969
|
+
if (markerSeries.marker || markerSeries.pointMarkers)
|
|
14970
|
+
out.push(chartSeriesMarkerSvg(s, i, x, y));
|
|
14971
|
+
marks.push({ series: s, index: i, x, y, radius: chartMarkerRadius(s, i) });
|
|
14972
|
+
});
|
|
14973
|
+
const points = vertices.map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
|
|
13858
14974
|
out.push(
|
|
13859
14975
|
`<polygon points="${points}" fill="none" stroke="${s.color}" stroke-width="2"${s.shadowFilter ? ` filter="${s.shadowFilter}"` : ""}/>`
|
|
13860
14976
|
);
|
|
13861
14977
|
}
|
|
14978
|
+
pointLabels(model, marks, out);
|
|
13862
14979
|
return out.join("");
|
|
13863
14980
|
}
|
|
13864
14981
|
|
|
@@ -13949,33 +15066,33 @@ var CHART_FONT_FAMILY = "Calibri, Carlito, Arial, sans-serif";
|
|
|
13949
15066
|
function cssFont(attrs) {
|
|
13950
15067
|
return `${attrs.italic ? "italic" : "normal"} ${attrs.weight ?? "normal"} ${attrs.size ?? 10}px ${attrs.family ?? CHART_FONT_FAMILY}`;
|
|
13951
15068
|
}
|
|
13952
|
-
function chartFontMetrics(attrs,
|
|
13953
|
-
const metrics =
|
|
15069
|
+
function chartFontMetrics(attrs, options2) {
|
|
15070
|
+
const metrics = options2.measureFont?.(cssFont(attrs));
|
|
13954
15071
|
return metrics && Number.isFinite(metrics.ascent) && Number.isFinite(metrics.descent) && metrics.ascent >= 0 && metrics.descent >= 0 && metrics.ascent + metrics.descent > 0 ? metrics : void 0;
|
|
13955
15072
|
}
|
|
13956
|
-
function chartTextWidth(content, attrs,
|
|
13957
|
-
const width =
|
|
15073
|
+
function chartTextWidth(content, attrs, options2) {
|
|
15074
|
+
const width = options2.measureText?.(content, cssFont(attrs));
|
|
13958
15075
|
return width !== void 0 && Number.isFinite(width) && width >= 0 ? width : textWidth(content, attrs.size);
|
|
13959
15076
|
}
|
|
13960
|
-
function fitChartText(content, maxWidth, attrs,
|
|
13961
|
-
if (!
|
|
13962
|
-
if (chartTextWidth(content, attrs,
|
|
15077
|
+
function fitChartText(content, maxWidth, attrs, options2) {
|
|
15078
|
+
if (!options2.measureText) return fit(content, maxWidth, attrs.size);
|
|
15079
|
+
if (chartTextWidth(content, attrs, options2) <= maxWidth) return content;
|
|
13963
15080
|
const points = [...content];
|
|
13964
15081
|
let low = 0;
|
|
13965
15082
|
let high = points.length;
|
|
13966
15083
|
while (low < high) {
|
|
13967
15084
|
const mid = Math.ceil((low + high) / 2);
|
|
13968
|
-
if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`, attrs,
|
|
15085
|
+
if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`, attrs, options2) <= maxWidth) low = mid;
|
|
13969
15086
|
else high = mid - 1;
|
|
13970
15087
|
}
|
|
13971
15088
|
return `${points.slice(0, low).join("")}\u2026`;
|
|
13972
15089
|
}
|
|
13973
15090
|
|
|
13974
15091
|
// chart/render/chart-svg-legend.ts
|
|
13975
|
-
function chartLegendSvg(model, area, frame2,
|
|
15092
|
+
function chartLegendSvg(model, area, frame2, options2) {
|
|
13976
15093
|
const automatic = [];
|
|
13977
15094
|
const bounds = {};
|
|
13978
|
-
const reserved = automaticLegend(model, area, automatic,
|
|
15095
|
+
const reserved = automaticLegend(model, area, automatic, options2, bounds);
|
|
13979
15096
|
const plot = model.legendOverlay ? area : reserved;
|
|
13980
15097
|
const box = bounds.box;
|
|
13981
15098
|
if (!box) return { plot, markup: "", foreground: false };
|
|
@@ -13989,11 +15106,11 @@ function chartLegendSvg(model, area, frame2, options) {
|
|
|
13989
15106
|
const entries = legendEntries(model);
|
|
13990
15107
|
const attrs = chartTextAttributes(model, "legend");
|
|
13991
15108
|
const size = attrs.size ?? 10;
|
|
13992
|
-
const font = chartFontMetrics(attrs,
|
|
15109
|
+
const font = chartFontMetrics(attrs, options2);
|
|
13993
15110
|
const keySize = size / 2;
|
|
13994
15111
|
const keyGap = size / 4;
|
|
13995
15112
|
const widths = entries.map(
|
|
13996
|
-
(entry) => chartTextWidth(entry.label, attrs,
|
|
15113
|
+
(entry) => chartTextWidth(entry.label, attrs, options2) + keySize + keyGap
|
|
13997
15114
|
);
|
|
13998
15115
|
const horizontal = manual.width > manual.height && widths.reduce((sum, width) => sum + width, 0) + size <= manual.width;
|
|
13999
15116
|
const rowWidth = horizontal ? manual.width / entries.length : manual.width;
|
|
@@ -14008,8 +15125,8 @@ function chartLegendSvg(model, area, frame2, options) {
|
|
|
14008
15125
|
];
|
|
14009
15126
|
const baselineOffset = font ? (font.ascent - font.descent) / 2 : size * 0.35;
|
|
14010
15127
|
entries.forEach((entry, i) => {
|
|
14011
|
-
const available = horizontal ? chartTextWidth(entry.label, attrs,
|
|
14012
|
-
const label = fitChartText(entry.label, available, attrs,
|
|
15128
|
+
const available = horizontal ? chartTextWidth(entry.label, attrs, options2) : Math.max(0, rowWidth - size / 2 - keySize - keyGap);
|
|
15129
|
+
const label = fitChartText(entry.label, available, attrs, options2);
|
|
14013
15130
|
const contentWidth = Math.min(
|
|
14014
15131
|
horizontal ? widths[i] ?? 0 : Math.max(...widths),
|
|
14015
15132
|
rowWidth - size / 2
|
|
@@ -14052,7 +15169,7 @@ function legendEntries(model) {
|
|
|
14052
15169
|
color: s.color
|
|
14053
15170
|
}));
|
|
14054
15171
|
}
|
|
14055
|
-
function automaticLegend(model, area, out,
|
|
15172
|
+
function automaticLegend(model, area, out, options2, bounds) {
|
|
14056
15173
|
const entries = legendEntries(model);
|
|
14057
15174
|
if (!model.showLegend || entries.length === 0) return area;
|
|
14058
15175
|
const pos = model.legendPosition;
|
|
@@ -14061,7 +15178,7 @@ function automaticLegend(model, area, out, options, bounds) {
|
|
|
14061
15178
|
const rowH = Math.max(16, size * 1.4);
|
|
14062
15179
|
if (pos === "t" || pos === "b") {
|
|
14063
15180
|
const widths = entries.map(
|
|
14064
|
-
(e) => Math.min(chartTextWidth(e.label, attrs,
|
|
15181
|
+
(e) => Math.min(chartTextWidth(e.label, attrs, options2) + 20, area.w / 2)
|
|
14065
15182
|
);
|
|
14066
15183
|
const total = widths.reduce((a, b) => a + b, 0);
|
|
14067
15184
|
let x2 = area.x + Math.max(0, (area.w - total) / 2);
|
|
@@ -14078,14 +15195,14 @@ function automaticLegend(model, area, out, options, bounds) {
|
|
|
14078
15195
|
entries.forEach((e, i) => {
|
|
14079
15196
|
const w = widths[i] ?? 0;
|
|
14080
15197
|
out.push(rect2(x2, y, 8, 8, e.color));
|
|
14081
|
-
out.push(text(x2 + 12, y + 8, fitChartText(e.label, w - 16, attrs,
|
|
15198
|
+
out.push(text(x2 + 12, y + 8, fitChartText(e.label, w - 16, attrs, options2), attrs));
|
|
14082
15199
|
x2 += w;
|
|
14083
15200
|
});
|
|
14084
15201
|
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 };
|
|
14085
15202
|
}
|
|
14086
15203
|
const width = Math.min(
|
|
14087
15204
|
area.w * 0.35,
|
|
14088
|
-
Math.max(...entries.map((e) => chartTextWidth(e.label, attrs,
|
|
15205
|
+
Math.max(...entries.map((e) => chartTextWidth(e.label, attrs, options2))) + 22
|
|
14089
15206
|
);
|
|
14090
15207
|
const height = entries.length * rowH;
|
|
14091
15208
|
const x = pos === "l" ? area.x + 4 : area.x + area.w - width;
|
|
@@ -14103,24 +15220,24 @@ function automaticLegend(model, area, out, options, bounds) {
|
|
|
14103
15220
|
const y = y0 + i * rowH;
|
|
14104
15221
|
if (y + rowH > area.y + area.h + 2) return;
|
|
14105
15222
|
out.push(rect2(x, y + 3, 8, 8, e.color));
|
|
14106
|
-
out.push(text(x + 12, y + 11, fitChartText(e.label, width - 16, attrs,
|
|
15223
|
+
out.push(text(x + 12, y + 11, fitChartText(e.label, width - 16, attrs, options2), attrs));
|
|
14107
15224
|
});
|
|
14108
15225
|
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 };
|
|
14109
15226
|
}
|
|
14110
15227
|
|
|
14111
15228
|
// text/wrap-styled-runs.ts
|
|
14112
15229
|
var graphemes = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
14113
|
-
function wrapStyledRuns(runs, maxWidth,
|
|
15230
|
+
function wrapStyledRuns(runs, maxWidth, measure2, options2 = {}) {
|
|
14114
15231
|
const groups = [];
|
|
14115
15232
|
for (const [source, run] of runs.entries()) {
|
|
14116
15233
|
for (const token of run.text.split(/(\r\n|[\r\n]|[ \t]+)/u).filter(Boolean)) {
|
|
14117
15234
|
const kind = /^[\r\n]+$/u.test(token) ? "break" : /^[ \t]+$/u.test(token) ? "space" : "word";
|
|
14118
|
-
let
|
|
14119
|
-
if (!
|
|
14120
|
-
|
|
14121
|
-
groups.push(
|
|
15235
|
+
let group2 = groups.at(-1);
|
|
15236
|
+
if (!group2 || group2.kind !== kind || kind === "break") {
|
|
15237
|
+
group2 = { kind, pieces: [] };
|
|
15238
|
+
groups.push(group2);
|
|
14122
15239
|
}
|
|
14123
|
-
if (kind !== "break")
|
|
15240
|
+
if (kind !== "break") group2.pieces.push({ run, source, text: token });
|
|
14124
15241
|
}
|
|
14125
15242
|
}
|
|
14126
15243
|
const merged = (left, right) => {
|
|
@@ -14133,7 +15250,7 @@ function wrapStyledRuns(runs, maxWidth, measure, options = {}) {
|
|
|
14133
15250
|
return result2;
|
|
14134
15251
|
};
|
|
14135
15252
|
const width = (pieces) => pieces.reduce((sum, piece) => {
|
|
14136
|
-
const advance =
|
|
15253
|
+
const advance = measure2(piece.text, piece.run);
|
|
14137
15254
|
return sum + (Number.isFinite(advance) && advance >= 0 ? advance : 0);
|
|
14138
15255
|
}, 0);
|
|
14139
15256
|
const result = [];
|
|
@@ -14144,29 +15261,29 @@ function wrapStyledRuns(runs, maxWidth, measure, options = {}) {
|
|
|
14144
15261
|
line3 = [];
|
|
14145
15262
|
spaces = [];
|
|
14146
15263
|
};
|
|
14147
|
-
for (const
|
|
14148
|
-
if (
|
|
15264
|
+
for (const group2 of groups) {
|
|
15265
|
+
if (group2.kind === "break") {
|
|
14149
15266
|
flush();
|
|
14150
15267
|
continue;
|
|
14151
15268
|
}
|
|
14152
|
-
if (
|
|
14153
|
-
spaces =
|
|
15269
|
+
if (group2.kind === "space") {
|
|
15270
|
+
spaces = group2.pieces;
|
|
14154
15271
|
continue;
|
|
14155
15272
|
}
|
|
14156
15273
|
const separator = line3.length ? spaces : [];
|
|
14157
|
-
const wordWidth = width(
|
|
14158
|
-
if (line3.length && width(merged(line3, [...separator, ...
|
|
15274
|
+
const wordWidth = width(group2.pieces);
|
|
15275
|
+
if (line3.length && width(merged(line3, [...separator, ...group2.pieces])) > maxWidth) flush();
|
|
14159
15276
|
else line3 = merged(line3, separator);
|
|
14160
15277
|
spaces = [];
|
|
14161
|
-
if (
|
|
14162
|
-
for (const piece of
|
|
15278
|
+
if (options2.breakWords && wordWidth > maxWidth) {
|
|
15279
|
+
for (const piece of group2.pieces) {
|
|
14163
15280
|
for (const { segment: segment2 } of graphemes.segment(piece.text)) {
|
|
14164
15281
|
const next = { ...piece, text: segment2 };
|
|
14165
15282
|
if (line3.length && width(merged(line3, [next])) > maxWidth) flush();
|
|
14166
15283
|
line3 = merged(line3, [next]);
|
|
14167
15284
|
}
|
|
14168
15285
|
}
|
|
14169
|
-
} else line3 = merged(line3,
|
|
15286
|
+
} else line3 = merged(line3, group2.pieces);
|
|
14170
15287
|
}
|
|
14171
15288
|
flush();
|
|
14172
15289
|
return result;
|
|
@@ -14176,11 +15293,11 @@ function wrapStyledRuns(runs, maxWidth, measure, options = {}) {
|
|
|
14176
15293
|
function spacing(value, naturalHeight, fallback) {
|
|
14177
15294
|
return value ? value.unit === "points" ? chartPointsToPixels(value.value) : naturalHeight * value.value : fallback;
|
|
14178
15295
|
}
|
|
14179
|
-
function chartRichTitleSvg(model, width,
|
|
15296
|
+
function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
|
|
14180
15297
|
if (!model.title) return void 0;
|
|
14181
15298
|
const base = chartTextAttributes(model, "title", 14);
|
|
14182
15299
|
const capacity = Math.max(1, width * 0.8 - 8);
|
|
14183
|
-
if (!model.titleText && !hasManualLayoutFields(model.titleLayout) && !model.titleOverlay && !model.title.includes("\n") && chartTextWidth(model.title, base,
|
|
15300
|
+
if (!model.titleText && !hasManualLayoutFields(model.titleLayout) && !model.titleOverlay && !model.title.includes("\n") && chartTextWidth(model.title, base, options2) <= capacity)
|
|
14184
15301
|
return void 0;
|
|
14185
15302
|
const paragraphs = model.titleText?.paragraphs ?? [
|
|
14186
15303
|
{
|
|
@@ -14216,7 +15333,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
14216
15333
|
"title",
|
|
14217
15334
|
base.size
|
|
14218
15335
|
),
|
|
14219
|
-
|
|
15336
|
+
options2
|
|
14220
15337
|
),
|
|
14221
15338
|
{ breakWords: true }
|
|
14222
15339
|
);
|
|
@@ -14240,10 +15357,10 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
14240
15357
|
return {
|
|
14241
15358
|
...line3,
|
|
14242
15359
|
runs,
|
|
14243
|
-
width: runs.reduce((sum, run) => sum + chartTextWidth(run.text, run.attrs,
|
|
15360
|
+
width: runs.reduce((sum, run) => sum + chartTextWidth(run.text, run.attrs, options2), 0),
|
|
14244
15361
|
size: runs.length ? Math.max(...runs.map((run) => run.attrs.size ?? 14)) : base.size ?? 14,
|
|
14245
15362
|
fontMetrics: (runs.length ? runs.map((run) => run.attrs) : [base]).map(
|
|
14246
|
-
(attrs) => chartFontMetrics(attrs,
|
|
15363
|
+
(attrs) => chartFontMetrics(attrs, options2)
|
|
14247
15364
|
)
|
|
14248
15365
|
};
|
|
14249
15366
|
});
|
|
@@ -14281,7 +15398,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
14281
15398
|
anchor: "start"
|
|
14282
15399
|
}).replace("<text ", '<tspan data-chart-title-run="true" ').replace("</text>", "</tspan>")
|
|
14283
15400
|
);
|
|
14284
|
-
x += chartTextWidth(run.text, run.attrs,
|
|
15401
|
+
x += chartTextWidth(run.text, run.attrs, options2);
|
|
14285
15402
|
}
|
|
14286
15403
|
}
|
|
14287
15404
|
const parent = text(0, 0, "", { ...base, underline: false }).replace(
|
|
@@ -14307,7 +15424,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
14307
15424
|
}
|
|
14308
15425
|
|
|
14309
15426
|
// chart/render/chart-svg.ts
|
|
14310
|
-
function renderChartSvg(model, width, height,
|
|
15427
|
+
function renderChartSvg(model, width, height, options2 = {}) {
|
|
14311
15428
|
const paint2 = chartGradientPaint(model, Math.max(1, width), Math.max(1, height));
|
|
14312
15429
|
model = paint2.model;
|
|
14313
15430
|
const w = Math.max(1, width);
|
|
@@ -14321,7 +15438,7 @@ function renderChartSvg(model, width, height, options = {}) {
|
|
|
14321
15438
|
if (paint2.defs) out.push(paint2.defs);
|
|
14322
15439
|
out.push(chartAreaRect(model, "chartArea", { x: 0, y: 0, w, h }));
|
|
14323
15440
|
let area = { x: 8, y: 8, w: w - 16, h: h - 16 };
|
|
14324
|
-
const richTitle = chartRichTitleSvg(model, w,
|
|
15441
|
+
const richTitle = chartRichTitleSvg(model, w, options2, h);
|
|
14325
15442
|
if (richTitle) {
|
|
14326
15443
|
if (model.titleLayout || model.titleOverlay) foregroundTitle = richTitle.markup;
|
|
14327
15444
|
else out.push(richTitle.markup);
|
|
@@ -14330,9 +15447,9 @@ function renderChartSvg(model, width, height, options = {}) {
|
|
|
14330
15447
|
} else if (model.title) {
|
|
14331
15448
|
const attrs = chartTextAttributes(model, "title", 14);
|
|
14332
15449
|
const size = attrs.size ?? 14;
|
|
14333
|
-
const label = fitChartText(model.title, w - 16, attrs,
|
|
14334
|
-
const titleWidth = Math.min(w - 16, chartTextWidth(label, attrs,
|
|
14335
|
-
const font = chartFontMetrics(attrs,
|
|
15450
|
+
const label = fitChartText(model.title, w - 16, attrs, options2);
|
|
15451
|
+
const titleWidth = Math.min(w - 16, chartTextWidth(label, attrs, options2) + 8);
|
|
15452
|
+
const font = chartFontMetrics(attrs, options2);
|
|
14336
15453
|
const titleHeight = Math.max(24, font ? font.ascent + font.descent + 4 : size * 1.4 + 4);
|
|
14337
15454
|
out.push(
|
|
14338
15455
|
chartAreaRect(model, "title", {
|
|
@@ -14360,7 +15477,7 @@ function renderChartSvg(model, width, height, options = {}) {
|
|
|
14360
15477
|
out.push("</svg>");
|
|
14361
15478
|
return out.join("");
|
|
14362
15479
|
}
|
|
14363
|
-
const legend = chartLegendSvg(model, area, { width: w, height: h },
|
|
15480
|
+
const legend = chartLegendSvg(model, area, { width: w, height: h }, options2);
|
|
14364
15481
|
area = legend.plot;
|
|
14365
15482
|
if (!legend.foreground) out.push(legend.markup);
|
|
14366
15483
|
if (area.w > 4 && area.h > 4) {
|
|
@@ -14407,8 +15524,8 @@ function chartSpaceKind(space) {
|
|
|
14407
15524
|
const type = chartSummaryFromSpace(space).chartType;
|
|
14408
15525
|
return { type, drawn: DRAWN_CHART_TYPES.has(type) };
|
|
14409
15526
|
}
|
|
14410
|
-
function renderChartSpaceSvg(space,
|
|
14411
|
-
const { width, height, theme, fonts, formatting, colorPalette, styleDefinition, ...svg } =
|
|
15527
|
+
function renderChartSpaceSvg(space, options2) {
|
|
15528
|
+
const { width, height, theme, fonts, formatting, colorPalette, styleDefinition, ...svg } = options2;
|
|
14412
15529
|
const summary = chartSummaryFromSpace(space, {
|
|
14413
15530
|
...formatting ? { formatting } : {},
|
|
14414
15531
|
...colorPalette !== void 0 ? { colorPalette } : {},
|
|
@@ -14417,8 +15534,8 @@ function renderChartSpaceSvg(space, options) {
|
|
|
14417
15534
|
const view = chartSummaryView(summary, chartThemePalette(theme, fonts));
|
|
14418
15535
|
return renderChartSvg(view, width, height, svg);
|
|
14419
15536
|
}
|
|
14420
|
-
function renderChartSummarySvg(summary,
|
|
14421
|
-
const { width, height, theme, fonts, ...svg } =
|
|
15537
|
+
function renderChartSummarySvg(summary, options2) {
|
|
15538
|
+
const { width, height, theme, fonts, ...svg } = options2;
|
|
14422
15539
|
const view = chartSummaryView(summary, chartThemePalette(theme, fonts));
|
|
14423
15540
|
return renderChartSvg(view, width, height, svg);
|
|
14424
15541
|
}
|
|
@@ -14523,11 +15640,11 @@ function parseDirectParagraphProperties(props) {
|
|
|
14523
15640
|
|
|
14524
15641
|
// docx/numbering-parse.ts
|
|
14525
15642
|
var own = (map, key) => Object.prototype.hasOwnProperty.call(map, key) ? map[key] : void 0;
|
|
14526
|
-
function resolveNumberingLevel(catalog, numId,
|
|
15643
|
+
function resolveNumberingLevel(catalog, numId, level2) {
|
|
14527
15644
|
const num = own(catalog.nums, numId);
|
|
14528
15645
|
if (!num) return void 0;
|
|
14529
|
-
const override = num.levelOverrides?.[
|
|
14530
|
-
const sourceAbstract = own(catalog.abstractNums, num.abstractNumId)?.levels[
|
|
15646
|
+
const override = num.levelOverrides?.[level2];
|
|
15647
|
+
const sourceAbstract = own(catalog.abstractNums, num.abstractNumId)?.levels[level2];
|
|
14531
15648
|
const abstract = sourceAbstract?.startWasOmitted && sourceAbstract.start === 1 ? { ...sourceAbstract, start: 0 } : sourceAbstract;
|
|
14532
15649
|
let base = override?.lvl ?? abstract;
|
|
14533
15650
|
if (!base) return void 0;
|
|
@@ -14926,10 +16043,10 @@ function resolveParagraphNumbering(paragraph, styleCatalog, numberingCatalog) {
|
|
|
14926
16043
|
const inherited = resolveStyleNumbering(paragraph.style, styleCatalog);
|
|
14927
16044
|
if (!inherited || inherited.numId <= 0) return void 0;
|
|
14928
16045
|
if (numberingCatalog && paragraph.style && styleCatalog.styles[paragraph.style]) {
|
|
14929
|
-
for (let
|
|
14930
|
-
const definition = resolveNumberingLevel(numberingCatalog, String(inherited.numId),
|
|
16046
|
+
for (let level2 = 0; level2 < 9; level2++) {
|
|
16047
|
+
const definition = resolveNumberingLevel(numberingCatalog, String(inherited.numId), level2);
|
|
14931
16048
|
if (definition?.paragraphStyleId === paragraph.style)
|
|
14932
|
-
return { numId: inherited.numId, level };
|
|
16049
|
+
return { numId: inherited.numId, level: level2 };
|
|
14933
16050
|
}
|
|
14934
16051
|
}
|
|
14935
16052
|
return inherited;
|
|
@@ -14962,23 +16079,23 @@ var NumberingCounters = class {
|
|
|
14962
16079
|
return started;
|
|
14963
16080
|
}
|
|
14964
16081
|
/** Advances one level and resets deeper counters according to their resolved restart rules. */
|
|
14965
|
-
advance(numId,
|
|
16082
|
+
advance(numId, level2, def, catalog) {
|
|
14966
16083
|
const counts = this.forNum(numId);
|
|
14967
16084
|
const started = this.startedLevels(numId);
|
|
14968
|
-
const next = started.has(
|
|
14969
|
-
counts.set(
|
|
14970
|
-
started.add(
|
|
16085
|
+
const next = started.has(level2) ? (counts.get(level2) ?? def.start) + 1 : def.start;
|
|
16086
|
+
counts.set(level2, next);
|
|
16087
|
+
started.add(level2);
|
|
14971
16088
|
for (const deeper of [...started]) {
|
|
14972
|
-
if (deeper <=
|
|
16089
|
+
if (deeper <= level2) continue;
|
|
14973
16090
|
const deeperDef = resolveNumberingLevel(catalog, numId, deeper);
|
|
14974
16091
|
const restart = deeperDef?.lvlRestart;
|
|
14975
16092
|
if (restart === 0) continue;
|
|
14976
16093
|
const trigger = restart !== void 0 && restart > 0 && restart <= deeper ? restart - 1 : deeper - 1;
|
|
14977
|
-
if (
|
|
16094
|
+
if (level2 > trigger) continue;
|
|
14978
16095
|
counts.delete(deeper);
|
|
14979
16096
|
started.delete(deeper);
|
|
14980
16097
|
}
|
|
14981
|
-
for (let ancestor = 0; ancestor <
|
|
16098
|
+
for (let ancestor = 0; ancestor < level2; ancestor++) {
|
|
14982
16099
|
if (started.has(ancestor)) continue;
|
|
14983
16100
|
const ancestorDef = resolveNumberingLevel(catalog, numId, ancestor);
|
|
14984
16101
|
if (!ancestorDef) continue;
|
|
@@ -14988,14 +16105,14 @@ var NumberingCounters = class {
|
|
|
14988
16105
|
return next;
|
|
14989
16106
|
}
|
|
14990
16107
|
/** Current value for an ancestor placeholder, defaulting to its own start when never instantiated. */
|
|
14991
|
-
current(numId,
|
|
14992
|
-
return this.forNum(numId).get(
|
|
16108
|
+
current(numId, level2, start) {
|
|
16109
|
+
return this.forNum(numId).get(level2) ?? start;
|
|
14993
16110
|
}
|
|
14994
16111
|
};
|
|
14995
|
-
function substituteLvlText(lvlText, numId,
|
|
16112
|
+
function substituteLvlText(lvlText, numId, level2, catalog, counters, forceDecimal) {
|
|
14996
16113
|
return lvlText.replace(/%([1-9])/g, (match, digit) => {
|
|
14997
16114
|
const ancestorLevel = Number(digit) - 1;
|
|
14998
|
-
if (ancestorLevel >
|
|
16115
|
+
if (ancestorLevel > level2) return match;
|
|
14999
16116
|
const ancestorDef = resolveNumberingLevel(catalog, numId, ancestorLevel);
|
|
15000
16117
|
const start = ancestorDef?.start ?? 1;
|
|
15001
16118
|
const value = counters.current(numId, ancestorLevel, start);
|
|
@@ -15012,15 +16129,15 @@ function computeListLabels(model) {
|
|
|
15012
16129
|
const numbering = resolveParagraphNumbering(paragraph, model.paragraphStyles, catalog);
|
|
15013
16130
|
if (!numbering) continue;
|
|
15014
16131
|
const numId = String(numbering.numId);
|
|
15015
|
-
const
|
|
15016
|
-
const def = resolveNumberingLevel(catalog, numId,
|
|
16132
|
+
const level2 = Math.min(8, Math.max(0, numbering.level));
|
|
16133
|
+
const def = resolveNumberingLevel(catalog, numId, level2);
|
|
15017
16134
|
if (!def) continue;
|
|
15018
16135
|
if (def.numFmt === "none") continue;
|
|
15019
|
-
counters.advance(numId,
|
|
15020
|
-
const text2 = def.numFmt === "bullet" ? def.lvlText : substituteLvlText(def.lvlText, numId,
|
|
16136
|
+
counters.advance(numId, level2, def, catalog);
|
|
16137
|
+
const text2 = def.numFmt === "bullet" ? def.lvlText : substituteLvlText(def.lvlText, numId, level2, catalog, counters, Boolean(def.isLgl));
|
|
15021
16138
|
labels.set(paragraph.id, {
|
|
15022
16139
|
numId,
|
|
15023
|
-
level,
|
|
16140
|
+
level: level2,
|
|
15024
16141
|
text: text2,
|
|
15025
16142
|
suffix: def.suffix ?? "tab",
|
|
15026
16143
|
...definedProps({
|
|
@@ -15155,7 +16272,7 @@ function datePicture(instr) {
|
|
|
15155
16272
|
}
|
|
15156
16273
|
var TOKENS = /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|am\/pm|AM\/PM|'[^']*'/g;
|
|
15157
16274
|
function formatWordDate(date, picture, locale = "en-US") {
|
|
15158
|
-
const name = (
|
|
16275
|
+
const name = (options2) => new Intl.DateTimeFormat(locale, options2).format(date);
|
|
15159
16276
|
const pad = (value) => String(value).padStart(2, "0");
|
|
15160
16277
|
const hours12 = date.getHours() % 12 || 12;
|
|
15161
16278
|
return picture.replace(TOKENS, (token) => {
|
|
@@ -15354,9 +16471,9 @@ function fontMetrics(measurer, font) {
|
|
|
15354
16471
|
const ascent = Math.min(height, measurer.ascentOf?.(font) ?? height * 0.8);
|
|
15355
16472
|
return { ascent, descent: height - ascent };
|
|
15356
16473
|
}
|
|
15357
|
-
function createFakeMeasurer(
|
|
15358
|
-
const charWidthFactor =
|
|
15359
|
-
const lineHeightFactor =
|
|
16474
|
+
function createFakeMeasurer(options2 = {}) {
|
|
16475
|
+
const charWidthFactor = options2.charWidthFactor ?? 0.6;
|
|
16476
|
+
const lineHeightFactor = options2.lineHeightFactor ?? 1.15;
|
|
15360
16477
|
return {
|
|
15361
16478
|
widthOf(text2, font) {
|
|
15362
16479
|
let width = 0;
|
|
@@ -15483,12 +16600,12 @@ function headerFooterSlotForPage(model, page, pageNumber) {
|
|
|
15483
16600
|
return page.pageInSection === 0 && section?.titlePage ? "first" : model.evenAndOddHeaders && pageNumber % 2 === 0 ? "even" : "default";
|
|
15484
16601
|
}
|
|
15485
16602
|
function headerFooterForPage(model, page, pageNumber, kind) {
|
|
15486
|
-
const
|
|
15487
|
-
const section =
|
|
16603
|
+
const sections2 = model.sections ?? [];
|
|
16604
|
+
const section = sections2[page.sectionIndex];
|
|
15488
16605
|
if (!section) return void 0;
|
|
15489
16606
|
const slot = headerFooterSlotForPage(model, page, pageNumber);
|
|
15490
16607
|
for (let index = page.sectionIndex; index >= 0; index--) {
|
|
15491
|
-
const content =
|
|
16608
|
+
const content = sections2[index]?.[kind]?.[slot];
|
|
15492
16609
|
if (content) return content;
|
|
15493
16610
|
}
|
|
15494
16611
|
return void 0;
|
|
@@ -17225,11 +18342,11 @@ function completedNoteStoryMinimum(row2, stories, pendingBlocks, available) {
|
|
|
17225
18342
|
for (const [index, cell] of row2.cells.entries()) {
|
|
17226
18343
|
const groups = /* @__PURE__ */ new Map();
|
|
17227
18344
|
for (const box of cell) {
|
|
17228
|
-
const
|
|
17229
|
-
if (
|
|
17230
|
-
const boxes = groups.get(
|
|
18345
|
+
const group2 = stories.get(box.blockId);
|
|
18346
|
+
if (group2 !== void 0) {
|
|
18347
|
+
const boxes = groups.get(group2) ?? [];
|
|
17231
18348
|
boxes.push(box);
|
|
17232
|
-
groups.set(
|
|
18349
|
+
groups.set(group2, boxes);
|
|
17233
18350
|
}
|
|
17234
18351
|
}
|
|
17235
18352
|
for (const boxes of groups.values()) {
|
|
@@ -17295,8 +18412,8 @@ var TableFootnotes = class {
|
|
|
17295
18412
|
for (const cell of row2.cells) {
|
|
17296
18413
|
for (const paragraph of cellParagraphs(cell))
|
|
17297
18414
|
if (paragraph.footnotes?.length) this.paragraphs.set(paragraph.id, paragraph);
|
|
17298
|
-
for (const [id,
|
|
17299
|
-
this.stories.set(id,
|
|
18415
|
+
for (const [id, group2] of (measured ? independentNoteStories(cell) : void 0) ?? []) {
|
|
18416
|
+
this.stories.set(id, group2);
|
|
17300
18417
|
}
|
|
17301
18418
|
}
|
|
17302
18419
|
}
|
|
@@ -17429,11 +18546,11 @@ var TableFootnotes = class {
|
|
|
17429
18546
|
for (const [index, cell] of row2.cells.entries()) {
|
|
17430
18547
|
const groups = /* @__PURE__ */ new Map();
|
|
17431
18548
|
for (const box of cell) {
|
|
17432
|
-
const
|
|
17433
|
-
if (
|
|
17434
|
-
const boxes = groups.get(
|
|
18549
|
+
const group2 = this.stories.get(box.blockId);
|
|
18550
|
+
if (group2 !== void 0) {
|
|
18551
|
+
const boxes = groups.get(group2) ?? [];
|
|
17435
18552
|
boxes.push(box);
|
|
17436
|
-
groups.set(
|
|
18553
|
+
groups.set(group2, boxes);
|
|
17437
18554
|
}
|
|
17438
18555
|
}
|
|
17439
18556
|
for (const boxes of groups.values()) {
|
|
@@ -19778,8 +20895,8 @@ function sectionBreak(type, note) {
|
|
|
19778
20895
|
return type;
|
|
19779
20896
|
}
|
|
19780
20897
|
function adaptDocumentModel(model, note = () => {
|
|
19781
|
-
},
|
|
19782
|
-
const reviewMode =
|
|
20898
|
+
}, options2 = {}) {
|
|
20899
|
+
const reviewMode = options2.reviewDisplayMode ?? "all";
|
|
19783
20900
|
const visibleModel = visibleReviewModel(model, reviewMode);
|
|
19784
20901
|
const catalog = model.paragraphStyles;
|
|
19785
20902
|
const noted = /* @__PURE__ */ new Set();
|
|
@@ -19957,14 +21074,14 @@ function adaptDocumentModel(model, note = () => {
|
|
|
19957
21074
|
note2.blocks.filter((block) => block.type === "paragraph").map((paragraph) => adaptParagraph(paragraph))
|
|
19958
21075
|
])
|
|
19959
21076
|
) : void 0;
|
|
19960
|
-
const
|
|
21077
|
+
const sections2 = model.sections;
|
|
19961
21078
|
const modernFootnoteSeparator = model.compatibilityMode === 15;
|
|
19962
21079
|
const legacyFootnoteColumns = model.compatibilityMode === 12 || model.compatibilityMode === 14;
|
|
19963
21080
|
if (!modernFootnoteSeparator && !legacyFootnoteColumns && model.sections?.some((section) => section.footnoteColumns !== void 0))
|
|
19964
21081
|
reportOnce(
|
|
19965
21082
|
"Footnote column settings are preserved, but this compatibility mode has not been verified against native Word; Print Layout uses the existing page-wide fallback."
|
|
19966
21083
|
);
|
|
19967
|
-
if (!
|
|
21084
|
+
if (!sections2 || !sections2.length) {
|
|
19968
21085
|
return {
|
|
19969
21086
|
sections: [
|
|
19970
21087
|
{
|
|
@@ -19986,8 +21103,8 @@ function adaptDocumentModel(model, note = () => {
|
|
|
19986
21103
|
}
|
|
19987
21104
|
const indexById = new Map(model.blocks.map((block, index) => [block.id, index]));
|
|
19988
21105
|
let start = 0;
|
|
19989
|
-
const result =
|
|
19990
|
-
const last = index ===
|
|
21106
|
+
const result = sections2.map((section, index) => {
|
|
21107
|
+
const last = index === sections2.length - 1;
|
|
19991
21108
|
const endIndex = last ? blocks.length : (indexById.get(section.endsAtBlockId) ?? start - 1) + 1;
|
|
19992
21109
|
const end = Math.max(start, endIndex);
|
|
19993
21110
|
const slice = blocks.slice(start, end);
|
|
@@ -20172,13 +21289,13 @@ function layoutDocument(input, measurer) {
|
|
|
20172
21289
|
}
|
|
20173
21290
|
return { ...result, approximations: [.../* @__PURE__ */ new Set([...result.approximations, FLOAT_WRAP_NOTE])] };
|
|
20174
21291
|
}
|
|
20175
|
-
function layoutDocumentModel(model, measurer,
|
|
20176
|
-
const projected = reviewDocumentFormatting(model,
|
|
21292
|
+
function layoutDocumentModel(model, measurer, options2 = {}, layout = layoutDocument) {
|
|
21293
|
+
const projected = reviewDocumentFormatting(model, options2.reviewDisplayMode ?? "all");
|
|
20177
21294
|
const approximations = reviewFormattingWarnings(projected.diagnostics);
|
|
20178
21295
|
const input = adaptDocumentModel(
|
|
20179
21296
|
projected.model,
|
|
20180
21297
|
(message) => approximations.push(message),
|
|
20181
|
-
|
|
21298
|
+
options2
|
|
20182
21299
|
);
|
|
20183
21300
|
const result = layout(input, measurer);
|
|
20184
21301
|
return {
|
|
@@ -20361,7 +21478,7 @@ function layoutDocumentIncremental(input, measurer, memory) {
|
|
|
20361
21478
|
}
|
|
20362
21479
|
|
|
20363
21480
|
// docx/layout/layout-session.ts
|
|
20364
|
-
function createLayoutSession(measurer,
|
|
21481
|
+
function createLayoutSession(measurer, options2 = {}) {
|
|
20365
21482
|
const sessionMeasurer = {
|
|
20366
21483
|
widthOf: (text2, font) => measurer.widthOf(text2, font),
|
|
20367
21484
|
lineHeightOf: (font) => measurer.lineHeightOf(font),
|
|
@@ -20369,7 +21486,7 @@ function createLayoutSession(measurer, options = {}) {
|
|
|
20369
21486
|
};
|
|
20370
21487
|
registerParagraphCache(sessionMeasurer);
|
|
20371
21488
|
const memory = {};
|
|
20372
|
-
const paginate =
|
|
21489
|
+
const paginate = options2.incremental ? (input, sessionMeasure) => layoutDocumentIncremental(input, sessionMeasure, memory) : layoutDocument;
|
|
20373
21490
|
return {
|
|
20374
21491
|
layoutDocument: (input) => paginate(input, sessionMeasurer),
|
|
20375
21492
|
layoutDocumentModel: (model, review = {}) => layoutDocumentModel(model, sessionMeasurer, review, paginate),
|