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.cjs
CHANGED
|
@@ -73,11 +73,11 @@ function checkXmlLimits(xml, label, limits = {}) {
|
|
|
73
73
|
throw new Error(`${label} XML exceeds the nesting depth limit of ${maxDepth}`);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
function parseXml(xml,
|
|
77
|
-
const label =
|
|
76
|
+
function parseXml(xml, options2 = {}) {
|
|
77
|
+
const label = options2.label ?? "OOXML";
|
|
78
78
|
if (/<!DOCTYPE|<!ENTITY/i.test(xml))
|
|
79
79
|
throw new Error(`${label} XML with DTD or entity declarations is not supported`);
|
|
80
|
-
checkXmlLimits(xml, label,
|
|
80
|
+
checkXmlLimits(xml, label, options2.limits);
|
|
81
81
|
let parseError = "";
|
|
82
82
|
let parsed;
|
|
83
83
|
try {
|
|
@@ -1575,8 +1575,8 @@ function rgbToHsl(r, g, b) {
|
|
|
1575
1575
|
}
|
|
1576
1576
|
return { h, s: clampUnitInterval(s), l: clampUnitInterval(l) };
|
|
1577
1577
|
}
|
|
1578
|
-
function hslToRgb(h, s, l, roundChannel = Math.round,
|
|
1579
|
-
const sC =
|
|
1578
|
+
function hslToRgb(h, s, l, roundChannel = Math.round, options2) {
|
|
1579
|
+
const sC = options2?.clampSaturation === false ? s : clampUnitInterval(s);
|
|
1580
1580
|
const lC = clampUnitInterval(l);
|
|
1581
1581
|
const hN = (h % 360 + 360) % 360;
|
|
1582
1582
|
const c2 = (1 - Math.abs(2 * lC - 1)) * sC;
|
|
@@ -2113,13 +2113,13 @@ var APPLIED = /* @__PURE__ */ new Set([
|
|
|
2113
2113
|
"lumMod",
|
|
2114
2114
|
"lumOff"
|
|
2115
2115
|
]);
|
|
2116
|
-
function resolveDrawingColor(color, theme,
|
|
2116
|
+
function resolveDrawingColor(color, theme, options2) {
|
|
2117
2117
|
const base = baseHex(color, theme);
|
|
2118
2118
|
const rgb = base ? hexToRgbChannels(base) : null;
|
|
2119
2119
|
if (!rgb) return void 0;
|
|
2120
|
-
if (
|
|
2120
|
+
if (options2?.transformOrder === "document") {
|
|
2121
2121
|
const value = orderedColorTransforms(rgb, color.transforms);
|
|
2122
|
-
const round2 =
|
|
2122
|
+
const round2 = options2.hslRounding === "halfDown" ? (channel) => Math.ceil(channel - 0.5) : Math.round;
|
|
2123
2123
|
return {
|
|
2124
2124
|
hex: `#${toHex(round2(value.r))}${toHex(round2(value.g))}${toHex(round2(value.b))}`,
|
|
2125
2125
|
alpha: value.alpha,
|
|
@@ -2170,7 +2170,7 @@ function resolveDrawingColor(color, theme, options) {
|
|
|
2170
2170
|
if (lumMod !== void 0) hsl.l = clampUnitInterval(hsl.l * lumMod);
|
|
2171
2171
|
const lumOff = parseDrawingFraction(find("lumOff"));
|
|
2172
2172
|
if (lumOff !== void 0) hsl.l = clampUnitInterval(hsl.l + lumOff);
|
|
2173
|
-
const round2 =
|
|
2173
|
+
const round2 = options2?.hslRounding === "halfDown" ? (value) => Math.ceil(value - 0.5) : Math.round;
|
|
2174
2174
|
({ r, g, b } = hslToRgb(hsl.h, hsl.s, hsl.l, round2));
|
|
2175
2175
|
}
|
|
2176
2176
|
let alpha = parseDrawingPercent(find("alpha")) ?? 1;
|
|
@@ -5893,7 +5893,7 @@ function resolveInnerRect(fillToRect, focalPoint) {
|
|
|
5893
5893
|
function lerpEdge(inner, outer, t) {
|
|
5894
5894
|
return inner + (outer - inner) * t;
|
|
5895
5895
|
}
|
|
5896
|
-
function buildRectPathGradientSvg(stops, focalPoint, fillToRect,
|
|
5896
|
+
function buildRectPathGradientSvg(stops, focalPoint, fillToRect, options2) {
|
|
5897
5897
|
if (stops.length === 0) {
|
|
5898
5898
|
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"/>';
|
|
5899
5899
|
}
|
|
@@ -5902,7 +5902,7 @@ function buildRectPathGradientSvg(stops, focalPoint, fillToRect, options) {
|
|
|
5902
5902
|
const rects = [];
|
|
5903
5903
|
const alphaRects = [];
|
|
5904
5904
|
const masked = sorted.some((stop) => (stop.opacity ?? 1) < 1);
|
|
5905
|
-
const bands =
|
|
5905
|
+
const bands = options2?.bands;
|
|
5906
5906
|
if (!Number.isInteger(bands) || bands < 1) throw new RangeError("Invalid gradient band count");
|
|
5907
5907
|
for (let i = bands; i >= 0; i -= 1) {
|
|
5908
5908
|
const t = i / bands;
|
|
@@ -16433,6 +16433,9 @@ function formatChartNumberWithColor(value, formatCode) {
|
|
|
16433
16433
|
return void 0;
|
|
16434
16434
|
}
|
|
16435
16435
|
}
|
|
16436
|
+
function formatChartNumber(value, formatCode) {
|
|
16437
|
+
return formatChartNumberWithColor(value, formatCode)?.text;
|
|
16438
|
+
}
|
|
16436
16439
|
|
|
16437
16440
|
// chart/data-label-text.ts
|
|
16438
16441
|
var DATA_LABEL_SEPARATOR = ", ";
|
|
@@ -16481,12 +16484,12 @@ function composeDataLabelText(input) {
|
|
|
16481
16484
|
}
|
|
16482
16485
|
|
|
16483
16486
|
// chart/bubble-radius.ts
|
|
16484
|
-
function computeBubbleRadius(sizeVal, maxBubble, medianRadius,
|
|
16485
|
-
const scale = (
|
|
16487
|
+
function computeBubbleRadius(sizeVal, maxBubble, medianRadius, options2) {
|
|
16488
|
+
const scale = (options2?.bubbleScale ?? 100) / 100;
|
|
16486
16489
|
if (sizeVal === void 0) return medianRadius * scale;
|
|
16487
16490
|
const denom = maxBubble > 0 ? maxBubble : 1;
|
|
16488
16491
|
const magnitude = Math.abs(sizeVal);
|
|
16489
|
-
const ratio = (
|
|
16492
|
+
const ratio = (options2?.sizeRepresents ?? "w") === "area" ? Math.sqrt(magnitude) / Math.sqrt(denom) : magnitude / denom;
|
|
16490
16493
|
return medianRadius * scale * 0.5 + ratio * medianRadius * scale * 1.5;
|
|
16491
16494
|
}
|
|
16492
16495
|
function maxBubbleSize(sizes) {
|
|
@@ -16814,14 +16817,14 @@ function scottBinCount(values, min, max) {
|
|
|
16814
16817
|
const width = 3.49 * sd * values.length ** (-1 / 3);
|
|
16815
16818
|
return Math.max(1, Math.ceil((max - min) / width));
|
|
16816
16819
|
}
|
|
16817
|
-
function computeHistogramBins(values,
|
|
16818
|
-
const closed =
|
|
16820
|
+
function computeHistogramBins(values, options2, format = String) {
|
|
16821
|
+
const closed = options2.intervalClosed ?? "l";
|
|
16819
16822
|
const finite2 = values.map((value, sourceIndex) => ({ value, sourceIndex })).filter((item) => Number.isFinite(item.value));
|
|
16820
16823
|
if (finite2.length === 0) {
|
|
16821
16824
|
return [];
|
|
16822
16825
|
}
|
|
16823
|
-
const underflow = typeof
|
|
16824
|
-
const overflow = typeof
|
|
16826
|
+
const underflow = typeof options2.underflow === "number" ? options2.underflow : void 0;
|
|
16827
|
+
const overflow = typeof options2.overflow === "number" ? options2.overflow : void 0;
|
|
16825
16828
|
const under = underflow === void 0 ? [] : finite2.filter(
|
|
16826
16829
|
(item) => closed === "r" ? item.value <= underflow : item.value < underflow
|
|
16827
16830
|
);
|
|
@@ -16838,8 +16841,8 @@ function computeHistogramBins(values, options, format = String) {
|
|
|
16838
16841
|
if (regular.length > 0) {
|
|
16839
16842
|
const min = Math.min(...regular.map((item) => item.value));
|
|
16840
16843
|
const max = Math.max(...regular.map((item) => item.value));
|
|
16841
|
-
const requestedSize =
|
|
16842
|
-
const requestedCount =
|
|
16844
|
+
const requestedSize = options2.binSize && options2.binSize > 0 ? options2.binSize : void 0;
|
|
16845
|
+
const requestedCount = options2.binCount && options2.binCount > 0 ? options2.binCount : void 0;
|
|
16843
16846
|
const start = requestedSize ? Math.floor(min / requestedSize) * requestedSize : min;
|
|
16844
16847
|
const count = requestedSize ? Math.max(
|
|
16845
16848
|
closed === "l" ? Math.floor((max - start) / requestedSize) + 1 : Math.ceil((max - start) / requestedSize),
|
|
@@ -16890,9 +16893,9 @@ function aggregateByCategory(values, rawCategories) {
|
|
|
16890
16893
|
}
|
|
16891
16894
|
|
|
16892
16895
|
// chart/waterfall.ts
|
|
16893
|
-
function buildWaterfallSteps(values,
|
|
16896
|
+
function buildWaterfallSteps(values, options2) {
|
|
16894
16897
|
const subtotalIndices = new Set(
|
|
16895
|
-
|
|
16898
|
+
options2?.subtotalIndices ?? (values.length > 0 ? [values.length - 1] : [])
|
|
16896
16899
|
);
|
|
16897
16900
|
const steps = [];
|
|
16898
16901
|
let runningTotal = 0;
|
|
@@ -16952,13 +16955,13 @@ var noFit = () => ({
|
|
|
16952
16955
|
rSquared: 0,
|
|
16953
16956
|
coefficients: []
|
|
16954
16957
|
});
|
|
16955
|
-
function fitModel(
|
|
16958
|
+
function fitModel(options2, xVals, yVals) {
|
|
16956
16959
|
const xs = [...xVals];
|
|
16957
16960
|
const ys = [...yVals];
|
|
16958
|
-
switch (
|
|
16961
|
+
switch (options2.kind) {
|
|
16959
16962
|
case "linear": {
|
|
16960
16963
|
const reg = computeLinearRegression(xs, ys);
|
|
16961
|
-
const fixed =
|
|
16964
|
+
const fixed = options2.intercept;
|
|
16962
16965
|
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;
|
|
16963
16966
|
const b = fixed ?? reg.intercept;
|
|
16964
16967
|
return {
|
|
@@ -17008,7 +17011,7 @@ function fitModel(options, xVals, yVals) {
|
|
|
17008
17011
|
};
|
|
17009
17012
|
}
|
|
17010
17013
|
case "polynomial": {
|
|
17011
|
-
const order = Math.min(
|
|
17014
|
+
const order = Math.min(options2.order ?? 2, 6);
|
|
17012
17015
|
const coeffs = fitPolynomial(xs, ys, order);
|
|
17013
17016
|
const evaluate = (x) => coeffs.reduce((s, c2, i) => s + c2 * x ** i, 0);
|
|
17014
17017
|
return {
|
|
@@ -17022,11 +17025,11 @@ function fitModel(options, xVals, yVals) {
|
|
|
17022
17025
|
return void 0;
|
|
17023
17026
|
}
|
|
17024
17027
|
}
|
|
17025
|
-
function fitChartTrendline(
|
|
17028
|
+
function fitChartTrendline(options2, xVals, yVals) {
|
|
17026
17029
|
const count = yVals.length;
|
|
17027
17030
|
if (count < 2) return noFit();
|
|
17028
|
-
if (
|
|
17029
|
-
const period =
|
|
17031
|
+
if (options2.kind === "movingAvg") {
|
|
17032
|
+
const period = options2.period ?? 2;
|
|
17030
17033
|
const points2 = [];
|
|
17031
17034
|
for (let i = period - 1; i < count; i++) {
|
|
17032
17035
|
let sum = 0;
|
|
@@ -17035,10 +17038,10 @@ function fitChartTrendline(options, xVals, yVals) {
|
|
|
17035
17038
|
}
|
|
17036
17039
|
return { points: points2, equation: `${period}-period moving average`, rSquared: 0, coefficients: [] };
|
|
17037
17040
|
}
|
|
17038
|
-
const model = fitModel(
|
|
17041
|
+
const model = fitModel(options2, xVals, yVals);
|
|
17039
17042
|
if (!model) return noFit();
|
|
17040
|
-
const startX = Math.min(...xVals) - (
|
|
17041
|
-
const endX = Math.max(...xVals) + (
|
|
17043
|
+
const startX = Math.min(...xVals) - (options2.backward ?? 0);
|
|
17044
|
+
const endX = Math.max(...xVals) + (options2.forward ?? 0);
|
|
17042
17045
|
const steps = Math.max(Math.ceil((endX - startX) * 4), 20);
|
|
17043
17046
|
const points = [];
|
|
17044
17047
|
for (let step = 0; step <= steps; step++) {
|
|
@@ -17061,18 +17064,18 @@ function chartSampleVariance(values) {
|
|
|
17061
17064
|
const mean = values.reduce((sum, value) => sum + value, 0) / count;
|
|
17062
17065
|
return values.reduce((sum, value) => sum + (value - mean) ** 2, 0) / Math.max(count - 1, 1);
|
|
17063
17066
|
}
|
|
17064
|
-
function chartErrorBarAmount(
|
|
17065
|
-
switch (
|
|
17067
|
+
function chartErrorBarAmount(options2, values, displayIndex, sourceIndex, side) {
|
|
17068
|
+
switch (options2.valueType) {
|
|
17066
17069
|
case "fixedVal":
|
|
17067
|
-
return
|
|
17070
|
+
return options2.value ?? 0;
|
|
17068
17071
|
case "percentage":
|
|
17069
|
-
return Math.abs(values[displayIndex] ?? 0) * ((
|
|
17072
|
+
return Math.abs(values[displayIndex] ?? 0) * ((options2.value ?? 0) / 100);
|
|
17070
17073
|
case "stdDev":
|
|
17071
|
-
return Math.sqrt(chartSampleVariance(values)) * (
|
|
17074
|
+
return Math.sqrt(chartSampleVariance(values)) * (options2.value ?? 1);
|
|
17072
17075
|
case "stdErr":
|
|
17073
17076
|
return Math.sqrt(chartSampleVariance(values) / Math.max(values.length, 1));
|
|
17074
17077
|
case "cust":
|
|
17075
|
-
return side === "plus" ?
|
|
17078
|
+
return side === "plus" ? options2.customPlus?.[sourceIndex] ?? 0 : options2.customMinus?.[sourceIndex] ?? 0;
|
|
17076
17079
|
}
|
|
17077
17080
|
}
|
|
17078
17081
|
|
|
@@ -18571,6 +18574,191 @@ function drawingLineXml(line3) {
|
|
|
18571
18574
|
return buildXml(doc);
|
|
18572
18575
|
}
|
|
18573
18576
|
|
|
18577
|
+
// chart/marker-shape.ts
|
|
18578
|
+
var CHART_PX_PER_PT = 4 / 3;
|
|
18579
|
+
var DEFAULT_MARKER_OUTLINE_PT = 0.75;
|
|
18580
|
+
var AUTOMATIC_MARKER_CYCLE = [
|
|
18581
|
+
"diamond",
|
|
18582
|
+
"square",
|
|
18583
|
+
"triangle",
|
|
18584
|
+
"x",
|
|
18585
|
+
"star",
|
|
18586
|
+
"circle",
|
|
18587
|
+
"plus",
|
|
18588
|
+
"dot",
|
|
18589
|
+
"dash"
|
|
18590
|
+
];
|
|
18591
|
+
function automaticMarkerSymbol(seriesIdx) {
|
|
18592
|
+
const length = AUTOMATIC_MARKER_CYCLE.length;
|
|
18593
|
+
const normalized = (Math.trunc(seriesIdx) % length + length) % length;
|
|
18594
|
+
return AUTOMATIC_MARKER_CYCLE[Number.isFinite(normalized) ? normalized : 0];
|
|
18595
|
+
}
|
|
18596
|
+
function markerRadius(size, defaultRadius) {
|
|
18597
|
+
if (size === void 0 || !Number.isFinite(size) || size <= 0) {
|
|
18598
|
+
return defaultRadius;
|
|
18599
|
+
}
|
|
18600
|
+
return size / 2;
|
|
18601
|
+
}
|
|
18602
|
+
function polygonPoints(vertices) {
|
|
18603
|
+
return vertices.map(([x, y]) => `${x.toFixed(2)},${y.toFixed(2)}`).join(" ");
|
|
18604
|
+
}
|
|
18605
|
+
function starVertices(cx2, cy, r) {
|
|
18606
|
+
const inner = r * 0.5;
|
|
18607
|
+
const out = [];
|
|
18608
|
+
for (let i = 0; i < 10; i++) {
|
|
18609
|
+
const radius = i % 2 === 0 ? r : inner;
|
|
18610
|
+
const angle = -Math.PI / 2 + Math.PI * i / 5;
|
|
18611
|
+
out.push([cx2 + radius * Math.cos(angle), cy + radius * Math.sin(angle)]);
|
|
18612
|
+
}
|
|
18613
|
+
return out;
|
|
18614
|
+
}
|
|
18615
|
+
function rectPolygon(x, y, w, h) {
|
|
18616
|
+
return polygonPoints([
|
|
18617
|
+
[x, y],
|
|
18618
|
+
[x + w, y],
|
|
18619
|
+
[x + w, y + h],
|
|
18620
|
+
[x, y + h]
|
|
18621
|
+
]);
|
|
18622
|
+
}
|
|
18623
|
+
function buildMarkerPrimitive(input) {
|
|
18624
|
+
const { symbol, cx: cx2, cy, fill } = input;
|
|
18625
|
+
const part = input.part === void 0 ? {} : { part: input.part };
|
|
18626
|
+
if (symbol === "none") {
|
|
18627
|
+
return null;
|
|
18628
|
+
}
|
|
18629
|
+
const r = markerRadius(input.size, input.defaultRadius);
|
|
18630
|
+
const outline2 = input.stroke ? {
|
|
18631
|
+
stroke: input.stroke,
|
|
18632
|
+
strokeWidth: input.strokeWidth ?? DEFAULT_MARKER_OUTLINE_PT * CHART_PX_PER_PT
|
|
18633
|
+
} : void 0;
|
|
18634
|
+
const polygonStroke = outline2 ?? { stroke: fill, strokeWidth: 0 };
|
|
18635
|
+
const lineStroke = input.stroke ?? fill;
|
|
18636
|
+
switch (symbol) {
|
|
18637
|
+
case "square":
|
|
18638
|
+
case "dash": {
|
|
18639
|
+
const h = symbol === "dash" ? r * 0.64 : r * 2;
|
|
18640
|
+
const y = cy - h / 2;
|
|
18641
|
+
if (outline2) {
|
|
18642
|
+
return {
|
|
18643
|
+
kind: "polygon",
|
|
18644
|
+
points: rectPolygon(cx2 - r, y, r * 2, h),
|
|
18645
|
+
fill,
|
|
18646
|
+
...outline2,
|
|
18647
|
+
...part
|
|
18648
|
+
};
|
|
18649
|
+
}
|
|
18650
|
+
return { kind: "rect", x: cx2 - r, y, w: r * 2, h, fill, ...part };
|
|
18651
|
+
}
|
|
18652
|
+
case "diamond":
|
|
18653
|
+
return {
|
|
18654
|
+
kind: "polygon",
|
|
18655
|
+
points: polygonPoints([
|
|
18656
|
+
[cx2, cy - r],
|
|
18657
|
+
[cx2 + r, cy],
|
|
18658
|
+
[cx2, cy + r],
|
|
18659
|
+
[cx2 - r, cy]
|
|
18660
|
+
]),
|
|
18661
|
+
fill,
|
|
18662
|
+
...polygonStroke,
|
|
18663
|
+
...part
|
|
18664
|
+
};
|
|
18665
|
+
case "triangle":
|
|
18666
|
+
return {
|
|
18667
|
+
kind: "polygon",
|
|
18668
|
+
points: polygonPoints([
|
|
18669
|
+
[cx2, cy - r],
|
|
18670
|
+
[cx2 + r * 0.9, cy + r * 0.75],
|
|
18671
|
+
[cx2 - r * 0.9, cy + r * 0.75]
|
|
18672
|
+
]),
|
|
18673
|
+
fill,
|
|
18674
|
+
...polygonStroke,
|
|
18675
|
+
...part
|
|
18676
|
+
};
|
|
18677
|
+
case "star":
|
|
18678
|
+
return {
|
|
18679
|
+
kind: "polygon",
|
|
18680
|
+
points: polygonPoints(starVertices(cx2, cy, r)),
|
|
18681
|
+
fill,
|
|
18682
|
+
...polygonStroke,
|
|
18683
|
+
...part
|
|
18684
|
+
};
|
|
18685
|
+
case "plus":
|
|
18686
|
+
return {
|
|
18687
|
+
kind: "path",
|
|
18688
|
+
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)}`,
|
|
18689
|
+
fill: "none",
|
|
18690
|
+
stroke: lineStroke,
|
|
18691
|
+
strokeWidth: Math.max(1, r * 0.4),
|
|
18692
|
+
...part
|
|
18693
|
+
};
|
|
18694
|
+
case "x":
|
|
18695
|
+
return {
|
|
18696
|
+
kind: "path",
|
|
18697
|
+
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)}`,
|
|
18698
|
+
fill: "none",
|
|
18699
|
+
stroke: lineStroke,
|
|
18700
|
+
strokeWidth: Math.max(1, r * 0.4),
|
|
18701
|
+
...part
|
|
18702
|
+
};
|
|
18703
|
+
case "dot":
|
|
18704
|
+
return { kind: "circle", cx: cx2, cy, r: Math.max(r * 0.6, 1), fill, ...part, ...outline2 };
|
|
18705
|
+
default:
|
|
18706
|
+
return { kind: "circle", cx: cx2, cy, r, fill, ...part, ...outline2 };
|
|
18707
|
+
}
|
|
18708
|
+
}
|
|
18709
|
+
|
|
18710
|
+
// chart/render/chart-view-markers.ts
|
|
18711
|
+
function summaryMarkers(source, group2, seriesPosition) {
|
|
18712
|
+
if (!["line", "scatter", "radar"].includes(group2.kind)) return {};
|
|
18713
|
+
const enabled2 = group2.kind === "line" ? group2.marker === true : group2.kind === "radar" ? group2.radarStyle === "marker" : !["line", "smooth", "none"].includes(group2.scatterStyle ?? "marker");
|
|
18714
|
+
const symbol = source.marker?.symbol;
|
|
18715
|
+
const marker = {
|
|
18716
|
+
...source.marker,
|
|
18717
|
+
symbol: symbol && symbol !== "auto" ? symbol : source.marker || enabled2 ? automaticMarkerSymbol(source.index ?? seriesPosition) : "none"
|
|
18718
|
+
};
|
|
18719
|
+
const pointMarkers = {};
|
|
18720
|
+
for (const point of source.dataPoints) {
|
|
18721
|
+
if (point.index === void 0 || !point.marker) continue;
|
|
18722
|
+
const override = point.marker;
|
|
18723
|
+
pointMarkers[point.index] = {
|
|
18724
|
+
...marker,
|
|
18725
|
+
...override,
|
|
18726
|
+
...override.symbol === "auto" || !source.marker && override.symbol === void 0 ? { symbol: automaticMarkerSymbol(source.index ?? seriesPosition) } : {},
|
|
18727
|
+
...marker.spPr || override.spPr ? {
|
|
18728
|
+
spPr: {
|
|
18729
|
+
...marker.spPr,
|
|
18730
|
+
...override.spPr,
|
|
18731
|
+
...marker.spPr?.line || override.spPr?.line ? { line: { ...marker.spPr?.line, ...override.spPr?.line } } : {}
|
|
18732
|
+
}
|
|
18733
|
+
} : {}
|
|
18734
|
+
};
|
|
18735
|
+
}
|
|
18736
|
+
return { marker, ...Object.keys(pointMarkers).length ? { pointMarkers } : {} };
|
|
18737
|
+
}
|
|
18738
|
+
function seriesMarkerViews(source, drawingColor) {
|
|
18739
|
+
const fillColor = (fill) => fill?.kind === "none" ? "none" : fill?.kind === "solid" ? drawingColor(fill.color) : void 0;
|
|
18740
|
+
const resolve = (marker) => {
|
|
18741
|
+
const fill = fillColor(marker.spPr?.fill);
|
|
18742
|
+
const stroke = fillColor(marker.spPr?.line?.fill);
|
|
18743
|
+
const width = marker.spPr?.line?.widthEmu;
|
|
18744
|
+
return {
|
|
18745
|
+
...marker.symbol !== void 0 ? { symbol: marker.symbol } : {},
|
|
18746
|
+
...marker.size !== void 0 ? { size: marker.size } : {},
|
|
18747
|
+
...fill !== void 0 ? { fill } : {},
|
|
18748
|
+
...stroke !== void 0 ? { stroke } : {},
|
|
18749
|
+
...width !== void 0 ? { strokeWidth: width / 9525 } : {}
|
|
18750
|
+
};
|
|
18751
|
+
};
|
|
18752
|
+
return {
|
|
18753
|
+
...source.marker ? { marker: resolve(source.marker) } : {},
|
|
18754
|
+
...source.pointMarkers ? {
|
|
18755
|
+
pointMarkers: Object.fromEntries(
|
|
18756
|
+
Object.entries(source.pointMarkers).map(([i, marker]) => [i, resolve(marker)])
|
|
18757
|
+
)
|
|
18758
|
+
} : {}
|
|
18759
|
+
};
|
|
18760
|
+
}
|
|
18761
|
+
|
|
18574
18762
|
// chart/render/summary-analysis.ts
|
|
18575
18763
|
function summaryTrendline(source) {
|
|
18576
18764
|
const kind = chartTrendlineKind(source.trendlineType);
|
|
@@ -18612,17 +18800,17 @@ function summaryAnalysis(series) {
|
|
|
18612
18800
|
}
|
|
18613
18801
|
|
|
18614
18802
|
// chart/render/summary-labels.ts
|
|
18615
|
-
function level(
|
|
18803
|
+
function level(options2, custom) {
|
|
18616
18804
|
const out = {};
|
|
18617
|
-
if (
|
|
18618
|
-
if (
|
|
18619
|
-
if (
|
|
18620
|
-
if (
|
|
18621
|
-
if (
|
|
18622
|
-
if (
|
|
18623
|
-
if (
|
|
18624
|
-
if (
|
|
18625
|
-
if (
|
|
18805
|
+
if (options2.deleted !== void 0) out.deleted = options2.deleted;
|
|
18806
|
+
if (options2.showValue !== void 0) out.showValue = options2.showValue;
|
|
18807
|
+
if (options2.showCategoryName !== void 0) out.showCategory = options2.showCategoryName;
|
|
18808
|
+
if (options2.showSeriesName !== void 0) out.showSeriesName = options2.showSeriesName;
|
|
18809
|
+
if (options2.showPercent !== void 0) out.showPercent = options2.showPercent;
|
|
18810
|
+
if (options2.showBubbleSize !== void 0) out.showBubbleSize = options2.showBubbleSize;
|
|
18811
|
+
if (options2.separator !== void 0) out.separator = options2.separator;
|
|
18812
|
+
if (options2.position) out.position = options2.position;
|
|
18813
|
+
if (options2.numberFormat?.formatCode) out.numberFormat = options2.numberFormat.formatCode;
|
|
18626
18814
|
if (custom?.text !== void 0) out.text = custom.text;
|
|
18627
18815
|
return out;
|
|
18628
18816
|
}
|
|
@@ -18729,7 +18917,10 @@ function extraGroups(chartSpace, firstType) {
|
|
|
18729
18917
|
const type = group2.kind === "bar" ? "column" : group2.kind;
|
|
18730
18918
|
const entry2 = {
|
|
18731
18919
|
chartType: type,
|
|
18732
|
-
series: group2.series.map((source) =>
|
|
18920
|
+
series: group2.series.map((source, index) => ({
|
|
18921
|
+
...chartSummarySeries(source, type, group2.dataLabels),
|
|
18922
|
+
...summaryMarkers(source, group2, index)
|
|
18923
|
+
})),
|
|
18733
18924
|
secondary: valueAxisId(chartSpace, group2.axisIds) !== primary
|
|
18734
18925
|
};
|
|
18735
18926
|
if (group2.grouping && GROUPINGS.has(group2.grouping))
|
|
@@ -18747,13 +18938,16 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
|
|
|
18747
18938
|
const group2 = chartSpace.plotArea.groups[0];
|
|
18748
18939
|
let chartType = group2 ? GROUP_TYPES[group2.kind] : "column";
|
|
18749
18940
|
if (chartType === "bar" && group2?.barDirection !== "bar") chartType = "column";
|
|
18750
|
-
const series = (group2?.series ?? []).map(
|
|
18751
|
-
|
|
18752
|
-
|
|
18941
|
+
const series = (group2?.series ?? []).map((source, index) => ({
|
|
18942
|
+
...chartSummarySeries(source, chartType, group2?.dataLabels),
|
|
18943
|
+
...group2 ? summaryMarkers(source, group2, index) : {}
|
|
18944
|
+
}));
|
|
18753
18945
|
const summary = {
|
|
18754
18946
|
chartType,
|
|
18755
18947
|
series,
|
|
18756
|
-
showLegend: chartSpace.legend !== void 0
|
|
18948
|
+
showLegend: chartSpace.legend !== void 0,
|
|
18949
|
+
axes: chartSpace.plotArea.axes,
|
|
18950
|
+
axisIds: group2?.axisIds ?? []
|
|
18757
18951
|
};
|
|
18758
18952
|
const combined = extraGroups(chartSpace, chartType);
|
|
18759
18953
|
if (combined.length) summary.extraGroups = combined;
|
|
@@ -19214,7 +19408,7 @@ function chartTextAttributes(model, part, fallbackSize = FONT_SIZE) {
|
|
|
19214
19408
|
function chartStroke(model, part) {
|
|
19215
19409
|
const entry2 = model.appearance?.[part];
|
|
19216
19410
|
return {
|
|
19217
|
-
color: entry2?.axisVisible === false ? "none" : entry2?.lineColor ?? (part
|
|
19411
|
+
color: entry2?.axisVisible === false ? "none" : entry2?.lineColor ?? (part.startsWith("gridline") ? GRID_COLOR : AXIS_COLOR),
|
|
19218
19412
|
width: entry2?.lineWidth === void 0 ? 1 : chartPointsToPixels(entry2.lineWidth)
|
|
19219
19413
|
};
|
|
19220
19414
|
}
|
|
@@ -19505,6 +19699,60 @@ function scatterAnalysis(model, px3, py, out) {
|
|
|
19505
19699
|
});
|
|
19506
19700
|
}
|
|
19507
19701
|
|
|
19702
|
+
// chart/render/chart-svg-markers.ts
|
|
19703
|
+
function chartMarkerRadius(series, index, defaultRadius = 3) {
|
|
19704
|
+
const marker = { ...series.marker, ...series.pointMarkers?.[index] };
|
|
19705
|
+
if (marker.symbol === "none") return 0;
|
|
19706
|
+
const radius = markerRadius(marker.size, defaultRadius);
|
|
19707
|
+
return marker.symbol === "dot" ? Math.max(radius * 0.6, 1) : radius;
|
|
19708
|
+
}
|
|
19709
|
+
function chartSeriesMarkerSvg(series, index, cx2, cy, defaultRadius = 3) {
|
|
19710
|
+
const marker = { ...series.marker, ...series.pointMarkers?.[index] };
|
|
19711
|
+
const primitive = buildMarkerPrimitive({
|
|
19712
|
+
...marker,
|
|
19713
|
+
symbol: marker.symbol,
|
|
19714
|
+
size: marker.size,
|
|
19715
|
+
cx: cx2,
|
|
19716
|
+
cy,
|
|
19717
|
+
fill: marker.fill ?? series.pointColors?.[index] ?? series.color,
|
|
19718
|
+
defaultRadius
|
|
19719
|
+
});
|
|
19720
|
+
if (!primitive) return "";
|
|
19721
|
+
let geometry2;
|
|
19722
|
+
switch (primitive.kind) {
|
|
19723
|
+
case "circle":
|
|
19724
|
+
geometry2 = `cx="${n(primitive.cx)}" cy="${n(primitive.cy)}" r="${n(primitive.r)}"`;
|
|
19725
|
+
break;
|
|
19726
|
+
case "rect":
|
|
19727
|
+
geometry2 = `x="${n(primitive.x)}" y="${n(primitive.y)}" width="${n(primitive.w)}" height="${n(primitive.h)}"`;
|
|
19728
|
+
break;
|
|
19729
|
+
case "path":
|
|
19730
|
+
geometry2 = `d="${esc(primitive.d)}"`;
|
|
19731
|
+
break;
|
|
19732
|
+
case "polygon":
|
|
19733
|
+
geometry2 = `points="${esc(primitive.points)}"`;
|
|
19734
|
+
break;
|
|
19735
|
+
}
|
|
19736
|
+
const outline2 = primitive.stroke ? ` stroke="${esc(primitive.stroke)}" stroke-width="${n(primitive.strokeWidth ?? 1)}"` : "";
|
|
19737
|
+
const filter = series.shadowFilter ? ` filter="${esc(series.shadowFilter)}"` : "";
|
|
19738
|
+
return `<${primitive.kind} ${geometry2} fill="${esc(primitive.fill)}"${outline2}${filter}/>`;
|
|
19739
|
+
}
|
|
19740
|
+
|
|
19741
|
+
// chart/line-dash.ts
|
|
19742
|
+
function chartLineDashArray(style, width) {
|
|
19743
|
+
if (!style || style === "solid") {
|
|
19744
|
+
return void 0;
|
|
19745
|
+
}
|
|
19746
|
+
const unit = Math.max(width, 1);
|
|
19747
|
+
if (style === "dot" || style === "sysDot") {
|
|
19748
|
+
return `${unit} ${unit * 2}`;
|
|
19749
|
+
}
|
|
19750
|
+
if (style === "lgDash") {
|
|
19751
|
+
return `${unit * 6} ${unit * 3}`;
|
|
19752
|
+
}
|
|
19753
|
+
return `${unit * 3} ${unit * 2}`;
|
|
19754
|
+
}
|
|
19755
|
+
|
|
19508
19756
|
// chart/render/chart-scale.ts
|
|
19509
19757
|
var clean = (n2) => Number(n2.toPrecision(12));
|
|
19510
19758
|
function* units(raw) {
|
|
@@ -19515,14 +19763,14 @@ function* units(raw) {
|
|
|
19515
19763
|
exp++;
|
|
19516
19764
|
}
|
|
19517
19765
|
}
|
|
19518
|
-
function niceScale(dataMin, dataMax,
|
|
19519
|
-
const maxIntervals = Math.max(1,
|
|
19766
|
+
function niceScale(dataMin, dataMax, options2 = {}) {
|
|
19767
|
+
const maxIntervals = Math.max(1, options2.maxIntervals ?? 10);
|
|
19520
19768
|
let lo = Number.isFinite(dataMin) ? dataMin : 0;
|
|
19521
19769
|
let hi = Number.isFinite(dataMax) ? dataMax : 0;
|
|
19522
19770
|
if (lo > hi) [lo, hi] = [hi, lo];
|
|
19523
19771
|
if (lo === hi) {
|
|
19524
19772
|
if (lo === 0) hi = 1;
|
|
19525
|
-
else if (
|
|
19773
|
+
else if (options2.noZero) {
|
|
19526
19774
|
const pad = Math.abs(lo) * 0.1 || 1;
|
|
19527
19775
|
lo -= pad;
|
|
19528
19776
|
hi += pad;
|
|
@@ -19531,7 +19779,7 @@ function niceScale(dataMin, dataMax, options = {}) {
|
|
|
19531
19779
|
}
|
|
19532
19780
|
let fixedLo = false;
|
|
19533
19781
|
let fixedHi = false;
|
|
19534
|
-
if (!
|
|
19782
|
+
if (!options2.noZero) {
|
|
19535
19783
|
if (lo >= 0 && hi - lo >= hi / 6) {
|
|
19536
19784
|
lo = 0;
|
|
19537
19785
|
fixedLo = true;
|
|
@@ -19571,6 +19819,233 @@ function formatAxisValue(value, percent = false) {
|
|
|
19571
19819
|
return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
|
|
19572
19820
|
}
|
|
19573
19821
|
|
|
19822
|
+
// chart/render/chart-svg-axes.ts
|
|
19823
|
+
function axisTickText(value, axis, percent = false) {
|
|
19824
|
+
return formatChartNumber(value, axis?.source.numberFormat?.formatCode) ?? formatAxisValue(value, percent);
|
|
19825
|
+
}
|
|
19826
|
+
function axisLine(model, axis, part, x1, y1, x2, y2) {
|
|
19827
|
+
if (axis?.source.deleted) return "";
|
|
19828
|
+
return styledAxisLine(x1, y1, x2, y2, axis?.line, chartStroke(model, part));
|
|
19829
|
+
}
|
|
19830
|
+
function styledAxisLine(x1, y1, x2, y2, paint2, fallback) {
|
|
19831
|
+
const color = paint2?.color ?? fallback.color;
|
|
19832
|
+
const width = paint2?.width ?? fallback.width;
|
|
19833
|
+
if (color === "none" || width === 0) return "";
|
|
19834
|
+
const dash = chartLineDashArray(paint2?.dash, width);
|
|
19835
|
+
return line2(x1, y1, x2, y2, esc(color), width).replace(
|
|
19836
|
+
"/>",
|
|
19837
|
+
dash ? ` stroke-dasharray="${dash}"/>` : "/>"
|
|
19838
|
+
);
|
|
19839
|
+
}
|
|
19840
|
+
function axisGridlines(model, axis, ticks, position2, plot, vertical) {
|
|
19841
|
+
const draw2 = (values, paint2, minor2) => {
|
|
19842
|
+
const fallback = chartStroke(model, minor2 ? "gridlineMinor" : "gridlineMajor");
|
|
19843
|
+
return values.map((value) => {
|
|
19844
|
+
const p = position2(value);
|
|
19845
|
+
return vertical ? styledAxisLine(p, plot.y, p, plot.y + plot.h, paint2, fallback) : styledAxisLine(plot.x, p, plot.x + plot.w, p, paint2, fallback);
|
|
19846
|
+
}).join("");
|
|
19847
|
+
};
|
|
19848
|
+
const major = !axis || axis.source.majorGridlines ? draw2(ticks, axis?.majorGrid, false) : "";
|
|
19849
|
+
const minor = axis?.source.minorGridlines ? draw2(axis.minorTicks, axis.minorGrid, true) : "";
|
|
19850
|
+
return major + minor;
|
|
19851
|
+
}
|
|
19852
|
+
|
|
19853
|
+
// chart/axis-range.ts
|
|
19854
|
+
function computeLogValueRange(series, logBase) {
|
|
19855
|
+
const allValues = series.flatMap((item) => item.values).filter((value) => value !== null && Number.isFinite(value) && value > 0);
|
|
19856
|
+
if (allValues.length === 0) {
|
|
19857
|
+
return { min: 1, max: logBase, span: 1, logScale: true, logBase };
|
|
19858
|
+
}
|
|
19859
|
+
const dataMin = Math.min(...allValues);
|
|
19860
|
+
const dataMax = Math.max(...allValues);
|
|
19861
|
+
const logMin = Math.floor(Math.log(dataMin) / Math.log(logBase));
|
|
19862
|
+
const logMax = Math.ceil(Math.log(dataMax) / Math.log(logBase));
|
|
19863
|
+
const min = logBase ** logMin;
|
|
19864
|
+
const max = logBase ** Math.max(logMax, logMin + 1);
|
|
19865
|
+
return {
|
|
19866
|
+
min,
|
|
19867
|
+
max,
|
|
19868
|
+
span: Math.max(Math.log(max) / Math.log(logBase) - Math.log(min) / Math.log(logBase), 1),
|
|
19869
|
+
logScale: true,
|
|
19870
|
+
logBase
|
|
19871
|
+
};
|
|
19872
|
+
}
|
|
19873
|
+
function withAxisBounds(automatic, axis, logBase) {
|
|
19874
|
+
const validMin = typeof axis?.min === "number" && Number.isFinite(axis.min) && (!logBase || axis.min > 0) ? axis.min : void 0;
|
|
19875
|
+
const validMax = typeof axis?.max === "number" && Number.isFinite(axis.max) && (!logBase || axis.max > 0) ? axis.max : void 0;
|
|
19876
|
+
const min = validMin ?? automatic.min;
|
|
19877
|
+
let max = validMax ?? automatic.max;
|
|
19878
|
+
const majorUnit = validMin === void 0 && validMax === void 0 ? automatic.majorUnit : void 0;
|
|
19879
|
+
if (max <= min) {
|
|
19880
|
+
max = logBase ? min * logBase : min + 1;
|
|
19881
|
+
}
|
|
19882
|
+
const span = logBase ? Math.log(max) / Math.log(logBase) - Math.log(min) / Math.log(logBase) : max - min;
|
|
19883
|
+
return {
|
|
19884
|
+
min,
|
|
19885
|
+
max,
|
|
19886
|
+
span: Math.max(span, Number.EPSILON),
|
|
19887
|
+
...majorUnit !== void 0 ? { majorUnit } : {},
|
|
19888
|
+
...logBase ? { logScale: true, logBase } : {},
|
|
19889
|
+
...axis?.orientation === "maxMin" ? { reverseOrder: true } : {}
|
|
19890
|
+
};
|
|
19891
|
+
}
|
|
19892
|
+
|
|
19893
|
+
// chart/axis-ticks.ts
|
|
19894
|
+
var LOG_EXPONENT_TOLERANCE = 1e-12;
|
|
19895
|
+
function generateLogTicks(range) {
|
|
19896
|
+
if (!range.logScale || !range.logBase) {
|
|
19897
|
+
return [];
|
|
19898
|
+
}
|
|
19899
|
+
const base = range.logBase;
|
|
19900
|
+
const logMin = Math.log(range.min) / Math.log(base);
|
|
19901
|
+
const logMax = Math.log(range.max) / Math.log(base);
|
|
19902
|
+
const firstExponent = Math.ceil(logMin - LOG_EXPONENT_TOLERANCE);
|
|
19903
|
+
const lastExponent = Math.floor(logMax + LOG_EXPONENT_TOLERANCE);
|
|
19904
|
+
if (lastExponent < firstExponent) {
|
|
19905
|
+
return range.min === range.max ? [range.min] : [range.min, range.max];
|
|
19906
|
+
}
|
|
19907
|
+
return Array.from(
|
|
19908
|
+
{ length: lastExponent - firstExponent + 1 },
|
|
19909
|
+
(_unused, index) => base ** (firstExponent + index)
|
|
19910
|
+
);
|
|
19911
|
+
}
|
|
19912
|
+
function generateIntervalTicks(range, unit) {
|
|
19913
|
+
if (!Number.isFinite(unit) || unit <= 0 || range.logScale) {
|
|
19914
|
+
return [];
|
|
19915
|
+
}
|
|
19916
|
+
const tolerance = Math.max(1, Math.abs(range.min), Math.abs(range.max)) * 1e-12;
|
|
19917
|
+
const first3 = Math.ceil((range.min - tolerance) / unit);
|
|
19918
|
+
const last = Math.floor((range.max + tolerance) / unit);
|
|
19919
|
+
const count = Math.min(Math.max(last - first3 + 1, 0), 2e3);
|
|
19920
|
+
return Array.from({ length: count }, (_, index) => (first3 + index) * unit);
|
|
19921
|
+
}
|
|
19922
|
+
function generateAxisTicks(range, axis, defaultIntervals) {
|
|
19923
|
+
if (range.logScale && range.logBase) {
|
|
19924
|
+
return generateLogTicks(range);
|
|
19925
|
+
}
|
|
19926
|
+
const explicit = generateIntervalTicks(range, axis?.majorUnit ?? 0);
|
|
19927
|
+
if (explicit.length > 0) {
|
|
19928
|
+
return explicit;
|
|
19929
|
+
}
|
|
19930
|
+
const automatic = generateIntervalTicks(range, range.majorUnit ?? 0);
|
|
19931
|
+
if (automatic.length > 0) {
|
|
19932
|
+
return automatic;
|
|
19933
|
+
}
|
|
19934
|
+
return Array.from(
|
|
19935
|
+
{ length: defaultIntervals + 1 },
|
|
19936
|
+
(_, index) => range.min + range.span / defaultIntervals * index
|
|
19937
|
+
);
|
|
19938
|
+
}
|
|
19939
|
+
function generateMinorAxisTicks(range, axis) {
|
|
19940
|
+
const minor = generateIntervalTicks(range, axis?.minorUnit ?? 0);
|
|
19941
|
+
if (minor.length === 0) {
|
|
19942
|
+
return [];
|
|
19943
|
+
}
|
|
19944
|
+
const majorUnit = axis?.majorUnit;
|
|
19945
|
+
if (!majorUnit || !Number.isFinite(majorUnit) || majorUnit <= 0) {
|
|
19946
|
+
return minor;
|
|
19947
|
+
}
|
|
19948
|
+
const tolerance = Math.max(1, Math.abs(range.min), Math.abs(range.max)) * 1e-10;
|
|
19949
|
+
return minor.filter(
|
|
19950
|
+
(value) => Math.abs(value / majorUnit - Math.round(value / majorUnit)) > tolerance
|
|
19951
|
+
);
|
|
19952
|
+
}
|
|
19953
|
+
|
|
19954
|
+
// chart/render/chart-view-axes.ts
|
|
19955
|
+
function chartAxisRatio(value, scale, axis) {
|
|
19956
|
+
const range = axis?.range;
|
|
19957
|
+
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);
|
|
19958
|
+
return range?.reverseOrder ? 1 - ratio : ratio;
|
|
19959
|
+
}
|
|
19960
|
+
function chartAxisLabels(axis) {
|
|
19961
|
+
return axis?.source.deleted !== true && axis?.source.tickLabelPosition !== "none";
|
|
19962
|
+
}
|
|
19963
|
+
function options(axis) {
|
|
19964
|
+
return {
|
|
19965
|
+
...axis.scaling,
|
|
19966
|
+
...axis.scaling.logBase === void 0 ? {} : { logScale: true },
|
|
19967
|
+
...axis.majorUnit === void 0 ? {} : { majorUnit: axis.majorUnit },
|
|
19968
|
+
...axis.minorUnit === void 0 ? {} : { minorUnit: axis.minorUnit }
|
|
19969
|
+
};
|
|
19970
|
+
}
|
|
19971
|
+
function applyChartAxes(model, chart, color) {
|
|
19972
|
+
if (!chart.axes?.length) return;
|
|
19973
|
+
const axes = chart.axes;
|
|
19974
|
+
const linked = axes.filter((axis) => axis.id !== void 0 && chart.axisIds?.includes(axis.id));
|
|
19975
|
+
const candidates = linked.length ? linked : axes;
|
|
19976
|
+
const xy = model.type === "scatter" || model.type === "bubble";
|
|
19977
|
+
const value = candidates.find((axis) => axis.kind === "val" && !["b", "t"].includes(axis.position ?? "")) ?? candidates.find((axis) => axis.kind === "val");
|
|
19978
|
+
const category = candidates.find(
|
|
19979
|
+
(axis) => xy ? axis.kind === "val" && axis !== value : axis.kind === "cat" || axis.kind === "date"
|
|
19980
|
+
);
|
|
19981
|
+
const secondary = axes.find((axis) => axis.kind === "val" && axis !== value && axis !== category);
|
|
19982
|
+
const paint2 = (shape2) => {
|
|
19983
|
+
const ln = shape2?.line;
|
|
19984
|
+
const fill = ln?.fill;
|
|
19985
|
+
const resolved = fill?.kind === "none" ? "none" : color(fill?.kind === "solid" ? fill.color : void 0);
|
|
19986
|
+
return {
|
|
19987
|
+
...resolved === void 0 ? {} : { color: resolved },
|
|
19988
|
+
...ln?.widthEmu === void 0 ? {} : { width: ln.widthEmu / EMU_PER_PIXEL },
|
|
19989
|
+
...ln?.dash === void 0 ? {} : { dash: ln.dash }
|
|
19990
|
+
};
|
|
19991
|
+
};
|
|
19992
|
+
const bind = (axis, scale, values) => {
|
|
19993
|
+
const opts = options(axis);
|
|
19994
|
+
const automatic = opts.logScale ? computeLogValueRange(
|
|
19995
|
+
[{ values: values ?? [] }],
|
|
19996
|
+
opts.logBase && Number.isFinite(opts.logBase) && opts.logBase > 1 ? opts.logBase : 10
|
|
19997
|
+
) : {
|
|
19998
|
+
min: scale?.min ?? 0,
|
|
19999
|
+
max: scale?.max ?? 1,
|
|
20000
|
+
span: (scale?.max ?? 1) - (scale?.min ?? 0),
|
|
20001
|
+
...scale ? { majorUnit: scale.majorUnit } : {}
|
|
20002
|
+
};
|
|
20003
|
+
const logBase = automatic.logBase;
|
|
20004
|
+
const range = withAxisBounds(automatic, opts, logBase);
|
|
20005
|
+
if (scale) {
|
|
20006
|
+
scale.min = range.min;
|
|
20007
|
+
scale.max = range.max;
|
|
20008
|
+
scale.ticks = generateAxisTicks(range, opts, 5);
|
|
20009
|
+
}
|
|
20010
|
+
return {
|
|
20011
|
+
source: axis,
|
|
20012
|
+
range,
|
|
20013
|
+
minorTicks: generateMinorAxisTicks(range, opts),
|
|
20014
|
+
line: paint2(axis.spPr),
|
|
20015
|
+
majorGrid: paint2(axis.majorGridlinesSpPr),
|
|
20016
|
+
minorGrid: paint2(axis.minorGridlinesSpPr)
|
|
20017
|
+
};
|
|
20018
|
+
};
|
|
20019
|
+
const out = {};
|
|
20020
|
+
if (value)
|
|
20021
|
+
out.value = bind(
|
|
20022
|
+
value,
|
|
20023
|
+
model.valueAxis,
|
|
20024
|
+
[
|
|
20025
|
+
...model.series,
|
|
20026
|
+
...model.extraGroups?.filter((g) => !g.secondary).flatMap((g) => g.series) ?? []
|
|
20027
|
+
].flatMap((s) => s.values)
|
|
20028
|
+
);
|
|
20029
|
+
if (category)
|
|
20030
|
+
out.category = bind(
|
|
20031
|
+
category,
|
|
20032
|
+
model.xAxis ?? {
|
|
20033
|
+
min: 0,
|
|
20034
|
+
max: Math.max(1, model.categories.length - 1),
|
|
20035
|
+
majorUnit: 1,
|
|
20036
|
+
ticks: []
|
|
20037
|
+
},
|
|
20038
|
+
model.series.flatMap((s) => s.xValues ?? [])
|
|
20039
|
+
);
|
|
20040
|
+
if (secondary)
|
|
20041
|
+
out.secondary = bind(
|
|
20042
|
+
secondary,
|
|
20043
|
+
model.secondaryAxis,
|
|
20044
|
+
model.extraGroups?.filter((g) => g.secondary).flatMap((g) => g.series.flatMap((s) => s.values))
|
|
20045
|
+
);
|
|
20046
|
+
model.axes = out;
|
|
20047
|
+
}
|
|
20048
|
+
|
|
19574
20049
|
// chart/render/chart-view-analysis.ts
|
|
19575
20050
|
function strokeOf(line3, fallback, resolve) {
|
|
19576
20051
|
if (line3?.fill?.kind === "none") return void 0;
|
|
@@ -19620,15 +20095,15 @@ function seriesName(series, index, evaluateRef) {
|
|
|
19620
20095
|
const fromRef = resolveRef(series.nameRef, evaluateRef)?.map(toText).filter((t) => t !== "").join(" ");
|
|
19621
20096
|
return fromRef || series.name || `Series${index + 1}`;
|
|
19622
20097
|
}
|
|
19623
|
-
function seriesContext(chart, theme,
|
|
20098
|
+
function seriesContext(chart, theme, options2) {
|
|
19624
20099
|
const scheme = chartColorScheme(theme);
|
|
19625
20100
|
const resolver = { scheme: (name) => scheme[name] };
|
|
19626
20101
|
return {
|
|
19627
20102
|
theme,
|
|
19628
20103
|
scheme,
|
|
19629
20104
|
palette: chart.colorPalette === void 0 ? void 0 : findChartColorPalette(chart.colorPalette),
|
|
19630
|
-
evaluateRef:
|
|
19631
|
-
seriesColor:
|
|
20105
|
+
evaluateRef: options2.evaluateRef ?? (() => []),
|
|
20106
|
+
seriesColor: options2.seriesColor,
|
|
19632
20107
|
drawingColor: (color) => color && drawingColorCss(resolveDrawingColor(color, resolver, { transformOrder: "document" })),
|
|
19633
20108
|
gradient: (fill) => fill?.kind === "gradient" ? resolveChartGradient(
|
|
19634
20109
|
fill,
|
|
@@ -19654,7 +20129,11 @@ function seriesView(ctx, s, index, total, categoriesOf) {
|
|
|
19654
20129
|
})
|
|
19655
20130
|
);
|
|
19656
20131
|
if (Object.keys(points).length) view.pointGradients = points;
|
|
19657
|
-
Object.assign(
|
|
20132
|
+
Object.assign(
|
|
20133
|
+
view,
|
|
20134
|
+
analysisView(s, color, ctx.drawingColor),
|
|
20135
|
+
seriesMarkerViews(s, ctx.drawingColor)
|
|
20136
|
+
);
|
|
19658
20137
|
return view;
|
|
19659
20138
|
}
|
|
19660
20139
|
|
|
@@ -19954,11 +20433,11 @@ function histogramView(chart, model) {
|
|
|
19954
20433
|
const first3 = model.series[0];
|
|
19955
20434
|
if (!first3) return;
|
|
19956
20435
|
const raw = first3.values.map((v) => v ?? Number.NaN);
|
|
19957
|
-
const
|
|
19958
|
-
const bins =
|
|
20436
|
+
const options2 = chart.histogram ?? {};
|
|
20437
|
+
const bins = options2.aggregateByCategory ? aggregateByCategory(
|
|
19959
20438
|
first3.values.map((v) => v ?? 0),
|
|
19960
20439
|
model.categories
|
|
19961
|
-
) : computeHistogramBins(raw,
|
|
20440
|
+
) : computeHistogramBins(raw, options2, formatAxisValue);
|
|
19962
20441
|
model.categories = bins.map((bin) => bin.label);
|
|
19963
20442
|
first3.values = bins.map((bin) => bin.value);
|
|
19964
20443
|
model.barGapWidth = 0;
|
|
@@ -19982,11 +20461,11 @@ var SUPPORTED = /* @__PURE__ */ new Set([
|
|
|
19982
20461
|
"treemap",
|
|
19983
20462
|
"sunburst"
|
|
19984
20463
|
]);
|
|
19985
|
-
function chartSummaryView(chart, theme,
|
|
20464
|
+
function chartSummaryView(chart, theme, options2 = {}) {
|
|
19986
20465
|
const type = chart.chartType;
|
|
19987
20466
|
const radial = type === "pie" || type === "doughnut";
|
|
19988
20467
|
const byPoint = radial || type === "treemap" || type === "sunburst";
|
|
19989
|
-
const ctx = seriesContext(chart, theme,
|
|
20468
|
+
const ctx = seriesContext(chart, theme, options2);
|
|
19990
20469
|
const { palette, scheme, drawingColor } = ctx;
|
|
19991
20470
|
const grouping = chart.grouping ?? (type === "bar" || type === "column" ? "clustered" : "standard");
|
|
19992
20471
|
const rawCategories = [];
|
|
@@ -20072,6 +20551,7 @@ function chartSummaryView(chart, theme, options = {}) {
|
|
|
20072
20551
|
else if (!byPoint) model.valueAxis = valueAxis(model);
|
|
20073
20552
|
applyDataLabels(model, chart.series, extra);
|
|
20074
20553
|
chartExtraAxes(model);
|
|
20554
|
+
applyChartAxes(model, chart, ctx.drawingColor);
|
|
20075
20555
|
return model;
|
|
20076
20556
|
}
|
|
20077
20557
|
|
|
@@ -20079,15 +20559,13 @@ function chartSummaryView(chart, theme, options = {}) {
|
|
|
20079
20559
|
function cartesianAxes(model, area, out) {
|
|
20080
20560
|
const scale = model.valueAxis;
|
|
20081
20561
|
if (!scale) return void 0;
|
|
20082
|
-
const labels = scale.ticks.map((t) =>
|
|
20562
|
+
const labels = scale.ticks.map((t) => axisTickText(t, model.axes?.value, scale.percent));
|
|
20083
20563
|
const valueAttrs = chartTextAttributes(model, "valueAxis");
|
|
20084
20564
|
const categoryAttrs = chartTextAttributes(model, "categoryAxis");
|
|
20085
20565
|
const valueSize = valueAttrs.size ?? 10;
|
|
20086
20566
|
const categorySize = categoryAttrs.size ?? 10;
|
|
20087
|
-
const
|
|
20088
|
-
const
|
|
20089
|
-
const valueLabels = model.appearance?.valueAxis?.labelsVisible !== false;
|
|
20090
|
-
const categoryLabels = model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
20567
|
+
const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
|
|
20568
|
+
const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
20091
20569
|
const labelW = valueLabels ? Math.max(...labels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
|
|
20092
20570
|
const horizontal = model.horizontal;
|
|
20093
20571
|
const cats = Math.max(1, model.categories.length);
|
|
@@ -20096,7 +20574,7 @@ function cartesianAxes(model, area, out) {
|
|
|
20096
20574
|
Math.max(...model.categories.map((c2) => textWidth(c2, categorySize)), 8) + 6
|
|
20097
20575
|
);
|
|
20098
20576
|
const second = horizontal ? void 0 : model.secondaryAxis;
|
|
20099
|
-
const secondLabels = second?.ticks.map((t) =>
|
|
20577
|
+
const secondLabels = second?.ticks.map((t) => axisTickText(t, model.axes?.secondary, second.percent)) ?? [];
|
|
20100
20578
|
const secondW = second ? valueLabels ? Math.max(...secondLabels.map((l) => textWidth(l, valueSize)), 8) + 8 : 4 : 0;
|
|
20101
20579
|
const plot = horizontal ? {
|
|
20102
20580
|
x: area.x + catW,
|
|
@@ -20109,29 +20587,47 @@ function cartesianAxes(model, area, out) {
|
|
|
20109
20587
|
w: Math.max(1, area.w - labelW - 4 - secondW),
|
|
20110
20588
|
h: Math.max(1, area.h - Math.max(20, categorySize * 1.5))
|
|
20111
20589
|
};
|
|
20112
|
-
const
|
|
20113
|
-
const value = horizontal ? (v) => plot.x + (v - scale.min) / span * plot.w : (v) => plot.y + plot.h - (v - scale.min) / span * plot.h;
|
|
20590
|
+
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;
|
|
20114
20591
|
const bandSize = (horizontal ? plot.h : plot.w) / cats;
|
|
20115
|
-
const
|
|
20592
|
+
const index = (i) => model.axes?.category?.range.reverseOrder ? cats - 1 - i : i;
|
|
20593
|
+
const band = horizontal ? (i) => plot.y + plot.h - bandSize * (index(i) + 0.5) : (i) => plot.x + bandSize * (index(i) + 0.5);
|
|
20116
20594
|
out.push(chartAreaRect(model, "plotArea", plot));
|
|
20595
|
+
out.push(axisGridlines(model, model.axes?.value, scale.ticks, value, plot, horizontal));
|
|
20596
|
+
if (model.axes?.category?.source.majorGridlines || model.axes?.category?.source.minorGridlines)
|
|
20597
|
+
out.push(
|
|
20598
|
+
axisGridlines(
|
|
20599
|
+
model,
|
|
20600
|
+
model.axes.category,
|
|
20601
|
+
model.categories.map((_, i) => i),
|
|
20602
|
+
band,
|
|
20603
|
+
plot,
|
|
20604
|
+
!horizontal
|
|
20605
|
+
)
|
|
20606
|
+
);
|
|
20117
20607
|
scale.ticks.forEach((t, i) => {
|
|
20118
20608
|
const p = value(t);
|
|
20119
20609
|
const label = labels[i] ?? "";
|
|
20120
20610
|
if (horizontal) {
|
|
20121
|
-
out.push(line2(p, plot.y, p, plot.y + plot.h, grid.color, grid.width));
|
|
20122
20611
|
if (valueLabels)
|
|
20123
20612
|
out.push(
|
|
20124
20613
|
text2(p, plot.y + plot.h + valueSize + 2, label, { anchor: "middle", ...valueAttrs })
|
|
20125
20614
|
);
|
|
20126
20615
|
} else {
|
|
20127
|
-
out.push(line2(plot.x, p, plot.x + plot.w, p, grid.color, grid.width));
|
|
20128
20616
|
if (valueLabels)
|
|
20129
20617
|
out.push(text2(plot.x - 4, p + valueSize * 0.3, label, { anchor: "end", ...valueAttrs }));
|
|
20130
20618
|
}
|
|
20131
20619
|
});
|
|
20132
|
-
const
|
|
20133
|
-
|
|
20134
|
-
|
|
20620
|
+
const source = model.axes?.value?.source;
|
|
20621
|
+
const crossing = source?.crosses === "max" ? scale.max : source?.crosses === "min" ? scale.min : source?.crossesAt ?? 0;
|
|
20622
|
+
const zero = value(Math.min(Math.max(crossing, scale.min), scale.max));
|
|
20623
|
+
if (horizontal)
|
|
20624
|
+
out.push(
|
|
20625
|
+
axisLine(model, model.axes?.category, "categoryAxis", zero, plot.y, zero, plot.y + plot.h)
|
|
20626
|
+
);
|
|
20627
|
+
else
|
|
20628
|
+
out.push(
|
|
20629
|
+
axisLine(model, model.axes?.category, "categoryAxis", plot.x, zero, plot.x + plot.w, zero)
|
|
20630
|
+
);
|
|
20135
20631
|
const step = Math.max(
|
|
20136
20632
|
1,
|
|
20137
20633
|
Math.ceil(cats / Math.max(1, Math.floor((horizontal ? plot.h : plot.w) / 14)))
|
|
@@ -20156,20 +20652,23 @@ function cartesianAxes(model, area, out) {
|
|
|
20156
20652
|
});
|
|
20157
20653
|
const frame2 = { plot, value, band, bandSize };
|
|
20158
20654
|
if (second) {
|
|
20159
|
-
|
|
20160
|
-
frame2.secondary = (v) => plot.y + plot.h - (v - second.min) / secondSpan * plot.h;
|
|
20161
|
-
const secondAxis = chartStroke(model, "valueAxis");
|
|
20655
|
+
frame2.secondary = (v) => plot.y + plot.h - chartAxisRatio(v, second, model.axes?.secondary) * plot.h;
|
|
20162
20656
|
out.push(
|
|
20163
|
-
|
|
20657
|
+
axisLine(
|
|
20658
|
+
model,
|
|
20659
|
+
model.axes?.secondary,
|
|
20660
|
+
"valueAxis",
|
|
20164
20661
|
plot.x + plot.w,
|
|
20165
20662
|
plot.y,
|
|
20166
20663
|
plot.x + plot.w,
|
|
20167
|
-
plot.y + plot.h
|
|
20168
|
-
secondAxis.color,
|
|
20169
|
-
secondAxis.width
|
|
20664
|
+
plot.y + plot.h
|
|
20170
20665
|
)
|
|
20171
20666
|
);
|
|
20172
|
-
if (
|
|
20667
|
+
if (model.axes?.secondary?.source.majorGridlines || model.axes?.secondary?.source.minorGridlines)
|
|
20668
|
+
out.push(
|
|
20669
|
+
axisGridlines(model, model.axes.secondary, second.ticks, frame2.secondary, plot, false)
|
|
20670
|
+
);
|
|
20671
|
+
if (chartAxisLabels(model.axes?.secondary))
|
|
20173
20672
|
second.ticks.forEach(
|
|
20174
20673
|
(t, i) => out.push(
|
|
20175
20674
|
text2(plot.x + plot.w + 4, frame2.secondary(t) + valueSize * 0.3, secondLabels[i] ?? "", {
|
|
@@ -20213,18 +20712,19 @@ function linesAndAreas(model, frame2, out) {
|
|
|
20213
20712
|
index: i,
|
|
20214
20713
|
x: frame2.band(i),
|
|
20215
20714
|
y: frame2.value(top),
|
|
20216
|
-
radius: area ? 0 :
|
|
20715
|
+
radius: area ? 0 : chartMarkerRadius(s, i, 2.5)
|
|
20217
20716
|
});
|
|
20218
20717
|
lower.push([frame2.band(i), frame2.value(below)]);
|
|
20219
20718
|
});
|
|
20220
20719
|
layers.push({
|
|
20720
|
+
series: s,
|
|
20221
20721
|
points,
|
|
20222
20722
|
lower,
|
|
20223
20723
|
color: s.color,
|
|
20224
20724
|
filter: s.shadowFilter ? ` filter="${s.shadowFilter}"` : ""
|
|
20225
20725
|
});
|
|
20226
20726
|
});
|
|
20227
|
-
for (const { points, lower, color, filter } of area ? [...layers].reverse() : layers) {
|
|
20727
|
+
for (const { points, lower, color, filter, series } of area ? [...layers].reverse() : layers) {
|
|
20228
20728
|
if (area) {
|
|
20229
20729
|
const poly = [...points, ...[...lower].reverse()].map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
|
|
20230
20730
|
out.push(`<polygon points="${poly}" fill="${color}" fill-opacity="0.85"${filter}/>`);
|
|
@@ -20243,9 +20743,9 @@ function linesAndAreas(model, frame2, out) {
|
|
|
20243
20743
|
else segment2.push(`${n(x)},${n(y)}`);
|
|
20244
20744
|
}
|
|
20245
20745
|
flush();
|
|
20246
|
-
|
|
20247
|
-
if (!Number.isNaN(x))
|
|
20248
|
-
|
|
20746
|
+
points.forEach(([x, y], index) => {
|
|
20747
|
+
if (!Number.isNaN(x)) out.push(chartSeriesMarkerSvg(series, index, x, y, 2.5));
|
|
20748
|
+
});
|
|
20249
20749
|
}
|
|
20250
20750
|
pointLabels(model, marks, out);
|
|
20251
20751
|
}
|
|
@@ -20255,16 +20755,14 @@ function scatter(model, area, out) {
|
|
|
20255
20755
|
const ys = model.valueAxis;
|
|
20256
20756
|
const xs = model.xAxis;
|
|
20257
20757
|
if (!ys || !xs) return;
|
|
20258
|
-
const yLabels = ys.ticks.map((t) =>
|
|
20758
|
+
const yLabels = ys.ticks.map((t) => axisTickText(t, model.axes?.value));
|
|
20259
20759
|
const valueAttrs = chartTextAttributes(model, "valueAxis");
|
|
20260
20760
|
const categoryAttrs = chartTextAttributes(model, "categoryAxis");
|
|
20261
20761
|
const valueSize = valueAttrs.size ?? 10;
|
|
20262
20762
|
const categorySize = categoryAttrs.size ?? 10;
|
|
20263
|
-
const grid = chartStroke(model, "gridlineMajor");
|
|
20264
20763
|
const xAxis = chartStroke(model, "categoryAxis");
|
|
20265
|
-
const
|
|
20266
|
-
const
|
|
20267
|
-
const categoryLabels = model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
20764
|
+
const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
|
|
20765
|
+
const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
20268
20766
|
const labelW = valueLabels ? Math.max(...yLabels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
|
|
20269
20767
|
const plot = {
|
|
20270
20768
|
x: area.x + labelW,
|
|
@@ -20284,17 +20782,24 @@ function scatter(model, area, out) {
|
|
|
20284
20782
|
s.values.forEach((_, i) => {
|
|
20285
20783
|
reach = Math.max(reach, radiusOf(s.sizes?.[i] ?? void 0) ?? 0);
|
|
20286
20784
|
});
|
|
20287
|
-
const widen = (s, length) => {
|
|
20785
|
+
const widen = (s, length, axis) => {
|
|
20786
|
+
if (axis?.range.logScale) return s;
|
|
20288
20787
|
const pad = reach * (s.max - s.min || 1) / Math.max(1, length - 2 * reach);
|
|
20289
|
-
return {
|
|
20788
|
+
return {
|
|
20789
|
+
...s,
|
|
20790
|
+
min: axis?.source.scaling.min === void 0 ? s.min - pad : s.min,
|
|
20791
|
+
max: axis?.source.scaling.max === void 0 ? s.max + pad : s.max
|
|
20792
|
+
};
|
|
20290
20793
|
};
|
|
20291
|
-
const xView = widen(xs, plot.w);
|
|
20292
|
-
const yView = widen(ys, plot.h);
|
|
20293
|
-
const px3 = (v) => plot.x + (v
|
|
20294
|
-
const py = (v) => plot.y + plot.h - (v
|
|
20794
|
+
const xView = widen(xs, plot.w, model.axes?.category);
|
|
20795
|
+
const yView = widen(ys, plot.h, model.axes?.value);
|
|
20796
|
+
const px3 = (v) => plot.x + chartAxisRatio(v, xView, model.axes?.category) * plot.w;
|
|
20797
|
+
const py = (v) => plot.y + plot.h - chartAxisRatio(v, yView, model.axes?.value) * plot.h;
|
|
20295
20798
|
out.push(chartAreaRect(model, "plotArea", plot));
|
|
20799
|
+
out.push(axisGridlines(model, model.axes?.value, ys.ticks, py, plot, false));
|
|
20800
|
+
if (model.axes?.category)
|
|
20801
|
+
out.push(axisGridlines(model, model.axes.category, xs.ticks, px3, plot, true));
|
|
20296
20802
|
ys.ticks.forEach((t, i) => {
|
|
20297
|
-
out.push(line2(plot.x, py(t), plot.x + plot.w, py(t), grid.color, grid.width));
|
|
20298
20803
|
if (valueLabels)
|
|
20299
20804
|
out.push(
|
|
20300
20805
|
text2(plot.x - 4, py(t) + valueSize * 0.3, yLabels[i] ?? "", {
|
|
@@ -20304,19 +20809,30 @@ function scatter(model, area, out) {
|
|
|
20304
20809
|
);
|
|
20305
20810
|
});
|
|
20306
20811
|
for (const t of xs.ticks) {
|
|
20307
|
-
|
|
20812
|
+
if (!model.axes?.category?.source.deleted)
|
|
20813
|
+
out.push(line2(px3(t), plot.y + plot.h, px3(t), plot.y + plot.h + 3, xAxis.color, xAxis.width));
|
|
20308
20814
|
if (categoryLabels)
|
|
20309
20815
|
out.push(
|
|
20310
|
-
text2(px3(t), plot.y + plot.h + categorySize + 3,
|
|
20816
|
+
text2(px3(t), plot.y + plot.h + categorySize + 3, axisTickText(t, model.axes?.category), {
|
|
20311
20817
|
anchor: "middle",
|
|
20312
20818
|
...categoryAttrs
|
|
20313
20819
|
})
|
|
20314
20820
|
);
|
|
20315
20821
|
}
|
|
20316
20822
|
out.push(
|
|
20317
|
-
|
|
20823
|
+
axisLine(
|
|
20824
|
+
model,
|
|
20825
|
+
model.axes?.category,
|
|
20826
|
+
"categoryAxis",
|
|
20827
|
+
plot.x,
|
|
20828
|
+
plot.y + plot.h,
|
|
20829
|
+
plot.x + plot.w,
|
|
20830
|
+
plot.y + plot.h
|
|
20831
|
+
)
|
|
20832
|
+
);
|
|
20833
|
+
out.push(
|
|
20834
|
+
axisLine(model, model.axes?.value, "valueAxis", plot.x, plot.y, plot.x, plot.y + plot.h)
|
|
20318
20835
|
);
|
|
20319
|
-
out.push(line2(plot.x, plot.y, plot.x, plot.y + plot.h, yAxis.color, yAxis.width));
|
|
20320
20836
|
const marks = [];
|
|
20321
20837
|
for (const [si, s] of model.series.entries())
|
|
20322
20838
|
s.values.forEach((v, i) => {
|
|
@@ -20325,8 +20841,8 @@ function scatter(model, area, out) {
|
|
|
20325
20841
|
const filter = s.shadowFilter ? ` filter="${s.shadowFilter}"` : "";
|
|
20326
20842
|
const fill = s.pointColors?.[i] ?? s.color;
|
|
20327
20843
|
if (!bubble) {
|
|
20328
|
-
out.push(
|
|
20329
|
-
marks.push({ series: s, index: i, x: px3(x), y: py(v), radius:
|
|
20844
|
+
out.push(chartSeriesMarkerSvg(s, i, px3(x), py(v)));
|
|
20845
|
+
marks.push({ series: s, index: i, x: px3(x), y: py(v), radius: chartMarkerRadius(s, i) });
|
|
20330
20846
|
return;
|
|
20331
20847
|
}
|
|
20332
20848
|
const r = radiusOf(s.sizes?.[i] ?? void 0);
|
|
@@ -20546,32 +21062,37 @@ function radarSvg(model, area) {
|
|
|
20546
21062
|
const valueSize = valueAttrs.size ?? 9;
|
|
20547
21063
|
const categorySize = categoryAttrs.size ?? 10;
|
|
20548
21064
|
const grid = chartStroke(model, "gridlineMajor");
|
|
20549
|
-
const axis = chartStroke(model, "categoryAxis");
|
|
20550
21065
|
const cx2 = area.x + area.w / 2;
|
|
20551
21066
|
const cy = area.y + area.h / 2 + 4;
|
|
20552
21067
|
const radius = Math.max(1, Math.min(area.w, area.h) / 2 - Math.max(18, categorySize * 1.8));
|
|
20553
21068
|
const angle = (i) => i / count * Math.PI * 2;
|
|
20554
|
-
const r = (v) => (v
|
|
21069
|
+
const r = (v) => chartAxisRatio(v, scale, model.axes?.value) * radius;
|
|
20555
21070
|
const labelEvery = Math.max(
|
|
20556
21071
|
1,
|
|
20557
21072
|
Math.ceil(12 / Math.max(1, radius / Math.max(1, scale.ticks.length - 1)))
|
|
20558
21073
|
);
|
|
20559
21074
|
for (const [k, t] of scale.ticks.entries()) {
|
|
20560
21075
|
const ring = Array.from({ length: count }, (_, i) => polar(cx2, cy, r(t), angle(i))).map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
|
|
20561
|
-
|
|
20562
|
-
`<polygon points="${ring}" fill="none" stroke="${grid.color}" stroke-width="${n(grid.width)}"/>`
|
|
20563
|
-
);
|
|
20564
|
-
if (model.appearance?.valueAxis?.labelsVisible !== false && k % labelEvery === 0)
|
|
21076
|
+
if (!model.axes?.value || model.axes.value.source.majorGridlines)
|
|
20565
21077
|
out.push(
|
|
20566
|
-
|
|
21078
|
+
`<polygon points="${ring}" fill="none" stroke="${grid.color}" stroke-width="${n(grid.width)}"/>`
|
|
21079
|
+
);
|
|
21080
|
+
if (chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false && k % labelEvery === 0)
|
|
21081
|
+
out.push(
|
|
21082
|
+
text2(
|
|
21083
|
+
cx2 + 3,
|
|
21084
|
+
cy - r(t) + valueSize * 0.3,
|
|
21085
|
+
axisTickText(t, model.axes?.value, scale.percent),
|
|
21086
|
+
valueAttrs
|
|
21087
|
+
)
|
|
20567
21088
|
);
|
|
20568
21089
|
}
|
|
20569
21090
|
model.categories.forEach((c2, i) => {
|
|
20570
21091
|
const [x, y] = polar(cx2, cy, radius, angle(i));
|
|
20571
|
-
out.push(
|
|
21092
|
+
out.push(axisLine(model, model.axes?.category, "categoryAxis", cx2, cy, x, y));
|
|
20572
21093
|
const [lx, ly] = polar(cx2, cy, radius + 10, angle(i));
|
|
20573
21094
|
const anchor = Math.abs(lx - cx2) < 2 ? "middle" : lx > cx2 ? "start" : "end";
|
|
20574
|
-
if (model.appearance?.categoryAxis?.labelsVisible !== false)
|
|
21095
|
+
if (chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false)
|
|
20575
21096
|
out.push(
|
|
20576
21097
|
text2(lx, ly + categorySize * 0.3, fit(c2, area.w / 4, categorySize), {
|
|
20577
21098
|
anchor,
|
|
@@ -20582,7 +21103,13 @@ function radarSvg(model, area) {
|
|
|
20582
21103
|
const marks = [];
|
|
20583
21104
|
for (const s of model.series) {
|
|
20584
21105
|
const vertices = s.values.slice(0, count).map((v, i) => polar(cx2, cy, r(v ?? scale.min), angle(i)));
|
|
20585
|
-
vertices.forEach(([x, y], i) =>
|
|
21106
|
+
vertices.forEach(([x, y], i) => {
|
|
21107
|
+
if (s.values[i] === null) return;
|
|
21108
|
+
const markerSeries = s;
|
|
21109
|
+
if (markerSeries.marker || markerSeries.pointMarkers)
|
|
21110
|
+
out.push(chartSeriesMarkerSvg(s, i, x, y));
|
|
21111
|
+
marks.push({ series: s, index: i, x, y, radius: chartMarkerRadius(s, i) });
|
|
21112
|
+
});
|
|
20586
21113
|
const points = vertices.map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
|
|
20587
21114
|
out.push(
|
|
20588
21115
|
`<polygon points="${points}" fill="none" stroke="${s.color}" stroke-width="2"${s.shadowFilter ? ` filter="${s.shadowFilter}"` : ""}/>`
|
|
@@ -20679,33 +21206,33 @@ var CHART_FONT_FAMILY = "Calibri, Carlito, Arial, sans-serif";
|
|
|
20679
21206
|
function cssFont(attrs2) {
|
|
20680
21207
|
return `${attrs2.italic ? "italic" : "normal"} ${attrs2.weight ?? "normal"} ${attrs2.size ?? 10}px ${attrs2.family ?? CHART_FONT_FAMILY}`;
|
|
20681
21208
|
}
|
|
20682
|
-
function chartFontMetrics(attrs2,
|
|
20683
|
-
const metrics =
|
|
21209
|
+
function chartFontMetrics(attrs2, options2) {
|
|
21210
|
+
const metrics = options2.measureFont?.(cssFont(attrs2));
|
|
20684
21211
|
return metrics && Number.isFinite(metrics.ascent) && Number.isFinite(metrics.descent) && metrics.ascent >= 0 && metrics.descent >= 0 && metrics.ascent + metrics.descent > 0 ? metrics : void 0;
|
|
20685
21212
|
}
|
|
20686
|
-
function chartTextWidth(content, attrs2,
|
|
20687
|
-
const width =
|
|
21213
|
+
function chartTextWidth(content, attrs2, options2) {
|
|
21214
|
+
const width = options2.measureText?.(content, cssFont(attrs2));
|
|
20688
21215
|
return width !== void 0 && Number.isFinite(width) && width >= 0 ? width : textWidth(content, attrs2.size);
|
|
20689
21216
|
}
|
|
20690
|
-
function fitChartText(content, maxWidth, attrs2,
|
|
20691
|
-
if (!
|
|
20692
|
-
if (chartTextWidth(content, attrs2,
|
|
21217
|
+
function fitChartText(content, maxWidth, attrs2, options2) {
|
|
21218
|
+
if (!options2.measureText) return fit(content, maxWidth, attrs2.size);
|
|
21219
|
+
if (chartTextWidth(content, attrs2, options2) <= maxWidth) return content;
|
|
20693
21220
|
const points = [...content];
|
|
20694
21221
|
let low = 0;
|
|
20695
21222
|
let high = points.length;
|
|
20696
21223
|
while (low < high) {
|
|
20697
21224
|
const mid = Math.ceil((low + high) / 2);
|
|
20698
|
-
if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`, attrs2,
|
|
21225
|
+
if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`, attrs2, options2) <= maxWidth) low = mid;
|
|
20699
21226
|
else high = mid - 1;
|
|
20700
21227
|
}
|
|
20701
21228
|
return `${points.slice(0, low).join("")}\u2026`;
|
|
20702
21229
|
}
|
|
20703
21230
|
|
|
20704
21231
|
// chart/render/chart-svg-legend.ts
|
|
20705
|
-
function chartLegendSvg(model, area, frame2,
|
|
21232
|
+
function chartLegendSvg(model, area, frame2, options2) {
|
|
20706
21233
|
const automatic = [];
|
|
20707
21234
|
const bounds = {};
|
|
20708
|
-
const reserved = automaticLegend(model, area, automatic,
|
|
21235
|
+
const reserved = automaticLegend(model, area, automatic, options2, bounds);
|
|
20709
21236
|
const plot = model.legendOverlay ? area : reserved;
|
|
20710
21237
|
const box = bounds.box;
|
|
20711
21238
|
if (!box) return { plot, markup: "", foreground: false };
|
|
@@ -20719,11 +21246,11 @@ function chartLegendSvg(model, area, frame2, options) {
|
|
|
20719
21246
|
const entries = legendEntries(model);
|
|
20720
21247
|
const attrs2 = chartTextAttributes(model, "legend");
|
|
20721
21248
|
const size = attrs2.size ?? 10;
|
|
20722
|
-
const font = chartFontMetrics(attrs2,
|
|
21249
|
+
const font = chartFontMetrics(attrs2, options2);
|
|
20723
21250
|
const keySize = size / 2;
|
|
20724
21251
|
const keyGap = size / 4;
|
|
20725
21252
|
const widths = entries.map(
|
|
20726
|
-
(entry2) => chartTextWidth(entry2.label, attrs2,
|
|
21253
|
+
(entry2) => chartTextWidth(entry2.label, attrs2, options2) + keySize + keyGap
|
|
20727
21254
|
);
|
|
20728
21255
|
const horizontal = manual.width > manual.height && widths.reduce((sum, width) => sum + width, 0) + size <= manual.width;
|
|
20729
21256
|
const rowWidth = horizontal ? manual.width / entries.length : manual.width;
|
|
@@ -20738,8 +21265,8 @@ function chartLegendSvg(model, area, frame2, options) {
|
|
|
20738
21265
|
];
|
|
20739
21266
|
const baselineOffset = font ? (font.ascent - font.descent) / 2 : size * 0.35;
|
|
20740
21267
|
entries.forEach((entry2, i) => {
|
|
20741
|
-
const available = horizontal ? chartTextWidth(entry2.label, attrs2,
|
|
20742
|
-
const label = fitChartText(entry2.label, available, attrs2,
|
|
21268
|
+
const available = horizontal ? chartTextWidth(entry2.label, attrs2, options2) : Math.max(0, rowWidth - size / 2 - keySize - keyGap);
|
|
21269
|
+
const label = fitChartText(entry2.label, available, attrs2, options2);
|
|
20743
21270
|
const contentWidth = Math.min(
|
|
20744
21271
|
horizontal ? widths[i] ?? 0 : Math.max(...widths),
|
|
20745
21272
|
rowWidth - size / 2
|
|
@@ -20782,7 +21309,7 @@ function legendEntries(model) {
|
|
|
20782
21309
|
color: s.color
|
|
20783
21310
|
}));
|
|
20784
21311
|
}
|
|
20785
|
-
function automaticLegend(model, area, out,
|
|
21312
|
+
function automaticLegend(model, area, out, options2, bounds) {
|
|
20786
21313
|
const entries = legendEntries(model);
|
|
20787
21314
|
if (!model.showLegend || entries.length === 0) return area;
|
|
20788
21315
|
const pos = model.legendPosition;
|
|
@@ -20791,7 +21318,7 @@ function automaticLegend(model, area, out, options, bounds) {
|
|
|
20791
21318
|
const rowH = Math.max(16, size * 1.4);
|
|
20792
21319
|
if (pos === "t" || pos === "b") {
|
|
20793
21320
|
const widths = entries.map(
|
|
20794
|
-
(e) => Math.min(chartTextWidth(e.label, attrs2,
|
|
21321
|
+
(e) => Math.min(chartTextWidth(e.label, attrs2, options2) + 20, area.w / 2)
|
|
20795
21322
|
);
|
|
20796
21323
|
const total = widths.reduce((a2, b) => a2 + b, 0);
|
|
20797
21324
|
let x2 = area.x + Math.max(0, (area.w - total) / 2);
|
|
@@ -20808,14 +21335,14 @@ function automaticLegend(model, area, out, options, bounds) {
|
|
|
20808
21335
|
entries.forEach((e, i) => {
|
|
20809
21336
|
const w = widths[i] ?? 0;
|
|
20810
21337
|
out.push(rect2(x2, y, 8, 8, e.color));
|
|
20811
|
-
out.push(text2(x2 + 12, y + 8, fitChartText(e.label, w - 16, attrs2,
|
|
21338
|
+
out.push(text2(x2 + 12, y + 8, fitChartText(e.label, w - 16, attrs2, options2), attrs2));
|
|
20812
21339
|
x2 += w;
|
|
20813
21340
|
});
|
|
20814
21341
|
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 };
|
|
20815
21342
|
}
|
|
20816
21343
|
const width = Math.min(
|
|
20817
21344
|
area.w * 0.35,
|
|
20818
|
-
Math.max(...entries.map((e) => chartTextWidth(e.label, attrs2,
|
|
21345
|
+
Math.max(...entries.map((e) => chartTextWidth(e.label, attrs2, options2))) + 22
|
|
20819
21346
|
);
|
|
20820
21347
|
const height = entries.length * rowH;
|
|
20821
21348
|
const x = pos === "l" ? area.x + 4 : area.x + area.w - width;
|
|
@@ -20833,14 +21360,14 @@ function automaticLegend(model, area, out, options, bounds) {
|
|
|
20833
21360
|
const y = y0 + i * rowH;
|
|
20834
21361
|
if (y + rowH > area.y + area.h + 2) return;
|
|
20835
21362
|
out.push(rect2(x, y + 3, 8, 8, e.color));
|
|
20836
|
-
out.push(text2(x + 12, y + 11, fitChartText(e.label, width - 16, attrs2,
|
|
21363
|
+
out.push(text2(x + 12, y + 11, fitChartText(e.label, width - 16, attrs2, options2), attrs2));
|
|
20837
21364
|
});
|
|
20838
21365
|
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 };
|
|
20839
21366
|
}
|
|
20840
21367
|
|
|
20841
21368
|
// text/wrap-styled-runs.ts
|
|
20842
21369
|
var graphemes = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
20843
|
-
function wrapStyledRuns(runs, maxWidth, measure2,
|
|
21370
|
+
function wrapStyledRuns(runs, maxWidth, measure2, options2 = {}) {
|
|
20844
21371
|
const groups = [];
|
|
20845
21372
|
for (const [source, run] of runs.entries()) {
|
|
20846
21373
|
for (const token of run.text.split(/(\r\n|[\r\n]|[ \t]+)/u).filter(Boolean)) {
|
|
@@ -20888,7 +21415,7 @@ function wrapStyledRuns(runs, maxWidth, measure2, options = {}) {
|
|
|
20888
21415
|
if (line3.length && width(merged(line3, [...separator, ...group2.pieces])) > maxWidth) flush();
|
|
20889
21416
|
else line3 = merged(line3, separator);
|
|
20890
21417
|
spaces = [];
|
|
20891
|
-
if (
|
|
21418
|
+
if (options2.breakWords && wordWidth > maxWidth) {
|
|
20892
21419
|
for (const piece of group2.pieces) {
|
|
20893
21420
|
for (const { segment: segment2 } of graphemes.segment(piece.text)) {
|
|
20894
21421
|
const next = { ...piece, text: segment2 };
|
|
@@ -20906,11 +21433,11 @@ function wrapStyledRuns(runs, maxWidth, measure2, options = {}) {
|
|
|
20906
21433
|
function spacing(value, naturalHeight, fallback) {
|
|
20907
21434
|
return value ? value.unit === "points" ? chartPointsToPixels(value.value) : naturalHeight * value.value : fallback;
|
|
20908
21435
|
}
|
|
20909
|
-
function chartRichTitleSvg(model, width,
|
|
21436
|
+
function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
|
|
20910
21437
|
if (!model.title) return void 0;
|
|
20911
21438
|
const base = chartTextAttributes(model, "title", 14);
|
|
20912
21439
|
const capacity = Math.max(1, width * 0.8 - 8);
|
|
20913
|
-
if (!model.titleText && !hasManualLayoutFields(model.titleLayout) && !model.titleOverlay && !model.title.includes("\n") && chartTextWidth(model.title, base,
|
|
21440
|
+
if (!model.titleText && !hasManualLayoutFields(model.titleLayout) && !model.titleOverlay && !model.title.includes("\n") && chartTextWidth(model.title, base, options2) <= capacity)
|
|
20914
21441
|
return void 0;
|
|
20915
21442
|
const paragraphs = model.titleText?.paragraphs ?? [
|
|
20916
21443
|
{
|
|
@@ -20946,7 +21473,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
20946
21473
|
"title",
|
|
20947
21474
|
base.size
|
|
20948
21475
|
),
|
|
20949
|
-
|
|
21476
|
+
options2
|
|
20950
21477
|
),
|
|
20951
21478
|
{ breakWords: true }
|
|
20952
21479
|
);
|
|
@@ -20970,10 +21497,10 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
20970
21497
|
return {
|
|
20971
21498
|
...line3,
|
|
20972
21499
|
runs,
|
|
20973
|
-
width: runs.reduce((sum, run) => sum + chartTextWidth(run.text, run.attrs,
|
|
21500
|
+
width: runs.reduce((sum, run) => sum + chartTextWidth(run.text, run.attrs, options2), 0),
|
|
20974
21501
|
size: runs.length ? Math.max(...runs.map((run) => run.attrs.size ?? 14)) : base.size ?? 14,
|
|
20975
21502
|
fontMetrics: (runs.length ? runs.map((run) => run.attrs) : [base]).map(
|
|
20976
|
-
(attrs2) => chartFontMetrics(attrs2,
|
|
21503
|
+
(attrs2) => chartFontMetrics(attrs2, options2)
|
|
20977
21504
|
)
|
|
20978
21505
|
};
|
|
20979
21506
|
});
|
|
@@ -21011,7 +21538,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
21011
21538
|
anchor: "start"
|
|
21012
21539
|
}).replace("<text ", '<tspan data-chart-title-run="true" ').replace("</text>", "</tspan>")
|
|
21013
21540
|
);
|
|
21014
|
-
x += chartTextWidth(run.text, run.attrs,
|
|
21541
|
+
x += chartTextWidth(run.text, run.attrs, options2);
|
|
21015
21542
|
}
|
|
21016
21543
|
}
|
|
21017
21544
|
const parent = text2(0, 0, "", { ...base, underline: false }).replace(
|
|
@@ -21037,7 +21564,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
21037
21564
|
}
|
|
21038
21565
|
|
|
21039
21566
|
// chart/render/chart-svg.ts
|
|
21040
|
-
function renderChartSvg(model, width, height,
|
|
21567
|
+
function renderChartSvg(model, width, height, options2 = {}) {
|
|
21041
21568
|
const paint2 = chartGradientPaint(model, Math.max(1, width), Math.max(1, height));
|
|
21042
21569
|
model = paint2.model;
|
|
21043
21570
|
const w = Math.max(1, width);
|
|
@@ -21051,7 +21578,7 @@ function renderChartSvg(model, width, height, options = {}) {
|
|
|
21051
21578
|
if (paint2.defs) out.push(paint2.defs);
|
|
21052
21579
|
out.push(chartAreaRect(model, "chartArea", { x: 0, y: 0, w, h }));
|
|
21053
21580
|
let area = { x: 8, y: 8, w: w - 16, h: h - 16 };
|
|
21054
|
-
const richTitle = chartRichTitleSvg(model, w,
|
|
21581
|
+
const richTitle = chartRichTitleSvg(model, w, options2, h);
|
|
21055
21582
|
if (richTitle) {
|
|
21056
21583
|
if (model.titleLayout || model.titleOverlay) foregroundTitle = richTitle.markup;
|
|
21057
21584
|
else out.push(richTitle.markup);
|
|
@@ -21060,9 +21587,9 @@ function renderChartSvg(model, width, height, options = {}) {
|
|
|
21060
21587
|
} else if (model.title) {
|
|
21061
21588
|
const attrs2 = chartTextAttributes(model, "title", 14);
|
|
21062
21589
|
const size = attrs2.size ?? 14;
|
|
21063
|
-
const label = fitChartText(model.title, w - 16, attrs2,
|
|
21064
|
-
const titleWidth = Math.min(w - 16, chartTextWidth(label, attrs2,
|
|
21065
|
-
const font = chartFontMetrics(attrs2,
|
|
21590
|
+
const label = fitChartText(model.title, w - 16, attrs2, options2);
|
|
21591
|
+
const titleWidth = Math.min(w - 16, chartTextWidth(label, attrs2, options2) + 8);
|
|
21592
|
+
const font = chartFontMetrics(attrs2, options2);
|
|
21066
21593
|
const titleHeight = Math.max(24, font ? font.ascent + font.descent + 4 : size * 1.4 + 4);
|
|
21067
21594
|
out.push(
|
|
21068
21595
|
chartAreaRect(model, "title", {
|
|
@@ -21090,7 +21617,7 @@ function renderChartSvg(model, width, height, options = {}) {
|
|
|
21090
21617
|
out.push("</svg>");
|
|
21091
21618
|
return out.join("");
|
|
21092
21619
|
}
|
|
21093
|
-
const legend = chartLegendSvg(model, area, { width: w, height: h },
|
|
21620
|
+
const legend = chartLegendSvg(model, area, { width: w, height: h }, options2);
|
|
21094
21621
|
area = legend.plot;
|
|
21095
21622
|
if (!legend.foreground) out.push(legend.markup);
|
|
21096
21623
|
if (area.w > 4 && area.h > 4) {
|
|
@@ -21137,8 +21664,8 @@ function chartSpaceKind(space) {
|
|
|
21137
21664
|
const type = chartSummaryFromSpace(space).chartType;
|
|
21138
21665
|
return { type, drawn: DRAWN_CHART_TYPES.has(type) };
|
|
21139
21666
|
}
|
|
21140
|
-
function renderChartSpaceSvg(space,
|
|
21141
|
-
const { width, height, theme, fonts, formatting, colorPalette, styleDefinition, ...svg } =
|
|
21667
|
+
function renderChartSpaceSvg(space, options2) {
|
|
21668
|
+
const { width, height, theme, fonts, formatting, colorPalette, styleDefinition, ...svg } = options2;
|
|
21142
21669
|
const summary = chartSummaryFromSpace(space, {
|
|
21143
21670
|
...formatting ? { formatting } : {},
|
|
21144
21671
|
...colorPalette !== void 0 ? { colorPalette } : {},
|
|
@@ -21147,8 +21674,8 @@ function renderChartSpaceSvg(space, options) {
|
|
|
21147
21674
|
const view = chartSummaryView(summary, chartThemePalette(theme, fonts));
|
|
21148
21675
|
return renderChartSvg(view, width, height, svg);
|
|
21149
21676
|
}
|
|
21150
|
-
function renderChartSummarySvg(summary,
|
|
21151
|
-
const { width, height, theme, fonts, ...svg } =
|
|
21677
|
+
function renderChartSummarySvg(summary, options2) {
|
|
21678
|
+
const { width, height, theme, fonts, ...svg } = options2;
|
|
21152
21679
|
const view = chartSummaryView(summary, chartThemePalette(theme, fonts));
|
|
21153
21680
|
return renderChartSvg(view, width, height, svg);
|
|
21154
21681
|
}
|
|
@@ -26540,7 +27067,7 @@ function datePicture(instr) {
|
|
|
26540
27067
|
}
|
|
26541
27068
|
var TOKENS = /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|am\/pm|AM\/PM|'[^']*'/g;
|
|
26542
27069
|
function formatWordDate(date, picture, locale = "en-US") {
|
|
26543
|
-
const name = (
|
|
27070
|
+
const name = (options2) => new Intl.DateTimeFormat(locale, options2).format(date);
|
|
26544
27071
|
const pad = (value) => String(value).padStart(2, "0");
|
|
26545
27072
|
const hours12 = date.getHours() % 12 || 12;
|
|
26546
27073
|
return picture.replace(TOKENS, (token) => {
|
|
@@ -26747,22 +27274,22 @@ function withTocBookmarks(model, added) {
|
|
|
26747
27274
|
)
|
|
26748
27275
|
};
|
|
26749
27276
|
}
|
|
26750
|
-
function buildTableOfContents(model,
|
|
26751
|
-
const instruction =
|
|
27277
|
+
function buildTableOfContents(model, options2) {
|
|
27278
|
+
const instruction = options2.instruction ?? DEFAULT_TOC_INSTRUCTION;
|
|
26752
27279
|
const field = { instr: instruction.trim() };
|
|
26753
|
-
const width =
|
|
27280
|
+
const width = options2.contentWidthTwips ?? twips(9360);
|
|
26754
27281
|
const styles = model.paragraphStyles?.styles ?? {};
|
|
26755
27282
|
const entries = tocEntries(model, instruction);
|
|
26756
27283
|
const figures = tocCaptionLabel(instruction) !== void 0;
|
|
26757
27284
|
const paragraphs = (entries.length ? entries : [void 0]).map((entry2) => {
|
|
26758
27285
|
const level2 = entry2?.level ?? 1;
|
|
26759
27286
|
const style = figures ? "TableofFigures" : `TOC${level2}`;
|
|
26760
|
-
const page = entry2 ?
|
|
26761
|
-
const bookmark = entry2 ?
|
|
27287
|
+
const page = entry2 ? options2.pageNumbers?.get(entry2.blockId) : void 0;
|
|
27288
|
+
const bookmark = entry2 ? options2.bookmarks?.get(entry2.blockId) : void 0;
|
|
26762
27289
|
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 }];
|
|
26763
27290
|
return {
|
|
26764
27291
|
type: "paragraph",
|
|
26765
|
-
id:
|
|
27292
|
+
id: options2.newId(),
|
|
26766
27293
|
runs,
|
|
26767
27294
|
...styles[style] ? { style } : {
|
|
26768
27295
|
...level2 > 1 ? { indentLeftTwips: signedTwips((level2 - 1) * 220) } : {},
|
|
@@ -26804,12 +27331,12 @@ function findTableOfContents(blocks, accepts = (instruction) => tocCaptionLabel(
|
|
|
26804
27331
|
}
|
|
26805
27332
|
return void 0;
|
|
26806
27333
|
}
|
|
26807
|
-
function updateTableOfContents(model,
|
|
27334
|
+
function updateTableOfContents(model, options2) {
|
|
26808
27335
|
const found = findTableOfContents(model.blocks);
|
|
26809
27336
|
if (!found) return void 0;
|
|
26810
27337
|
const linked = tocHyperlinks(found.instruction) ? tocBookmarks(model, tocEntries(model, found.instruction)) : void 0;
|
|
26811
27338
|
const rebuilt = buildTableOfContents(model, {
|
|
26812
|
-
...
|
|
27339
|
+
...options2,
|
|
26813
27340
|
instruction: found.instruction,
|
|
26814
27341
|
...linked ? { bookmarks: linked.bookmarks } : {}
|
|
26815
27342
|
});
|