@silurus/ooxml 0.43.0 → 0.44.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.
@@ -1,1024 +0,0 @@
1
- //#region packages/core/src/chart/axis-scale.ts
2
- function e(e, t = 5) {
3
- if (e === 0) return 1;
4
- let n = e / t, r = 10 ** Math.floor(Math.log10(n)), i = n / r;
5
- return (i < 1.5 ? 1 : i < 3.5 ? 2 : i < 7.5 ? 5 : 10) * r;
6
- }
7
- function t(e, t, n = 0) {
8
- if (e <= 0) return t;
9
- let r = e + (e - n) / 20;
10
- return Math.ceil(r / t) * t;
11
- }
12
- function n(e, t) {
13
- if (e >= 0) return 0;
14
- let n = Math.floor(e / t) * t;
15
- return Math.abs(n - e) < t * 1e-9 ? n - t : n;
16
- }
17
- //#endregion
18
- //#region packages/core/src/chart/chart-number-format.ts
19
- function r(e) {
20
- return Number.isInteger(e) ? String(e) : e.toFixed(6).replace(/\.?0+$/, "");
21
- }
22
- function i(e, t) {
23
- if (!t) return r(e);
24
- if (a(t)) return o(e, t);
25
- let n = s(t), i;
26
- return i = e > 0 ? n[0] ?? t : e < 0 ? n[1] ?? n[0] ?? t : n[2] ?? n[0] ?? t, i === "" ? "" : (e < 0 && n.length < 2 ? "-" : "") + c(Math.abs(e), i);
27
- }
28
- function a(e) {
29
- let t = !1;
30
- for (let n = 0; n < e.length; n++) {
31
- let r = e[n];
32
- if (r === "\"") {
33
- t = !t;
34
- continue;
35
- }
36
- if (!t) {
37
- if (r === "\\") {
38
- n++;
39
- continue;
40
- }
41
- if (r === "[") {
42
- for (; n < e.length && e[n] !== "]";) n++;
43
- continue;
44
- }
45
- if (r === "y" || r === "Y" || r === "d" || r === "D" || r === "m" || r === "M" || r === "h" || r === "H" || r === "s" || r === "S") return !0;
46
- }
47
- }
48
- return !1;
49
- }
50
- function o(e, t) {
51
- let n = Date.UTC(1899, 11, 30), r = e < 60 ? e + 1 : e, i = n + Math.floor(r) * 864e5, a = new Date(i), o = a.getUTCFullYear(), s = a.getUTCMonth() + 1, c = a.getUTCDate(), l = (e - Math.floor(e)) * 86400, u = Math.floor(l / 3600), d = Math.floor(l % 3600 / 60), f = Math.floor(l % 60), p = "", m = !1, h = 0;
52
- for (; h < t.length;) {
53
- let e = t[h];
54
- if (e === "\"") {
55
- m = !m, h++;
56
- continue;
57
- }
58
- if (m) {
59
- p += e, h++;
60
- continue;
61
- }
62
- if (e === "\\" && h + 1 < t.length) {
63
- p += t[h + 1], h += 2;
64
- continue;
65
- }
66
- if (e === "[") {
67
- for (; h < t.length && t[h] !== "]";) h++;
68
- h < t.length && h++;
69
- continue;
70
- }
71
- if (e === "y" || e === "Y") {
72
- let e = 0;
73
- for (; h < t.length && (t[h] === "y" || t[h] === "Y");) e++, h++;
74
- p += e >= 3 ? String(o) : String(o % 100).padStart(2, "0");
75
- continue;
76
- }
77
- if (e === "m" || e === "M") {
78
- let e = 0;
79
- for (; h < t.length && (t[h] === "m" || t[h] === "M");) e++, h++;
80
- p.match(/[Hh]+\W*$/) ? p += e >= 2 ? String(d).padStart(2, "0") : String(d) : p += e >= 2 ? String(s).padStart(2, "0") : String(s);
81
- continue;
82
- }
83
- if (e === "d" || e === "D") {
84
- let e = 0;
85
- for (; h < t.length && (t[h] === "d" || t[h] === "D");) e++, h++;
86
- p += e >= 2 ? String(c).padStart(2, "0") : String(c);
87
- continue;
88
- }
89
- if (e === "h" || e === "H") {
90
- let e = 0;
91
- for (; h < t.length && (t[h] === "h" || t[h] === "H");) e++, h++;
92
- p += e >= 2 ? String(u).padStart(2, "0") : String(u);
93
- continue;
94
- }
95
- if (e === "s" || e === "S") {
96
- let e = 0;
97
- for (; h < t.length && (t[h] === "s" || t[h] === "S");) e++, h++;
98
- p += e >= 2 ? String(f).padStart(2, "0") : String(f);
99
- continue;
100
- }
101
- p += e, h++;
102
- }
103
- return p;
104
- }
105
- function s(e) {
106
- let t = [], n = "";
107
- for (let r = 0; r < e.length; r++) {
108
- let i = e[r];
109
- if (i === "\\" && r + 1 < e.length) {
110
- n += i + e[r + 1], r++;
111
- continue;
112
- }
113
- if (i === "\"") {
114
- for (n += i, r++; r < e.length && e[r] !== "\"";) n += e[r], r++;
115
- r < e.length && (n += e[r]);
116
- continue;
117
- }
118
- if (i === "[") {
119
- for (n += i, r++; r < e.length && e[r] !== "]";) n += e[r], r++;
120
- r < e.length && (n += e[r]);
121
- continue;
122
- }
123
- if (i === ";") {
124
- t.push(n), n = "";
125
- continue;
126
- }
127
- n += i;
128
- }
129
- return t.push(n), t;
130
- }
131
- function c(e, t) {
132
- let n = [], r = 0, i = !1, a = !1;
133
- for (; r < t.length;) {
134
- let e = t[r];
135
- if (e === "\"") {
136
- r++;
137
- let e = "";
138
- for (; r < t.length && t[r] !== "\"";) e += t[r], r++;
139
- r < t.length && r++, n.push({
140
- kind: "lit",
141
- text: e
142
- });
143
- continue;
144
- }
145
- if (e === "\\" && r + 1 < t.length) {
146
- n.push({
147
- kind: "lit",
148
- text: t[r + 1]
149
- }), r += 2;
150
- continue;
151
- }
152
- if (e === "_" && r + 1 < t.length) {
153
- n.push({
154
- kind: "lit",
155
- text: " "
156
- }), r += 2;
157
- continue;
158
- }
159
- if (e === "*" && r + 1 < t.length) {
160
- r += 2;
161
- continue;
162
- }
163
- if (e === "[") {
164
- for (r++; r < t.length && t[r] !== "]";) r++;
165
- r < t.length && r++;
166
- continue;
167
- }
168
- if (e === "%") {
169
- a = !0, n.push({
170
- kind: "lit",
171
- text: "%"
172
- }), r++;
173
- continue;
174
- }
175
- if (e === "#" || e === "0" || e === "." || e === "," || e === "?") {
176
- let e = "";
177
- for (; r < t.length && (t[r] === "#" || t[r] === "0" || t[r] === "." || t[r] === "," || t[r] === "?");) e += t[r], r++;
178
- n.push({
179
- kind: "num",
180
- text: e
181
- }), i = !0;
182
- continue;
183
- }
184
- n.push({
185
- kind: "lit",
186
- text: e
187
- }), r++;
188
- }
189
- if (!i) return n.map((e) => e.text).join("");
190
- let o = a ? e * 100 : e, s = "";
191
- for (let e of n) e.kind === "num" && (s += e.text);
192
- let c = l(o, s), u = !1;
193
- return n.map((e) => e.kind === "lit" ? e.text : u ? "" : (u = !0, c)).join("");
194
- }
195
- function l(e, t) {
196
- let n = t.indexOf("."), r = n >= 0 ? t.slice(0, n) : t, i = n >= 0 ? t.slice(n + 1) : "", a = /,/.test(r), o = (i.match(/[#0?]/g) ?? []).length, s = (r.replace(/,/g, "").match(/0/g) ?? []).length, [c, l = ""] = e.toFixed(o).split("."), u = c.padStart(s, "0"), d = a ? u.replace(/\B(?=(\d{3})+(?!\d))/g, ",") : u;
197
- return o === 0 ? d : `${d}.${l.padEnd(o, "0")}`;
198
- }
199
- //#endregion
200
- //#region packages/core/src/chart/renderer.ts
201
- var u = [
202
- "4472C4",
203
- "ED7D31",
204
- "A9D18E",
205
- "FF0000",
206
- "70AD47",
207
- "4BACC6",
208
- "FFC000",
209
- "9E480E",
210
- "843C0C",
211
- "636363",
212
- "255E91",
213
- "967300"
214
- ];
215
- function d(e, t) {
216
- return t?.color ? `#${t.color}` : `#${u[e % u.length]}`;
217
- }
218
- function f(e, t) {
219
- let n = t.dataPointColors?.[e];
220
- return n ? `#${n}` : `#${u[e % u.length]}`;
221
- }
222
- function p(e, t) {
223
- let n = e.startsWith("#") ? e.slice(1) : e;
224
- return `rgba(${parseInt(n.slice(0, 2), 16)},${parseInt(n.slice(2, 4), 16)},${parseInt(n.slice(4, 6), 16)},${t})`;
225
- }
226
- function m(e, t, n, r, i, a, o, s) {
227
- 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();
228
- }
229
- function h(e) {
230
- return e && (e === "line" || e === "stackedLine" || e === "stackedLinePct" || e === "radar" || e === "scatter") ? "line" : "fill";
231
- }
232
- function g(e, t, n, r, i, a, o) {
233
- if (e.fillStyle = n, t === "line") {
234
- e.strokeStyle = n;
235
- let t = e.lineWidth;
236
- e.lineWidth = Math.max(1.5, o * .15), e.beginPath();
237
- let s = i + o / 2;
238
- e.moveTo(r, s), e.lineTo(r + a, s), e.stroke(), e.lineWidth = t;
239
- } else e.fillRect(r, i, a, o);
240
- }
241
- function _(e, t, n, r, i, a, o = "vertical", s) {
242
- let c = h(s);
243
- if (o === "horizontal") {
244
- let o = Math.max(9, Math.min(12, a * .7));
245
- e.font = `${o}px sans-serif`, e.textBaseline = "middle";
246
- let s = t.map((e, t) => e.name || `Series ${t + 1}`), l = s.map((t) => 14 + e.measureText(t.slice(0, 30)).width), u = n + (i - (l.reduce((e, t) => e + t, 0) + 12 * Math.max(0, t.length - 1))) / 2, f = r + a / 2;
247
- for (let n = 0; n < t.length; n++) g(e, c, d(n, t[n]), u, f - o / 2, 10, o), e.fillStyle = "#333", e.textAlign = "left", e.fillText(s[n].slice(0, 30), u + 10 + 4, f), u += l[n] + 12;
248
- return;
249
- }
250
- let l = Math.max(9, Math.min(12, a / (t.length + 1)));
251
- e.font = `${l}px sans-serif`, e.textBaseline = "middle";
252
- let u = l + 4, f = r + (a - u * t.length) / 2;
253
- for (let r = 0; r < t.length; r++) {
254
- g(e, c, d(r, t[r]), n, f, 10, l), e.fillStyle = "#333", e.textAlign = "left";
255
- let i = t[r].name || `Series ${r + 1}`;
256
- e.fillText(i.slice(0, 20), n + 10 + 4, f + l / 2), f += u;
257
- }
258
- }
259
- function v(e, t, n) {
260
- if (!e.showLegend) return null;
261
- let r = e.legendPos ?? "r", i = r === "l" ? "l" : r === "t" ? "t" : r === "b" ? "b" : "r";
262
- return i === "r" || i === "l" ? {
263
- side: i,
264
- reserveW: Math.max(80, t * .22),
265
- reserveH: 0
266
- } : {
267
- side: i,
268
- reserveW: 0,
269
- reserveH: Math.max(18, n * .08)
270
- };
271
- }
272
- function y(e, t, n, r, i, a, o, s, c, l, u, d) {
273
- if (!n) return;
274
- let f = t.legendManualLayout;
275
- if (f && f.xMode === "edge" && f.yMode === "edge" && f.w > 0 && f.h > 0) {
276
- let n = r + f.x * a, s = i + f.y * o, c = f.w * a, l = f.h * o, u = c >= l ? "horizontal" : "vertical";
277
- _(e, t.series, n, s, c, l, u, t.chartType);
278
- return;
279
- }
280
- switch (n.side) {
281
- case "r":
282
- _(e, t.series, r + a - n.reserveW + 4, c, n.reserveW - 8, u, "vertical", t.chartType);
283
- break;
284
- case "l":
285
- _(e, t.series, r + 4, c, n.reserveW - 8, u, "vertical", t.chartType);
286
- break;
287
- case "t":
288
- _(e, t.series, s, i + d, l, n.reserveH, "horizontal", t.chartType);
289
- break;
290
- case "b":
291
- _(e, t.series, s, i + o - n.reserveH, l, n.reserveH, "horizontal", t.chartType);
292
- break;
293
- }
294
- }
295
- function b(e, t, n, r, i, a, o) {
296
- if (t === "none" || !t) return;
297
- let s = o ? Math.max(4, o + 2) : 4, c = e.strokeStyle, l = e.lineWidth;
298
- if (e.strokeStyle = a ?? "#888", e.lineWidth = o ?? 1, e.beginPath(), n === "val") {
299
- let n = r, a = i, o = t === "out" || t === "cross" ? -s : 0, c = t === "in" || t === "cross" ? s : 0;
300
- e.moveTo(n + o, a), e.lineTo(n + c, a);
301
- } else {
302
- let n = r, a = i, o = t === "out" || t === "cross" ? s : 0, c = t === "in" || t === "cross" ? -s : 0;
303
- e.moveTo(a, n + o), e.lineTo(a, n + c);
304
- }
305
- e.stroke(), e.strokeStyle = c, e.lineWidth = l;
306
- }
307
- function x(e, t, n) {
308
- return e.titleFontSizeHpt ? e.titleFontSizeHpt / 100 * n : Math.max(10, t * .085);
309
- }
310
- function S(e, t, n) {
311
- return e ? e / 100 * n : Math.max(8, t * .045);
312
- }
313
- function C(e, t, n, r, i, a) {
314
- t.title && (e.font = `bold ${a}px ${t.titleFontFace ? `"${t.titleFontFace}", Calibri, Arial, sans-serif` : "Calibri, Arial, sans-serif"}`, e.fillStyle = t.titleFontColor ? `#${t.titleFontColor}` : "#333", e.textAlign = "center", e.textBaseline = "top", e.fillText(t.title, n + i / 2, r));
315
- }
316
- function w(e) {
317
- if (e.categories.length > 0) return e.categories;
318
- let t = e.series[0];
319
- if (t?.categories && t.categories.length > 0) return t.categories;
320
- let n = 0;
321
- for (let t of e.series) t.values.length > n && (n = t.values.length);
322
- return n > 0 ? Array.from({ length: n }, (e, t) => String(t + 1)) : [];
323
- }
324
- function T(e, t, n, r, i, a, o, s, c) {
325
- let l = s ?? "outEnd";
326
- if (e.fillStyle = c ? `#${c}` : "#333", o === "vertical") {
327
- let o = n + a / 2;
328
- l === "inBase" ? (e.textAlign = "center", e.textBaseline = "bottom", e.fillText(t, o, r + i - 2)) : l === "inEnd" ? (e.textAlign = "center", e.textBaseline = "top", e.fillText(t, o, r + 2)) : l === "ctr" ? (e.textAlign = "center", e.textBaseline = "middle", e.fillText(t, o, r + i / 2)) : (e.textAlign = "center", e.textBaseline = "bottom", e.fillText(t, o, r - 1));
329
- } else {
330
- let o = r + a / 2;
331
- l === "inBase" ? (e.textAlign = "left", e.textBaseline = "middle", e.fillText(t, n + 4, o)) : l === "inEnd" ? (e.textAlign = "right", e.textBaseline = "middle", e.fillText(t, n + i - 4, o)) : l === "ctr" ? (e.textAlign = "center", e.textBaseline = "middle", e.fillText(t, n + i / 2, o)) : (e.textAlign = "left", e.textBaseline = "middle", e.fillText(t, n + i + 2, o));
332
- }
333
- }
334
- function E(n, r, a, o) {
335
- let { x: s, y: c, w: l, h: u } = a, f = r.chartType === "clusteredBarH" || r.chartType === "stackedBarH" || r.chartType === "stackedBarHPct", p = r.chartType.startsWith("stacked"), h = r.chartType === "stackedBarPct" || r.chartType === "stackedBarHPct", g = r.series.filter((e) => e.seriesType !== "line"), _ = r.series.filter((e) => e.seriesType === "line"), b = w(r), S = b.length;
336
- if (S === 0) return;
337
- let E = r.title ? x(r, u, o) : 0, D = r.title ? u * .02 : 0, O = r.title ? u * .025 : 0, k = r.title ? E + D + O : 0, A = v(r, l, u), j = A?.side === "r" ? A.reserveW : 0, M = A?.side === "l" ? A.reserveW : 0, N = A?.side === "t" ? A.reserveH : 0, P = A?.side === "b" ? A.reserveH : 0, F = Math.max(8, Math.min(10, u * .045)), I = r.catAxisTitle ? F + 4 : 0, L = r.valAxisTitle ? F + 4 : 0, R = {
338
- t: k + N + u * .02,
339
- r: j + l * .03,
340
- b: u * .14 + I + P,
341
- l: l * .12 + L + M
342
- };
343
- f && (R.l = (r.catAxisHidden ? l * .03 : l * .22) + L + M, R.b = (r.valAxisHidden ? u * .02 : u * .08) + I + P), C(n, r, s, c + D, l, E);
344
- let z = r.plotAreaManualLayout, B, V, H, U;
345
- if (z && z.w != null && z.h != null ? (B = s + z.x * l, V = c + z.y * u, H = z.w * l, U = z.h * u) : (B = s + R.l, V = c + R.t, H = l - R.l - R.r, U = u - R.t - R.b), H <= 0 || U <= 0) return;
346
- r.plotAreaBg && (n.fillStyle = `#${r.plotAreaBg}`, n.fillRect(B, V, H, U));
347
- let W = 0;
348
- for (let e = 0; e < S; e++) {
349
- let t = 0;
350
- for (let n of g) {
351
- let r = n.values[e] ?? 0;
352
- p ? t += Math.abs(r) : W = Math.max(W, Math.abs(r));
353
- }
354
- p && (W = Math.max(W, t));
355
- }
356
- h && (W = 100), r.valMax != null && (W = r.valMax), W === 0 && (W = 1);
357
- let G = e(W), K = r.valMax ?? t(W, G), q = "#e0e0e0", J = Math.round(K / G);
358
- if (n.textBaseline = "middle", n.font = `${Math.max(8, Math.min(11, U / 20))}px sans-serif`, n.fillStyle = r.valAxisFontColor ? `#${r.valAxisFontColor}` : "#555", !r.valAxisHidden) for (let e = 0; e <= J; e++) {
359
- let t = e * G, a = h ? `${Math.round(t)}%` : i(t, r.valAxisFormatCode);
360
- if (f) {
361
- let r = B + t / K * H;
362
- n.strokeStyle = e === 0 ? "#aaa" : q, n.lineWidth = e === 0 ? 1 : .5, n.beginPath(), n.moveTo(r, V), n.lineTo(r, V + U), n.stroke(), n.textAlign = "center", n.fillText(a, r, V + U + 10);
363
- } else {
364
- let r = V + U - t / K * U;
365
- n.strokeStyle = e === 0 ? "#aaa" : q, n.lineWidth = e === 0 ? 1 : .5, n.beginPath(), n.moveTo(B, r), n.lineTo(B + H, r), n.stroke(), n.textAlign = "right", n.fillText(a, B - 4, r);
366
- }
367
- }
368
- let Y = r.catAxisLineColor ? `#${r.catAxisLineColor}` : "#aaa", X = r.valAxisLineColor ? `#${r.valAxisLineColor}` : "#aaa", Z = r.catAxisLineWidthEmu ? Math.max(.5, r.catAxisLineWidthEmu / 12700) : 1, ee = r.valAxisLineWidthEmu ? Math.max(.5, r.valAxisLineWidthEmu / 12700) : 1, te = (e, t, r, i, a, o) => {
369
- n.strokeStyle = a, n.lineWidth = o, n.beginPath(), n.moveTo(e, t), n.lineTo(r, i), n.stroke();
370
- }, ne = !r.catAxisHidden && !r.catAxisLineHidden, re = !r.valAxisHidden && !r.valAxisLineHidden && r.valAxisLineColor != null;
371
- f ? (ne && te(B, V, B, V + U, Y, Z), re && te(B, V + U, B + H, V + U, X, ee)) : (ne && te(B, V + U, B + H, V + U, Y, Z), re && te(B, V, B, V + U, X, ee));
372
- let Q = f ? U / S : H / S, ie = p ? 1 : Math.max(1, g.length), ae = p ? 0 : r.barOverlap ?? 0, oe = r.barGapWidth ?? 150, $ = Q / (1 + (ie - 1) * (1 - ae / 100) + oe / 100), se = p ? 0 : $ * (1 - ae / 100), ce = (Q - ($ + (ie - 1) * se)) / 2;
373
- for (let e = 0; e < S; e++) {
374
- let t = 0, a = 0;
375
- if (h) {
376
- for (let t of g) a += Math.abs(t.values[e] ?? 0);
377
- a === 0 && (a = 1);
378
- }
379
- for (let s = 0; s < g.length; s++) {
380
- let c = g[s], l = c.values[e] ?? 0, u = h ? Math.abs(l) / a * 100 : Math.abs(l), m = d(s, c);
381
- if (f) {
382
- let a = p ? s : g.length - 1 - s, l = p ? V + (S - 1 - e) * Q + ce : V + (S - 1 - e) * Q + ce + a * se, d = u / K * H, f = p ? B + t / K * H : B;
383
- n.fillStyle = m, n.fillRect(f, l, d, $), r.showDataLabels && u > 0 && (n.font = `bold ${r.dataLabelFontSizeHpt ? r.dataLabelFontSizeHpt / 100 * o : Math.max(7, Math.min(11, $ * .6))}px sans-serif`, T(n, h ? `${Math.round(u)}%` : i(u, r.dataLabelFormatCode ?? c.valFormatCode ?? null), f, l, d, $, "horizontal", r.dataLabelPosition ?? null, c.labelColor ?? r.dataLabelFontColor ?? null));
384
- } else {
385
- let a = p ? B + e * Q + ce : B + e * Q + ce + s * se, l = u / K * U, d = V + U - (p ? t + u : u) / K * U;
386
- n.fillStyle = m, n.fillRect(a, d, $, l), r.showDataLabels && u > 0 && (n.font = `bold ${r.dataLabelFontSizeHpt ? r.dataLabelFontSizeHpt / 100 * o : Math.max(7, Math.min(11, $ * .6))}px sans-serif`, T(n, h ? `${Math.round(u)}%` : i(u, r.dataLabelFormatCode ?? c.valFormatCode ?? null), a, d, l, $, "vertical", r.dataLabelPosition ?? null, c.labelColor ?? r.dataLabelFontColor ?? null));
387
- }
388
- p && (t += u);
389
- }
390
- }
391
- if (!r.catAxisHidden) {
392
- n.fillStyle = r.catAxisFontColor ? `#${r.catAxisFontColor}` : "#555", n.font = `${Math.max(8, Math.min(11, Q * .5))}px sans-serif`;
393
- for (let e = 0; e < S; e++) {
394
- let t = (b[e] ?? "").toString().slice(0, 12);
395
- if (f) {
396
- let r = V + (S - 1 - e) * Q + Q / 2;
397
- n.textAlign = "right", n.textBaseline = "middle", n.fillText(t, B - 4, r);
398
- } else {
399
- let r = B + e * Q + Q / 2;
400
- n.textAlign = "center", n.textBaseline = "top", n.fillText(t, r, V + U + 3);
401
- }
402
- }
403
- }
404
- if (_.length > 0 && !f) for (let e = 0; e < _.length; e++) {
405
- let t = _[e], r = d(g.length + e, t);
406
- n.strokeStyle = r, n.lineWidth = 2, n.setLineDash([]), n.beginPath();
407
- let i = !1;
408
- for (let e = 0; e < S; e++) {
409
- let r = t.values[e];
410
- if (r == null) {
411
- i = !1;
412
- continue;
413
- }
414
- let a = B + e * Q + Q / 2, o = V + U - r / K * U;
415
- i ? n.lineTo(a, o) : (n.moveTo(a, o), i = !0);
416
- }
417
- if (n.stroke(), t.showMarker !== !1) for (let e = 0; e < S; e++) {
418
- let i = t.values[e];
419
- if (i == null) continue;
420
- let a = B + e * Q + Q / 2, o = V + U - i / K * U;
421
- n.fillStyle = r, n.beginPath(), n.arc(a, o, 3, 0, Math.PI * 2), n.fill();
422
- }
423
- }
424
- y(n, f && !p ? {
425
- ...r,
426
- series: [...r.series].reverse()
427
- } : r, A, s, c, l, u, B, V, H, U, k + 2), r.catAxisTitle && m(n, r.catAxisTitle, B, V, H, U, "cat", F), r.valAxisTitle && m(n, r.valAxisTitle, B, V, H, U, "val", F);
428
- }
429
- function D(a, o, s, c) {
430
- let { x: l, y: u, w: f, h: p } = s, h = w(o), g = h.length;
431
- if (g === 0) return;
432
- let _ = o.title ? x(o, p, c) : 0, T = o.title ? p * .045 : 0, E = o.title ? p * .035 : 0, D = o.title ? _ + T + E : 0, O = v(o, f, p), k = O?.side === "r" ? O.reserveW : 0, A = O?.side === "l" ? O.reserveW : 0, j = O?.side === "t" ? O.reserveH : 0, M = O?.side === "b" ? O.reserveH : 0, N = S(o.catAxisFontSizeHpt, p, c), P = S(o.valAxisFontSizeHpt, p, c), F = Math.max(N, P), I = o.catAxisTitle ? F + 4 : 0, L = o.valAxisTitle ? F + 4 : 0, R = {
433
- t: D + j + P / 2 + 2,
434
- r: k + f * .05,
435
- b: N + 12 + I + M,
436
- l: P * 2.2 + 10 + L + A
437
- };
438
- C(a, o, l, u + T, f, _);
439
- let z = l + R.l, B = u + R.t, V = f - R.l - R.r, H = p - R.t - R.b;
440
- if (V <= 0 || H <= 0) return;
441
- o.plotAreaBg && (a.fillStyle = `#${o.plotAreaBg}`, a.fillRect(z, B, V, H));
442
- let U = Infinity, W = -Infinity;
443
- for (let e of o.series) for (let t of e.values) t != null && (U = Math.min(U, t), W = Math.max(W, t));
444
- isFinite(U) || (U = 0, W = 1), o.valMin == null ? U > 0 && (U = 0) : U = o.valMin, o.valMax == null ? W < 0 && (W = 0) : W = o.valMax, W === U && (W = U + 1);
445
- let G = e(W - U), K = o.valMin ?? n(U, G), q = o.valMax ?? t(W, G), J = q - K;
446
- if (J === 0) return;
447
- let Y = (e) => B + H - (e - K) / J * H, X = o.catAxisCrossBetween === "midCat" ? (e) => z + (g === 1 ? V / 2 : e / (g - 1) * V) : (e) => z + (e + .5) / g * V;
448
- if (!o.valAxisHidden) {
449
- let e = Math.round((q - K) / G);
450
- a.font = `${P}px sans-serif`, a.textBaseline = "middle";
451
- for (let t = 0; t <= e; t++) {
452
- let e = K + t * G, n = Y(e);
453
- a.strokeStyle = e === 0 ? "#aaa" : "#e0e0e0", a.lineWidth = e === 0 ? 1 : .5, a.beginPath(), a.moveTo(z, n), a.lineTo(z + V, n), a.stroke(), b(a, o.valAxisMajorTickMark, "val", z, n), a.fillStyle = o.valAxisFontColor ? `#${o.valAxisFontColor}` : "#555", a.textAlign = "right", a.fillText(i(e, o.valAxisFormatCode), z - 6, n);
454
- }
455
- }
456
- a.strokeStyle = "#aaa", a.lineWidth = 1, !o.catAxisHidden && !o.catAxisLineHidden && (a.beginPath(), a.moveTo(z, B + H), a.lineTo(z + V, B + H), a.stroke()), !o.valAxisHidden && !o.valAxisLineHidden && (a.beginPath(), a.moveTo(z, B), a.lineTo(z, B + H), a.stroke());
457
- let Z = Math.max(1, 2.25 * c), ee = Math.max(2, 2.5 * c), te = S(o.dataLabelFontSizeHpt, p, c);
458
- for (let e = 0; e < o.series.length; e++) {
459
- let t = o.series[e], n = d(e, t);
460
- a.strokeStyle = n, a.lineWidth = Z, a.setLineDash([]), a.beginPath();
461
- let i = !1;
462
- for (let e = 0; e < g; e++) {
463
- let n = t.values[e];
464
- if (n == null) {
465
- i = !1;
466
- continue;
467
- }
468
- let r = X(e), o = Y(n);
469
- i ? a.lineTo(r, o) : (a.moveTo(r, o), i = !0);
470
- }
471
- a.stroke(), a.fillStyle = n;
472
- let s = t.showMarker !== !1;
473
- for (let e = 0; e < g; e++) {
474
- let i = t.values[e];
475
- if (i != null && (s && (a.beginPath(), a.arc(X(e), Y(i), ee, 0, Math.PI * 2), a.fill()), o.showDataLabels)) {
476
- a.font = `${te}px sans-serif`, a.fillStyle = "#333", a.textAlign = "center", a.textBaseline = "bottom";
477
- let t = s ? ee + 1 : 2;
478
- a.fillText(r(i), X(e), Y(i) - t), a.fillStyle = n;
479
- }
480
- }
481
- }
482
- if (!o.catAxisHidden) {
483
- let e = Math.max(1, Math.ceil(g / 8)), t = o.catAxisFontColor ? `#${o.catAxisFontColor}` : "#555";
484
- a.fillStyle = t, a.textAlign = "center", a.textBaseline = "top", a.font = `${N}px sans-serif`;
485
- for (let n = 0; n < g; n += e) {
486
- let e = X(n);
487
- b(a, o.catAxisMajorTickMark, "cat", B + H, e), a.fillStyle = t, a.fillText((h[n] ?? "").toString().slice(0, 10), e, B + H + 5);
488
- }
489
- }
490
- y(a, o, O, l, u, f, p, z, B, V, H, D + 2), o.catAxisTitle && m(a, o.catAxisTitle, z, B, V, H, "cat", F), o.valAxisTitle && m(a, o.valAxisTitle, z, B, V, H, "val", F);
491
- }
492
- function O(n, r, a, o) {
493
- let { x: s, y: c, w: l, h: u } = a, f = w(r), h = f.length;
494
- if (h === 0) return;
495
- let g = r.chartType === "stackedArea" || r.chartType === "stackedAreaPct", _ = r.title ? x(r, u, o) : 0, b = r.title ? u * .035 : 0, S = r.title ? u * .035 : 0, T = r.title ? _ + b + S : 0, E = v(r, l, u), D = E?.side === "r" ? E.reserveW : 0, O = E?.side === "l" ? E.reserveW : 0, k = E?.side === "t" ? E.reserveH : 0, A = E?.side === "b" ? E.reserveH : 0, j = Math.max(8, Math.min(10, u * .045)), M = r.catAxisTitle ? j + 4 : 0, N = r.valAxisTitle ? j + 4 : 0, P = {
496
- t: T + k + u * .02,
497
- r: D + l * .05,
498
- b: u * .14 + M + A,
499
- l: l * .12 + N + O
500
- };
501
- C(n, r, s, c + b, l, _);
502
- let F = s + P.l, I = c + P.t, L = l - P.l - P.r, R = u - P.t - P.b;
503
- if (L <= 0 || R <= 0) return;
504
- r.plotAreaBg && (n.fillStyle = `#${r.plotAreaBg}`, n.fillRect(F, I, L, R));
505
- let z = 0;
506
- for (let e = 0; e < h; e++) if (g) {
507
- let t = 0;
508
- for (let n of r.series) t += n.values[e] ?? 0;
509
- z = Math.max(z, t);
510
- } else for (let t of r.series) z = Math.max(z, t.values[e] ?? 0);
511
- r.valMax != null && (z = r.valMax), z === 0 && (z = 1);
512
- let B = e(z), V = r.valMax ?? t(z, B), H = (e) => F + (h === 1 ? L / 2 : e / (h - 1) * L), U = (e) => I + R - e / V * R;
513
- if (!r.valAxisHidden) {
514
- n.font = `${Math.max(8, Math.min(11, R / 20))}px sans-serif`, n.textBaseline = "middle";
515
- let e = Math.round(V / B);
516
- for (let t = 0; t <= e; t++) {
517
- let e = t * B, a = U(e);
518
- n.strokeStyle = t === 0 ? "#aaa" : "#e0e0e0", n.lineWidth = t === 0 ? 1 : .5, n.beginPath(), n.moveTo(F, a), n.lineTo(F + L, a), n.stroke(), n.fillStyle = r.valAxisFontColor ? `#${r.valAxisFontColor}` : "#555", n.textAlign = "right", n.fillText(i(e, r.valAxisFormatCode), F - 4, a);
519
- }
520
- }
521
- !r.catAxisHidden && !r.catAxisLineHidden && (n.strokeStyle = "#aaa", n.lineWidth = 1, n.beginPath(), n.moveTo(F, I + R), n.lineTo(F + L, I + R), n.stroke());
522
- let W = g ? Array(h).fill(0) : null;
523
- for (let e = r.series.length - 1; e >= 0; e--) {
524
- let t = r.series[e], i = d(e, t), a = I + R;
525
- if (n.beginPath(), g && W) {
526
- for (let e = 0; e < h; e++) {
527
- let r = (t.values[e] ?? 0) + W[e], i = H(e), a = U(r);
528
- e === 0 ? n.moveTo(i, a) : n.lineTo(i, a);
529
- }
530
- for (let e = h - 1; e >= 0; e--) n.lineTo(H(e), U(W[e]));
531
- for (let e = 0; e < h; e++) W[e] += t.values[e] ?? 0;
532
- } else {
533
- n.moveTo(H(0), a);
534
- for (let e = 0; e < h; e++) n.lineTo(H(e), U(t.values[e] ?? 0));
535
- n.lineTo(H(h - 1), a);
536
- }
537
- n.closePath(), n.fillStyle = p(i, .6), n.fill(), n.strokeStyle = i, n.lineWidth = 1.5, n.setLineDash([]), n.stroke();
538
- }
539
- if (!r.catAxisHidden) {
540
- let e = Math.max(1, Math.ceil(h / 8));
541
- n.fillStyle = r.catAxisFontColor ? `#${r.catAxisFontColor}` : "#555", n.textAlign = "center", n.textBaseline = "top", n.font = `${Math.max(8, Math.min(11, L / h * .8))}px sans-serif`;
542
- for (let t = 0; t < h; t += e) n.fillText((f[t] ?? "").toString().slice(0, 10), H(t), I + R + 3);
543
- }
544
- y(n, r, E, s, c, l, u, F, I, L, R, T + 2), r.catAxisTitle && m(n, r.catAxisTitle, F, I, L, R, "cat", j), r.valAxisTitle && m(n, r.valAxisTitle, F, I, L, R, "val", j);
545
- }
546
- function k(e, t, n, r, i) {
547
- let { x: a, y: o, w: s, h: c } = n, l = t.series[0];
548
- if (!l) return;
549
- let d = l.categories && l.categories.length > 0 ? l.categories : t.categories, p = l.values.map((e) => Math.abs(e ?? 0)), m = p.reduce((e, t) => e + t, 0);
550
- if (m === 0) return;
551
- let h = t.title ? x(t, c, i) : 0, g = t.title ? c * .035 : 0, _ = t.title ? c * .035 : 0, v = t.title ? h + g + _ : 0;
552
- C(e, t, a, o + g, s, h);
553
- let b = t.showLegend ? (() => {
554
- let e = t.legendPos ?? "r", n = e === "l" ? "l" : e === "t" ? "t" : e === "b" ? "b" : "r";
555
- return n === "r" || n === "l" ? {
556
- side: n,
557
- reserveW: Math.max(80, s * .28),
558
- reserveH: 0
559
- } : {
560
- side: n,
561
- reserveW: 0,
562
- reserveH: Math.max(18, c * .08)
563
- };
564
- })() : null, S = b?.side === "r" ? b.reserveW : 0, w = b?.side === "l" ? b.reserveW : 0, T = b?.side === "t" ? b.reserveH : 0, E = b?.side === "b" ? b.reserveH : 0, D = s - S - w, O = c - v - T - E - c * .02, k = a + w + D / 2, A = o + v + T + c * .02 + O / 2, j = Math.min(D, O) * .42, M = r ? j * .5 : 0, N = -Math.PI / 2;
565
- for (let n = 0; n < p.length; n++) {
566
- let i = p[n] / m * Math.PI * 2, a = f(n, l);
567
- if (e.beginPath(), e.moveTo(k, A), e.arc(k, A, j, N, N + i), e.closePath(), e.fillStyle = a, e.fill(), e.strokeStyle = "#fff", e.lineWidth = 1, e.stroke(), t.showDataLabels && i > .15) {
568
- let t = N + i / 2, a = j * (r ? .75 : .6), o = k + Math.cos(t) * a, s = A + Math.sin(t) * a, c = Math.round(p[n] / m * 100);
569
- e.font = `bold ${Math.max(8, j * .1)}px sans-serif`, e.fillStyle = "#fff", e.textAlign = "center", e.textBaseline = "middle", e.fillText(`${c}%`, o, s);
570
- }
571
- N += i;
572
- }
573
- if (r && (e.beginPath(), e.arc(k, A, M, 0, Math.PI * 2), e.fillStyle = "#fff", e.fill()), b) {
574
- let n = p.map((e, t) => ({
575
- name: (d[t] ?? `Item ${t + 1}`).toString(),
576
- color: l.dataPointColors?.[t] ?? l.color ?? u[t % u.length],
577
- values: []
578
- })), r = k - D / 2;
579
- y(e, {
580
- ...t,
581
- series: n
582
- }, b, a, o, s, c, r, A - O / 2, D, O, v + 2);
583
- }
584
- }
585
- function A(n, i, a, o) {
586
- let { x: s, y: c, w: l, h: u } = a, f = w(i), m = f.length;
587
- if (m < 3) return;
588
- let h = i.title ? x(i, u, o) : 0, g = i.title ? u * .035 : 0, _ = i.title ? u * .035 : 0, b = i.title ? h + g + _ : 0, T = v(i, l, u), E = T?.side === "r" ? T.reserveW : 0, D = T?.side === "l" ? T.reserveW : 0, O = T?.side === "t" ? T.reserveH : 0, k = T?.side === "b" ? T.reserveH : 0;
589
- C(n, i, s, c + g, l, h);
590
- let A = l - E - D, j = u - b - O - k - u * .02, M = s + D + A / 2, N = c + b + O + u * .02 + j / 2, P = Math.min(A, j) * .38, F = 0;
591
- for (let e of i.series) for (let t of e.values) F = Math.max(F, t ?? 0);
592
- i.valMax != null && (F = i.valMax), F === 0 && (F = 1);
593
- let I = e(F), L = i.valMax ?? t(F, I), R = -Math.PI / 2, z = (e) => R + e / m * Math.PI * 2, B = Math.round(L / I);
594
- n.strokeStyle = "#ddd", n.lineWidth = .5;
595
- for (let e = 1; e <= B; e++) {
596
- let t = e / B * P;
597
- n.beginPath();
598
- for (let e = 0; e < m; e++) {
599
- let r = z(e), i = M + Math.cos(r) * t, a = N + Math.sin(r) * t;
600
- e === 0 ? n.moveTo(i, a) : n.lineTo(i, a);
601
- }
602
- n.closePath(), n.stroke();
603
- }
604
- n.strokeStyle = "#bbb", n.lineWidth = .5;
605
- for (let e = 0; e < m; e++) {
606
- let t = z(e);
607
- n.beginPath(), n.moveTo(M, N), n.lineTo(M + Math.cos(t) * P, N + Math.sin(t) * P), n.stroke();
608
- }
609
- if (!i.valAxisHidden) {
610
- n.font = `${S(i.valAxisFontSizeHpt, u, o)}px sans-serif`, n.fillStyle = "#555", n.textAlign = "right", n.textBaseline = "middle";
611
- for (let e = 1; e <= B; e++) {
612
- let t = e / B * L, i = e / B * P;
613
- n.fillText(r(t), M - 3, N - i);
614
- }
615
- }
616
- n.font = `${Math.max(8, Math.min(11, P * .2))}px sans-serif`, n.fillStyle = "#444", n.textBaseline = "middle";
617
- for (let e = 0; e < m; e++) {
618
- let t = z(e), r = M + Math.cos(t) * (P + 12), i = N + Math.sin(t) * (P + 12);
619
- n.textAlign = Math.cos(t) < -.1 ? "right" : Math.cos(t) > .1 ? "left" : "center", n.fillText((f[e] ?? "").toString().slice(0, 12), r, i);
620
- }
621
- let V = i.radarStyle === "filled", H = Math.max(2, P * .025);
622
- for (let e = 0; e < i.series.length; e++) {
623
- let t = i.series[e], r = d(e, t), a = [];
624
- for (let e = 0; e < m; e++) {
625
- let n = t.values[e];
626
- if (n == null) {
627
- a.push(null);
628
- continue;
629
- }
630
- let r = n / L, i = z(e);
631
- a.push([M + Math.cos(i) * P * r, N + Math.sin(i) * P * r]);
632
- }
633
- n.beginPath();
634
- let o = !1;
635
- for (let e of a) {
636
- if (e == null) {
637
- o = !1;
638
- continue;
639
- }
640
- o ? n.lineTo(e[0], e[1]) : (n.moveTo(e[0], e[1]), o = !0);
641
- }
642
- let s = a.every((e) => e != null);
643
- if (V && s ? (n.closePath(), n.fillStyle = p(r, .25), n.fill()) : s && n.closePath(), n.strokeStyle = r, n.lineWidth = 2, n.stroke(), !V && t.showMarker !== !1) {
644
- n.fillStyle = r;
645
- for (let e of a) e != null && (n.beginPath(), n.arc(e[0], e[1], H, 0, Math.PI * 2), n.fill());
646
- }
647
- }
648
- y(n, i, T, s, c, l, u, M - A / 2, N - j / 2, A, j, b + 2);
649
- }
650
- function j(t, n, r, a) {
651
- let { x: o, y: s, w: c, h: l } = r, u = n.title ? x(n, l, a) : 0, f = n.title ? l * .035 : 0, p = n.title ? l * .035 : 0, h = n.title ? u + f + p : 0, g = v(n, c, l), _ = g?.side === "r" ? g.reserveW : 0, S = g?.side === "l" ? g.reserveW : 0, w = g?.side === "t" ? g.reserveH : 0, T = g?.side === "b" ? g.reserveH : 0, E = Math.max(8, Math.min(10, l * .045)), D = n.catAxisTitle ? E + 4 : 0, O = n.valAxisTitle ? E + 4 : 0;
652
- if (n.title) {
653
- let e = n.titleManualLayout;
654
- e && (e.x !== void 0 || e.y !== void 0) ? C(t, n, o + e.x * c, s + e.y * l, (e.w ?? .5) * c, u) : C(t, n, o, s + f, c, u);
655
- }
656
- let k = n.plotAreaManualLayout, A, j, F, L;
657
- if (k && k.w != null && k.h != null) A = o + k.x * c, j = s + k.y * l, F = k.w * c, L = k.h * l;
658
- else {
659
- let e = {
660
- t: h + w + l * .02,
661
- r: _ + c * .05,
662
- b: (n.catAxisHidden ? l * .04 : l * .12) + D + T,
663
- l: (n.valAxisHidden ? c * .04 : c * .12) + O + S
664
- };
665
- A = o + e.l, j = s + e.t, F = c - e.l - e.r, L = l - e.t - e.b;
666
- }
667
- if (F <= 0 || L <= 0) return;
668
- n.plotAreaBg && (t.fillStyle = `#${n.plotAreaBg}`, t.fillRect(A, j, F, L));
669
- let R = [], z = [];
670
- for (let e of n.series) {
671
- let t = e.categories ?? [];
672
- for (let e of t) {
673
- let t = parseFloat(e);
674
- isNaN(t) || R.push(t);
675
- }
676
- for (let t of e.values) t != null && z.push(t);
677
- }
678
- let B = R.length === 0;
679
- if (B) {
680
- let e = Math.max(...n.series.map((e) => e.values.length));
681
- for (let t = 0; t < e; t++) R.push(t);
682
- }
683
- let V = Math.min(...R), H = Math.max(...R), U = Math.min(...z), W = Math.max(...z);
684
- if (V === H && (--V, H += 1), U === W && (--U, W += 1), n.valMin == null ? U > 0 && (U = 0) : U = n.valMin, n.valMax != null && (W = n.valMax), n.catAxisMin != null && (V = n.catAxisMin), n.catAxisMax != null && (H = n.catAxisMax), n.catAxisMin == null || n.catAxisMax == null) {
685
- let t = e(H - V);
686
- t > 0 && (n.catAxisMin ?? (V = Math.floor(V / t) * t), n.catAxisMax ?? (H = Math.ceil(H / t) * t));
687
- }
688
- let G = (e) => A + (e - V) / (H - V) * F, K = (e) => j + L - (e - U) / (W - U) * L;
689
- if (!n.valAxisHidden) {
690
- let r = Math.max(8, Math.min(11, L / 20));
691
- t.font = `${n.valAxisFontBold ? "bold " : ""}${r}px sans-serif`;
692
- let a = e(W - U), o = Math.round((W - U) / a) + 1;
693
- for (let e = 0; e < o; e++) {
694
- let r = U + e * a;
695
- if (r > W + a * .01) break;
696
- let o = K(r);
697
- t.strokeStyle = "#e0e0e0", t.lineWidth = .5, t.beginPath(), t.moveTo(A, o), t.lineTo(A + F, o), t.stroke(), t.fillStyle = "#555", t.textAlign = "right", t.textBaseline = "middle", t.fillText(i(r, n.valAxisFormatCode), A - 4, o);
698
- let s = n.valAxisLineColor ? `#${n.valAxisLineColor}` : void 0, c = n.valAxisLineWidthEmu ? Math.max(.5, n.valAxisLineWidthEmu / 12700) : void 0;
699
- b(t, n.valAxisMajorTickMark, "val", A, o, s, c);
700
- }
701
- }
702
- let q = j + L;
703
- if (n.catAxisCrossesAt != null) q = I(K(n.catAxisCrossesAt), j, j + L);
704
- else {
705
- let e = n.catAxisCrosses ?? "autoZero";
706
- e === "autoZero" && U < 0 && W > 0 ? q = I(K(0), j, j + L) : e === "min" ? q = j + L : e === "max" && (q = j);
707
- }
708
- if (!n.catAxisHidden && !n.catAxisLineHidden && (t.save(), t.strokeStyle = n.catAxisLineColor ? `#${n.catAxisLineColor}` : "#888", t.lineWidth = n.catAxisLineWidthEmu ? Math.max(.5, n.catAxisLineWidthEmu / 12700) : 1, t.lineCap = "butt", t.beginPath(), t.moveTo(A, q), t.lineTo(A + F, q), t.stroke(), t.restore()), !n.valAxisHidden && !n.valAxisLineHidden && (t.save(), t.strokeStyle = n.valAxisLineColor ? `#${n.valAxisLineColor}` : "#888", t.lineWidth = n.valAxisLineWidthEmu ? Math.max(.5, n.valAxisLineWidthEmu / 12700) : 1, t.beginPath(), t.moveTo(A, j), t.lineTo(A, j + L), t.stroke(), t.restore()), !n.catAxisHidden) {
709
- let r = Math.max(8, Math.min(11, L / 20));
710
- t.font = `${n.catAxisFontBold ? "bold " : ""}${r}px sans-serif`;
711
- let a = e(H - V), o = Math.round((H - V) / a) + 1;
712
- t.fillStyle = "#555", t.textAlign = "center", t.textBaseline = "top";
713
- for (let e = 0; e < o; e++) {
714
- let r = V + e * a;
715
- if (r > H + a * .01) break;
716
- let o = G(r);
717
- t.fillText(i(r, n.catAxisFormatCode), o, q + 4);
718
- let s = n.catAxisLineColor ? `#${n.catAxisLineColor}` : void 0, c = n.catAxisLineWidthEmu ? Math.max(.5, n.catAxisLineWidthEmu / 12700) : void 0;
719
- b(t, n.catAxisMajorTickMark, "cat", q, o, s, c);
720
- }
721
- }
722
- let J = n.chartType === "bubble", Y = J ? "marker" : n.scatterStyle ?? "marker", X = Y === "line" || Y === "lineMarker" || Y === "lineNoMarker", Z = Y === "smooth" || Y === "smoothMarker" || Y === "smoothNoMarker", ee = Y === "lineNoMarker" || Y === "smoothNoMarker";
723
- for (let e = 0; e < n.series.length; e++) {
724
- let r = n.series[e], i = d(e, r), o = r.categories ?? [];
725
- for (let e of r.errBars ?? []) N(t, r, e, o, B, G, K, i);
726
- if (X || Z) {
727
- let e = [];
728
- for (let t = 0; t < r.values.length; t++) {
729
- let n = r.values[t];
730
- if (n == null) continue;
731
- let i = B ? t : parseFloat(o[t] ?? "0");
732
- isNaN(i) || e.push({
733
- x: G(i),
734
- y: K(n)
735
- });
736
- }
737
- if (e.length >= 2) {
738
- if (t.save(), t.strokeStyle = r.color ? `#${r.color}` : i, t.lineWidth = 1.5, t.beginPath(), t.moveTo(e[0].x, e[0].y), Z && e.length >= 3) for (let n = 0; n < e.length - 1; n++) {
739
- let r = e[n - 1] ?? e[n], i = e[n], a = e[n + 1], o = e[n + 2] ?? a, s = i.x + (a.x - r.x) / 6, c = i.y + (a.y - r.y) / 6, l = a.x - (o.x - i.x) / 6, u = a.y - (o.y - i.y) / 6;
740
- t.bezierCurveTo(s, c, l, u, a.x, a.y);
741
- }
742
- else for (let n = 1; n < e.length; n++) t.lineTo(e[n].x, e[n].y);
743
- t.stroke(), t.restore();
744
- }
745
- }
746
- if (!(ee || r.showMarker === !1 || typeof r.markerSymbol == "string" && r.markerSymbol === "none")) {
747
- let e = 0;
748
- if (J && r.bubbleSizes && r.bubbleSizes.length > 0) {
749
- let t = Math.max(0, ...r.bubbleSizes.filter((e) => e != null));
750
- t > 0 && (e = Math.min(F, L) / Math.max(8, r.values.length * 1.6) / Math.sqrt(t));
751
- }
752
- for (let n = 0; n < r.values.length; n++) {
753
- let s = r.values[n];
754
- if (s == null) continue;
755
- let c = B ? n : parseFloat(o[n] ?? "0");
756
- if (isNaN(c)) continue;
757
- let l = (r.dataPointOverrides ?? []).find((e) => e.idx === n), u = l?.markerSymbol ?? r.markerSymbol ?? "circle", d = l?.markerSize ?? r.markerSize ?? 5;
758
- if (J && e > 0) {
759
- let t = r.bubbleSizes?.[n];
760
- t != null && t > 0 && (d = Math.sqrt(t) * e * 2 / a);
761
- }
762
- let f = l?.markerFill ?? l?.color ?? r.markerFill ?? i, p = l?.markerLine ?? r.markerLine ?? null;
763
- M(t, G(c), K(s), u, d, f, p, a);
764
- }
765
- }
766
- P(t, r, o, B, G, K, L, a);
767
- }
768
- y(t, n, g, o, s, c, l, A, j, F, L, h + 2), n.catAxisTitle && m(t, n.catAxisTitle, A, j, F, L, "cat", E), n.valAxisTitle && m(t, n.valAxisTitle, A, j, F, L, "val", E);
769
- }
770
- function M(e, t, n, r, i, a, o, s) {
771
- let c = Math.max(2, i * s), l = c / 2, u = a.startsWith("#") ? a : `#${a}`, d = o ? o.startsWith("#") ? o : `#${o}` : null;
772
- switch (e.save(), e.fillStyle = u, d && (e.strokeStyle = d, e.lineWidth = 1), r) {
773
- case "square":
774
- e.fillRect(t - l, n - l, c, c), o && e.strokeRect(t - l, n - l, c, c);
775
- break;
776
- case "diamond":
777
- e.beginPath(), e.moveTo(t, n - l), e.lineTo(t + l, n), e.lineTo(t, n + l), e.lineTo(t - l, n), e.closePath(), e.fill(), o && e.stroke();
778
- break;
779
- case "triangle":
780
- e.beginPath(), e.moveTo(t, n - l), e.lineTo(t + l, n + l), e.lineTo(t - l, n + l), e.closePath(), e.fill(), o && e.stroke();
781
- break;
782
- case "x":
783
- e.strokeStyle = u, e.lineWidth = Math.max(1, c * .18), e.beginPath(), e.moveTo(t - l, n - l), e.lineTo(t + l, n + l), e.moveTo(t - l, n + l), e.lineTo(t + l, n - l), e.stroke();
784
- break;
785
- case "plus":
786
- e.strokeStyle = u, e.lineWidth = Math.max(1, c * .18), e.beginPath(), e.moveTo(t - l, n), e.lineTo(t + l, n), e.moveTo(t, n - l), e.lineTo(t, n + l), e.stroke();
787
- break;
788
- case "star":
789
- e.beginPath();
790
- for (let r = 0; r < 10; r++) {
791
- let i = r % 2 == 0 ? l : l * .45, a = -Math.PI / 2 + r * Math.PI / 5, o = t + Math.cos(a) * i, s = n + Math.sin(a) * i;
792
- r === 0 ? e.moveTo(o, s) : e.lineTo(o, s);
793
- }
794
- e.closePath(), e.fill(), o && e.stroke();
795
- break;
796
- case "dot":
797
- e.beginPath(), e.arc(t, n, Math.max(1, c * .25), 0, Math.PI * 2), e.fill();
798
- break;
799
- case "dash": {
800
- let r = Math.max(1, c * .25);
801
- e.fillRect(t - l, n - r / 2, c, r);
802
- break;
803
- }
804
- default:
805
- e.beginPath(), e.arc(t, n, l, 0, Math.PI * 2), e.fill(), o && e.stroke();
806
- break;
807
- }
808
- e.restore();
809
- }
810
- function N(e, t, n, r, i, a, o, s) {
811
- e.save(), e.strokeStyle = n.color ? `#${n.color}` : s, e.lineWidth = n.lineWidthEmu ? Math.max(.5, n.lineWidthEmu / 12700) : 1, e.setLineDash(L(n.dash));
812
- let c = n.barType === "plus" || n.barType === "both", l = n.barType === "minus" || n.barType === "both", u = n.dir === "x", d = e.lineWidth * 1.5;
813
- for (let s = 0; s < t.values.length; s++) {
814
- let f = t.values[s];
815
- if (f == null) continue;
816
- let p = i ? s : parseFloat(r[s] ?? "0");
817
- if (isNaN(p)) continue;
818
- let m = a(p), h = o(f), g = (t) => {
819
- let r = m, i = h;
820
- u ? r = a(p + t) : i = o(f + t), e.beginPath(), e.moveTo(m, h), e.lineTo(r, i), e.stroke(), n.noEndCap || (e.save(), e.setLineDash([]), e.beginPath(), u ? (e.moveTo(r, i - d), e.lineTo(r, i + d)) : (e.moveTo(r - d, i), e.lineTo(r + d, i)), e.stroke(), e.restore());
821
- };
822
- if (c) {
823
- let e = n.plus[s];
824
- e != null && g(e);
825
- }
826
- if (l) {
827
- let e = n.minus[s];
828
- e != null && g(-e);
829
- }
830
- }
831
- e.restore();
832
- }
833
- function P(e, t, n, r, a, o, s, c) {
834
- let l = t.dataLabelOverrides ?? [];
835
- if (l.length === 0 && !t.seriesDataLabels) return;
836
- let u = t.seriesDataLabels;
837
- for (let d = 0; d < t.values.length; d++) {
838
- let f = t.values[d];
839
- if (f == null) continue;
840
- let p = r ? d : parseFloat(n[d] ?? "0");
841
- if (isNaN(p)) continue;
842
- let m = l.find((e) => e.idx === d), h;
843
- if (m) {
844
- if (m.text === "") continue;
845
- h = m.text;
846
- } else if (u && (u.showVal || u.showSerName || u.showCatName)) {
847
- let e = [];
848
- if (u.showCatName && !r && e.push(n[d] ?? ""), u.showSerName && e.push(t.name), u.showVal && e.push(i(f, u.formatCode ?? null)), h = e.filter(Boolean).join(" "), !h) continue;
849
- } else continue;
850
- let g = m?.position ?? u?.position ?? "r", _ = m?.fontSizeHpt ?? u?.fontSizeHpt, v = _ ? _ / 100 * c : Math.max(9, Math.min(11, s / 25)), y = m?.fontColor ?? u?.fontColor, b = m?.fontBold ?? u?.fontBold ?? !1;
851
- F(e, a(p), o(f), h, g, v, y, b);
852
- }
853
- }
854
- function F(e, t, n, r, i, a, o, s) {
855
- e.save(), e.font = `${s ? "bold " : ""}${a}px sans-serif`, e.fillStyle = o ? `#${o}` : "#333";
856
- let c = a * .6, l = t, u = n;
857
- switch (i) {
858
- case "l":
859
- e.textAlign = "right", e.textBaseline = "middle", l = t - c;
860
- break;
861
- case "r":
862
- e.textAlign = "left", e.textBaseline = "middle", l = t + c;
863
- break;
864
- case "t":
865
- e.textAlign = "center", e.textBaseline = "bottom", u = n - c;
866
- break;
867
- case "b":
868
- e.textAlign = "center", e.textBaseline = "top", u = n + c;
869
- break;
870
- case "ctr":
871
- e.textAlign = "center", e.textBaseline = "middle";
872
- break;
873
- default:
874
- e.textAlign = "left", e.textBaseline = "middle", l = t + c;
875
- break;
876
- }
877
- let d = r.split(/\r?\n/), f = a * 1.15, p = f * d.length, m = u;
878
- e.textBaseline === "middle" ? m = u - (p - f) / 2 : e.textBaseline === "bottom" && (m = u - (p - f));
879
- for (let t of d) e.fillText(t, l, m), m += f;
880
- e.restore();
881
- }
882
- function I(e, t, n) {
883
- return e < t ? t : e > n ? n : e;
884
- }
885
- function L(e) {
886
- if (!e) return [];
887
- switch (e) {
888
- case "solid": return [];
889
- case "dot":
890
- case "sysDot": return [1, 2];
891
- case "dash":
892
- case "sysDash": return [4, 2];
893
- case "lgDash": return [8, 3];
894
- case "dashDot":
895
- case "sysDashDot": return [
896
- 4,
897
- 2,
898
- 1,
899
- 2
900
- ];
901
- case "lgDashDot": return [
902
- 8,
903
- 3,
904
- 1,
905
- 3
906
- ];
907
- case "dashDotDot":
908
- case "sysDashDotDot":
909
- case "lgDashDotDot": return [
910
- 4,
911
- 2,
912
- 1,
913
- 2,
914
- 1,
915
- 2
916
- ];
917
- default: return [];
918
- }
919
- }
920
- function R(t, n, r) {
921
- let { x: i, y: a, w: o, h: s } = r, c = n.plotAreaManualLayout, l, u, d, f;
922
- if (c && c.w != null && c.h != null) l = i + c.x * o, u = a + c.y * s, d = c.w * o, f = c.h * s;
923
- else {
924
- let e = n.valAxisHidden ? o * .01 : o * .11, t = o * .01, r = s * .12, c = s * .14;
925
- l = i + e, u = a + r, d = o - e - t, f = s - r - c;
926
- }
927
- let p = n.series[0]?.values ?? [], m = n.categories, h = m.length;
928
- if (h === 0) return;
929
- let g = new Set(n.subtotalIndices), _ = 0, v = [];
930
- for (let e = 0; e < h; e++) {
931
- let t = p[e] ?? 0;
932
- if (e === 0 || g.has(e)) v.push({
933
- start: 0,
934
- end: t,
935
- isSub: !0,
936
- isPos: !0
937
- }), _ = t;
938
- else {
939
- let e = t >= 0 ? _ : _ + t, n = t >= 0 ? _ + t : _;
940
- v.push({
941
- start: e,
942
- end: n,
943
- isSub: !1,
944
- isPos: t >= 0
945
- }), _ += t;
946
- }
947
- }
948
- let y = v.map((e) => e.end), b = v.map((e) => e.start), x = Math.max(...y, ...b), S = Math.min(...b, 0), C = x - S;
949
- if (C <= 0) return;
950
- let w = S < 0 ? S - C * .05 : 0, T = (x - w) * 1.1, E = w + T, D = e(T);
951
- t.save();
952
- let O = Math.round(s * .042);
953
- if (t.font = `${O}px sans-serif`, !n.valAxisHidden) {
954
- t.strokeStyle = "#e8e8e8", t.lineWidth = .7, t.fillStyle = "#666", t.textAlign = "right", t.textBaseline = "middle";
955
- for (let e = Math.ceil(w / D) * D; e <= E; e += D) {
956
- let n = u + f * (1 - (e - w) / T);
957
- t.beginPath(), t.moveTo(l, n), t.lineTo(l + d, n), t.stroke(), t.fillText(e.toLocaleString(), l - 4, n);
958
- }
959
- }
960
- let k = !n.valAxisHidden && !n.valAxisLineHidden, A = !n.catAxisHidden && !n.catAxisLineHidden;
961
- (k || A) && (t.strokeStyle = "#bbb", t.lineWidth = 1, t.beginPath(), k ? (t.moveTo(l, u), t.lineTo(l, u + f), A && t.lineTo(l + d, u + f)) : A && (t.moveTo(l, u + f), t.lineTo(l + d, u + f)), t.stroke());
962
- let j = d / h, M = j / (1 + (n.barGapWidth ?? 150) / 100);
963
- v.forEach((e, r) => {
964
- let i = l + j * r + (j - M) / 2, a = u + f * (1 - (e.end - w) / T), o = u + f * (1 - (e.start - w) / T), c = Math.max(1, o - a);
965
- if (e.isSub ? (t.fillStyle = "#196ECA", t.fillRect(i, a, M, c)) : (t.strokeStyle = e.isPos ? "#5BA4E6" : "#E46970", t.lineWidth = 1.5, t.strokeRect(i + .75, a + .75, M - 1.5, c - 1.5)), r < h - 1) {
966
- let n = l + j * (r + 1) + (j - M) / 2, s = e.isPos ? a : o;
967
- t.strokeStyle = "#ccc", t.lineWidth = .8, t.setLineDash([3, 3]), t.beginPath(), t.moveTo(i + M, s), t.lineTo(n, s), t.stroke(), t.setLineDash([]);
968
- }
969
- let d = p[r] ?? 0, m = d < 0 ? `△ ${Math.abs(d).toLocaleString()}` : d.toLocaleString(), g = n.series[0]?.dataLabelColors?.[r] ?? null;
970
- t.fillStyle = g ? `#${g}` : n.dataLabelFontColor ? `#${n.dataLabelFontColor}` : "#595959", t.font = `bold ${Math.round(s * .044)}px sans-serif`, t.textAlign = "center", d < 0 ? (t.textBaseline = "top", t.fillText(m, i + M / 2, o + 3)) : (t.textBaseline = "bottom", t.fillText(m, i + M / 2, a - 3));
971
- }), t.textAlign = "center", t.textBaseline = "top", t.fillStyle = "#666", t.font = `${Math.round(s * .038)}px sans-serif`;
972
- let N = u + f + 4;
973
- for (let e = 0; e < h; e++) {
974
- let n = l + j * e + j / 2;
975
- m[e].split(/\s+/).forEach((e, r) => t.fillText(e, n, N + r * (O + 2)));
976
- }
977
- t.restore();
978
- }
979
- function z(e, t, n, r = 1.333) {
980
- let { x: i, y: a, w: o, h: s } = n;
981
- if (t.chartBg && (e.fillStyle = `#${t.chartBg}`, e.fillRect(i, a, o, s)), t.series.length === 0) {
982
- e.fillStyle = "#888", e.font = "12px sans-serif", e.textAlign = "center", e.textBaseline = "middle", e.fillText("(no data)", i + o / 2, a + s / 2);
983
- return;
984
- }
985
- switch (t.chartType) {
986
- case "clusteredBar":
987
- case "clusteredBarH":
988
- case "stackedBar":
989
- case "stackedBarH":
990
- case "stackedBarPct":
991
- case "stackedBarHPct":
992
- E(e, t, n, r);
993
- break;
994
- case "line":
995
- case "stackedLine":
996
- case "stackedLinePct":
997
- D(e, t, n, r);
998
- break;
999
- case "area":
1000
- case "stackedArea":
1001
- case "stackedAreaPct":
1002
- O(e, t, n, r);
1003
- break;
1004
- case "pie":
1005
- k(e, t, n, !1, r);
1006
- break;
1007
- case "doughnut":
1008
- k(e, t, n, !0, r);
1009
- break;
1010
- case "radar":
1011
- A(e, t, n, r);
1012
- break;
1013
- case "scatter":
1014
- case "bubble":
1015
- j(e, t, n, r);
1016
- break;
1017
- case "waterfall":
1018
- R(e, t, n);
1019
- break;
1020
- 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);
1021
- }
1022
- }
1023
- //#endregion
1024
- export { z as t };