@silurus/ooxml 0.3.0 → 0.4.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/docx-B96_4Bp5.cjs +1 -0
- package/dist/docx-CPf_N42P.js +784 -0
- package/dist/docx.cjs +1 -1
- package/dist/docx.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +3 -3
- package/dist/pptx-BHGTs5zW.js +1682 -0
- package/dist/pptx-CYYMOWs4.cjs +1 -0
- package/dist/pptx.cjs +1 -1
- package/dist/pptx.mjs +1 -1
- package/dist/{renderer-BlgQO3S_.js → renderer-CpJhtczQ.js} +117 -96
- package/dist/renderer-ckRjuWz0.cjs +1 -0
- package/dist/types/docx.d.ts +12 -1
- package/dist/types/index.d.ts +89 -2
- package/dist/types/pptx.d.ts +77 -1
- package/dist/{xlsx-DqnFMSVb.js → xlsx--fOMyOGC.js} +10 -1
- package/dist/{xlsx-BbZiHoyu.cjs → xlsx-C2jK_dYK.cjs} +2 -2
- package/dist/xlsx.cjs +1 -1
- package/dist/xlsx.mjs +1 -1
- package/package.json +1 -1
- package/dist/docx-CBTSExoH.cjs +0 -1
- package/dist/docx-DPRNEbrA.js +0 -763
- package/dist/pptx-BTI_RpCN.js +0 -1392
- package/dist/pptx-D-l5vpjt.cjs +0 -1
- package/dist/renderer-B5mmiYKF.cjs +0 -1
package/dist/pptx.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./autoResize-ggn4hzd8.cjs`),t=require(`./pptx-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./autoResize-ggn4hzd8.cjs`),t=require(`./pptx-CYYMOWs4.cjs`);exports.PptxPresentation=t.r,exports.PptxViewer=t.n,exports.autoResize=e.t,exports.renderSlide=t.i;
|
package/dist/pptx.mjs
CHANGED
|
@@ -55,23 +55,41 @@ function l(e, n, r, i, a, o) {
|
|
|
55
55
|
e.fillText(a.slice(0, 20), r + 10 + 4, l + s / 2), l += c;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
function u(e, t, n, r, i
|
|
58
|
+
function u(e, t, n, r, i) {
|
|
59
|
+
if (t === "none" || !t) return;
|
|
60
|
+
let a = e.strokeStyle;
|
|
61
|
+
if (e.strokeStyle = "#888", e.lineWidth = 1, e.beginPath(), n === "val") {
|
|
62
|
+
let n = r, a = i, o = t === "out" || t === "cross" ? -4 : 0, s = t === "in" || t === "cross" ? 4 : 0;
|
|
63
|
+
e.moveTo(n + o, a), e.lineTo(n + s, a);
|
|
64
|
+
} else {
|
|
65
|
+
let n = r, a = i, o = t === "out" || t === "cross" ? 4 : 0, s = t === "in" || t === "cross" ? -4 : 0;
|
|
66
|
+
e.moveTo(a, n + o), e.lineTo(a, n + s);
|
|
67
|
+
}
|
|
68
|
+
e.stroke(), e.strokeStyle = a;
|
|
69
|
+
}
|
|
70
|
+
function d(e, t, n) {
|
|
71
|
+
return e.titleFontSizeHpt ? e.titleFontSizeHpt / 100 * n : Math.max(10, t * .085);
|
|
72
|
+
}
|
|
73
|
+
function f(e, t, n) {
|
|
74
|
+
return e ? e / 100 * n : Math.max(8, t * .045);
|
|
75
|
+
}
|
|
76
|
+
function p(e, t, n, r, i, a) {
|
|
59
77
|
t && (e.font = `bold ${a}px sans-serif`, e.fillStyle = "#333", e.textAlign = "center", e.textBaseline = "top", e.fillText(t, n + i / 2, r));
|
|
60
78
|
}
|
|
61
|
-
function
|
|
79
|
+
function m(e) {
|
|
62
80
|
return e.categories.length > 0 ? e.categories : e.series[0]?.categories ?? [];
|
|
63
81
|
}
|
|
64
|
-
function
|
|
65
|
-
let { x: o, y:
|
|
82
|
+
function h(e, n, r) {
|
|
83
|
+
let { x: o, y: u, w: d, h: f } = r, h = n.chartType === "clusteredBarH" || n.chartType === "stackedBarH" || n.chartType === "stackedBarHPct", g = n.chartType.startsWith("stacked"), _ = n.chartType === "stackedBarPct" || n.chartType === "stackedBarHPct", v = n.series.filter((e) => e.seriesType !== "line"), y = n.series.filter((e) => e.seriesType === "line"), b = m(n), x = b.length;
|
|
66
84
|
if (x === 0) return;
|
|
67
|
-
let S = n.title ? Math.max(14,
|
|
68
|
-
t: S +
|
|
69
|
-
r: C +
|
|
70
|
-
b:
|
|
71
|
-
l:
|
|
85
|
+
let S = n.title ? Math.max(14, f * .06) : 0, C = n.showLegend ? Math.max(80, d * .22) : 0, w = Math.max(8, Math.min(10, f * .045)), T = n.catAxisTitle ? w + 4 : 0, E = n.valAxisTitle ? w + 4 : 0, D = {
|
|
86
|
+
t: S + f * .04,
|
|
87
|
+
r: C + d * .03,
|
|
88
|
+
b: f * .14 + T,
|
|
89
|
+
l: d * .12 + E
|
|
72
90
|
};
|
|
73
|
-
h && (D.l =
|
|
74
|
-
let O = o + D.l, k =
|
|
91
|
+
h && (D.l = d * .22 + E, D.b = f * .08 + T), p(e, n.title, o, u + 2, d, Math.max(11, S * .7));
|
|
92
|
+
let O = o + D.l, k = u + D.t, A = d - D.l - D.r, j = f - D.t - D.b;
|
|
75
93
|
if (A <= 0 || j <= 0) return;
|
|
76
94
|
n.plotAreaBg && (e.fillStyle = `#${n.plotAreaBg}`, e.fillRect(O, k, A, j));
|
|
77
95
|
let M = 0;
|
|
@@ -149,74 +167,77 @@ function f(e, n, r) {
|
|
|
149
167
|
e.fillStyle = i, e.beginPath(), e.arc(a, o, 3, 0, Math.PI * 2), e.fill();
|
|
150
168
|
}
|
|
151
169
|
}
|
|
152
|
-
C > 0 && l(e, n.series, o +
|
|
170
|
+
C > 0 && l(e, n.series, o + d - C + 4, k, C - 8, j), n.catAxisTitle && c(e, n.catAxisTitle, O, k, A, j, "cat", w), n.valAxisTitle && c(e, n.valAxisTitle, O, k, A, j, "val", w);
|
|
153
171
|
}
|
|
154
|
-
function
|
|
155
|
-
let { x:
|
|
156
|
-
if (
|
|
157
|
-
let
|
|
158
|
-
t:
|
|
159
|
-
r:
|
|
160
|
-
b:
|
|
161
|
-
l:
|
|
172
|
+
function g(e, n, r, h) {
|
|
173
|
+
let { x: g, y: _, w: v, h: y } = r, b = m(n), x = b.length;
|
|
174
|
+
if (x === 0) return;
|
|
175
|
+
let S = n.title ? d(n, y, h) : 0, C = n.title ? y * .045 : 0, w = n.title ? y * .035 : 0, T = n.title ? S + C + w : 0, E = n.showLegend ? Math.max(80, v * .22) : 0, D = f(n.catAxisFontSizeHpt, y, h), O = f(n.valAxisFontSizeHpt, y, h), k = Math.max(D, O), A = n.catAxisTitle ? k + 4 : 0, j = n.valAxisTitle ? k + 4 : 0, M = {
|
|
176
|
+
t: T + O / 2 + 2,
|
|
177
|
+
r: E + v * .05,
|
|
178
|
+
b: D + 12 + A,
|
|
179
|
+
l: O * 2.2 + 10 + j
|
|
162
180
|
};
|
|
163
|
-
|
|
164
|
-
let
|
|
165
|
-
if (
|
|
166
|
-
n.plotAreaBg && (e.fillStyle = `#${n.plotAreaBg}`, e.fillRect(
|
|
167
|
-
let
|
|
168
|
-
for (let e of n.series) for (let t of e.values) t != null && (
|
|
169
|
-
isFinite(
|
|
170
|
-
let
|
|
171
|
-
if (
|
|
172
|
-
let
|
|
181
|
+
p(e, n.title, g, _ + C, v, S);
|
|
182
|
+
let N = g + M.l, P = _ + M.t, F = v - M.l - M.r, I = y - M.t - M.b;
|
|
183
|
+
if (F <= 0 || I <= 0) return;
|
|
184
|
+
n.plotAreaBg && (e.fillStyle = `#${n.plotAreaBg}`, e.fillRect(N, P, F, I));
|
|
185
|
+
let L = Infinity, R = -Infinity;
|
|
186
|
+
for (let e of n.series) for (let t of e.values) t != null && (L = Math.min(L, t), R = Math.max(R, t));
|
|
187
|
+
isFinite(L) || (L = 0, R = 1), n.valMin == null ? L > 0 && (L = 0) : L = n.valMin, n.valMax == null ? R < 0 && (R = 0) : R = n.valMax, R === L && (R = L + 1);
|
|
188
|
+
let z = i(R - L), B = n.valMin ?? o(L, z), V = n.valMax ?? a(R, z), H = V - B;
|
|
189
|
+
if (H === 0) return;
|
|
190
|
+
let U = (e) => P + I - (e - B) / H * I, W = n.catAxisCrossBetween === "midCat" ? (e) => N + (x === 1 ? F / 2 : e / (x - 1) * F) : (e) => N + (e + .5) / x * F;
|
|
173
191
|
if (!n.valAxisHidden) {
|
|
174
|
-
let t = Math.round((
|
|
175
|
-
e.font = `${
|
|
176
|
-
for (let
|
|
177
|
-
let t =
|
|
178
|
-
e.strokeStyle = t === 0 ? "#aaa" : "#e0e0e0", e.lineWidth = t === 0 ? 1 : .5, e.beginPath(), e.moveTo(
|
|
192
|
+
let t = Math.round((V - B) / z);
|
|
193
|
+
e.font = `${O}px sans-serif`, e.textBaseline = "middle";
|
|
194
|
+
for (let r = 0; r <= t; r++) {
|
|
195
|
+
let t = B + r * z, i = U(t);
|
|
196
|
+
e.strokeStyle = t === 0 ? "#aaa" : "#e0e0e0", e.lineWidth = t === 0 ? 1 : .5, e.beginPath(), e.moveTo(N, i), e.lineTo(N + F, i), e.stroke(), u(e, n.valAxisMajorTickMark, "val", N, i), e.fillStyle = "#555", e.textAlign = "right", e.fillText(s(t), N - 6, i);
|
|
179
197
|
}
|
|
180
198
|
}
|
|
181
|
-
e.strokeStyle = "#aaa", e.lineWidth = 1, e.beginPath(), e.moveTo(
|
|
182
|
-
let
|
|
199
|
+
e.strokeStyle = "#aaa", e.lineWidth = 1, e.beginPath(), e.moveTo(N, P + I), e.lineTo(N + F, P + I), e.stroke(), n.valAxisHidden || (e.beginPath(), e.moveTo(N, P), e.lineTo(N, P + I), e.stroke());
|
|
200
|
+
let G = Math.max(1, 2.25 * h), K = Math.max(2, 2.5 * h), q = f(n.dataLabelFontSizeHpt, y, h);
|
|
183
201
|
for (let r = 0; r < n.series.length; r++) {
|
|
184
202
|
let i = n.series[r], a = t(r, i);
|
|
185
|
-
e.strokeStyle = a, e.lineWidth =
|
|
203
|
+
e.strokeStyle = a, e.lineWidth = G, e.setLineDash([]), e.beginPath();
|
|
186
204
|
let o = !1;
|
|
187
|
-
for (let t = 0; t <
|
|
205
|
+
for (let t = 0; t < x; t++) {
|
|
188
206
|
let n = i.values[t];
|
|
189
207
|
if (n == null) {
|
|
190
208
|
o = !1;
|
|
191
209
|
continue;
|
|
192
210
|
}
|
|
193
|
-
let r =
|
|
211
|
+
let r = W(t), a = U(n);
|
|
194
212
|
o ? e.lineTo(r, a) : (e.moveTo(r, a), o = !0);
|
|
195
213
|
}
|
|
196
214
|
e.stroke(), e.fillStyle = a;
|
|
197
|
-
for (let t = 0; t <
|
|
215
|
+
for (let t = 0; t < x; t++) {
|
|
198
216
|
let r = i.values[t];
|
|
199
|
-
r != null && (e.beginPath(), e.arc(
|
|
217
|
+
r != null && (e.beginPath(), e.arc(W(t), U(r), K, 0, Math.PI * 2), e.fill(), n.showDataLabels && (e.font = `${q}px sans-serif`, e.fillStyle = "#333", e.textAlign = "center", e.textBaseline = "bottom", e.fillText(s(r), W(t), U(r) - K - 1), e.fillStyle = a));
|
|
200
218
|
}
|
|
201
219
|
}
|
|
202
220
|
if (!n.catAxisHidden) {
|
|
203
|
-
let t = Math.max(1, Math.ceil(
|
|
204
|
-
e.fillStyle = "#555", e.textAlign = "center", e.textBaseline = "top", e.font = `${
|
|
205
|
-
for (let
|
|
221
|
+
let t = Math.max(1, Math.ceil(x / 8));
|
|
222
|
+
e.fillStyle = "#555", e.textAlign = "center", e.textBaseline = "top", e.font = `${D}px sans-serif`;
|
|
223
|
+
for (let r = 0; r < x; r += t) {
|
|
224
|
+
let t = W(r);
|
|
225
|
+
u(e, n.catAxisMajorTickMark, "cat", P + I, t), e.fillStyle = "#555", e.fillText((b[r] ?? "").toString().slice(0, 10), t, P + I + 5);
|
|
226
|
+
}
|
|
206
227
|
}
|
|
207
|
-
|
|
228
|
+
E > 0 && l(e, n.series, g + v - E + 4, P, E - 8, I), n.catAxisTitle && c(e, n.catAxisTitle, N, P, F, I, "cat", k), n.valAxisTitle && c(e, n.valAxisTitle, N, P, F, I, "val", k);
|
|
208
229
|
}
|
|
209
|
-
function
|
|
210
|
-
let { x:
|
|
230
|
+
function _(e, n, o) {
|
|
231
|
+
let { x: u, y: d, w: f, h } = o, g = m(n), _ = g.length;
|
|
211
232
|
if (_ === 0) return;
|
|
212
|
-
let v = n.chartType === "stackedArea" || n.chartType === "stackedAreaPct", y = n.title ? Math.max(14, h * .06) : 0, b = n.
|
|
233
|
+
let v = n.chartType === "stackedArea" || n.chartType === "stackedAreaPct", y = n.title ? Math.max(14, h * .06) : 0, b = n.showLegend ? Math.max(80, f * .22) : 0, x = Math.max(8, Math.min(10, h * .045)), S = n.catAxisTitle ? x + 4 : 0, C = n.valAxisTitle ? x + 4 : 0, w = {
|
|
213
234
|
t: y + h * .04,
|
|
214
|
-
r: b +
|
|
235
|
+
r: b + f * .05,
|
|
215
236
|
b: h * .14 + S,
|
|
216
|
-
l:
|
|
237
|
+
l: f * .12 + C
|
|
217
238
|
};
|
|
218
|
-
|
|
219
|
-
let T =
|
|
239
|
+
p(e, n.title, u, d + 2, f, Math.max(11, y * .7));
|
|
240
|
+
let T = u + w.l, E = d + w.t, D = f - w.l - w.r, O = h - w.t - w.b;
|
|
220
241
|
if (D <= 0 || O <= 0) return;
|
|
221
242
|
n.plotAreaBg && (e.fillStyle = `#${n.plotAreaBg}`, e.fillRect(T, E, D, O));
|
|
222
243
|
let k = 0;
|
|
@@ -258,36 +279,36 @@ function m(e, n, o) {
|
|
|
258
279
|
e.fillStyle = "#555", e.textAlign = "center", e.textBaseline = "top", e.font = `${Math.max(8, Math.min(11, D / _ * .8))}px sans-serif`;
|
|
259
280
|
for (let n = 0; n < _; n += t) e.fillText((g[n] ?? "").toString().slice(0, 10), M(n), E + O + 3);
|
|
260
281
|
}
|
|
261
|
-
b > 0 && l(e, n.series,
|
|
282
|
+
b > 0 && l(e, n.series, u + f - b + 4, E, b - 8, O), n.catAxisTitle && c(e, n.catAxisTitle, T, E, D, O, "cat", x), n.valAxisTitle && c(e, n.valAxisTitle, T, E, D, O, "val", x);
|
|
262
283
|
}
|
|
263
|
-
function
|
|
284
|
+
function v(e, t, r, i) {
|
|
264
285
|
let { x: a, y: o, w: s, h: c } = r, l = t.series[0];
|
|
265
286
|
if (!l) return;
|
|
266
|
-
let
|
|
267
|
-
if (
|
|
287
|
+
let u = l.categories && l.categories.length > 0 ? l.categories : t.categories, d = l.values.map((e) => Math.abs(e ?? 0)), f = d.reduce((e, t) => e + t, 0);
|
|
288
|
+
if (f === 0) return;
|
|
268
289
|
let m = t.title ? Math.max(14, c * .06) : 0;
|
|
269
|
-
|
|
270
|
-
let h = s - Math.max(80, s * .28), g = c - m - c * .04, _ = a + h / 2, v = o + m + c * .04 + g / 2, y = Math.min(h, g) * .42, b = i ? y * .5 : 0, x = -Math.PI / 2;
|
|
271
|
-
for (let r = 0; r <
|
|
272
|
-
let a =
|
|
290
|
+
p(e, t.title, a, o + 2, s, Math.max(11, m * .7));
|
|
291
|
+
let h = s - (t.showLegend ? Math.max(80, s * .28) : 0), g = c - m - c * .04, _ = a + h / 2, v = o + m + c * .04 + g / 2, y = Math.min(h, g) * .42, b = i ? y * .5 : 0, x = -Math.PI / 2;
|
|
292
|
+
for (let r = 0; r < d.length; r++) {
|
|
293
|
+
let a = d[r] / f * Math.PI * 2, o = n(r, l);
|
|
273
294
|
if (e.beginPath(), e.moveTo(_, v), e.arc(_, v, y, x, x + a), e.closePath(), e.fillStyle = o, e.fill(), e.strokeStyle = "#fff", e.lineWidth = 1, e.stroke(), t.showDataLabels && a > .15) {
|
|
274
|
-
let t = x + a / 2, n = y * (i ? .75 : .6), o = _ + Math.cos(t) * n, s = v + Math.sin(t) * n, c = Math.round(
|
|
295
|
+
let t = x + a / 2, n = y * (i ? .75 : .6), o = _ + Math.cos(t) * n, s = v + Math.sin(t) * n, c = Math.round(d[r] / f * 100);
|
|
275
296
|
e.font = `bold ${Math.max(8, y * .1)}px sans-serif`, e.fillStyle = "#fff", e.textAlign = "center", e.textBaseline = "middle", e.fillText(`${c}%`, o, s);
|
|
276
297
|
}
|
|
277
298
|
x += a;
|
|
278
299
|
}
|
|
279
300
|
i && (e.beginPath(), e.arc(_, v, b, 0, Math.PI * 2), e.fillStyle = "#fff", e.fill());
|
|
280
|
-
let S = a + h + 4, C = Math.max(9, Math.min(12, c / (
|
|
301
|
+
let S = a + h + 4, C = Math.max(9, Math.min(12, c / (d.length + 2)));
|
|
281
302
|
e.font = `${C}px sans-serif`, e.textBaseline = "middle";
|
|
282
|
-
let w = C + 4, T = o + (c - w *
|
|
283
|
-
for (let t = 0; t <
|
|
303
|
+
let w = C + 4, T = o + (c - w * d.length) / 2;
|
|
304
|
+
for (let t = 0; t < d.length; t++) e.fillStyle = n(t, l), e.fillRect(S, T, 10, C), e.fillStyle = "#333", e.textAlign = "left", e.fillText((u[t] ?? `Item ${t + 1}`).toString().slice(0, 18), S + 14, T + C / 2), T += w;
|
|
284
305
|
}
|
|
285
|
-
function
|
|
286
|
-
let { x: s, y: c, w:
|
|
306
|
+
function y(e, n, o) {
|
|
307
|
+
let { x: s, y: c, w: u, h: d } = o, f = m(n), h = f.length;
|
|
287
308
|
if (h < 3) return;
|
|
288
|
-
let g = n.title ? Math.max(14,
|
|
289
|
-
|
|
290
|
-
let v =
|
|
309
|
+
let g = n.title ? Math.max(14, d * .06) : 0, _ = n.showLegend ? Math.max(70, u * .2) : 0;
|
|
310
|
+
p(e, n.title, s, c + 2, u, Math.max(11, g * .7));
|
|
311
|
+
let v = u - _, y = d - g - d * .04, b = s + v / 2, x = c + g + d * .04 + y / 2, S = Math.min(v, y) * .38, C = 0;
|
|
291
312
|
for (let e of n.series) for (let t of e.values) C = Math.max(C, t ?? 0);
|
|
292
313
|
n.valMax != null && (C = n.valMax), C === 0 && (C = 1);
|
|
293
314
|
let w = i(C), T = n.valMax ?? a(C, w), E = -Math.PI / 2, D = (e) => E + e / h * Math.PI * 2, O = Math.round(T / w);
|
|
@@ -309,7 +330,7 @@ function g(e, n, o) {
|
|
|
309
330
|
e.font = `${Math.max(8, Math.min(11, S * .2))}px sans-serif`, e.fillStyle = "#444", e.textBaseline = "middle";
|
|
310
331
|
for (let t = 0; t < h; t++) {
|
|
311
332
|
let n = D(t), r = b + Math.cos(n) * (S + 12), i = x + Math.sin(n) * (S + 12);
|
|
312
|
-
e.textAlign = Math.cos(n) < -.1 ? "right" : Math.cos(n) > .1 ? "left" : "center", e.fillText((
|
|
333
|
+
e.textAlign = Math.cos(n) < -.1 ? "right" : Math.cos(n) > .1 ? "left" : "center", e.fillText((f[t] ?? "").toString().slice(0, 12), r, i);
|
|
313
334
|
}
|
|
314
335
|
for (let i = 0; i < n.series.length; i++) {
|
|
315
336
|
let a = n.series[i], o = t(i, a);
|
|
@@ -320,17 +341,17 @@ function g(e, n, o) {
|
|
|
320
341
|
}
|
|
321
342
|
e.closePath(), e.fillStyle = r(o, .25), e.fill(), e.strokeStyle = o, e.lineWidth = 2, e.stroke();
|
|
322
343
|
}
|
|
323
|
-
_ > 0 && l(e, n.series, s +
|
|
344
|
+
_ > 0 && l(e, n.series, s + u - _ + 4, c + g + d * .04, _ - 8, y);
|
|
324
345
|
}
|
|
325
|
-
function
|
|
326
|
-
let { x: a, y: o, w:
|
|
327
|
-
t:
|
|
328
|
-
r: m +
|
|
329
|
-
b:
|
|
330
|
-
l:
|
|
346
|
+
function b(e, n, r) {
|
|
347
|
+
let { x: a, y: o, w: u, h: d } = r, f = n.title ? Math.max(14, d * .06) : 0, m = n.showLegend ? Math.max(80, u * .22) : 0, h = Math.max(8, Math.min(10, d * .045)), g = n.catAxisTitle ? h + 4 : 0, _ = n.valAxisTitle ? h + 4 : 0, v = {
|
|
348
|
+
t: f + d * .06,
|
|
349
|
+
r: m + u * .05,
|
|
350
|
+
b: d * .12 + g,
|
|
351
|
+
l: u * .12 + _
|
|
331
352
|
};
|
|
332
|
-
|
|
333
|
-
let y = a + v.l, b = o + v.t, x =
|
|
353
|
+
p(e, n.title, a, o + 2, u, Math.max(11, f * .7));
|
|
354
|
+
let y = a + v.l, b = o + v.t, x = u - v.l - v.r, S = d - v.t - v.b;
|
|
334
355
|
if (x <= 0 || S <= 0) return;
|
|
335
356
|
n.plotAreaBg && (e.fillStyle = `#${n.plotAreaBg}`, e.fillRect(y, b, x, S));
|
|
336
357
|
let C = [], w = [];
|
|
@@ -373,9 +394,9 @@ function _(e, n, r) {
|
|
|
373
394
|
isNaN(r) || (e.beginPath(), e.arc(A(r), j(n), M, 0, Math.PI * 2), e.fill());
|
|
374
395
|
}
|
|
375
396
|
}
|
|
376
|
-
m > 0 && l(e, n.series, a +
|
|
397
|
+
m > 0 && l(e, n.series, a + u - m + 4, b, m - 8, S), n.catAxisTitle && c(e, n.catAxisTitle, y, b, x, S, "cat", h), n.valAxisTitle && c(e, n.valAxisTitle, y, b, x, S, "val", h);
|
|
377
398
|
}
|
|
378
|
-
function
|
|
399
|
+
function x(e, t, n) {
|
|
379
400
|
let { x: r, y: a, w: o, h: s } = n, c = o * .11, l = o * .04, u = s * .08, d = s * .18, f = r + c, p = a + u, m = o - c - l, h = s - u - d, g = t.series[0]?.values ?? [], _ = t.categories, v = _.length;
|
|
380
401
|
if (v === 0) return;
|
|
381
402
|
let y = new Set(t.subtotalIndices), b = 0, x = [];
|
|
@@ -425,10 +446,10 @@ function v(e, t, n) {
|
|
|
425
446
|
}
|
|
426
447
|
e.restore();
|
|
427
448
|
}
|
|
428
|
-
function
|
|
429
|
-
let { x:
|
|
430
|
-
if (
|
|
431
|
-
e.fillStyle = "#888", e.font = "12px sans-serif", e.textAlign = "center", e.textBaseline = "middle", e.fillText("(no data)",
|
|
449
|
+
function S(e, t, n, r = 1.333) {
|
|
450
|
+
let { x: i, y: a, w: o, h: s } = n;
|
|
451
|
+
if (t.chartBg && (e.fillStyle = `#${t.chartBg}`, e.fillRect(i, a, o, s)), t.series.length === 0) {
|
|
452
|
+
e.fillStyle = "#888", e.font = "12px sans-serif", e.textAlign = "center", e.textBaseline = "middle", e.fillText("(no data)", i + o / 2, a + s / 2);
|
|
432
453
|
return;
|
|
433
454
|
}
|
|
434
455
|
switch (t.chartType) {
|
|
@@ -438,36 +459,36 @@ function y(e, t, n) {
|
|
|
438
459
|
case "stackedBarH":
|
|
439
460
|
case "stackedBarPct":
|
|
440
461
|
case "stackedBarHPct":
|
|
441
|
-
|
|
462
|
+
h(e, t, n);
|
|
442
463
|
break;
|
|
443
464
|
case "line":
|
|
444
465
|
case "stackedLine":
|
|
445
466
|
case "stackedLinePct":
|
|
446
|
-
|
|
467
|
+
g(e, t, n, r);
|
|
447
468
|
break;
|
|
448
469
|
case "area":
|
|
449
470
|
case "stackedArea":
|
|
450
471
|
case "stackedAreaPct":
|
|
451
|
-
|
|
472
|
+
_(e, t, n);
|
|
452
473
|
break;
|
|
453
474
|
case "pie":
|
|
454
|
-
|
|
475
|
+
v(e, t, n, !1);
|
|
455
476
|
break;
|
|
456
477
|
case "doughnut":
|
|
457
|
-
|
|
478
|
+
v(e, t, n, !0);
|
|
458
479
|
break;
|
|
459
480
|
case "radar":
|
|
460
|
-
|
|
481
|
+
y(e, t, n);
|
|
461
482
|
break;
|
|
462
483
|
case "scatter":
|
|
463
484
|
case "bubble":
|
|
464
|
-
|
|
485
|
+
b(e, t, n);
|
|
465
486
|
break;
|
|
466
487
|
case "waterfall":
|
|
467
|
-
|
|
488
|
+
x(e, t, n);
|
|
468
489
|
break;
|
|
469
|
-
default: e.fillStyle = "#888", e.font = "11px sans-serif", e.textAlign = "center", e.textBaseline = "middle", e.fillText(`Chart: ${t.chartType}`,
|
|
490
|
+
default: e.fillStyle = "#888", e.font = "11px sans-serif", e.textAlign = "center", e.textBaseline = "middle", e.fillText(`Chart: ${t.chartType}`, i + o / 2, a + s / 2);
|
|
470
491
|
}
|
|
471
492
|
}
|
|
472
493
|
//#endregion
|
|
473
|
-
export {
|
|
494
|
+
export { S as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=[`4472C4`,`ED7D31`,`A9D18E`,`FF0000`,`70AD47`,`4BACC6`,`FFC000`,`9E480E`,`843C0C`,`636363`,`255E91`,`967300`];function t(t,n){return n?.color?`#${n.color}`:`#${e[t%e.length]}`}function n(t,n){let r=n.dataPointColors?.[t];return r?`#${r}`:`#${e[t%e.length]}`}function r(e,t){let n=e.startsWith(`#`)?e.slice(1):e;return`rgba(${parseInt(n.slice(0,2),16)},${parseInt(n.slice(2,4),16)},${parseInt(n.slice(4,6),16)},${t})`}function i(e,t=5){if(e===0)return 1;let n=e/t,r=10**Math.floor(Math.log10(n)),i=n/r;return(i<1.5?1:i<3.5?2:i<7.5?5:10)*r}function a(e,t){if(e<=0)return t;let n=Math.ceil(e/t)*t;return Math.abs(n-e)<t*1e-9?n+t:n}function o(e,t){if(e>=0)return 0;let n=Math.floor(e/t)*t;return Math.abs(n-e)<t*1e-9?n-t:n}function s(e){return Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}k`:Number.isInteger(e)?String(e):e.toFixed(2).replace(/\.?0+$/,``)}function c(e,t,n,r,i,a,o,s){e.save(),e.font=`${s}px sans-serif`,e.fillStyle=`#555`,o===`cat`?(e.textAlign=`center`,e.textBaseline=`bottom`,e.fillText(t.slice(0,30),n+i/2,r+a+s+2)):(e.translate(n-s-4,r+a/2),e.rotate(-Math.PI/2),e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(t.slice(0,30),0,0)),e.restore()}function l(e,n,r,i,a,o){let s=Math.max(9,Math.min(12,o/(n.length+1)));e.font=`${s}px sans-serif`,e.textBaseline=`middle`;let c=s+4,l=i+(o-c*n.length)/2;for(let i=0;i<n.length;i++){e.fillStyle=t(i,n[i]),e.fillRect(r,l,10,s),e.fillStyle=`#333`,e.textAlign=`left`;let a=n[i].name||`Series ${i+1}`;e.fillText(a.slice(0,20),r+10+4,l+s/2),l+=c}}function u(e,t,n,r,i){if(t===`none`||!t)return;let a=e.strokeStyle;if(e.strokeStyle=`#888`,e.lineWidth=1,e.beginPath(),n===`val`){let n=r,a=i,o=t===`out`||t===`cross`?-4:0,s=t===`in`||t===`cross`?4:0;e.moveTo(n+o,a),e.lineTo(n+s,a)}else{let n=r,a=i,o=t===`out`||t===`cross`?4:0,s=t===`in`||t===`cross`?-4:0;e.moveTo(a,n+o),e.lineTo(a,n+s)}e.stroke(),e.strokeStyle=a}function d(e,t,n){return e.titleFontSizeHpt?e.titleFontSizeHpt/100*n:Math.max(10,t*.085)}function f(e,t,n){return e?e/100*n:Math.max(8,t*.045)}function p(e,t,n,r,i,a){t&&(e.font=`bold ${a}px sans-serif`,e.fillStyle=`#333`,e.textAlign=`center`,e.textBaseline=`top`,e.fillText(t,n+i/2,r))}function m(e){return e.categories.length>0?e.categories:e.series[0]?.categories??[]}function h(e,n,r){let{x:o,y:u,w:d,h:f}=r,h=n.chartType===`clusteredBarH`||n.chartType===`stackedBarH`||n.chartType===`stackedBarHPct`,g=n.chartType.startsWith(`stacked`),_=n.chartType===`stackedBarPct`||n.chartType===`stackedBarHPct`,v=n.series.filter(e=>e.seriesType!==`line`),y=n.series.filter(e=>e.seriesType===`line`),b=m(n),x=b.length;if(x===0)return;let S=n.title?Math.max(14,f*.06):0,C=n.showLegend?Math.max(80,d*.22):0,w=Math.max(8,Math.min(10,f*.045)),T=n.catAxisTitle?w+4:0,E=n.valAxisTitle?w+4:0,D={t:S+f*.04,r:C+d*.03,b:f*.14+T,l:d*.12+E};h&&(D.l=d*.22+E,D.b=f*.08+T),p(e,n.title,o,u+2,d,Math.max(11,S*.7));let O=o+D.l,k=u+D.t,A=d-D.l-D.r,j=f-D.t-D.b;if(A<=0||j<=0)return;n.plotAreaBg&&(e.fillStyle=`#${n.plotAreaBg}`,e.fillRect(O,k,A,j));let M=0;for(let e=0;e<x;e++){let t=0;for(let n of v){let r=n.values[e]??0;g?t+=Math.abs(r):M=Math.max(M,Math.abs(r))}g&&(M=Math.max(M,t))}_&&(M=100),n.valMax!=null&&(M=n.valMax),M===0&&(M=1);let N=i(M),P=n.valMax??a(M,N),F=`#e0e0e0`,I=Math.round(P/N);if(e.textBaseline=`middle`,e.font=`${Math.max(8,Math.min(11,j/20))}px sans-serif`,e.fillStyle=`#555`,!n.valAxisHidden)for(let t=0;t<=I;t++){let n=t*N,r=_?`${Math.round(n)}%`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n);if(h){let i=O+n/P*A;e.strokeStyle=t===0?`#aaa`:F,e.lineWidth=t===0?1:.5,e.beginPath(),e.moveTo(i,k),e.lineTo(i,k+j),e.stroke(),e.textAlign=`center`,e.fillText(r,i,k+j+10)}else{let i=k+j-n/P*j;e.strokeStyle=t===0?`#aaa`:F,e.lineWidth=t===0?1:.5,e.beginPath(),e.moveTo(O,i),e.lineTo(O+A,i),e.stroke(),e.textAlign=`right`,e.fillText(r,O-4,i)}}e.strokeStyle=`#aaa`,e.lineWidth=1,h?(e.beginPath(),e.moveTo(O,k),e.lineTo(O,k+j),e.stroke()):(e.beginPath(),e.moveTo(O,k+j),e.lineTo(O+A,k+j),e.stroke());let L=h?j/x:A/x,R=L*(g?.6:.6/Math.max(1,v.length)),z=g?0:L*.6/Math.max(1,v.length),B=L*.2;for(let r=0;r<x;r++){let i=0,a=0;if(_){for(let e of v)a+=Math.abs(e.values[r]??0);a===0&&(a=1)}for(let o=0;o<v.length;o++){let c=v[o],l=c.values[r]??0,u=_?Math.abs(l)/a*100:Math.abs(l),d=t(o,c);if(h){let t=g?k+(x-1-r)*L+B:k+(x-1-r)*L+B+o*z,a=u/P*A,c=g?O+i/P*A:O;e.fillStyle=d,e.fillRect(c,t,a,R),n.showDataLabels&&u>0&&(e.font=`bold ${Math.max(7,Math.min(10,R*.7))}px sans-serif`,e.fillStyle=`#333`,e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(_?`${Math.round(u)}%`:s(u),c+a+2,t+R/2))}else{let t=g?O+r*L+B:O+r*L+B+o*z,a=u/P*j,c=k+j-(g?i+u:u)/P*j;e.fillStyle=d,e.fillRect(t,c,R,a),n.showDataLabels&&u>0&&(e.font=`bold ${Math.max(7,Math.min(10,R*.7))}px sans-serif`,e.fillStyle=`#333`,e.textAlign=`center`,e.textBaseline=`bottom`,e.fillText(_?`${Math.round(u)}%`:s(u),t+R/2,c-1))}g&&(i+=u)}}if(!n.catAxisHidden){e.fillStyle=`#555`,e.font=`${Math.max(8,Math.min(11,L*.5))}px sans-serif`;for(let t=0;t<x;t++){let n=(b[t]??``).toString().slice(0,12);if(h){let r=k+(x-1-t)*L+L/2;e.textAlign=`right`,e.textBaseline=`middle`,e.fillText(n,O-4,r)}else{let r=O+t*L+L/2;e.textAlign=`center`,e.textBaseline=`top`,e.fillText(n,r,k+j+3)}}}if(y.length>0&&!h)for(let n=0;n<y.length;n++){let r=y[n],i=t(v.length+n,r);e.strokeStyle=i,e.lineWidth=2,e.setLineDash([]),e.beginPath();let a=!1;for(let t=0;t<x;t++){let n=r.values[t];if(n==null){a=!1;continue}let i=O+t*L+L/2,o=k+j-n/P*j;a?e.lineTo(i,o):(e.moveTo(i,o),a=!0)}e.stroke();for(let t=0;t<x;t++){let n=r.values[t];if(n==null)continue;let a=O+t*L+L/2,o=k+j-n/P*j;e.fillStyle=i,e.beginPath(),e.arc(a,o,3,0,Math.PI*2),e.fill()}}C>0&&l(e,n.series,o+d-C+4,k,C-8,j),n.catAxisTitle&&c(e,n.catAxisTitle,O,k,A,j,`cat`,w),n.valAxisTitle&&c(e,n.valAxisTitle,O,k,A,j,`val`,w)}function g(e,n,r,h){let{x:g,y:_,w:v,h:y}=r,b=m(n),x=b.length;if(x===0)return;let S=n.title?d(n,y,h):0,C=n.title?y*.045:0,w=n.title?y*.035:0,T=n.title?S+C+w:0,E=n.showLegend?Math.max(80,v*.22):0,D=f(n.catAxisFontSizeHpt,y,h),O=f(n.valAxisFontSizeHpt,y,h),k=Math.max(D,O),A=n.catAxisTitle?k+4:0,j=n.valAxisTitle?k+4:0,M={t:T+O/2+2,r:E+v*.05,b:D+12+A,l:O*2.2+10+j};p(e,n.title,g,_+C,v,S);let N=g+M.l,P=_+M.t,F=v-M.l-M.r,I=y-M.t-M.b;if(F<=0||I<=0)return;n.plotAreaBg&&(e.fillStyle=`#${n.plotAreaBg}`,e.fillRect(N,P,F,I));let L=1/0,R=-1/0;for(let e of n.series)for(let t of e.values)t!=null&&(L=Math.min(L,t),R=Math.max(R,t));isFinite(L)||(L=0,R=1),n.valMin==null?L>0&&(L=0):L=n.valMin,n.valMax==null?R<0&&(R=0):R=n.valMax,R===L&&(R=L+1);let z=i(R-L),B=n.valMin??o(L,z),V=n.valMax??a(R,z),H=V-B;if(H===0)return;let U=e=>P+I-(e-B)/H*I,W=n.catAxisCrossBetween===`midCat`?e=>N+(x===1?F/2:e/(x-1)*F):e=>N+(e+.5)/x*F;if(!n.valAxisHidden){let t=Math.round((V-B)/z);e.font=`${O}px sans-serif`,e.textBaseline=`middle`;for(let r=0;r<=t;r++){let t=B+r*z,i=U(t);e.strokeStyle=t===0?`#aaa`:`#e0e0e0`,e.lineWidth=t===0?1:.5,e.beginPath(),e.moveTo(N,i),e.lineTo(N+F,i),e.stroke(),u(e,n.valAxisMajorTickMark,`val`,N,i),e.fillStyle=`#555`,e.textAlign=`right`,e.fillText(s(t),N-6,i)}}e.strokeStyle=`#aaa`,e.lineWidth=1,e.beginPath(),e.moveTo(N,P+I),e.lineTo(N+F,P+I),e.stroke(),n.valAxisHidden||(e.beginPath(),e.moveTo(N,P),e.lineTo(N,P+I),e.stroke());let G=Math.max(1,2.25*h),K=Math.max(2,2.5*h),q=f(n.dataLabelFontSizeHpt,y,h);for(let r=0;r<n.series.length;r++){let i=n.series[r],a=t(r,i);e.strokeStyle=a,e.lineWidth=G,e.setLineDash([]),e.beginPath();let o=!1;for(let t=0;t<x;t++){let n=i.values[t];if(n==null){o=!1;continue}let r=W(t),a=U(n);o?e.lineTo(r,a):(e.moveTo(r,a),o=!0)}e.stroke(),e.fillStyle=a;for(let t=0;t<x;t++){let r=i.values[t];r!=null&&(e.beginPath(),e.arc(W(t),U(r),K,0,Math.PI*2),e.fill(),n.showDataLabels&&(e.font=`${q}px sans-serif`,e.fillStyle=`#333`,e.textAlign=`center`,e.textBaseline=`bottom`,e.fillText(s(r),W(t),U(r)-K-1),e.fillStyle=a))}}if(!n.catAxisHidden){let t=Math.max(1,Math.ceil(x/8));e.fillStyle=`#555`,e.textAlign=`center`,e.textBaseline=`top`,e.font=`${D}px sans-serif`;for(let r=0;r<x;r+=t){let t=W(r);u(e,n.catAxisMajorTickMark,`cat`,P+I,t),e.fillStyle=`#555`,e.fillText((b[r]??``).toString().slice(0,10),t,P+I+5)}}E>0&&l(e,n.series,g+v-E+4,P,E-8,I),n.catAxisTitle&&c(e,n.catAxisTitle,N,P,F,I,`cat`,k),n.valAxisTitle&&c(e,n.valAxisTitle,N,P,F,I,`val`,k)}function _(e,n,o){let{x:u,y:d,w:f,h}=o,g=m(n),_=g.length;if(_===0)return;let v=n.chartType===`stackedArea`||n.chartType===`stackedAreaPct`,y=n.title?Math.max(14,h*.06):0,b=n.showLegend?Math.max(80,f*.22):0,x=Math.max(8,Math.min(10,h*.045)),S=n.catAxisTitle?x+4:0,C=n.valAxisTitle?x+4:0,w={t:y+h*.04,r:b+f*.05,b:h*.14+S,l:f*.12+C};p(e,n.title,u,d+2,f,Math.max(11,y*.7));let T=u+w.l,E=d+w.t,D=f-w.l-w.r,O=h-w.t-w.b;if(D<=0||O<=0)return;n.plotAreaBg&&(e.fillStyle=`#${n.plotAreaBg}`,e.fillRect(T,E,D,O));let k=0;for(let e=0;e<_;e++)if(v){let t=0;for(let r of n.series)t+=r.values[e]??0;k=Math.max(k,t)}else for(let t of n.series)k=Math.max(k,t.values[e]??0);n.valMax!=null&&(k=n.valMax),k===0&&(k=1);let A=i(k),j=n.valMax??a(k,A),M=e=>T+(_===1?D/2:e/(_-1)*D),N=e=>E+O-e/j*O;if(!n.valAxisHidden){e.font=`${Math.max(8,Math.min(11,O/20))}px sans-serif`,e.textBaseline=`middle`;let t=Math.round(j/A);for(let n=0;n<=t;n++){let t=n*A,r=N(t);e.strokeStyle=n===0?`#aaa`:`#e0e0e0`,e.lineWidth=n===0?1:.5,e.beginPath(),e.moveTo(T,r),e.lineTo(T+D,r),e.stroke(),e.fillStyle=`#555`,e.textAlign=`right`,e.fillText(s(t),T-4,r)}}e.strokeStyle=`#aaa`,e.lineWidth=1,e.beginPath(),e.moveTo(T,E+O),e.lineTo(T+D,E+O),e.stroke();let P=v?Array(_).fill(0):null;for(let i=n.series.length-1;i>=0;i--){let a=n.series[i],o=t(i,a),s=E+O;if(e.beginPath(),v&&P){for(let t=0;t<_;t++){let n=(a.values[t]??0)+P[t],r=M(t),i=N(n);t===0?e.moveTo(r,i):e.lineTo(r,i)}for(let t=_-1;t>=0;t--)e.lineTo(M(t),N(P[t]));for(let e=0;e<_;e++)P[e]+=a.values[e]??0}else{e.moveTo(M(0),s);for(let t=0;t<_;t++)e.lineTo(M(t),N(a.values[t]??0));e.lineTo(M(_-1),s)}e.closePath(),e.fillStyle=r(o,.6),e.fill(),e.strokeStyle=o,e.lineWidth=1.5,e.setLineDash([]),e.stroke()}if(!n.catAxisHidden){let t=Math.max(1,Math.ceil(_/8));e.fillStyle=`#555`,e.textAlign=`center`,e.textBaseline=`top`,e.font=`${Math.max(8,Math.min(11,D/_*.8))}px sans-serif`;for(let n=0;n<_;n+=t)e.fillText((g[n]??``).toString().slice(0,10),M(n),E+O+3)}b>0&&l(e,n.series,u+f-b+4,E,b-8,O),n.catAxisTitle&&c(e,n.catAxisTitle,T,E,D,O,`cat`,x),n.valAxisTitle&&c(e,n.valAxisTitle,T,E,D,O,`val`,x)}function v(e,t,r,i){let{x:a,y:o,w:s,h:c}=r,l=t.series[0];if(!l)return;let u=l.categories&&l.categories.length>0?l.categories:t.categories,d=l.values.map(e=>Math.abs(e??0)),f=d.reduce((e,t)=>e+t,0);if(f===0)return;let m=t.title?Math.max(14,c*.06):0;p(e,t.title,a,o+2,s,Math.max(11,m*.7));let h=s-(t.showLegend?Math.max(80,s*.28):0),g=c-m-c*.04,_=a+h/2,v=o+m+c*.04+g/2,y=Math.min(h,g)*.42,b=i?y*.5:0,x=-Math.PI/2;for(let r=0;r<d.length;r++){let a=d[r]/f*Math.PI*2,o=n(r,l);if(e.beginPath(),e.moveTo(_,v),e.arc(_,v,y,x,x+a),e.closePath(),e.fillStyle=o,e.fill(),e.strokeStyle=`#fff`,e.lineWidth=1,e.stroke(),t.showDataLabels&&a>.15){let t=x+a/2,n=y*(i?.75:.6),o=_+Math.cos(t)*n,s=v+Math.sin(t)*n,c=Math.round(d[r]/f*100);e.font=`bold ${Math.max(8,y*.1)}px sans-serif`,e.fillStyle=`#fff`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(`${c}%`,o,s)}x+=a}i&&(e.beginPath(),e.arc(_,v,b,0,Math.PI*2),e.fillStyle=`#fff`,e.fill());let S=a+h+4,C=Math.max(9,Math.min(12,c/(d.length+2)));e.font=`${C}px sans-serif`,e.textBaseline=`middle`;let w=C+4,T=o+(c-w*d.length)/2;for(let t=0;t<d.length;t++)e.fillStyle=n(t,l),e.fillRect(S,T,10,C),e.fillStyle=`#333`,e.textAlign=`left`,e.fillText((u[t]??`Item ${t+1}`).toString().slice(0,18),S+14,T+C/2),T+=w}function y(e,n,o){let{x:s,y:c,w:u,h:d}=o,f=m(n),h=f.length;if(h<3)return;let g=n.title?Math.max(14,d*.06):0,_=n.showLegend?Math.max(70,u*.2):0;p(e,n.title,s,c+2,u,Math.max(11,g*.7));let v=u-_,y=d-g-d*.04,b=s+v/2,x=c+g+d*.04+y/2,S=Math.min(v,y)*.38,C=0;for(let e of n.series)for(let t of e.values)C=Math.max(C,t??0);n.valMax!=null&&(C=n.valMax),C===0&&(C=1);let w=i(C),T=n.valMax??a(C,w),E=-Math.PI/2,D=e=>E+e/h*Math.PI*2,O=Math.round(T/w);e.strokeStyle=`#ddd`,e.lineWidth=.5;for(let t=1;t<=O;t++){let n=t/O*S;e.beginPath();for(let t=0;t<h;t++){let r=D(t),i=b+Math.cos(r)*n,a=x+Math.sin(r)*n;t===0?e.moveTo(i,a):e.lineTo(i,a)}e.closePath(),e.stroke()}e.strokeStyle=`#bbb`,e.lineWidth=.5;for(let t=0;t<h;t++){let n=D(t);e.beginPath(),e.moveTo(b,x),e.lineTo(b+Math.cos(n)*S,x+Math.sin(n)*S),e.stroke()}e.font=`${Math.max(8,Math.min(11,S*.2))}px sans-serif`,e.fillStyle=`#444`,e.textBaseline=`middle`;for(let t=0;t<h;t++){let n=D(t),r=b+Math.cos(n)*(S+12),i=x+Math.sin(n)*(S+12);e.textAlign=Math.cos(n)<-.1?`right`:Math.cos(n)>.1?`left`:`center`,e.fillText((f[t]??``).toString().slice(0,12),r,i)}for(let i=0;i<n.series.length;i++){let a=n.series[i],o=t(i,a);e.beginPath();for(let t=0;t<h;t++){let n=(a.values[t]??0)/T,r=D(t),i=b+Math.cos(r)*S*n,o=x+Math.sin(r)*S*n;t===0?e.moveTo(i,o):e.lineTo(i,o)}e.closePath(),e.fillStyle=r(o,.25),e.fill(),e.strokeStyle=o,e.lineWidth=2,e.stroke()}_>0&&l(e,n.series,s+u-_+4,c+g+d*.04,_-8,y)}function b(e,n,r){let{x:a,y:o,w:u,h:d}=r,f=n.title?Math.max(14,d*.06):0,m=n.showLegend?Math.max(80,u*.22):0,h=Math.max(8,Math.min(10,d*.045)),g=n.catAxisTitle?h+4:0,_=n.valAxisTitle?h+4:0,v={t:f+d*.06,r:m+u*.05,b:d*.12+g,l:u*.12+_};p(e,n.title,a,o+2,u,Math.max(11,f*.7));let y=a+v.l,b=o+v.t,x=u-v.l-v.r,S=d-v.t-v.b;if(x<=0||S<=0)return;n.plotAreaBg&&(e.fillStyle=`#${n.plotAreaBg}`,e.fillRect(y,b,x,S));let C=[],w=[];for(let e of n.series){let t=e.categories??[];for(let e of t){let t=parseFloat(e);isNaN(t)||C.push(t)}for(let t of e.values)t!=null&&w.push(t)}let T=C.length===0;if(T){let e=Math.max(...n.series.map(e=>e.values.length));for(let t=0;t<e;t++)C.push(t)}let E=Math.min(...C),D=Math.max(...C),O=Math.min(...w),k=Math.max(...w);E===D&&(--E,D+=1),O===k&&(--O,k+=1),n.valMin==null?O>0&&(O=0):O=n.valMin,n.valMax!=null&&(k=n.valMax);let A=e=>y+(e-E)/(D-E)*x,j=e=>b+S-(e-O)/(k-O)*S;if(!n.valAxisHidden){e.font=`${Math.max(8,Math.min(11,S/20))}px sans-serif`;let t=i(k-O),n=Math.round((k-O)/t)+1;for(let r=0;r<n;r++){let n=O+r*t;if(n>k+t*.01)break;let i=j(n);e.strokeStyle=`#e0e0e0`,e.lineWidth=.5,e.beginPath(),e.moveTo(y,i),e.lineTo(y+x,i),e.stroke(),e.fillStyle=`#555`,e.textAlign=`right`,e.textBaseline=`middle`,e.fillText(s(n),y-4,i)}}e.strokeStyle=`#aaa`,e.lineWidth=1,e.beginPath(),e.moveTo(y,b+S),e.lineTo(y+x,b+S),e.stroke(),e.beginPath(),e.moveTo(y,b),e.lineTo(y,b+S),e.stroke();let M=Math.max(3,S*.015);for(let r=0;r<n.series.length;r++){let i=n.series[r];e.fillStyle=t(r,i);let a=i.categories??[];for(let t=0;t<i.values.length;t++){let n=i.values[t];if(n==null)continue;let r=T?t:parseFloat(a[t]??`0`);isNaN(r)||(e.beginPath(),e.arc(A(r),j(n),M,0,Math.PI*2),e.fill())}}m>0&&l(e,n.series,a+u-m+4,b,m-8,S),n.catAxisTitle&&c(e,n.catAxisTitle,y,b,x,S,`cat`,h),n.valAxisTitle&&c(e,n.valAxisTitle,y,b,x,S,`val`,h)}function x(e,t,n){let{x:r,y:a,w:o,h:s}=n,c=o*.11,l=o*.04,u=s*.08,d=s*.18,f=r+c,p=a+u,m=o-c-l,h=s-u-d,g=t.series[0]?.values??[],_=t.categories,v=_.length;if(v===0)return;let y=new Set(t.subtotalIndices),b=0,x=[];for(let e=0;e<v;e++){let t=g[e]??0;if(e===0||y.has(e))x.push({start:0,end:t,isSub:!0,isPos:!0}),b=t;else{let e=t>=0?b:b+t,n=t>=0?b+t:b;x.push({start:e,end:n,isSub:!1,isPos:t>=0}),b+=t}}let S=x.map(e=>e.end),C=x.map(e=>e.start),w=Math.max(...S,...C),T=Math.min(...C,0),E=w-T;if(E<=0)return;let D=E*1.1,O=T-E*.05,k=O+D,A=i(D);e.save();let j=Math.round(s*.042);e.font=`${j}px sans-serif`,e.strokeStyle=`#e8e8e8`,e.lineWidth=.7,e.fillStyle=`#666`,e.textAlign=`right`,e.textBaseline=`middle`;for(let t=Math.ceil(O/A)*A;t<=k;t+=A){let n=p+h*(1-(t-O)/D);e.beginPath(),e.moveTo(f,n),e.lineTo(f+m,n),e.stroke(),e.fillText(t.toLocaleString(),f-4,n)}e.strokeStyle=`#bbb`,e.lineWidth=1,e.beginPath(),e.moveTo(f,p),e.lineTo(f,p+h),e.lineTo(f+m,p+h),e.stroke();let M=m/v*.55,N=m/v;x.forEach((t,n)=>{let r=f+N*n+(N-M)/2,i=p+h*(1-(t.end-O)/D),a=p+h*(1-(t.start-O)/D),o=Math.max(1,a-i);if(t.isSub?(e.fillStyle=`#196ECA`,e.fillRect(r,i,M,o)):(e.strokeStyle=t.isPos?`#5BA4E6`:`#E46970`,e.lineWidth=1.5,e.strokeRect(r+.75,i+.75,M-1.5,o-1.5)),n<v-1){let o=f+N*(n+1)+(N-M)/2,s=t.isPos?i:a;e.strokeStyle=`#ccc`,e.lineWidth=.8,e.setLineDash([3,3]),e.beginPath(),e.moveTo(r+M,s),e.lineTo(o,s),e.stroke(),e.setLineDash([])}let c=g[n]??0,l=c<0?`△ ${Math.abs(c).toLocaleString()}`:c.toLocaleString();e.fillStyle=`#595959`,e.font=`bold ${Math.round(s*.044)}px sans-serif`,e.textAlign=`center`,e.textBaseline=`bottom`,e.fillText(l,r+M/2,i-3)}),e.textAlign=`center`,e.textBaseline=`top`,e.fillStyle=`#666`,e.font=`${Math.round(s*.038)}px sans-serif`;let P=p+h+4;for(let t=0;t<v;t++){let n=f+N*t+N/2;_[t].split(/\s+/).forEach((t,r)=>e.fillText(t,n,P+r*(j+2)))}e.restore()}function S(e,t,n,r=1.333){let{x:i,y:a,w:o,h:s}=n;if(t.chartBg&&(e.fillStyle=`#${t.chartBg}`,e.fillRect(i,a,o,s)),t.series.length===0){e.fillStyle=`#888`,e.font=`12px sans-serif`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(`(no data)`,i+o/2,a+s/2);return}switch(t.chartType){case`clusteredBar`:case`clusteredBarH`:case`stackedBar`:case`stackedBarH`:case`stackedBarPct`:case`stackedBarHPct`:h(e,t,n);break;case`line`:case`stackedLine`:case`stackedLinePct`:g(e,t,n,r);break;case`area`:case`stackedArea`:case`stackedAreaPct`:_(e,t,n);break;case`pie`:v(e,t,n,!1);break;case`doughnut`:v(e,t,n,!0);break;case`radar`:y(e,t,n);break;case`scatter`:case`bubble`:b(e,t,n);break;case`waterfall`:x(e,t,n);break;default:e.fillStyle=`#888`,e.font=`11px sans-serif`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(`Chart: ${t.chartType}`,i+o/2,a+s/2)}}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return S}});
|
package/dist/types/docx.d.ts
CHANGED
|
@@ -45,7 +45,12 @@ declare interface CellBorders {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export declare interface DocParagraph {
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
|
+
* ECMA-376 §17.18.44 ST_Jc. Renderer honors left, start, center, right, end,
|
|
50
|
+
* both, distribute. Other values (kashida variants, numTab, thaiDistribute)
|
|
51
|
+
* are treated as start-aligned.
|
|
52
|
+
*/
|
|
53
|
+
alignment: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | 'both' | 'distribute' | string;
|
|
49
54
|
indentLeft: number;
|
|
50
55
|
indentRight: number;
|
|
51
56
|
indentFirst: number;
|
|
@@ -61,6 +66,12 @@ export declare interface DocParagraph {
|
|
|
61
66
|
pageBreakBefore?: boolean;
|
|
62
67
|
/** Suppress spacing between adjacent same-style paragraphs (w:contextualSpacing) */
|
|
63
68
|
contextualSpacing?: boolean;
|
|
69
|
+
/** Keep paragraph on same page as the next paragraph (w:keepNext) */
|
|
70
|
+
keepNext?: boolean;
|
|
71
|
+
/** Keep all lines of this paragraph on the same page (w:keepLines) */
|
|
72
|
+
keepLines?: boolean;
|
|
73
|
+
/** Widow/orphan control (w:widowControl). ECMA-376 default is true. */
|
|
74
|
+
widowControl?: boolean;
|
|
64
75
|
/** Paragraph borders (w:pBdr) */
|
|
65
76
|
borders?: ParagraphBorders | null;
|
|
66
77
|
/** Style ID of the applied paragraph style */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -243,6 +243,24 @@ declare interface ChartElement {
|
|
|
243
243
|
catAxisHidden: boolean;
|
|
244
244
|
valAxisHidden: boolean;
|
|
245
245
|
plotAreaBg: string | null;
|
|
246
|
+
/** Outer chartSpace background (hex without '#'). null when noFill/absent. */
|
|
247
|
+
chartBg: string | null;
|
|
248
|
+
/** True when <c:legend> is declared; false suppresses the legend entirely. */
|
|
249
|
+
showLegend: boolean;
|
|
250
|
+
/** catAx crossBetween: "between" (default, 0.5-step padding) or "midCat". */
|
|
251
|
+
catAxisCrossBetween: 'between' | 'midCat' | string;
|
|
252
|
+
/** `<c:valAx><c:majorTickMark>`. "cross" (default) | "out" | "in" | "none". */
|
|
253
|
+
valAxisMajorTickMark: 'cross' | 'out' | 'in' | 'none' | string;
|
|
254
|
+
/** `<c:catAx><c:majorTickMark>`. */
|
|
255
|
+
catAxisMajorTickMark: 'cross' | 'out' | 'in' | 'none' | string;
|
|
256
|
+
/** Title font size in OOXML hundredths of a point (1600 = 16pt). null = default. */
|
|
257
|
+
titleFontSizeHpt: number | null;
|
|
258
|
+
/** `<c:catAx><c:txPr>` font size (hpt). null = proportional default. */
|
|
259
|
+
catAxisFontSizeHpt: number | null;
|
|
260
|
+
/** `<c:valAx><c:txPr>` font size (hpt). null = proportional default. */
|
|
261
|
+
valAxisFontSizeHpt: number | null;
|
|
262
|
+
/** `<c:dLbls><c:txPr>` font size (hpt) for data-point value labels. */
|
|
263
|
+
dataLabelFontSizeHpt: number | null;
|
|
246
264
|
}
|
|
247
265
|
|
|
248
266
|
declare interface ChartSeries {
|
|
@@ -274,7 +292,12 @@ declare interface ConditionalFormat {
|
|
|
274
292
|
}
|
|
275
293
|
|
|
276
294
|
declare interface DocParagraph {
|
|
277
|
-
|
|
295
|
+
/**
|
|
296
|
+
* ECMA-376 §17.18.44 ST_Jc. Renderer honors left, start, center, right, end,
|
|
297
|
+
* both, distribute. Other values (kashida variants, numTab, thaiDistribute)
|
|
298
|
+
* are treated as start-aligned.
|
|
299
|
+
*/
|
|
300
|
+
alignment: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | 'both' | 'distribute' | string;
|
|
278
301
|
indentLeft: number;
|
|
279
302
|
indentRight: number;
|
|
280
303
|
indentFirst: number;
|
|
@@ -290,6 +313,12 @@ declare interface DocParagraph {
|
|
|
290
313
|
pageBreakBefore?: boolean;
|
|
291
314
|
/** Suppress spacing between adjacent same-style paragraphs (w:contextualSpacing) */
|
|
292
315
|
contextualSpacing?: boolean;
|
|
316
|
+
/** Keep paragraph on same page as the next paragraph (w:keepNext) */
|
|
317
|
+
keepNext?: boolean;
|
|
318
|
+
/** Keep all lines of this paragraph on the same page (w:keepLines) */
|
|
319
|
+
keepLines?: boolean;
|
|
320
|
+
/** Widow/orphan control (w:widowControl). ECMA-376 default is true. */
|
|
321
|
+
widowControl?: boolean;
|
|
293
322
|
/** Paragraph borders (w:pBdr) */
|
|
294
323
|
borders?: ParagraphBorders | null;
|
|
295
324
|
/** Style ID of the applied paragraph style */
|
|
@@ -558,6 +587,24 @@ declare interface LoadOptions {
|
|
|
558
587
|
useGoogleFonts?: boolean;
|
|
559
588
|
}
|
|
560
589
|
|
|
590
|
+
declare interface MediaElement {
|
|
591
|
+
type: 'media';
|
|
592
|
+
x: number;
|
|
593
|
+
y: number;
|
|
594
|
+
width: number;
|
|
595
|
+
height: number;
|
|
596
|
+
/** "audio" or "video" */
|
|
597
|
+
mediaKind: 'audio' | 'video';
|
|
598
|
+
/** Poster image zip path (e.g. "ppt/media/image2.png"). Empty when no poster. */
|
|
599
|
+
posterPath: string;
|
|
600
|
+
/** Poster image MIME type (empty when no poster). */
|
|
601
|
+
posterMimeType: string;
|
|
602
|
+
/** Path inside the pptx zip (e.g. "ppt/media/media2.mp4"). Used by getMedia. */
|
|
603
|
+
mediaPath: string;
|
|
604
|
+
/** MIME type of the underlying media (e.g. "audio/mpeg", "video/mp4"). */
|
|
605
|
+
mimeType: string;
|
|
606
|
+
}
|
|
607
|
+
|
|
561
608
|
declare interface MergeCell {
|
|
562
609
|
top: number;
|
|
563
610
|
left: number;
|
|
@@ -757,6 +804,8 @@ declare class PptxPresentation {
|
|
|
757
804
|
private readonly _worker;
|
|
758
805
|
private _presentation;
|
|
759
806
|
private _pendingParseCallbacks;
|
|
807
|
+
private _pendingMediaCallbacks;
|
|
808
|
+
private _mediaCache;
|
|
760
809
|
private _nextId;
|
|
761
810
|
private _workerReady;
|
|
762
811
|
private _workerReadyCallbacks;
|
|
@@ -773,6 +822,19 @@ declare class PptxPresentation {
|
|
|
773
822
|
get slideHeight(): number;
|
|
774
823
|
/** Render a slide onto the given canvas. */
|
|
775
824
|
renderSlide(canvas: HTMLCanvasElement, slideIndex: number, opts?: RenderSlideOptions): Promise<void>;
|
|
825
|
+
/**
|
|
826
|
+
* Extract raw media bytes for a zip path referenced by {@link MediaElement}.
|
|
827
|
+
* Results are cached by path for the lifetime of this instance.
|
|
828
|
+
*/
|
|
829
|
+
getMedia(mediaPath: string): Promise<Blob>;
|
|
830
|
+
private _findMimeTypeForPath;
|
|
831
|
+
/**
|
|
832
|
+
* Render a slide and attach canvas-native playback controls for any
|
|
833
|
+
* embedded audio/video. Returns a disposable handle that owns the RAF loop,
|
|
834
|
+
* media elements, and object URLs. Unlike {@link renderSlide}, this method
|
|
835
|
+
* is stateful — always call `handle.dispose()` when leaving the slide.
|
|
836
|
+
*/
|
|
837
|
+
presentSlide(canvas: HTMLCanvasElement, slideIndex: number, opts?: RenderSlideOptions): Promise<PresentationHandle>;
|
|
776
838
|
/** Terminate the worker and release all resources. */
|
|
777
839
|
destroy(): void;
|
|
778
840
|
}
|
|
@@ -830,12 +892,31 @@ declare interface Presentation {
|
|
|
830
892
|
minorFont: string | null;
|
|
831
893
|
}
|
|
832
894
|
|
|
895
|
+
declare interface PresentationHandle {
|
|
896
|
+
play(mediaPath?: string): void;
|
|
897
|
+
pause(mediaPath?: string): void;
|
|
898
|
+
dispose(): void;
|
|
899
|
+
}
|
|
900
|
+
|
|
833
901
|
declare interface RenderOptions {
|
|
834
902
|
width?: number;
|
|
835
903
|
defaultTextColor?: string | null;
|
|
836
904
|
dpr?: number;
|
|
837
905
|
majorFont?: string | null;
|
|
838
906
|
minorFont?: string | null;
|
|
907
|
+
/**
|
|
908
|
+
* Lazily resolve an archive-internal asset (by zip path) to a Blob. The
|
|
909
|
+
* renderer uses this to fetch posters and other large embedded assets on
|
|
910
|
+
* demand, keeping the parse output free of inlined base64.
|
|
911
|
+
*/
|
|
912
|
+
fetchMedia?: (path: string) => Promise<Blob>;
|
|
913
|
+
/**
|
|
914
|
+
* When true, renderMedia draws only the poster frame — play/pause badges
|
|
915
|
+
* and progress bars are left to the caller. Set by the pptx presentSlide
|
|
916
|
+
* API so its interactive handle can own all control chrome without
|
|
917
|
+
* the static renderer drawing a duplicate play badge.
|
|
918
|
+
*/
|
|
919
|
+
skipMediaControls?: boolean;
|
|
839
920
|
}
|
|
840
921
|
|
|
841
922
|
declare interface RenderPageOptions {
|
|
@@ -857,6 +938,12 @@ declare interface RenderSlideOptions {
|
|
|
857
938
|
width?: number;
|
|
858
939
|
/** Device pixel ratio. Defaults to window.devicePixelRatio or 1. */
|
|
859
940
|
dpr?: number;
|
|
941
|
+
/**
|
|
942
|
+
* Skip drawing the play badge overlay on media elements. Used internally by
|
|
943
|
+
* {@link PptxPresentation.presentSlide} so its interactive handle can draw
|
|
944
|
+
* its own play/pause chrome without duplication.
|
|
945
|
+
*/
|
|
946
|
+
skipMediaControls?: boolean;
|
|
860
947
|
}
|
|
861
948
|
|
|
862
949
|
declare interface RenderViewportOptions {
|
|
@@ -1003,7 +1090,7 @@ declare interface Slide {
|
|
|
1003
1090
|
elements: SlideElement[];
|
|
1004
1091
|
}
|
|
1005
1092
|
|
|
1006
|
-
declare type SlideElement = ShapeElement | PictureElement | TableElement | ChartElement;
|
|
1093
|
+
declare type SlideElement = ShapeElement | PictureElement | TableElement | ChartElement | MediaElement;
|
|
1007
1094
|
|
|
1008
1095
|
declare interface SolidFill {
|
|
1009
1096
|
fillType: 'solid';
|