ooxml-core 1.18.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-X6AO6LKJ.mjs → PptxHandler-5GBBVJCR.mjs} +2 -2
- package/dist/{PptxHandler-5X4VOWAO.mjs → PptxHandler-H43MAMTO.mjs} +1 -1
- package/dist/{PptxHandler-4AHDZDA5.cjs → PptxHandler-ZHPGBSAF.cjs} +2 -2
- package/dist/{PresentationBuilder-UY3S4YE2.mjs → PresentationBuilder-7ZSUKCX5.mjs} +1 -1
- package/dist/{PresentationBuilder-LRX55PXA.mjs → PresentationBuilder-IJW42L3R.mjs} +2 -2
- package/dist/{PresentationBuilder-MJB4LIFS.cjs → PresentationBuilder-O4H4MMWB.cjs} +4 -4
- package/dist/automation/index.cjs +535 -266
- package/dist/automation/index.mjs +535 -266
- 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/index.cjs +815 -165
- package/dist/chart/index.d.ts +6 -0
- package/dist/chart/index.d.ts.map +1 -1
- package/dist/chart/index.mjs +795 -166
- 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/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-cartesian.d.ts.map +1 -1
- 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-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 +4 -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.map +1 -1
- package/dist/chart/render/summary.d.ts +6 -1
- package/dist/chart/render/summary.d.ts.map +1 -1
- package/dist/{chunk-7NWQUCGX.mjs → chunk-3XFPCZKB.mjs} +1 -1
- package/dist/{chunk-Z5Y53IZD.mjs → chunk-75GLSRZE.mjs} +4 -4
- package/dist/{chunk-LT7RCEHY.mjs → chunk-BIVNVDAH.mjs} +1 -1
- package/dist/{chunk-I5ZE3VLI.mjs → chunk-QBJRB6WW.mjs} +1 -1
- package/dist/{chunk-U7IDT6VT.mjs → chunk-RUZEMWDI.mjs} +1 -1
- package/dist/docx/index.cjs +695 -168
- package/dist/docx/index.mjs +695 -168
- package/dist/docx/layout/index.cjs +697 -170
- package/dist/docx/layout/index.mjs +697 -170
- package/dist/docx/ui/index.cjs +704 -177
- package/dist/docx/ui/index.mjs +704 -177
- package/dist/index.cjs +912 -262
- package/dist/index.mjs +912 -262
- package/dist/pptx/automation/index.cjs +54 -0
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/cli/index.cjs +54 -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 +54 -0
- package/dist/pptx/index.mjs +5 -5
- package/dist/teams/index.cjs +71 -5
- package/dist/teams/index.mjs +71 -5
- package/dist/visio/index.cjs +483 -214
- package/dist/visio/index.mjs +483 -214
- package/dist/visio/ui/index.cjs +504 -235
- package/dist/visio/ui/index.mjs +504 -235
- package/dist/xlsx/edit/chart-colors.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +818 -281
- package/dist/xlsx/index.mjs +818 -281
- package/dist/xlsx/load/index.cjs +58 -5
- package/dist/xlsx/load/index.mjs +58 -5
- package/dist/xlsx/read/chart.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +835 -298
- package/dist/xlsx/ui/index.mjs +835 -298
- package/package.json +1 -1
- /package/dist/{chunk-C363NN2C.mjs → chunk-H6TNNXJK.mjs} +0 -0
- /package/dist/{chunk-R4BCOQHB.cjs → chunk-MHMVD23Y.cjs} +0 -0
package/dist/docx/index.mjs
CHANGED
|
@@ -67,11 +67,11 @@ function checkXmlLimits(xml, label, limits = {}) {
|
|
|
67
67
|
throw new Error(`${label} XML exceeds the nesting depth limit of ${maxDepth}`);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
function parseXml(xml,
|
|
71
|
-
const label =
|
|
70
|
+
function parseXml(xml, options2 = {}) {
|
|
71
|
+
const label = options2.label ?? "OOXML";
|
|
72
72
|
if (/<!DOCTYPE|<!ENTITY/i.test(xml))
|
|
73
73
|
throw new Error(`${label} XML with DTD or entity declarations is not supported`);
|
|
74
|
-
checkXmlLimits(xml, label,
|
|
74
|
+
checkXmlLimits(xml, label, options2.limits);
|
|
75
75
|
let parseError = "";
|
|
76
76
|
let parsed;
|
|
77
77
|
try {
|
|
@@ -1569,8 +1569,8 @@ function rgbToHsl(r, g, b) {
|
|
|
1569
1569
|
}
|
|
1570
1570
|
return { h, s: clampUnitInterval(s), l: clampUnitInterval(l) };
|
|
1571
1571
|
}
|
|
1572
|
-
function hslToRgb(h, s, l, roundChannel = Math.round,
|
|
1573
|
-
const sC =
|
|
1572
|
+
function hslToRgb(h, s, l, roundChannel = Math.round, options2) {
|
|
1573
|
+
const sC = options2?.clampSaturation === false ? s : clampUnitInterval(s);
|
|
1574
1574
|
const lC = clampUnitInterval(l);
|
|
1575
1575
|
const hN = (h % 360 + 360) % 360;
|
|
1576
1576
|
const c2 = (1 - Math.abs(2 * lC - 1)) * sC;
|
|
@@ -2107,13 +2107,13 @@ var APPLIED = /* @__PURE__ */ new Set([
|
|
|
2107
2107
|
"lumMod",
|
|
2108
2108
|
"lumOff"
|
|
2109
2109
|
]);
|
|
2110
|
-
function resolveDrawingColor(color, theme,
|
|
2110
|
+
function resolveDrawingColor(color, theme, options2) {
|
|
2111
2111
|
const base = baseHex(color, theme);
|
|
2112
2112
|
const rgb = base ? hexToRgbChannels(base) : null;
|
|
2113
2113
|
if (!rgb) return void 0;
|
|
2114
|
-
if (
|
|
2114
|
+
if (options2?.transformOrder === "document") {
|
|
2115
2115
|
const value = orderedColorTransforms(rgb, color.transforms);
|
|
2116
|
-
const round2 =
|
|
2116
|
+
const round2 = options2.hslRounding === "halfDown" ? (channel) => Math.ceil(channel - 0.5) : Math.round;
|
|
2117
2117
|
return {
|
|
2118
2118
|
hex: `#${toHex(round2(value.r))}${toHex(round2(value.g))}${toHex(round2(value.b))}`,
|
|
2119
2119
|
alpha: value.alpha,
|
|
@@ -2164,7 +2164,7 @@ function resolveDrawingColor(color, theme, options) {
|
|
|
2164
2164
|
if (lumMod !== void 0) hsl.l = clampUnitInterval(hsl.l * lumMod);
|
|
2165
2165
|
const lumOff = parseDrawingFraction(find("lumOff"));
|
|
2166
2166
|
if (lumOff !== void 0) hsl.l = clampUnitInterval(hsl.l + lumOff);
|
|
2167
|
-
const round2 =
|
|
2167
|
+
const round2 = options2?.hslRounding === "halfDown" ? (value) => Math.ceil(value - 0.5) : Math.round;
|
|
2168
2168
|
({ r, g, b } = hslToRgb(hsl.h, hsl.s, hsl.l, round2));
|
|
2169
2169
|
}
|
|
2170
2170
|
let alpha = parseDrawingPercent(find("alpha")) ?? 1;
|
|
@@ -5887,7 +5887,7 @@ function resolveInnerRect(fillToRect, focalPoint) {
|
|
|
5887
5887
|
function lerpEdge(inner, outer, t) {
|
|
5888
5888
|
return inner + (outer - inner) * t;
|
|
5889
5889
|
}
|
|
5890
|
-
function buildRectPathGradientSvg(stops, focalPoint, fillToRect,
|
|
5890
|
+
function buildRectPathGradientSvg(stops, focalPoint, fillToRect, options2) {
|
|
5891
5891
|
if (stops.length === 0) {
|
|
5892
5892
|
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"/>';
|
|
5893
5893
|
}
|
|
@@ -5896,7 +5896,7 @@ function buildRectPathGradientSvg(stops, focalPoint, fillToRect, options) {
|
|
|
5896
5896
|
const rects = [];
|
|
5897
5897
|
const alphaRects = [];
|
|
5898
5898
|
const masked = sorted.some((stop) => (stop.opacity ?? 1) < 1);
|
|
5899
|
-
const bands =
|
|
5899
|
+
const bands = options2?.bands;
|
|
5900
5900
|
if (!Number.isInteger(bands) || bands < 1) throw new RangeError("Invalid gradient band count");
|
|
5901
5901
|
for (let i = bands; i >= 0; i -= 1) {
|
|
5902
5902
|
const t = i / bands;
|
|
@@ -16427,6 +16427,9 @@ function formatChartNumberWithColor(value, formatCode) {
|
|
|
16427
16427
|
return void 0;
|
|
16428
16428
|
}
|
|
16429
16429
|
}
|
|
16430
|
+
function formatChartNumber(value, formatCode) {
|
|
16431
|
+
return formatChartNumberWithColor(value, formatCode)?.text;
|
|
16432
|
+
}
|
|
16430
16433
|
|
|
16431
16434
|
// chart/data-label-text.ts
|
|
16432
16435
|
var DATA_LABEL_SEPARATOR = ", ";
|
|
@@ -16475,12 +16478,12 @@ function composeDataLabelText(input) {
|
|
|
16475
16478
|
}
|
|
16476
16479
|
|
|
16477
16480
|
// chart/bubble-radius.ts
|
|
16478
|
-
function computeBubbleRadius(sizeVal, maxBubble, medianRadius,
|
|
16479
|
-
const scale = (
|
|
16481
|
+
function computeBubbleRadius(sizeVal, maxBubble, medianRadius, options2) {
|
|
16482
|
+
const scale = (options2?.bubbleScale ?? 100) / 100;
|
|
16480
16483
|
if (sizeVal === void 0) return medianRadius * scale;
|
|
16481
16484
|
const denom = maxBubble > 0 ? maxBubble : 1;
|
|
16482
16485
|
const magnitude = Math.abs(sizeVal);
|
|
16483
|
-
const ratio = (
|
|
16486
|
+
const ratio = (options2?.sizeRepresents ?? "w") === "area" ? Math.sqrt(magnitude) / Math.sqrt(denom) : magnitude / denom;
|
|
16484
16487
|
return medianRadius * scale * 0.5 + ratio * medianRadius * scale * 1.5;
|
|
16485
16488
|
}
|
|
16486
16489
|
function maxBubbleSize(sizes) {
|
|
@@ -16808,14 +16811,14 @@ function scottBinCount(values, min, max) {
|
|
|
16808
16811
|
const width = 3.49 * sd * values.length ** (-1 / 3);
|
|
16809
16812
|
return Math.max(1, Math.ceil((max - min) / width));
|
|
16810
16813
|
}
|
|
16811
|
-
function computeHistogramBins(values,
|
|
16812
|
-
const closed =
|
|
16814
|
+
function computeHistogramBins(values, options2, format = String) {
|
|
16815
|
+
const closed = options2.intervalClosed ?? "l";
|
|
16813
16816
|
const finite2 = values.map((value, sourceIndex) => ({ value, sourceIndex })).filter((item) => Number.isFinite(item.value));
|
|
16814
16817
|
if (finite2.length === 0) {
|
|
16815
16818
|
return [];
|
|
16816
16819
|
}
|
|
16817
|
-
const underflow = typeof
|
|
16818
|
-
const overflow = typeof
|
|
16820
|
+
const underflow = typeof options2.underflow === "number" ? options2.underflow : void 0;
|
|
16821
|
+
const overflow = typeof options2.overflow === "number" ? options2.overflow : void 0;
|
|
16819
16822
|
const under = underflow === void 0 ? [] : finite2.filter(
|
|
16820
16823
|
(item) => closed === "r" ? item.value <= underflow : item.value < underflow
|
|
16821
16824
|
);
|
|
@@ -16832,8 +16835,8 @@ function computeHistogramBins(values, options, format = String) {
|
|
|
16832
16835
|
if (regular.length > 0) {
|
|
16833
16836
|
const min = Math.min(...regular.map((item) => item.value));
|
|
16834
16837
|
const max = Math.max(...regular.map((item) => item.value));
|
|
16835
|
-
const requestedSize =
|
|
16836
|
-
const requestedCount =
|
|
16838
|
+
const requestedSize = options2.binSize && options2.binSize > 0 ? options2.binSize : void 0;
|
|
16839
|
+
const requestedCount = options2.binCount && options2.binCount > 0 ? options2.binCount : void 0;
|
|
16837
16840
|
const start = requestedSize ? Math.floor(min / requestedSize) * requestedSize : min;
|
|
16838
16841
|
const count = requestedSize ? Math.max(
|
|
16839
16842
|
closed === "l" ? Math.floor((max - start) / requestedSize) + 1 : Math.ceil((max - start) / requestedSize),
|
|
@@ -16884,9 +16887,9 @@ function aggregateByCategory(values, rawCategories) {
|
|
|
16884
16887
|
}
|
|
16885
16888
|
|
|
16886
16889
|
// chart/waterfall.ts
|
|
16887
|
-
function buildWaterfallSteps(values,
|
|
16890
|
+
function buildWaterfallSteps(values, options2) {
|
|
16888
16891
|
const subtotalIndices = new Set(
|
|
16889
|
-
|
|
16892
|
+
options2?.subtotalIndices ?? (values.length > 0 ? [values.length - 1] : [])
|
|
16890
16893
|
);
|
|
16891
16894
|
const steps = [];
|
|
16892
16895
|
let runningTotal = 0;
|
|
@@ -16946,13 +16949,13 @@ var noFit = () => ({
|
|
|
16946
16949
|
rSquared: 0,
|
|
16947
16950
|
coefficients: []
|
|
16948
16951
|
});
|
|
16949
|
-
function fitModel(
|
|
16952
|
+
function fitModel(options2, xVals, yVals) {
|
|
16950
16953
|
const xs = [...xVals];
|
|
16951
16954
|
const ys = [...yVals];
|
|
16952
|
-
switch (
|
|
16955
|
+
switch (options2.kind) {
|
|
16953
16956
|
case "linear": {
|
|
16954
16957
|
const reg = computeLinearRegression(xs, ys);
|
|
16955
|
-
const fixed =
|
|
16958
|
+
const fixed = options2.intercept;
|
|
16956
16959
|
const slope = fixed !== void 0 ? ys.reduce((s, y, i) => s + (y - fixed) * xs[i], 0) / xs.reduce((s, x) => s + x * x, 0) : reg.slope;
|
|
16957
16960
|
const b = fixed ?? reg.intercept;
|
|
16958
16961
|
return {
|
|
@@ -17002,7 +17005,7 @@ function fitModel(options, xVals, yVals) {
|
|
|
17002
17005
|
};
|
|
17003
17006
|
}
|
|
17004
17007
|
case "polynomial": {
|
|
17005
|
-
const order = Math.min(
|
|
17008
|
+
const order = Math.min(options2.order ?? 2, 6);
|
|
17006
17009
|
const coeffs = fitPolynomial(xs, ys, order);
|
|
17007
17010
|
const evaluate = (x) => coeffs.reduce((s, c2, i) => s + c2 * x ** i, 0);
|
|
17008
17011
|
return {
|
|
@@ -17016,11 +17019,11 @@ function fitModel(options, xVals, yVals) {
|
|
|
17016
17019
|
return void 0;
|
|
17017
17020
|
}
|
|
17018
17021
|
}
|
|
17019
|
-
function fitChartTrendline(
|
|
17022
|
+
function fitChartTrendline(options2, xVals, yVals) {
|
|
17020
17023
|
const count = yVals.length;
|
|
17021
17024
|
if (count < 2) return noFit();
|
|
17022
|
-
if (
|
|
17023
|
-
const period =
|
|
17025
|
+
if (options2.kind === "movingAvg") {
|
|
17026
|
+
const period = options2.period ?? 2;
|
|
17024
17027
|
const points2 = [];
|
|
17025
17028
|
for (let i = period - 1; i < count; i++) {
|
|
17026
17029
|
let sum = 0;
|
|
@@ -17029,10 +17032,10 @@ function fitChartTrendline(options, xVals, yVals) {
|
|
|
17029
17032
|
}
|
|
17030
17033
|
return { points: points2, equation: `${period}-period moving average`, rSquared: 0, coefficients: [] };
|
|
17031
17034
|
}
|
|
17032
|
-
const model = fitModel(
|
|
17035
|
+
const model = fitModel(options2, xVals, yVals);
|
|
17033
17036
|
if (!model) return noFit();
|
|
17034
|
-
const startX = Math.min(...xVals) - (
|
|
17035
|
-
const endX = Math.max(...xVals) + (
|
|
17037
|
+
const startX = Math.min(...xVals) - (options2.backward ?? 0);
|
|
17038
|
+
const endX = Math.max(...xVals) + (options2.forward ?? 0);
|
|
17036
17039
|
const steps = Math.max(Math.ceil((endX - startX) * 4), 20);
|
|
17037
17040
|
const points = [];
|
|
17038
17041
|
for (let step = 0; step <= steps; step++) {
|
|
@@ -17055,18 +17058,18 @@ function chartSampleVariance(values) {
|
|
|
17055
17058
|
const mean = values.reduce((sum, value) => sum + value, 0) / count;
|
|
17056
17059
|
return values.reduce((sum, value) => sum + (value - mean) ** 2, 0) / Math.max(count - 1, 1);
|
|
17057
17060
|
}
|
|
17058
|
-
function chartErrorBarAmount(
|
|
17059
|
-
switch (
|
|
17061
|
+
function chartErrorBarAmount(options2, values, displayIndex, sourceIndex, side) {
|
|
17062
|
+
switch (options2.valueType) {
|
|
17060
17063
|
case "fixedVal":
|
|
17061
|
-
return
|
|
17064
|
+
return options2.value ?? 0;
|
|
17062
17065
|
case "percentage":
|
|
17063
|
-
return Math.abs(values[displayIndex] ?? 0) * ((
|
|
17066
|
+
return Math.abs(values[displayIndex] ?? 0) * ((options2.value ?? 0) / 100);
|
|
17064
17067
|
case "stdDev":
|
|
17065
|
-
return Math.sqrt(chartSampleVariance(values)) * (
|
|
17068
|
+
return Math.sqrt(chartSampleVariance(values)) * (options2.value ?? 1);
|
|
17066
17069
|
case "stdErr":
|
|
17067
17070
|
return Math.sqrt(chartSampleVariance(values) / Math.max(values.length, 1));
|
|
17068
17071
|
case "cust":
|
|
17069
|
-
return side === "plus" ?
|
|
17072
|
+
return side === "plus" ? options2.customPlus?.[sourceIndex] ?? 0 : options2.customMinus?.[sourceIndex] ?? 0;
|
|
17070
17073
|
}
|
|
17071
17074
|
}
|
|
17072
17075
|
|
|
@@ -18565,6 +18568,191 @@ function drawingLineXml(line3) {
|
|
|
18565
18568
|
return buildXml(doc);
|
|
18566
18569
|
}
|
|
18567
18570
|
|
|
18571
|
+
// chart/marker-shape.ts
|
|
18572
|
+
var CHART_PX_PER_PT = 4 / 3;
|
|
18573
|
+
var DEFAULT_MARKER_OUTLINE_PT = 0.75;
|
|
18574
|
+
var AUTOMATIC_MARKER_CYCLE = [
|
|
18575
|
+
"diamond",
|
|
18576
|
+
"square",
|
|
18577
|
+
"triangle",
|
|
18578
|
+
"x",
|
|
18579
|
+
"star",
|
|
18580
|
+
"circle",
|
|
18581
|
+
"plus",
|
|
18582
|
+
"dot",
|
|
18583
|
+
"dash"
|
|
18584
|
+
];
|
|
18585
|
+
function automaticMarkerSymbol(seriesIdx) {
|
|
18586
|
+
const length = AUTOMATIC_MARKER_CYCLE.length;
|
|
18587
|
+
const normalized = (Math.trunc(seriesIdx) % length + length) % length;
|
|
18588
|
+
return AUTOMATIC_MARKER_CYCLE[Number.isFinite(normalized) ? normalized : 0];
|
|
18589
|
+
}
|
|
18590
|
+
function markerRadius(size, defaultRadius) {
|
|
18591
|
+
if (size === void 0 || !Number.isFinite(size) || size <= 0) {
|
|
18592
|
+
return defaultRadius;
|
|
18593
|
+
}
|
|
18594
|
+
return size / 2;
|
|
18595
|
+
}
|
|
18596
|
+
function polygonPoints(vertices) {
|
|
18597
|
+
return vertices.map(([x, y]) => `${x.toFixed(2)},${y.toFixed(2)}`).join(" ");
|
|
18598
|
+
}
|
|
18599
|
+
function starVertices(cx2, cy, r) {
|
|
18600
|
+
const inner = r * 0.5;
|
|
18601
|
+
const out = [];
|
|
18602
|
+
for (let i = 0; i < 10; i++) {
|
|
18603
|
+
const radius = i % 2 === 0 ? r : inner;
|
|
18604
|
+
const angle = -Math.PI / 2 + Math.PI * i / 5;
|
|
18605
|
+
out.push([cx2 + radius * Math.cos(angle), cy + radius * Math.sin(angle)]);
|
|
18606
|
+
}
|
|
18607
|
+
return out;
|
|
18608
|
+
}
|
|
18609
|
+
function rectPolygon(x, y, w, h) {
|
|
18610
|
+
return polygonPoints([
|
|
18611
|
+
[x, y],
|
|
18612
|
+
[x + w, y],
|
|
18613
|
+
[x + w, y + h],
|
|
18614
|
+
[x, y + h]
|
|
18615
|
+
]);
|
|
18616
|
+
}
|
|
18617
|
+
function buildMarkerPrimitive(input) {
|
|
18618
|
+
const { symbol, cx: cx2, cy, fill } = input;
|
|
18619
|
+
const part = input.part === void 0 ? {} : { part: input.part };
|
|
18620
|
+
if (symbol === "none") {
|
|
18621
|
+
return null;
|
|
18622
|
+
}
|
|
18623
|
+
const r = markerRadius(input.size, input.defaultRadius);
|
|
18624
|
+
const outline2 = input.stroke ? {
|
|
18625
|
+
stroke: input.stroke,
|
|
18626
|
+
strokeWidth: input.strokeWidth ?? DEFAULT_MARKER_OUTLINE_PT * CHART_PX_PER_PT
|
|
18627
|
+
} : void 0;
|
|
18628
|
+
const polygonStroke = outline2 ?? { stroke: fill, strokeWidth: 0 };
|
|
18629
|
+
const lineStroke = input.stroke ?? fill;
|
|
18630
|
+
switch (symbol) {
|
|
18631
|
+
case "square":
|
|
18632
|
+
case "dash": {
|
|
18633
|
+
const h = symbol === "dash" ? r * 0.64 : r * 2;
|
|
18634
|
+
const y = cy - h / 2;
|
|
18635
|
+
if (outline2) {
|
|
18636
|
+
return {
|
|
18637
|
+
kind: "polygon",
|
|
18638
|
+
points: rectPolygon(cx2 - r, y, r * 2, h),
|
|
18639
|
+
fill,
|
|
18640
|
+
...outline2,
|
|
18641
|
+
...part
|
|
18642
|
+
};
|
|
18643
|
+
}
|
|
18644
|
+
return { kind: "rect", x: cx2 - r, y, w: r * 2, h, fill, ...part };
|
|
18645
|
+
}
|
|
18646
|
+
case "diamond":
|
|
18647
|
+
return {
|
|
18648
|
+
kind: "polygon",
|
|
18649
|
+
points: polygonPoints([
|
|
18650
|
+
[cx2, cy - r],
|
|
18651
|
+
[cx2 + r, cy],
|
|
18652
|
+
[cx2, cy + r],
|
|
18653
|
+
[cx2 - r, cy]
|
|
18654
|
+
]),
|
|
18655
|
+
fill,
|
|
18656
|
+
...polygonStroke,
|
|
18657
|
+
...part
|
|
18658
|
+
};
|
|
18659
|
+
case "triangle":
|
|
18660
|
+
return {
|
|
18661
|
+
kind: "polygon",
|
|
18662
|
+
points: polygonPoints([
|
|
18663
|
+
[cx2, cy - r],
|
|
18664
|
+
[cx2 + r * 0.9, cy + r * 0.75],
|
|
18665
|
+
[cx2 - r * 0.9, cy + r * 0.75]
|
|
18666
|
+
]),
|
|
18667
|
+
fill,
|
|
18668
|
+
...polygonStroke,
|
|
18669
|
+
...part
|
|
18670
|
+
};
|
|
18671
|
+
case "star":
|
|
18672
|
+
return {
|
|
18673
|
+
kind: "polygon",
|
|
18674
|
+
points: polygonPoints(starVertices(cx2, cy, r)),
|
|
18675
|
+
fill,
|
|
18676
|
+
...polygonStroke,
|
|
18677
|
+
...part
|
|
18678
|
+
};
|
|
18679
|
+
case "plus":
|
|
18680
|
+
return {
|
|
18681
|
+
kind: "path",
|
|
18682
|
+
d: `M${(cx2 - r).toFixed(2)},${cy.toFixed(2)} L${(cx2 + r).toFixed(2)},${cy.toFixed(2)} M${cx2.toFixed(2)},${(cy - r).toFixed(2)} L${cx2.toFixed(2)},${(cy + r).toFixed(2)}`,
|
|
18683
|
+
fill: "none",
|
|
18684
|
+
stroke: lineStroke,
|
|
18685
|
+
strokeWidth: Math.max(1, r * 0.4),
|
|
18686
|
+
...part
|
|
18687
|
+
};
|
|
18688
|
+
case "x":
|
|
18689
|
+
return {
|
|
18690
|
+
kind: "path",
|
|
18691
|
+
d: `M${(cx2 - r).toFixed(2)},${(cy - r).toFixed(2)} L${(cx2 + r).toFixed(2)},${(cy + r).toFixed(2)} M${(cx2 + r).toFixed(2)},${(cy - r).toFixed(2)} L${(cx2 - r).toFixed(2)},${(cy + r).toFixed(2)}`,
|
|
18692
|
+
fill: "none",
|
|
18693
|
+
stroke: lineStroke,
|
|
18694
|
+
strokeWidth: Math.max(1, r * 0.4),
|
|
18695
|
+
...part
|
|
18696
|
+
};
|
|
18697
|
+
case "dot":
|
|
18698
|
+
return { kind: "circle", cx: cx2, cy, r: Math.max(r * 0.6, 1), fill, ...part, ...outline2 };
|
|
18699
|
+
default:
|
|
18700
|
+
return { kind: "circle", cx: cx2, cy, r, fill, ...part, ...outline2 };
|
|
18701
|
+
}
|
|
18702
|
+
}
|
|
18703
|
+
|
|
18704
|
+
// chart/render/chart-view-markers.ts
|
|
18705
|
+
function summaryMarkers(source, group2, seriesPosition) {
|
|
18706
|
+
if (!["line", "scatter", "radar"].includes(group2.kind)) return {};
|
|
18707
|
+
const enabled2 = group2.kind === "line" ? group2.marker === true : group2.kind === "radar" ? group2.radarStyle === "marker" : !["line", "smooth", "none"].includes(group2.scatterStyle ?? "marker");
|
|
18708
|
+
const symbol = source.marker?.symbol;
|
|
18709
|
+
const marker = {
|
|
18710
|
+
...source.marker,
|
|
18711
|
+
symbol: symbol && symbol !== "auto" ? symbol : source.marker || enabled2 ? automaticMarkerSymbol(source.index ?? seriesPosition) : "none"
|
|
18712
|
+
};
|
|
18713
|
+
const pointMarkers = {};
|
|
18714
|
+
for (const point of source.dataPoints) {
|
|
18715
|
+
if (point.index === void 0 || !point.marker) continue;
|
|
18716
|
+
const override = point.marker;
|
|
18717
|
+
pointMarkers[point.index] = {
|
|
18718
|
+
...marker,
|
|
18719
|
+
...override,
|
|
18720
|
+
...override.symbol === "auto" || !source.marker && override.symbol === void 0 ? { symbol: automaticMarkerSymbol(source.index ?? seriesPosition) } : {},
|
|
18721
|
+
...marker.spPr || override.spPr ? {
|
|
18722
|
+
spPr: {
|
|
18723
|
+
...marker.spPr,
|
|
18724
|
+
...override.spPr,
|
|
18725
|
+
...marker.spPr?.line || override.spPr?.line ? { line: { ...marker.spPr?.line, ...override.spPr?.line } } : {}
|
|
18726
|
+
}
|
|
18727
|
+
} : {}
|
|
18728
|
+
};
|
|
18729
|
+
}
|
|
18730
|
+
return { marker, ...Object.keys(pointMarkers).length ? { pointMarkers } : {} };
|
|
18731
|
+
}
|
|
18732
|
+
function seriesMarkerViews(source, drawingColor) {
|
|
18733
|
+
const fillColor = (fill) => fill?.kind === "none" ? "none" : fill?.kind === "solid" ? drawingColor(fill.color) : void 0;
|
|
18734
|
+
const resolve = (marker) => {
|
|
18735
|
+
const fill = fillColor(marker.spPr?.fill);
|
|
18736
|
+
const stroke = fillColor(marker.spPr?.line?.fill);
|
|
18737
|
+
const width = marker.spPr?.line?.widthEmu;
|
|
18738
|
+
return {
|
|
18739
|
+
...marker.symbol !== void 0 ? { symbol: marker.symbol } : {},
|
|
18740
|
+
...marker.size !== void 0 ? { size: marker.size } : {},
|
|
18741
|
+
...fill !== void 0 ? { fill } : {},
|
|
18742
|
+
...stroke !== void 0 ? { stroke } : {},
|
|
18743
|
+
...width !== void 0 ? { strokeWidth: width / 9525 } : {}
|
|
18744
|
+
};
|
|
18745
|
+
};
|
|
18746
|
+
return {
|
|
18747
|
+
...source.marker ? { marker: resolve(source.marker) } : {},
|
|
18748
|
+
...source.pointMarkers ? {
|
|
18749
|
+
pointMarkers: Object.fromEntries(
|
|
18750
|
+
Object.entries(source.pointMarkers).map(([i, marker]) => [i, resolve(marker)])
|
|
18751
|
+
)
|
|
18752
|
+
} : {}
|
|
18753
|
+
};
|
|
18754
|
+
}
|
|
18755
|
+
|
|
18568
18756
|
// chart/render/summary-analysis.ts
|
|
18569
18757
|
function summaryTrendline(source) {
|
|
18570
18758
|
const kind = chartTrendlineKind(source.trendlineType);
|
|
@@ -18606,17 +18794,17 @@ function summaryAnalysis(series) {
|
|
|
18606
18794
|
}
|
|
18607
18795
|
|
|
18608
18796
|
// chart/render/summary-labels.ts
|
|
18609
|
-
function level(
|
|
18797
|
+
function level(options2, custom) {
|
|
18610
18798
|
const out = {};
|
|
18611
|
-
if (
|
|
18612
|
-
if (
|
|
18613
|
-
if (
|
|
18614
|
-
if (
|
|
18615
|
-
if (
|
|
18616
|
-
if (
|
|
18617
|
-
if (
|
|
18618
|
-
if (
|
|
18619
|
-
if (
|
|
18799
|
+
if (options2.deleted !== void 0) out.deleted = options2.deleted;
|
|
18800
|
+
if (options2.showValue !== void 0) out.showValue = options2.showValue;
|
|
18801
|
+
if (options2.showCategoryName !== void 0) out.showCategory = options2.showCategoryName;
|
|
18802
|
+
if (options2.showSeriesName !== void 0) out.showSeriesName = options2.showSeriesName;
|
|
18803
|
+
if (options2.showPercent !== void 0) out.showPercent = options2.showPercent;
|
|
18804
|
+
if (options2.showBubbleSize !== void 0) out.showBubbleSize = options2.showBubbleSize;
|
|
18805
|
+
if (options2.separator !== void 0) out.separator = options2.separator;
|
|
18806
|
+
if (options2.position) out.position = options2.position;
|
|
18807
|
+
if (options2.numberFormat?.formatCode) out.numberFormat = options2.numberFormat.formatCode;
|
|
18620
18808
|
if (custom?.text !== void 0) out.text = custom.text;
|
|
18621
18809
|
return out;
|
|
18622
18810
|
}
|
|
@@ -18723,7 +18911,10 @@ function extraGroups(chartSpace, firstType) {
|
|
|
18723
18911
|
const type = group2.kind === "bar" ? "column" : group2.kind;
|
|
18724
18912
|
const entry2 = {
|
|
18725
18913
|
chartType: type,
|
|
18726
|
-
series: group2.series.map((source) =>
|
|
18914
|
+
series: group2.series.map((source, index) => ({
|
|
18915
|
+
...chartSummarySeries(source, type, group2.dataLabels),
|
|
18916
|
+
...summaryMarkers(source, group2, index)
|
|
18917
|
+
})),
|
|
18727
18918
|
secondary: valueAxisId(chartSpace, group2.axisIds) !== primary
|
|
18728
18919
|
};
|
|
18729
18920
|
if (group2.grouping && GROUPINGS.has(group2.grouping))
|
|
@@ -18741,13 +18932,16 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
|
|
|
18741
18932
|
const group2 = chartSpace.plotArea.groups[0];
|
|
18742
18933
|
let chartType = group2 ? GROUP_TYPES[group2.kind] : "column";
|
|
18743
18934
|
if (chartType === "bar" && group2?.barDirection !== "bar") chartType = "column";
|
|
18744
|
-
const series = (group2?.series ?? []).map(
|
|
18745
|
-
|
|
18746
|
-
|
|
18935
|
+
const series = (group2?.series ?? []).map((source, index) => ({
|
|
18936
|
+
...chartSummarySeries(source, chartType, group2?.dataLabels),
|
|
18937
|
+
...group2 ? summaryMarkers(source, group2, index) : {}
|
|
18938
|
+
}));
|
|
18747
18939
|
const summary = {
|
|
18748
18940
|
chartType,
|
|
18749
18941
|
series,
|
|
18750
|
-
showLegend: chartSpace.legend !== void 0
|
|
18942
|
+
showLegend: chartSpace.legend !== void 0,
|
|
18943
|
+
axes: chartSpace.plotArea.axes,
|
|
18944
|
+
axisIds: group2?.axisIds ?? []
|
|
18751
18945
|
};
|
|
18752
18946
|
const combined = extraGroups(chartSpace, chartType);
|
|
18753
18947
|
if (combined.length) summary.extraGroups = combined;
|
|
@@ -19208,7 +19402,7 @@ function chartTextAttributes(model, part, fallbackSize = FONT_SIZE) {
|
|
|
19208
19402
|
function chartStroke(model, part) {
|
|
19209
19403
|
const entry2 = model.appearance?.[part];
|
|
19210
19404
|
return {
|
|
19211
|
-
color: entry2?.axisVisible === false ? "none" : entry2?.lineColor ?? (part
|
|
19405
|
+
color: entry2?.axisVisible === false ? "none" : entry2?.lineColor ?? (part.startsWith("gridline") ? GRID_COLOR : AXIS_COLOR),
|
|
19212
19406
|
width: entry2?.lineWidth === void 0 ? 1 : chartPointsToPixels(entry2.lineWidth)
|
|
19213
19407
|
};
|
|
19214
19408
|
}
|
|
@@ -19499,6 +19693,60 @@ function scatterAnalysis(model, px3, py, out) {
|
|
|
19499
19693
|
});
|
|
19500
19694
|
}
|
|
19501
19695
|
|
|
19696
|
+
// chart/render/chart-svg-markers.ts
|
|
19697
|
+
function chartMarkerRadius(series, index, defaultRadius = 3) {
|
|
19698
|
+
const marker = { ...series.marker, ...series.pointMarkers?.[index] };
|
|
19699
|
+
if (marker.symbol === "none") return 0;
|
|
19700
|
+
const radius = markerRadius(marker.size, defaultRadius);
|
|
19701
|
+
return marker.symbol === "dot" ? Math.max(radius * 0.6, 1) : radius;
|
|
19702
|
+
}
|
|
19703
|
+
function chartSeriesMarkerSvg(series, index, cx2, cy, defaultRadius = 3) {
|
|
19704
|
+
const marker = { ...series.marker, ...series.pointMarkers?.[index] };
|
|
19705
|
+
const primitive = buildMarkerPrimitive({
|
|
19706
|
+
...marker,
|
|
19707
|
+
symbol: marker.symbol,
|
|
19708
|
+
size: marker.size,
|
|
19709
|
+
cx: cx2,
|
|
19710
|
+
cy,
|
|
19711
|
+
fill: marker.fill ?? series.pointColors?.[index] ?? series.color,
|
|
19712
|
+
defaultRadius
|
|
19713
|
+
});
|
|
19714
|
+
if (!primitive) return "";
|
|
19715
|
+
let geometry2;
|
|
19716
|
+
switch (primitive.kind) {
|
|
19717
|
+
case "circle":
|
|
19718
|
+
geometry2 = `cx="${n(primitive.cx)}" cy="${n(primitive.cy)}" r="${n(primitive.r)}"`;
|
|
19719
|
+
break;
|
|
19720
|
+
case "rect":
|
|
19721
|
+
geometry2 = `x="${n(primitive.x)}" y="${n(primitive.y)}" width="${n(primitive.w)}" height="${n(primitive.h)}"`;
|
|
19722
|
+
break;
|
|
19723
|
+
case "path":
|
|
19724
|
+
geometry2 = `d="${esc(primitive.d)}"`;
|
|
19725
|
+
break;
|
|
19726
|
+
case "polygon":
|
|
19727
|
+
geometry2 = `points="${esc(primitive.points)}"`;
|
|
19728
|
+
break;
|
|
19729
|
+
}
|
|
19730
|
+
const outline2 = primitive.stroke ? ` stroke="${esc(primitive.stroke)}" stroke-width="${n(primitive.strokeWidth ?? 1)}"` : "";
|
|
19731
|
+
const filter = series.shadowFilter ? ` filter="${esc(series.shadowFilter)}"` : "";
|
|
19732
|
+
return `<${primitive.kind} ${geometry2} fill="${esc(primitive.fill)}"${outline2}${filter}/>`;
|
|
19733
|
+
}
|
|
19734
|
+
|
|
19735
|
+
// chart/line-dash.ts
|
|
19736
|
+
function chartLineDashArray(style, width) {
|
|
19737
|
+
if (!style || style === "solid") {
|
|
19738
|
+
return void 0;
|
|
19739
|
+
}
|
|
19740
|
+
const unit = Math.max(width, 1);
|
|
19741
|
+
if (style === "dot" || style === "sysDot") {
|
|
19742
|
+
return `${unit} ${unit * 2}`;
|
|
19743
|
+
}
|
|
19744
|
+
if (style === "lgDash") {
|
|
19745
|
+
return `${unit * 6} ${unit * 3}`;
|
|
19746
|
+
}
|
|
19747
|
+
return `${unit * 3} ${unit * 2}`;
|
|
19748
|
+
}
|
|
19749
|
+
|
|
19502
19750
|
// chart/render/chart-scale.ts
|
|
19503
19751
|
var clean = (n2) => Number(n2.toPrecision(12));
|
|
19504
19752
|
function* units(raw) {
|
|
@@ -19509,14 +19757,14 @@ function* units(raw) {
|
|
|
19509
19757
|
exp++;
|
|
19510
19758
|
}
|
|
19511
19759
|
}
|
|
19512
|
-
function niceScale(dataMin, dataMax,
|
|
19513
|
-
const maxIntervals = Math.max(1,
|
|
19760
|
+
function niceScale(dataMin, dataMax, options2 = {}) {
|
|
19761
|
+
const maxIntervals = Math.max(1, options2.maxIntervals ?? 10);
|
|
19514
19762
|
let lo = Number.isFinite(dataMin) ? dataMin : 0;
|
|
19515
19763
|
let hi = Number.isFinite(dataMax) ? dataMax : 0;
|
|
19516
19764
|
if (lo > hi) [lo, hi] = [hi, lo];
|
|
19517
19765
|
if (lo === hi) {
|
|
19518
19766
|
if (lo === 0) hi = 1;
|
|
19519
|
-
else if (
|
|
19767
|
+
else if (options2.noZero) {
|
|
19520
19768
|
const pad = Math.abs(lo) * 0.1 || 1;
|
|
19521
19769
|
lo -= pad;
|
|
19522
19770
|
hi += pad;
|
|
@@ -19525,7 +19773,7 @@ function niceScale(dataMin, dataMax, options = {}) {
|
|
|
19525
19773
|
}
|
|
19526
19774
|
let fixedLo = false;
|
|
19527
19775
|
let fixedHi = false;
|
|
19528
|
-
if (!
|
|
19776
|
+
if (!options2.noZero) {
|
|
19529
19777
|
if (lo >= 0 && hi - lo >= hi / 6) {
|
|
19530
19778
|
lo = 0;
|
|
19531
19779
|
fixedLo = true;
|
|
@@ -19565,6 +19813,233 @@ function formatAxisValue(value, percent = false) {
|
|
|
19565
19813
|
return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
|
|
19566
19814
|
}
|
|
19567
19815
|
|
|
19816
|
+
// chart/render/chart-svg-axes.ts
|
|
19817
|
+
function axisTickText(value, axis, percent = false) {
|
|
19818
|
+
return formatChartNumber(value, axis?.source.numberFormat?.formatCode) ?? formatAxisValue(value, percent);
|
|
19819
|
+
}
|
|
19820
|
+
function axisLine(model, axis, part, x1, y1, x2, y2) {
|
|
19821
|
+
if (axis?.source.deleted) return "";
|
|
19822
|
+
return styledAxisLine(x1, y1, x2, y2, axis?.line, chartStroke(model, part));
|
|
19823
|
+
}
|
|
19824
|
+
function styledAxisLine(x1, y1, x2, y2, paint2, fallback) {
|
|
19825
|
+
const color = paint2?.color ?? fallback.color;
|
|
19826
|
+
const width = paint2?.width ?? fallback.width;
|
|
19827
|
+
if (color === "none" || width === 0) return "";
|
|
19828
|
+
const dash = chartLineDashArray(paint2?.dash, width);
|
|
19829
|
+
return line2(x1, y1, x2, y2, esc(color), width).replace(
|
|
19830
|
+
"/>",
|
|
19831
|
+
dash ? ` stroke-dasharray="${dash}"/>` : "/>"
|
|
19832
|
+
);
|
|
19833
|
+
}
|
|
19834
|
+
function axisGridlines(model, axis, ticks, position2, plot, vertical) {
|
|
19835
|
+
const draw2 = (values, paint2, minor2) => {
|
|
19836
|
+
const fallback = chartStroke(model, minor2 ? "gridlineMinor" : "gridlineMajor");
|
|
19837
|
+
return values.map((value) => {
|
|
19838
|
+
const p = position2(value);
|
|
19839
|
+
return vertical ? styledAxisLine(p, plot.y, p, plot.y + plot.h, paint2, fallback) : styledAxisLine(plot.x, p, plot.x + plot.w, p, paint2, fallback);
|
|
19840
|
+
}).join("");
|
|
19841
|
+
};
|
|
19842
|
+
const major = !axis || axis.source.majorGridlines ? draw2(ticks, axis?.majorGrid, false) : "";
|
|
19843
|
+
const minor = axis?.source.minorGridlines ? draw2(axis.minorTicks, axis.minorGrid, true) : "";
|
|
19844
|
+
return major + minor;
|
|
19845
|
+
}
|
|
19846
|
+
|
|
19847
|
+
// chart/axis-range.ts
|
|
19848
|
+
function computeLogValueRange(series, logBase) {
|
|
19849
|
+
const allValues = series.flatMap((item) => item.values).filter((value) => value !== null && Number.isFinite(value) && value > 0);
|
|
19850
|
+
if (allValues.length === 0) {
|
|
19851
|
+
return { min: 1, max: logBase, span: 1, logScale: true, logBase };
|
|
19852
|
+
}
|
|
19853
|
+
const dataMin = Math.min(...allValues);
|
|
19854
|
+
const dataMax = Math.max(...allValues);
|
|
19855
|
+
const logMin = Math.floor(Math.log(dataMin) / Math.log(logBase));
|
|
19856
|
+
const logMax = Math.ceil(Math.log(dataMax) / Math.log(logBase));
|
|
19857
|
+
const min = logBase ** logMin;
|
|
19858
|
+
const max = logBase ** Math.max(logMax, logMin + 1);
|
|
19859
|
+
return {
|
|
19860
|
+
min,
|
|
19861
|
+
max,
|
|
19862
|
+
span: Math.max(Math.log(max) / Math.log(logBase) - Math.log(min) / Math.log(logBase), 1),
|
|
19863
|
+
logScale: true,
|
|
19864
|
+
logBase
|
|
19865
|
+
};
|
|
19866
|
+
}
|
|
19867
|
+
function withAxisBounds(automatic, axis, logBase) {
|
|
19868
|
+
const validMin = typeof axis?.min === "number" && Number.isFinite(axis.min) && (!logBase || axis.min > 0) ? axis.min : void 0;
|
|
19869
|
+
const validMax = typeof axis?.max === "number" && Number.isFinite(axis.max) && (!logBase || axis.max > 0) ? axis.max : void 0;
|
|
19870
|
+
const min = validMin ?? automatic.min;
|
|
19871
|
+
let max = validMax ?? automatic.max;
|
|
19872
|
+
const majorUnit = validMin === void 0 && validMax === void 0 ? automatic.majorUnit : void 0;
|
|
19873
|
+
if (max <= min) {
|
|
19874
|
+
max = logBase ? min * logBase : min + 1;
|
|
19875
|
+
}
|
|
19876
|
+
const span = logBase ? Math.log(max) / Math.log(logBase) - Math.log(min) / Math.log(logBase) : max - min;
|
|
19877
|
+
return {
|
|
19878
|
+
min,
|
|
19879
|
+
max,
|
|
19880
|
+
span: Math.max(span, Number.EPSILON),
|
|
19881
|
+
...majorUnit !== void 0 ? { majorUnit } : {},
|
|
19882
|
+
...logBase ? { logScale: true, logBase } : {},
|
|
19883
|
+
...axis?.orientation === "maxMin" ? { reverseOrder: true } : {}
|
|
19884
|
+
};
|
|
19885
|
+
}
|
|
19886
|
+
|
|
19887
|
+
// chart/axis-ticks.ts
|
|
19888
|
+
var LOG_EXPONENT_TOLERANCE = 1e-12;
|
|
19889
|
+
function generateLogTicks(range) {
|
|
19890
|
+
if (!range.logScale || !range.logBase) {
|
|
19891
|
+
return [];
|
|
19892
|
+
}
|
|
19893
|
+
const base = range.logBase;
|
|
19894
|
+
const logMin = Math.log(range.min) / Math.log(base);
|
|
19895
|
+
const logMax = Math.log(range.max) / Math.log(base);
|
|
19896
|
+
const firstExponent = Math.ceil(logMin - LOG_EXPONENT_TOLERANCE);
|
|
19897
|
+
const lastExponent = Math.floor(logMax + LOG_EXPONENT_TOLERANCE);
|
|
19898
|
+
if (lastExponent < firstExponent) {
|
|
19899
|
+
return range.min === range.max ? [range.min] : [range.min, range.max];
|
|
19900
|
+
}
|
|
19901
|
+
return Array.from(
|
|
19902
|
+
{ length: lastExponent - firstExponent + 1 },
|
|
19903
|
+
(_unused, index) => base ** (firstExponent + index)
|
|
19904
|
+
);
|
|
19905
|
+
}
|
|
19906
|
+
function generateIntervalTicks(range, unit) {
|
|
19907
|
+
if (!Number.isFinite(unit) || unit <= 0 || range.logScale) {
|
|
19908
|
+
return [];
|
|
19909
|
+
}
|
|
19910
|
+
const tolerance = Math.max(1, Math.abs(range.min), Math.abs(range.max)) * 1e-12;
|
|
19911
|
+
const first3 = Math.ceil((range.min - tolerance) / unit);
|
|
19912
|
+
const last = Math.floor((range.max + tolerance) / unit);
|
|
19913
|
+
const count = Math.min(Math.max(last - first3 + 1, 0), 2e3);
|
|
19914
|
+
return Array.from({ length: count }, (_, index) => (first3 + index) * unit);
|
|
19915
|
+
}
|
|
19916
|
+
function generateAxisTicks(range, axis, defaultIntervals) {
|
|
19917
|
+
if (range.logScale && range.logBase) {
|
|
19918
|
+
return generateLogTicks(range);
|
|
19919
|
+
}
|
|
19920
|
+
const explicit = generateIntervalTicks(range, axis?.majorUnit ?? 0);
|
|
19921
|
+
if (explicit.length > 0) {
|
|
19922
|
+
return explicit;
|
|
19923
|
+
}
|
|
19924
|
+
const automatic = generateIntervalTicks(range, range.majorUnit ?? 0);
|
|
19925
|
+
if (automatic.length > 0) {
|
|
19926
|
+
return automatic;
|
|
19927
|
+
}
|
|
19928
|
+
return Array.from(
|
|
19929
|
+
{ length: defaultIntervals + 1 },
|
|
19930
|
+
(_, index) => range.min + range.span / defaultIntervals * index
|
|
19931
|
+
);
|
|
19932
|
+
}
|
|
19933
|
+
function generateMinorAxisTicks(range, axis) {
|
|
19934
|
+
const minor = generateIntervalTicks(range, axis?.minorUnit ?? 0);
|
|
19935
|
+
if (minor.length === 0) {
|
|
19936
|
+
return [];
|
|
19937
|
+
}
|
|
19938
|
+
const majorUnit = axis?.majorUnit;
|
|
19939
|
+
if (!majorUnit || !Number.isFinite(majorUnit) || majorUnit <= 0) {
|
|
19940
|
+
return minor;
|
|
19941
|
+
}
|
|
19942
|
+
const tolerance = Math.max(1, Math.abs(range.min), Math.abs(range.max)) * 1e-10;
|
|
19943
|
+
return minor.filter(
|
|
19944
|
+
(value) => Math.abs(value / majorUnit - Math.round(value / majorUnit)) > tolerance
|
|
19945
|
+
);
|
|
19946
|
+
}
|
|
19947
|
+
|
|
19948
|
+
// chart/render/chart-view-axes.ts
|
|
19949
|
+
function chartAxisRatio(value, scale, axis) {
|
|
19950
|
+
const range = axis?.range;
|
|
19951
|
+
const ratio = range?.logScale ? Math.log(Math.max(value, range.min) / range.min) / Math.log(range.max / range.min) : (value - scale.min) / (scale.max - scale.min || 1);
|
|
19952
|
+
return range?.reverseOrder ? 1 - ratio : ratio;
|
|
19953
|
+
}
|
|
19954
|
+
function chartAxisLabels(axis) {
|
|
19955
|
+
return axis?.source.deleted !== true && axis?.source.tickLabelPosition !== "none";
|
|
19956
|
+
}
|
|
19957
|
+
function options(axis) {
|
|
19958
|
+
return {
|
|
19959
|
+
...axis.scaling,
|
|
19960
|
+
...axis.scaling.logBase === void 0 ? {} : { logScale: true },
|
|
19961
|
+
...axis.majorUnit === void 0 ? {} : { majorUnit: axis.majorUnit },
|
|
19962
|
+
...axis.minorUnit === void 0 ? {} : { minorUnit: axis.minorUnit }
|
|
19963
|
+
};
|
|
19964
|
+
}
|
|
19965
|
+
function applyChartAxes(model, chart, color) {
|
|
19966
|
+
if (!chart.axes?.length) return;
|
|
19967
|
+
const axes = chart.axes;
|
|
19968
|
+
const linked = axes.filter((axis) => axis.id !== void 0 && chart.axisIds?.includes(axis.id));
|
|
19969
|
+
const candidates = linked.length ? linked : axes;
|
|
19970
|
+
const xy = model.type === "scatter" || model.type === "bubble";
|
|
19971
|
+
const value = candidates.find((axis) => axis.kind === "val" && !["b", "t"].includes(axis.position ?? "")) ?? candidates.find((axis) => axis.kind === "val");
|
|
19972
|
+
const category = candidates.find(
|
|
19973
|
+
(axis) => xy ? axis.kind === "val" && axis !== value : axis.kind === "cat" || axis.kind === "date"
|
|
19974
|
+
);
|
|
19975
|
+
const secondary = axes.find((axis) => axis.kind === "val" && axis !== value && axis !== category);
|
|
19976
|
+
const paint2 = (shape2) => {
|
|
19977
|
+
const ln = shape2?.line;
|
|
19978
|
+
const fill = ln?.fill;
|
|
19979
|
+
const resolved = fill?.kind === "none" ? "none" : color(fill?.kind === "solid" ? fill.color : void 0);
|
|
19980
|
+
return {
|
|
19981
|
+
...resolved === void 0 ? {} : { color: resolved },
|
|
19982
|
+
...ln?.widthEmu === void 0 ? {} : { width: ln.widthEmu / EMU_PER_PIXEL },
|
|
19983
|
+
...ln?.dash === void 0 ? {} : { dash: ln.dash }
|
|
19984
|
+
};
|
|
19985
|
+
};
|
|
19986
|
+
const bind = (axis, scale, values) => {
|
|
19987
|
+
const opts = options(axis);
|
|
19988
|
+
const automatic = opts.logScale ? computeLogValueRange(
|
|
19989
|
+
[{ values: values ?? [] }],
|
|
19990
|
+
opts.logBase && Number.isFinite(opts.logBase) && opts.logBase > 1 ? opts.logBase : 10
|
|
19991
|
+
) : {
|
|
19992
|
+
min: scale?.min ?? 0,
|
|
19993
|
+
max: scale?.max ?? 1,
|
|
19994
|
+
span: (scale?.max ?? 1) - (scale?.min ?? 0),
|
|
19995
|
+
...scale ? { majorUnit: scale.majorUnit } : {}
|
|
19996
|
+
};
|
|
19997
|
+
const logBase = automatic.logBase;
|
|
19998
|
+
const range = withAxisBounds(automatic, opts, logBase);
|
|
19999
|
+
if (scale) {
|
|
20000
|
+
scale.min = range.min;
|
|
20001
|
+
scale.max = range.max;
|
|
20002
|
+
scale.ticks = generateAxisTicks(range, opts, 5);
|
|
20003
|
+
}
|
|
20004
|
+
return {
|
|
20005
|
+
source: axis,
|
|
20006
|
+
range,
|
|
20007
|
+
minorTicks: generateMinorAxisTicks(range, opts),
|
|
20008
|
+
line: paint2(axis.spPr),
|
|
20009
|
+
majorGrid: paint2(axis.majorGridlinesSpPr),
|
|
20010
|
+
minorGrid: paint2(axis.minorGridlinesSpPr)
|
|
20011
|
+
};
|
|
20012
|
+
};
|
|
20013
|
+
const out = {};
|
|
20014
|
+
if (value)
|
|
20015
|
+
out.value = bind(
|
|
20016
|
+
value,
|
|
20017
|
+
model.valueAxis,
|
|
20018
|
+
[
|
|
20019
|
+
...model.series,
|
|
20020
|
+
...model.extraGroups?.filter((g) => !g.secondary).flatMap((g) => g.series) ?? []
|
|
20021
|
+
].flatMap((s) => s.values)
|
|
20022
|
+
);
|
|
20023
|
+
if (category)
|
|
20024
|
+
out.category = bind(
|
|
20025
|
+
category,
|
|
20026
|
+
model.xAxis ?? {
|
|
20027
|
+
min: 0,
|
|
20028
|
+
max: Math.max(1, model.categories.length - 1),
|
|
20029
|
+
majorUnit: 1,
|
|
20030
|
+
ticks: []
|
|
20031
|
+
},
|
|
20032
|
+
model.series.flatMap((s) => s.xValues ?? [])
|
|
20033
|
+
);
|
|
20034
|
+
if (secondary)
|
|
20035
|
+
out.secondary = bind(
|
|
20036
|
+
secondary,
|
|
20037
|
+
model.secondaryAxis,
|
|
20038
|
+
model.extraGroups?.filter((g) => g.secondary).flatMap((g) => g.series.flatMap((s) => s.values))
|
|
20039
|
+
);
|
|
20040
|
+
model.axes = out;
|
|
20041
|
+
}
|
|
20042
|
+
|
|
19568
20043
|
// chart/render/chart-view-analysis.ts
|
|
19569
20044
|
function strokeOf(line3, fallback, resolve) {
|
|
19570
20045
|
if (line3?.fill?.kind === "none") return void 0;
|
|
@@ -19614,15 +20089,15 @@ function seriesName(series, index, evaluateRef) {
|
|
|
19614
20089
|
const fromRef = resolveRef(series.nameRef, evaluateRef)?.map(toText).filter((t) => t !== "").join(" ");
|
|
19615
20090
|
return fromRef || series.name || `Series${index + 1}`;
|
|
19616
20091
|
}
|
|
19617
|
-
function seriesContext(chart, theme,
|
|
20092
|
+
function seriesContext(chart, theme, options2) {
|
|
19618
20093
|
const scheme = chartColorScheme(theme);
|
|
19619
20094
|
const resolver = { scheme: (name) => scheme[name] };
|
|
19620
20095
|
return {
|
|
19621
20096
|
theme,
|
|
19622
20097
|
scheme,
|
|
19623
20098
|
palette: chart.colorPalette === void 0 ? void 0 : findChartColorPalette(chart.colorPalette),
|
|
19624
|
-
evaluateRef:
|
|
19625
|
-
seriesColor:
|
|
20099
|
+
evaluateRef: options2.evaluateRef ?? (() => []),
|
|
20100
|
+
seriesColor: options2.seriesColor,
|
|
19626
20101
|
drawingColor: (color) => color && drawingColorCss(resolveDrawingColor(color, resolver, { transformOrder: "document" })),
|
|
19627
20102
|
gradient: (fill) => fill?.kind === "gradient" ? resolveChartGradient(
|
|
19628
20103
|
fill,
|
|
@@ -19648,7 +20123,11 @@ function seriesView(ctx, s, index, total, categoriesOf) {
|
|
|
19648
20123
|
})
|
|
19649
20124
|
);
|
|
19650
20125
|
if (Object.keys(points).length) view.pointGradients = points;
|
|
19651
|
-
Object.assign(
|
|
20126
|
+
Object.assign(
|
|
20127
|
+
view,
|
|
20128
|
+
analysisView(s, color, ctx.drawingColor),
|
|
20129
|
+
seriesMarkerViews(s, ctx.drawingColor)
|
|
20130
|
+
);
|
|
19652
20131
|
return view;
|
|
19653
20132
|
}
|
|
19654
20133
|
|
|
@@ -19948,11 +20427,11 @@ function histogramView(chart, model) {
|
|
|
19948
20427
|
const first3 = model.series[0];
|
|
19949
20428
|
if (!first3) return;
|
|
19950
20429
|
const raw = first3.values.map((v) => v ?? Number.NaN);
|
|
19951
|
-
const
|
|
19952
|
-
const bins =
|
|
20430
|
+
const options2 = chart.histogram ?? {};
|
|
20431
|
+
const bins = options2.aggregateByCategory ? aggregateByCategory(
|
|
19953
20432
|
first3.values.map((v) => v ?? 0),
|
|
19954
20433
|
model.categories
|
|
19955
|
-
) : computeHistogramBins(raw,
|
|
20434
|
+
) : computeHistogramBins(raw, options2, formatAxisValue);
|
|
19956
20435
|
model.categories = bins.map((bin) => bin.label);
|
|
19957
20436
|
first3.values = bins.map((bin) => bin.value);
|
|
19958
20437
|
model.barGapWidth = 0;
|
|
@@ -19976,11 +20455,11 @@ var SUPPORTED = /* @__PURE__ */ new Set([
|
|
|
19976
20455
|
"treemap",
|
|
19977
20456
|
"sunburst"
|
|
19978
20457
|
]);
|
|
19979
|
-
function chartSummaryView(chart, theme,
|
|
20458
|
+
function chartSummaryView(chart, theme, options2 = {}) {
|
|
19980
20459
|
const type = chart.chartType;
|
|
19981
20460
|
const radial = type === "pie" || type === "doughnut";
|
|
19982
20461
|
const byPoint = radial || type === "treemap" || type === "sunburst";
|
|
19983
|
-
const ctx = seriesContext(chart, theme,
|
|
20462
|
+
const ctx = seriesContext(chart, theme, options2);
|
|
19984
20463
|
const { palette, scheme, drawingColor } = ctx;
|
|
19985
20464
|
const grouping = chart.grouping ?? (type === "bar" || type === "column" ? "clustered" : "standard");
|
|
19986
20465
|
const rawCategories = [];
|
|
@@ -20066,6 +20545,7 @@ function chartSummaryView(chart, theme, options = {}) {
|
|
|
20066
20545
|
else if (!byPoint) model.valueAxis = valueAxis(model);
|
|
20067
20546
|
applyDataLabels(model, chart.series, extra);
|
|
20068
20547
|
chartExtraAxes(model);
|
|
20548
|
+
applyChartAxes(model, chart, ctx.drawingColor);
|
|
20069
20549
|
return model;
|
|
20070
20550
|
}
|
|
20071
20551
|
|
|
@@ -20073,15 +20553,13 @@ function chartSummaryView(chart, theme, options = {}) {
|
|
|
20073
20553
|
function cartesianAxes(model, area, out) {
|
|
20074
20554
|
const scale = model.valueAxis;
|
|
20075
20555
|
if (!scale) return void 0;
|
|
20076
|
-
const labels = scale.ticks.map((t) =>
|
|
20556
|
+
const labels = scale.ticks.map((t) => axisTickText(t, model.axes?.value, scale.percent));
|
|
20077
20557
|
const valueAttrs = chartTextAttributes(model, "valueAxis");
|
|
20078
20558
|
const categoryAttrs = chartTextAttributes(model, "categoryAxis");
|
|
20079
20559
|
const valueSize = valueAttrs.size ?? 10;
|
|
20080
20560
|
const categorySize = categoryAttrs.size ?? 10;
|
|
20081
|
-
const
|
|
20082
|
-
const
|
|
20083
|
-
const valueLabels = model.appearance?.valueAxis?.labelsVisible !== false;
|
|
20084
|
-
const categoryLabels = model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
20561
|
+
const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
|
|
20562
|
+
const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
20085
20563
|
const labelW = valueLabels ? Math.max(...labels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
|
|
20086
20564
|
const horizontal = model.horizontal;
|
|
20087
20565
|
const cats = Math.max(1, model.categories.length);
|
|
@@ -20090,7 +20568,7 @@ function cartesianAxes(model, area, out) {
|
|
|
20090
20568
|
Math.max(...model.categories.map((c2) => textWidth(c2, categorySize)), 8) + 6
|
|
20091
20569
|
);
|
|
20092
20570
|
const second = horizontal ? void 0 : model.secondaryAxis;
|
|
20093
|
-
const secondLabels = second?.ticks.map((t) =>
|
|
20571
|
+
const secondLabels = second?.ticks.map((t) => axisTickText(t, model.axes?.secondary, second.percent)) ?? [];
|
|
20094
20572
|
const secondW = second ? valueLabels ? Math.max(...secondLabels.map((l) => textWidth(l, valueSize)), 8) + 8 : 4 : 0;
|
|
20095
20573
|
const plot = horizontal ? {
|
|
20096
20574
|
x: area.x + catW,
|
|
@@ -20103,29 +20581,47 @@ function cartesianAxes(model, area, out) {
|
|
|
20103
20581
|
w: Math.max(1, area.w - labelW - 4 - secondW),
|
|
20104
20582
|
h: Math.max(1, area.h - Math.max(20, categorySize * 1.5))
|
|
20105
20583
|
};
|
|
20106
|
-
const
|
|
20107
|
-
const value = horizontal ? (v) => plot.x + (v - scale.min) / span * plot.w : (v) => plot.y + plot.h - (v - scale.min) / span * plot.h;
|
|
20584
|
+
const value = horizontal ? (v) => plot.x + chartAxisRatio(v, scale, model.axes?.value) * plot.w : (v) => plot.y + plot.h - chartAxisRatio(v, scale, model.axes?.value) * plot.h;
|
|
20108
20585
|
const bandSize = (horizontal ? plot.h : plot.w) / cats;
|
|
20109
|
-
const
|
|
20586
|
+
const index = (i) => model.axes?.category?.range.reverseOrder ? cats - 1 - i : i;
|
|
20587
|
+
const band = horizontal ? (i) => plot.y + plot.h - bandSize * (index(i) + 0.5) : (i) => plot.x + bandSize * (index(i) + 0.5);
|
|
20110
20588
|
out.push(chartAreaRect(model, "plotArea", plot));
|
|
20589
|
+
out.push(axisGridlines(model, model.axes?.value, scale.ticks, value, plot, horizontal));
|
|
20590
|
+
if (model.axes?.category?.source.majorGridlines || model.axes?.category?.source.minorGridlines)
|
|
20591
|
+
out.push(
|
|
20592
|
+
axisGridlines(
|
|
20593
|
+
model,
|
|
20594
|
+
model.axes.category,
|
|
20595
|
+
model.categories.map((_, i) => i),
|
|
20596
|
+
band,
|
|
20597
|
+
plot,
|
|
20598
|
+
!horizontal
|
|
20599
|
+
)
|
|
20600
|
+
);
|
|
20111
20601
|
scale.ticks.forEach((t, i) => {
|
|
20112
20602
|
const p = value(t);
|
|
20113
20603
|
const label = labels[i] ?? "";
|
|
20114
20604
|
if (horizontal) {
|
|
20115
|
-
out.push(line2(p, plot.y, p, plot.y + plot.h, grid.color, grid.width));
|
|
20116
20605
|
if (valueLabels)
|
|
20117
20606
|
out.push(
|
|
20118
20607
|
text2(p, plot.y + plot.h + valueSize + 2, label, { anchor: "middle", ...valueAttrs })
|
|
20119
20608
|
);
|
|
20120
20609
|
} else {
|
|
20121
|
-
out.push(line2(plot.x, p, plot.x + plot.w, p, grid.color, grid.width));
|
|
20122
20610
|
if (valueLabels)
|
|
20123
20611
|
out.push(text2(plot.x - 4, p + valueSize * 0.3, label, { anchor: "end", ...valueAttrs }));
|
|
20124
20612
|
}
|
|
20125
20613
|
});
|
|
20126
|
-
const
|
|
20127
|
-
|
|
20128
|
-
|
|
20614
|
+
const source = model.axes?.value?.source;
|
|
20615
|
+
const crossing = source?.crosses === "max" ? scale.max : source?.crosses === "min" ? scale.min : source?.crossesAt ?? 0;
|
|
20616
|
+
const zero = value(Math.min(Math.max(crossing, scale.min), scale.max));
|
|
20617
|
+
if (horizontal)
|
|
20618
|
+
out.push(
|
|
20619
|
+
axisLine(model, model.axes?.category, "categoryAxis", zero, plot.y, zero, plot.y + plot.h)
|
|
20620
|
+
);
|
|
20621
|
+
else
|
|
20622
|
+
out.push(
|
|
20623
|
+
axisLine(model, model.axes?.category, "categoryAxis", plot.x, zero, plot.x + plot.w, zero)
|
|
20624
|
+
);
|
|
20129
20625
|
const step = Math.max(
|
|
20130
20626
|
1,
|
|
20131
20627
|
Math.ceil(cats / Math.max(1, Math.floor((horizontal ? plot.h : plot.w) / 14)))
|
|
@@ -20150,20 +20646,23 @@ function cartesianAxes(model, area, out) {
|
|
|
20150
20646
|
});
|
|
20151
20647
|
const frame2 = { plot, value, band, bandSize };
|
|
20152
20648
|
if (second) {
|
|
20153
|
-
|
|
20154
|
-
frame2.secondary = (v) => plot.y + plot.h - (v - second.min) / secondSpan * plot.h;
|
|
20155
|
-
const secondAxis = chartStroke(model, "valueAxis");
|
|
20649
|
+
frame2.secondary = (v) => plot.y + plot.h - chartAxisRatio(v, second, model.axes?.secondary) * plot.h;
|
|
20156
20650
|
out.push(
|
|
20157
|
-
|
|
20651
|
+
axisLine(
|
|
20652
|
+
model,
|
|
20653
|
+
model.axes?.secondary,
|
|
20654
|
+
"valueAxis",
|
|
20158
20655
|
plot.x + plot.w,
|
|
20159
20656
|
plot.y,
|
|
20160
20657
|
plot.x + plot.w,
|
|
20161
|
-
plot.y + plot.h
|
|
20162
|
-
secondAxis.color,
|
|
20163
|
-
secondAxis.width
|
|
20658
|
+
plot.y + plot.h
|
|
20164
20659
|
)
|
|
20165
20660
|
);
|
|
20166
|
-
if (
|
|
20661
|
+
if (model.axes?.secondary?.source.majorGridlines || model.axes?.secondary?.source.minorGridlines)
|
|
20662
|
+
out.push(
|
|
20663
|
+
axisGridlines(model, model.axes.secondary, second.ticks, frame2.secondary, plot, false)
|
|
20664
|
+
);
|
|
20665
|
+
if (chartAxisLabels(model.axes?.secondary))
|
|
20167
20666
|
second.ticks.forEach(
|
|
20168
20667
|
(t, i) => out.push(
|
|
20169
20668
|
text2(plot.x + plot.w + 4, frame2.secondary(t) + valueSize * 0.3, secondLabels[i] ?? "", {
|
|
@@ -20207,18 +20706,19 @@ function linesAndAreas(model, frame2, out) {
|
|
|
20207
20706
|
index: i,
|
|
20208
20707
|
x: frame2.band(i),
|
|
20209
20708
|
y: frame2.value(top),
|
|
20210
|
-
radius: area ? 0 :
|
|
20709
|
+
radius: area ? 0 : chartMarkerRadius(s, i, 2.5)
|
|
20211
20710
|
});
|
|
20212
20711
|
lower.push([frame2.band(i), frame2.value(below)]);
|
|
20213
20712
|
});
|
|
20214
20713
|
layers.push({
|
|
20714
|
+
series: s,
|
|
20215
20715
|
points,
|
|
20216
20716
|
lower,
|
|
20217
20717
|
color: s.color,
|
|
20218
20718
|
filter: s.shadowFilter ? ` filter="${s.shadowFilter}"` : ""
|
|
20219
20719
|
});
|
|
20220
20720
|
});
|
|
20221
|
-
for (const { points, lower, color, filter } of area ? [...layers].reverse() : layers) {
|
|
20721
|
+
for (const { points, lower, color, filter, series } of area ? [...layers].reverse() : layers) {
|
|
20222
20722
|
if (area) {
|
|
20223
20723
|
const poly = [...points, ...[...lower].reverse()].map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
|
|
20224
20724
|
out.push(`<polygon points="${poly}" fill="${color}" fill-opacity="0.85"${filter}/>`);
|
|
@@ -20237,9 +20737,9 @@ function linesAndAreas(model, frame2, out) {
|
|
|
20237
20737
|
else segment2.push(`${n(x)},${n(y)}`);
|
|
20238
20738
|
}
|
|
20239
20739
|
flush();
|
|
20240
|
-
|
|
20241
|
-
if (!Number.isNaN(x))
|
|
20242
|
-
|
|
20740
|
+
points.forEach(([x, y], index) => {
|
|
20741
|
+
if (!Number.isNaN(x)) out.push(chartSeriesMarkerSvg(series, index, x, y, 2.5));
|
|
20742
|
+
});
|
|
20243
20743
|
}
|
|
20244
20744
|
pointLabels(model, marks, out);
|
|
20245
20745
|
}
|
|
@@ -20249,16 +20749,14 @@ function scatter(model, area, out) {
|
|
|
20249
20749
|
const ys = model.valueAxis;
|
|
20250
20750
|
const xs = model.xAxis;
|
|
20251
20751
|
if (!ys || !xs) return;
|
|
20252
|
-
const yLabels = ys.ticks.map((t) =>
|
|
20752
|
+
const yLabels = ys.ticks.map((t) => axisTickText(t, model.axes?.value));
|
|
20253
20753
|
const valueAttrs = chartTextAttributes(model, "valueAxis");
|
|
20254
20754
|
const categoryAttrs = chartTextAttributes(model, "categoryAxis");
|
|
20255
20755
|
const valueSize = valueAttrs.size ?? 10;
|
|
20256
20756
|
const categorySize = categoryAttrs.size ?? 10;
|
|
20257
|
-
const grid = chartStroke(model, "gridlineMajor");
|
|
20258
20757
|
const xAxis = chartStroke(model, "categoryAxis");
|
|
20259
|
-
const
|
|
20260
|
-
const
|
|
20261
|
-
const categoryLabels = model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
20758
|
+
const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
|
|
20759
|
+
const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
20262
20760
|
const labelW = valueLabels ? Math.max(...yLabels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
|
|
20263
20761
|
const plot = {
|
|
20264
20762
|
x: area.x + labelW,
|
|
@@ -20278,17 +20776,24 @@ function scatter(model, area, out) {
|
|
|
20278
20776
|
s.values.forEach((_, i) => {
|
|
20279
20777
|
reach = Math.max(reach, radiusOf(s.sizes?.[i] ?? void 0) ?? 0);
|
|
20280
20778
|
});
|
|
20281
|
-
const widen = (s, length) => {
|
|
20779
|
+
const widen = (s, length, axis) => {
|
|
20780
|
+
if (axis?.range.logScale) return s;
|
|
20282
20781
|
const pad = reach * (s.max - s.min || 1) / Math.max(1, length - 2 * reach);
|
|
20283
|
-
return {
|
|
20782
|
+
return {
|
|
20783
|
+
...s,
|
|
20784
|
+
min: axis?.source.scaling.min === void 0 ? s.min - pad : s.min,
|
|
20785
|
+
max: axis?.source.scaling.max === void 0 ? s.max + pad : s.max
|
|
20786
|
+
};
|
|
20284
20787
|
};
|
|
20285
|
-
const xView = widen(xs, plot.w);
|
|
20286
|
-
const yView = widen(ys, plot.h);
|
|
20287
|
-
const px3 = (v) => plot.x + (v
|
|
20288
|
-
const py = (v) => plot.y + plot.h - (v
|
|
20788
|
+
const xView = widen(xs, plot.w, model.axes?.category);
|
|
20789
|
+
const yView = widen(ys, plot.h, model.axes?.value);
|
|
20790
|
+
const px3 = (v) => plot.x + chartAxisRatio(v, xView, model.axes?.category) * plot.w;
|
|
20791
|
+
const py = (v) => plot.y + plot.h - chartAxisRatio(v, yView, model.axes?.value) * plot.h;
|
|
20289
20792
|
out.push(chartAreaRect(model, "plotArea", plot));
|
|
20793
|
+
out.push(axisGridlines(model, model.axes?.value, ys.ticks, py, plot, false));
|
|
20794
|
+
if (model.axes?.category)
|
|
20795
|
+
out.push(axisGridlines(model, model.axes.category, xs.ticks, px3, plot, true));
|
|
20290
20796
|
ys.ticks.forEach((t, i) => {
|
|
20291
|
-
out.push(line2(plot.x, py(t), plot.x + plot.w, py(t), grid.color, grid.width));
|
|
20292
20797
|
if (valueLabels)
|
|
20293
20798
|
out.push(
|
|
20294
20799
|
text2(plot.x - 4, py(t) + valueSize * 0.3, yLabels[i] ?? "", {
|
|
@@ -20298,19 +20803,30 @@ function scatter(model, area, out) {
|
|
|
20298
20803
|
);
|
|
20299
20804
|
});
|
|
20300
20805
|
for (const t of xs.ticks) {
|
|
20301
|
-
|
|
20806
|
+
if (!model.axes?.category?.source.deleted)
|
|
20807
|
+
out.push(line2(px3(t), plot.y + plot.h, px3(t), plot.y + plot.h + 3, xAxis.color, xAxis.width));
|
|
20302
20808
|
if (categoryLabels)
|
|
20303
20809
|
out.push(
|
|
20304
|
-
text2(px3(t), plot.y + plot.h + categorySize + 3,
|
|
20810
|
+
text2(px3(t), plot.y + plot.h + categorySize + 3, axisTickText(t, model.axes?.category), {
|
|
20305
20811
|
anchor: "middle",
|
|
20306
20812
|
...categoryAttrs
|
|
20307
20813
|
})
|
|
20308
20814
|
);
|
|
20309
20815
|
}
|
|
20310
20816
|
out.push(
|
|
20311
|
-
|
|
20817
|
+
axisLine(
|
|
20818
|
+
model,
|
|
20819
|
+
model.axes?.category,
|
|
20820
|
+
"categoryAxis",
|
|
20821
|
+
plot.x,
|
|
20822
|
+
plot.y + plot.h,
|
|
20823
|
+
plot.x + plot.w,
|
|
20824
|
+
plot.y + plot.h
|
|
20825
|
+
)
|
|
20826
|
+
);
|
|
20827
|
+
out.push(
|
|
20828
|
+
axisLine(model, model.axes?.value, "valueAxis", plot.x, plot.y, plot.x, plot.y + plot.h)
|
|
20312
20829
|
);
|
|
20313
|
-
out.push(line2(plot.x, plot.y, plot.x, plot.y + plot.h, yAxis.color, yAxis.width));
|
|
20314
20830
|
const marks = [];
|
|
20315
20831
|
for (const [si, s] of model.series.entries())
|
|
20316
20832
|
s.values.forEach((v, i) => {
|
|
@@ -20319,8 +20835,8 @@ function scatter(model, area, out) {
|
|
|
20319
20835
|
const filter = s.shadowFilter ? ` filter="${s.shadowFilter}"` : "";
|
|
20320
20836
|
const fill = s.pointColors?.[i] ?? s.color;
|
|
20321
20837
|
if (!bubble) {
|
|
20322
|
-
out.push(
|
|
20323
|
-
marks.push({ series: s, index: i, x: px3(x), y: py(v), radius:
|
|
20838
|
+
out.push(chartSeriesMarkerSvg(s, i, px3(x), py(v)));
|
|
20839
|
+
marks.push({ series: s, index: i, x: px3(x), y: py(v), radius: chartMarkerRadius(s, i) });
|
|
20324
20840
|
return;
|
|
20325
20841
|
}
|
|
20326
20842
|
const r = radiusOf(s.sizes?.[i] ?? void 0);
|
|
@@ -20540,32 +21056,37 @@ function radarSvg(model, area) {
|
|
|
20540
21056
|
const valueSize = valueAttrs.size ?? 9;
|
|
20541
21057
|
const categorySize = categoryAttrs.size ?? 10;
|
|
20542
21058
|
const grid = chartStroke(model, "gridlineMajor");
|
|
20543
|
-
const axis = chartStroke(model, "categoryAxis");
|
|
20544
21059
|
const cx2 = area.x + area.w / 2;
|
|
20545
21060
|
const cy = area.y + area.h / 2 + 4;
|
|
20546
21061
|
const radius = Math.max(1, Math.min(area.w, area.h) / 2 - Math.max(18, categorySize * 1.8));
|
|
20547
21062
|
const angle = (i) => i / count * Math.PI * 2;
|
|
20548
|
-
const r = (v) => (v
|
|
21063
|
+
const r = (v) => chartAxisRatio(v, scale, model.axes?.value) * radius;
|
|
20549
21064
|
const labelEvery = Math.max(
|
|
20550
21065
|
1,
|
|
20551
21066
|
Math.ceil(12 / Math.max(1, radius / Math.max(1, scale.ticks.length - 1)))
|
|
20552
21067
|
);
|
|
20553
21068
|
for (const [k, t] of scale.ticks.entries()) {
|
|
20554
21069
|
const ring = Array.from({ length: count }, (_, i) => polar(cx2, cy, r(t), angle(i))).map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
|
|
20555
|
-
|
|
20556
|
-
`<polygon points="${ring}" fill="none" stroke="${grid.color}" stroke-width="${n(grid.width)}"/>`
|
|
20557
|
-
);
|
|
20558
|
-
if (model.appearance?.valueAxis?.labelsVisible !== false && k % labelEvery === 0)
|
|
21070
|
+
if (!model.axes?.value || model.axes.value.source.majorGridlines)
|
|
20559
21071
|
out.push(
|
|
20560
|
-
|
|
21072
|
+
`<polygon points="${ring}" fill="none" stroke="${grid.color}" stroke-width="${n(grid.width)}"/>`
|
|
21073
|
+
);
|
|
21074
|
+
if (chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false && k % labelEvery === 0)
|
|
21075
|
+
out.push(
|
|
21076
|
+
text2(
|
|
21077
|
+
cx2 + 3,
|
|
21078
|
+
cy - r(t) + valueSize * 0.3,
|
|
21079
|
+
axisTickText(t, model.axes?.value, scale.percent),
|
|
21080
|
+
valueAttrs
|
|
21081
|
+
)
|
|
20561
21082
|
);
|
|
20562
21083
|
}
|
|
20563
21084
|
model.categories.forEach((c2, i) => {
|
|
20564
21085
|
const [x, y] = polar(cx2, cy, radius, angle(i));
|
|
20565
|
-
out.push(
|
|
21086
|
+
out.push(axisLine(model, model.axes?.category, "categoryAxis", cx2, cy, x, y));
|
|
20566
21087
|
const [lx, ly] = polar(cx2, cy, radius + 10, angle(i));
|
|
20567
21088
|
const anchor = Math.abs(lx - cx2) < 2 ? "middle" : lx > cx2 ? "start" : "end";
|
|
20568
|
-
if (model.appearance?.categoryAxis?.labelsVisible !== false)
|
|
21089
|
+
if (chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false)
|
|
20569
21090
|
out.push(
|
|
20570
21091
|
text2(lx, ly + categorySize * 0.3, fit(c2, area.w / 4, categorySize), {
|
|
20571
21092
|
anchor,
|
|
@@ -20576,7 +21097,13 @@ function radarSvg(model, area) {
|
|
|
20576
21097
|
const marks = [];
|
|
20577
21098
|
for (const s of model.series) {
|
|
20578
21099
|
const vertices = s.values.slice(0, count).map((v, i) => polar(cx2, cy, r(v ?? scale.min), angle(i)));
|
|
20579
|
-
vertices.forEach(([x, y], i) =>
|
|
21100
|
+
vertices.forEach(([x, y], i) => {
|
|
21101
|
+
if (s.values[i] === null) return;
|
|
21102
|
+
const markerSeries = s;
|
|
21103
|
+
if (markerSeries.marker || markerSeries.pointMarkers)
|
|
21104
|
+
out.push(chartSeriesMarkerSvg(s, i, x, y));
|
|
21105
|
+
marks.push({ series: s, index: i, x, y, radius: chartMarkerRadius(s, i) });
|
|
21106
|
+
});
|
|
20580
21107
|
const points = vertices.map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
|
|
20581
21108
|
out.push(
|
|
20582
21109
|
`<polygon points="${points}" fill="none" stroke="${s.color}" stroke-width="2"${s.shadowFilter ? ` filter="${s.shadowFilter}"` : ""}/>`
|
|
@@ -20673,33 +21200,33 @@ var CHART_FONT_FAMILY = "Calibri, Carlito, Arial, sans-serif";
|
|
|
20673
21200
|
function cssFont(attrs2) {
|
|
20674
21201
|
return `${attrs2.italic ? "italic" : "normal"} ${attrs2.weight ?? "normal"} ${attrs2.size ?? 10}px ${attrs2.family ?? CHART_FONT_FAMILY}`;
|
|
20675
21202
|
}
|
|
20676
|
-
function chartFontMetrics(attrs2,
|
|
20677
|
-
const metrics =
|
|
21203
|
+
function chartFontMetrics(attrs2, options2) {
|
|
21204
|
+
const metrics = options2.measureFont?.(cssFont(attrs2));
|
|
20678
21205
|
return metrics && Number.isFinite(metrics.ascent) && Number.isFinite(metrics.descent) && metrics.ascent >= 0 && metrics.descent >= 0 && metrics.ascent + metrics.descent > 0 ? metrics : void 0;
|
|
20679
21206
|
}
|
|
20680
|
-
function chartTextWidth(content, attrs2,
|
|
20681
|
-
const width =
|
|
21207
|
+
function chartTextWidth(content, attrs2, options2) {
|
|
21208
|
+
const width = options2.measureText?.(content, cssFont(attrs2));
|
|
20682
21209
|
return width !== void 0 && Number.isFinite(width) && width >= 0 ? width : textWidth(content, attrs2.size);
|
|
20683
21210
|
}
|
|
20684
|
-
function fitChartText(content, maxWidth, attrs2,
|
|
20685
|
-
if (!
|
|
20686
|
-
if (chartTextWidth(content, attrs2,
|
|
21211
|
+
function fitChartText(content, maxWidth, attrs2, options2) {
|
|
21212
|
+
if (!options2.measureText) return fit(content, maxWidth, attrs2.size);
|
|
21213
|
+
if (chartTextWidth(content, attrs2, options2) <= maxWidth) return content;
|
|
20687
21214
|
const points = [...content];
|
|
20688
21215
|
let low = 0;
|
|
20689
21216
|
let high = points.length;
|
|
20690
21217
|
while (low < high) {
|
|
20691
21218
|
const mid = Math.ceil((low + high) / 2);
|
|
20692
|
-
if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`, attrs2,
|
|
21219
|
+
if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`, attrs2, options2) <= maxWidth) low = mid;
|
|
20693
21220
|
else high = mid - 1;
|
|
20694
21221
|
}
|
|
20695
21222
|
return `${points.slice(0, low).join("")}\u2026`;
|
|
20696
21223
|
}
|
|
20697
21224
|
|
|
20698
21225
|
// chart/render/chart-svg-legend.ts
|
|
20699
|
-
function chartLegendSvg(model, area, frame2,
|
|
21226
|
+
function chartLegendSvg(model, area, frame2, options2) {
|
|
20700
21227
|
const automatic = [];
|
|
20701
21228
|
const bounds = {};
|
|
20702
|
-
const reserved = automaticLegend(model, area, automatic,
|
|
21229
|
+
const reserved = automaticLegend(model, area, automatic, options2, bounds);
|
|
20703
21230
|
const plot = model.legendOverlay ? area : reserved;
|
|
20704
21231
|
const box = bounds.box;
|
|
20705
21232
|
if (!box) return { plot, markup: "", foreground: false };
|
|
@@ -20713,11 +21240,11 @@ function chartLegendSvg(model, area, frame2, options) {
|
|
|
20713
21240
|
const entries = legendEntries(model);
|
|
20714
21241
|
const attrs2 = chartTextAttributes(model, "legend");
|
|
20715
21242
|
const size = attrs2.size ?? 10;
|
|
20716
|
-
const font = chartFontMetrics(attrs2,
|
|
21243
|
+
const font = chartFontMetrics(attrs2, options2);
|
|
20717
21244
|
const keySize = size / 2;
|
|
20718
21245
|
const keyGap = size / 4;
|
|
20719
21246
|
const widths = entries.map(
|
|
20720
|
-
(entry2) => chartTextWidth(entry2.label, attrs2,
|
|
21247
|
+
(entry2) => chartTextWidth(entry2.label, attrs2, options2) + keySize + keyGap
|
|
20721
21248
|
);
|
|
20722
21249
|
const horizontal = manual.width > manual.height && widths.reduce((sum, width) => sum + width, 0) + size <= manual.width;
|
|
20723
21250
|
const rowWidth = horizontal ? manual.width / entries.length : manual.width;
|
|
@@ -20732,8 +21259,8 @@ function chartLegendSvg(model, area, frame2, options) {
|
|
|
20732
21259
|
];
|
|
20733
21260
|
const baselineOffset = font ? (font.ascent - font.descent) / 2 : size * 0.35;
|
|
20734
21261
|
entries.forEach((entry2, i) => {
|
|
20735
|
-
const available = horizontal ? chartTextWidth(entry2.label, attrs2,
|
|
20736
|
-
const label = fitChartText(entry2.label, available, attrs2,
|
|
21262
|
+
const available = horizontal ? chartTextWidth(entry2.label, attrs2, options2) : Math.max(0, rowWidth - size / 2 - keySize - keyGap);
|
|
21263
|
+
const label = fitChartText(entry2.label, available, attrs2, options2);
|
|
20737
21264
|
const contentWidth = Math.min(
|
|
20738
21265
|
horizontal ? widths[i] ?? 0 : Math.max(...widths),
|
|
20739
21266
|
rowWidth - size / 2
|
|
@@ -20776,7 +21303,7 @@ function legendEntries(model) {
|
|
|
20776
21303
|
color: s.color
|
|
20777
21304
|
}));
|
|
20778
21305
|
}
|
|
20779
|
-
function automaticLegend(model, area, out,
|
|
21306
|
+
function automaticLegend(model, area, out, options2, bounds) {
|
|
20780
21307
|
const entries = legendEntries(model);
|
|
20781
21308
|
if (!model.showLegend || entries.length === 0) return area;
|
|
20782
21309
|
const pos = model.legendPosition;
|
|
@@ -20785,7 +21312,7 @@ function automaticLegend(model, area, out, options, bounds) {
|
|
|
20785
21312
|
const rowH = Math.max(16, size * 1.4);
|
|
20786
21313
|
if (pos === "t" || pos === "b") {
|
|
20787
21314
|
const widths = entries.map(
|
|
20788
|
-
(e) => Math.min(chartTextWidth(e.label, attrs2,
|
|
21315
|
+
(e) => Math.min(chartTextWidth(e.label, attrs2, options2) + 20, area.w / 2)
|
|
20789
21316
|
);
|
|
20790
21317
|
const total = widths.reduce((a2, b) => a2 + b, 0);
|
|
20791
21318
|
let x2 = area.x + Math.max(0, (area.w - total) / 2);
|
|
@@ -20802,14 +21329,14 @@ function automaticLegend(model, area, out, options, bounds) {
|
|
|
20802
21329
|
entries.forEach((e, i) => {
|
|
20803
21330
|
const w = widths[i] ?? 0;
|
|
20804
21331
|
out.push(rect2(x2, y, 8, 8, e.color));
|
|
20805
|
-
out.push(text2(x2 + 12, y + 8, fitChartText(e.label, w - 16, attrs2,
|
|
21332
|
+
out.push(text2(x2 + 12, y + 8, fitChartText(e.label, w - 16, attrs2, options2), attrs2));
|
|
20806
21333
|
x2 += w;
|
|
20807
21334
|
});
|
|
20808
21335
|
return pos === "t" ? { x: area.x, y: area.y + rowH + 4, w: area.w, h: area.h - rowH - 4 } : { x: area.x, y: area.y, w: area.w, h: area.h - rowH - 4 };
|
|
20809
21336
|
}
|
|
20810
21337
|
const width = Math.min(
|
|
20811
21338
|
area.w * 0.35,
|
|
20812
|
-
Math.max(...entries.map((e) => chartTextWidth(e.label, attrs2,
|
|
21339
|
+
Math.max(...entries.map((e) => chartTextWidth(e.label, attrs2, options2))) + 22
|
|
20813
21340
|
);
|
|
20814
21341
|
const height = entries.length * rowH;
|
|
20815
21342
|
const x = pos === "l" ? area.x + 4 : area.x + area.w - width;
|
|
@@ -20827,14 +21354,14 @@ function automaticLegend(model, area, out, options, bounds) {
|
|
|
20827
21354
|
const y = y0 + i * rowH;
|
|
20828
21355
|
if (y + rowH > area.y + area.h + 2) return;
|
|
20829
21356
|
out.push(rect2(x, y + 3, 8, 8, e.color));
|
|
20830
|
-
out.push(text2(x + 12, y + 11, fitChartText(e.label, width - 16, attrs2,
|
|
21357
|
+
out.push(text2(x + 12, y + 11, fitChartText(e.label, width - 16, attrs2, options2), attrs2));
|
|
20831
21358
|
});
|
|
20832
21359
|
return pos === "l" ? { x: area.x + width + 8, y: area.y, w: area.w - width - 8, h: area.h } : { x: area.x, y: area.y, w: area.w - width - 8, h: area.h };
|
|
20833
21360
|
}
|
|
20834
21361
|
|
|
20835
21362
|
// text/wrap-styled-runs.ts
|
|
20836
21363
|
var graphemes = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
20837
|
-
function wrapStyledRuns(runs, maxWidth, measure2,
|
|
21364
|
+
function wrapStyledRuns(runs, maxWidth, measure2, options2 = {}) {
|
|
20838
21365
|
const groups = [];
|
|
20839
21366
|
for (const [source, run] of runs.entries()) {
|
|
20840
21367
|
for (const token of run.text.split(/(\r\n|[\r\n]|[ \t]+)/u).filter(Boolean)) {
|
|
@@ -20882,7 +21409,7 @@ function wrapStyledRuns(runs, maxWidth, measure2, options = {}) {
|
|
|
20882
21409
|
if (line3.length && width(merged(line3, [...separator, ...group2.pieces])) > maxWidth) flush();
|
|
20883
21410
|
else line3 = merged(line3, separator);
|
|
20884
21411
|
spaces = [];
|
|
20885
|
-
if (
|
|
21412
|
+
if (options2.breakWords && wordWidth > maxWidth) {
|
|
20886
21413
|
for (const piece of group2.pieces) {
|
|
20887
21414
|
for (const { segment: segment2 } of graphemes.segment(piece.text)) {
|
|
20888
21415
|
const next = { ...piece, text: segment2 };
|
|
@@ -20900,11 +21427,11 @@ function wrapStyledRuns(runs, maxWidth, measure2, options = {}) {
|
|
|
20900
21427
|
function spacing(value, naturalHeight, fallback) {
|
|
20901
21428
|
return value ? value.unit === "points" ? chartPointsToPixels(value.value) : naturalHeight * value.value : fallback;
|
|
20902
21429
|
}
|
|
20903
|
-
function chartRichTitleSvg(model, width,
|
|
21430
|
+
function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
|
|
20904
21431
|
if (!model.title) return void 0;
|
|
20905
21432
|
const base = chartTextAttributes(model, "title", 14);
|
|
20906
21433
|
const capacity = Math.max(1, width * 0.8 - 8);
|
|
20907
|
-
if (!model.titleText && !hasManualLayoutFields(model.titleLayout) && !model.titleOverlay && !model.title.includes("\n") && chartTextWidth(model.title, base,
|
|
21434
|
+
if (!model.titleText && !hasManualLayoutFields(model.titleLayout) && !model.titleOverlay && !model.title.includes("\n") && chartTextWidth(model.title, base, options2) <= capacity)
|
|
20908
21435
|
return void 0;
|
|
20909
21436
|
const paragraphs = model.titleText?.paragraphs ?? [
|
|
20910
21437
|
{
|
|
@@ -20940,7 +21467,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
20940
21467
|
"title",
|
|
20941
21468
|
base.size
|
|
20942
21469
|
),
|
|
20943
|
-
|
|
21470
|
+
options2
|
|
20944
21471
|
),
|
|
20945
21472
|
{ breakWords: true }
|
|
20946
21473
|
);
|
|
@@ -20964,10 +21491,10 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
20964
21491
|
return {
|
|
20965
21492
|
...line3,
|
|
20966
21493
|
runs,
|
|
20967
|
-
width: runs.reduce((sum, run) => sum + chartTextWidth(run.text, run.attrs,
|
|
21494
|
+
width: runs.reduce((sum, run) => sum + chartTextWidth(run.text, run.attrs, options2), 0),
|
|
20968
21495
|
size: runs.length ? Math.max(...runs.map((run) => run.attrs.size ?? 14)) : base.size ?? 14,
|
|
20969
21496
|
fontMetrics: (runs.length ? runs.map((run) => run.attrs) : [base]).map(
|
|
20970
|
-
(attrs2) => chartFontMetrics(attrs2,
|
|
21497
|
+
(attrs2) => chartFontMetrics(attrs2, options2)
|
|
20971
21498
|
)
|
|
20972
21499
|
};
|
|
20973
21500
|
});
|
|
@@ -21005,7 +21532,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
21005
21532
|
anchor: "start"
|
|
21006
21533
|
}).replace("<text ", '<tspan data-chart-title-run="true" ').replace("</text>", "</tspan>")
|
|
21007
21534
|
);
|
|
21008
|
-
x += chartTextWidth(run.text, run.attrs,
|
|
21535
|
+
x += chartTextWidth(run.text, run.attrs, options2);
|
|
21009
21536
|
}
|
|
21010
21537
|
}
|
|
21011
21538
|
const parent = text2(0, 0, "", { ...base, underline: false }).replace(
|
|
@@ -21031,7 +21558,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
21031
21558
|
}
|
|
21032
21559
|
|
|
21033
21560
|
// chart/render/chart-svg.ts
|
|
21034
|
-
function renderChartSvg(model, width, height,
|
|
21561
|
+
function renderChartSvg(model, width, height, options2 = {}) {
|
|
21035
21562
|
const paint2 = chartGradientPaint(model, Math.max(1, width), Math.max(1, height));
|
|
21036
21563
|
model = paint2.model;
|
|
21037
21564
|
const w = Math.max(1, width);
|
|
@@ -21045,7 +21572,7 @@ function renderChartSvg(model, width, height, options = {}) {
|
|
|
21045
21572
|
if (paint2.defs) out.push(paint2.defs);
|
|
21046
21573
|
out.push(chartAreaRect(model, "chartArea", { x: 0, y: 0, w, h }));
|
|
21047
21574
|
let area = { x: 8, y: 8, w: w - 16, h: h - 16 };
|
|
21048
|
-
const richTitle = chartRichTitleSvg(model, w,
|
|
21575
|
+
const richTitle = chartRichTitleSvg(model, w, options2, h);
|
|
21049
21576
|
if (richTitle) {
|
|
21050
21577
|
if (model.titleLayout || model.titleOverlay) foregroundTitle = richTitle.markup;
|
|
21051
21578
|
else out.push(richTitle.markup);
|
|
@@ -21054,9 +21581,9 @@ function renderChartSvg(model, width, height, options = {}) {
|
|
|
21054
21581
|
} else if (model.title) {
|
|
21055
21582
|
const attrs2 = chartTextAttributes(model, "title", 14);
|
|
21056
21583
|
const size = attrs2.size ?? 14;
|
|
21057
|
-
const label = fitChartText(model.title, w - 16, attrs2,
|
|
21058
|
-
const titleWidth = Math.min(w - 16, chartTextWidth(label, attrs2,
|
|
21059
|
-
const font = chartFontMetrics(attrs2,
|
|
21584
|
+
const label = fitChartText(model.title, w - 16, attrs2, options2);
|
|
21585
|
+
const titleWidth = Math.min(w - 16, chartTextWidth(label, attrs2, options2) + 8);
|
|
21586
|
+
const font = chartFontMetrics(attrs2, options2);
|
|
21060
21587
|
const titleHeight = Math.max(24, font ? font.ascent + font.descent + 4 : size * 1.4 + 4);
|
|
21061
21588
|
out.push(
|
|
21062
21589
|
chartAreaRect(model, "title", {
|
|
@@ -21084,7 +21611,7 @@ function renderChartSvg(model, width, height, options = {}) {
|
|
|
21084
21611
|
out.push("</svg>");
|
|
21085
21612
|
return out.join("");
|
|
21086
21613
|
}
|
|
21087
|
-
const legend = chartLegendSvg(model, area, { width: w, height: h },
|
|
21614
|
+
const legend = chartLegendSvg(model, area, { width: w, height: h }, options2);
|
|
21088
21615
|
area = legend.plot;
|
|
21089
21616
|
if (!legend.foreground) out.push(legend.markup);
|
|
21090
21617
|
if (area.w > 4 && area.h > 4) {
|
|
@@ -21131,8 +21658,8 @@ function chartSpaceKind(space) {
|
|
|
21131
21658
|
const type = chartSummaryFromSpace(space).chartType;
|
|
21132
21659
|
return { type, drawn: DRAWN_CHART_TYPES.has(type) };
|
|
21133
21660
|
}
|
|
21134
|
-
function renderChartSpaceSvg(space,
|
|
21135
|
-
const { width, height, theme, fonts, formatting, colorPalette, styleDefinition, ...svg } =
|
|
21661
|
+
function renderChartSpaceSvg(space, options2) {
|
|
21662
|
+
const { width, height, theme, fonts, formatting, colorPalette, styleDefinition, ...svg } = options2;
|
|
21136
21663
|
const summary = chartSummaryFromSpace(space, {
|
|
21137
21664
|
...formatting ? { formatting } : {},
|
|
21138
21665
|
...colorPalette !== void 0 ? { colorPalette } : {},
|
|
@@ -21141,8 +21668,8 @@ function renderChartSpaceSvg(space, options) {
|
|
|
21141
21668
|
const view = chartSummaryView(summary, chartThemePalette(theme, fonts));
|
|
21142
21669
|
return renderChartSvg(view, width, height, svg);
|
|
21143
21670
|
}
|
|
21144
|
-
function renderChartSummarySvg(summary,
|
|
21145
|
-
const { width, height, theme, fonts, ...svg } =
|
|
21671
|
+
function renderChartSummarySvg(summary, options2) {
|
|
21672
|
+
const { width, height, theme, fonts, ...svg } = options2;
|
|
21146
21673
|
const view = chartSummaryView(summary, chartThemePalette(theme, fonts));
|
|
21147
21674
|
return renderChartSvg(view, width, height, svg);
|
|
21148
21675
|
}
|
|
@@ -26534,7 +27061,7 @@ function datePicture(instr) {
|
|
|
26534
27061
|
}
|
|
26535
27062
|
var TOKENS = /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|am\/pm|AM\/PM|'[^']*'/g;
|
|
26536
27063
|
function formatWordDate(date, picture, locale = "en-US") {
|
|
26537
|
-
const name = (
|
|
27064
|
+
const name = (options2) => new Intl.DateTimeFormat(locale, options2).format(date);
|
|
26538
27065
|
const pad = (value) => String(value).padStart(2, "0");
|
|
26539
27066
|
const hours12 = date.getHours() % 12 || 12;
|
|
26540
27067
|
return picture.replace(TOKENS, (token) => {
|
|
@@ -26741,22 +27268,22 @@ function withTocBookmarks(model, added) {
|
|
|
26741
27268
|
)
|
|
26742
27269
|
};
|
|
26743
27270
|
}
|
|
26744
|
-
function buildTableOfContents(model,
|
|
26745
|
-
const instruction =
|
|
27271
|
+
function buildTableOfContents(model, options2) {
|
|
27272
|
+
const instruction = options2.instruction ?? DEFAULT_TOC_INSTRUCTION;
|
|
26746
27273
|
const field = { instr: instruction.trim() };
|
|
26747
|
-
const width =
|
|
27274
|
+
const width = options2.contentWidthTwips ?? twips(9360);
|
|
26748
27275
|
const styles = model.paragraphStyles?.styles ?? {};
|
|
26749
27276
|
const entries = tocEntries(model, instruction);
|
|
26750
27277
|
const figures = tocCaptionLabel(instruction) !== void 0;
|
|
26751
27278
|
const paragraphs = (entries.length ? entries : [void 0]).map((entry2) => {
|
|
26752
27279
|
const level2 = entry2?.level ?? 1;
|
|
26753
27280
|
const style = figures ? "TableofFigures" : `TOC${level2}`;
|
|
26754
|
-
const page = entry2 ?
|
|
26755
|
-
const bookmark = entry2 ?
|
|
27281
|
+
const page = entry2 ? options2.pageNumbers?.get(entry2.blockId) : void 0;
|
|
27282
|
+
const bookmark = entry2 ? options2.bookmarks?.get(entry2.blockId) : void 0;
|
|
26756
27283
|
const runs = !entry2 ? [{ text: figures ? EMPTY_FIGURES_TEXT : EMPTY_TOC_TEXT, bold: true, field }] : bookmark ? linkedEntry(entry2.text, bookmark, page) : [{ text: page ? `${entry2.text} ${page}` : entry2.text, field }];
|
|
26757
27284
|
return {
|
|
26758
27285
|
type: "paragraph",
|
|
26759
|
-
id:
|
|
27286
|
+
id: options2.newId(),
|
|
26760
27287
|
runs,
|
|
26761
27288
|
...styles[style] ? { style } : {
|
|
26762
27289
|
...level2 > 1 ? { indentLeftTwips: signedTwips((level2 - 1) * 220) } : {},
|
|
@@ -26798,12 +27325,12 @@ function findTableOfContents(blocks, accepts = (instruction) => tocCaptionLabel(
|
|
|
26798
27325
|
}
|
|
26799
27326
|
return void 0;
|
|
26800
27327
|
}
|
|
26801
|
-
function updateTableOfContents(model,
|
|
27328
|
+
function updateTableOfContents(model, options2) {
|
|
26802
27329
|
const found = findTableOfContents(model.blocks);
|
|
26803
27330
|
if (!found) return void 0;
|
|
26804
27331
|
const linked = tocHyperlinks(found.instruction) ? tocBookmarks(model, tocEntries(model, found.instruction)) : void 0;
|
|
26805
27332
|
const rebuilt = buildTableOfContents(model, {
|
|
26806
|
-
...
|
|
27333
|
+
...options2,
|
|
26807
27334
|
instruction: found.instruction,
|
|
26808
27335
|
...linked ? { bookmarks: linked.bookmarks } : {}
|
|
26809
27336
|
});
|