@svgrid/grid-wc 3.0.0 → 3.0.1
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/README.md +110 -110
- package/dist/{GridMenus-DpmS1pzo.js → GridMenus-YwTw9Upd.js} +64 -62
- package/dist/{SvDateRangeInput-u4ibte8S.js → SvDateRangeInput-CrxeppBV.js} +6 -6
- package/dist/{shadow/SvDateTimePicker-DVFiDxUq.js → SvDateTimePicker-xAO-Pb4S.js} +22 -22
- package/dist/{shadow/SvField-ChCI-O2O.js → SvField-CE345DyF.js} +3 -3
- package/dist/{SvGridCellEditor-DvsQyE9a.js → SvGridCellEditor-D7SyHtff.js} +2 -2
- package/dist/SvGridChart-CMaVmlso.js +1477 -0
- package/dist/SvGridChartPanel-Pc_IW0eA.js +833 -0
- package/dist/{SvGridChartView-ScXTF6t-.js → SvGridChartView-DLhhzmFy.js} +6 -4
- package/dist/{shadow/SvGridDropdown-DnAESFDu.js → SvGridDropdown-DUncHqM-.js} +2 -2
- package/dist/{cell-formatting-C0OsDmi_.js → cell-formatting-Eypm-id0.js} +1 -1
- package/dist/chart-GRBAgN1M.js +1658 -0
- package/dist/{date-format-CPHqTHN6.js → date-format-D_oQ5Yw0.js} +13 -13
- package/dist/{export-format-B6FUgOll.js → export-format-uGayRKWM.js} +3 -3
- package/dist/shadow/{GridMenus-DpmS1pzo.js → GridMenus-YwTw9Upd.js} +64 -62
- package/dist/shadow/{SvDateRangeInput-u4ibte8S.js → SvDateRangeInput-CrxeppBV.js} +6 -6
- package/dist/{SvDateTimePicker-DVFiDxUq.js → shadow/SvDateTimePicker-xAO-Pb4S.js} +22 -22
- package/dist/{SvField-ChCI-O2O.js → shadow/SvField-CE345DyF.js} +3 -3
- package/dist/shadow/{SvGridCellEditor-DvsQyE9a.js → SvGridCellEditor-D7SyHtff.js} +2 -2
- package/dist/shadow/SvGridChart-CMaVmlso.js +1477 -0
- package/dist/shadow/SvGridChartPanel-Pc_IW0eA.js +833 -0
- package/dist/shadow/{SvGridChartView-ScXTF6t-.js → SvGridChartView-DLhhzmFy.js} +6 -4
- package/dist/{SvGridDropdown-DnAESFDu.js → shadow/SvGridDropdown-DUncHqM-.js} +2 -2
- package/dist/shadow/{cell-formatting-C0OsDmi_.js → cell-formatting-Eypm-id0.js} +1 -1
- package/dist/shadow/chart-GRBAgN1M.js +1658 -0
- package/dist/shadow/{date-format-CPHqTHN6.js → date-format-D_oQ5Yw0.js} +13 -13
- package/dist/shadow/{export-format-C8kZGZfz.js → export-format-DhdZREP1.js} +3 -3
- package/dist/shadow/sv-grid-shadow-element.js +2160 -2000
- package/dist/sv-grid-element.js +2158 -1998
- package/package.json +3 -3
- package/dist/SvGridChart-yK5Zv85y.js +0 -1199
- package/dist/SvGridChartPanel-B38_VjXM.js +0 -584
- package/dist/chart-uvs3sFJA.js +0 -1220
- package/dist/shadow/SvGridChart-yK5Zv85y.js +0 -1199
- package/dist/shadow/SvGridChartPanel-B38_VjXM.js +0 -584
- package/dist/shadow/chart-uvs3sFJA.js +0 -1220
|
@@ -0,0 +1,1658 @@
|
|
|
1
|
+
import { r as e } from "./cell-formatting-Eypm-id0.js";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var t = Object.defineProperty, n = /* @__PURE__ */ ((e, n) => {
|
|
4
|
+
let r = {};
|
|
5
|
+
for (var i in e) t(r, i, {
|
|
6
|
+
get: e[i],
|
|
7
|
+
enumerable: !0
|
|
8
|
+
});
|
|
9
|
+
return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
10
|
+
})({
|
|
11
|
+
DEFAULT_PALETTE: () => o,
|
|
12
|
+
boxStats: () => r,
|
|
13
|
+
buildChart: () => M,
|
|
14
|
+
buildLinePath: () => b,
|
|
15
|
+
chartScales: () => y,
|
|
16
|
+
computeOverlay: () => T,
|
|
17
|
+
exponentialMovingAverage: () => w,
|
|
18
|
+
formatChartValue: () => O,
|
|
19
|
+
linearTrend: () => S,
|
|
20
|
+
niceLogScale: () => _,
|
|
21
|
+
niceScale: () => E,
|
|
22
|
+
ordinalDateTicks: () => ee,
|
|
23
|
+
pickContrastText: () => g,
|
|
24
|
+
rowsToBoxSpec: () => I,
|
|
25
|
+
rowsToChartSpec: () => re,
|
|
26
|
+
rowsToDirectSpec: () => ae,
|
|
27
|
+
rowsToGaugeSpec: () => R,
|
|
28
|
+
rowsToScatterSpec: () => L,
|
|
29
|
+
sampleGradient: () => m,
|
|
30
|
+
simpleMovingAverage: () => C,
|
|
31
|
+
sliceChartWindow: () => N,
|
|
32
|
+
specToCalendar: () => F,
|
|
33
|
+
specToSankey: () => ie,
|
|
34
|
+
specToTreemap: () => P
|
|
35
|
+
});
|
|
36
|
+
function r(e, t = 1.5) {
|
|
37
|
+
let n = e.filter((e) => Number.isFinite(e)).slice().sort((e, t) => e - t);
|
|
38
|
+
if (!n.length) return null;
|
|
39
|
+
let r = (e) => {
|
|
40
|
+
let t = (n.length - 1) * e, r = Math.floor(t), i = Math.ceil(t);
|
|
41
|
+
return r === i ? n[r] : n[r] + (n[i] - n[r]) * (t - r);
|
|
42
|
+
}, i = r(.25), a = r(.5), o = r(.75), s = i - t * (o - i), c = o + t * (o - i), l = n.filter((e) => e >= s && e <= c), u = n.filter((e) => e < s || e > c);
|
|
43
|
+
return {
|
|
44
|
+
min: l.length ? l[0] : n[0],
|
|
45
|
+
q1: i,
|
|
46
|
+
median: a,
|
|
47
|
+
q3: o,
|
|
48
|
+
max: l.length ? l[l.length - 1] : n[n.length - 1],
|
|
49
|
+
...u.length ? { outliers: u } : {}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function i(e, t, n, r) {
|
|
53
|
+
let i = Math.max(1, Math.ceil((r ? 18 : 60) / Math.max(n, .001))), a = [];
|
|
54
|
+
for (let n = 0; n < e.length; n += i) a.push({
|
|
55
|
+
label: e[n],
|
|
56
|
+
x: t(n)
|
|
57
|
+
});
|
|
58
|
+
return a;
|
|
59
|
+
}
|
|
60
|
+
function a(e, t) {
|
|
61
|
+
if (e == null) return null;
|
|
62
|
+
if (typeof e == "number") {
|
|
63
|
+
if (!Number.isFinite(e)) return null;
|
|
64
|
+
let n = Math.abs(e);
|
|
65
|
+
return {
|
|
66
|
+
lo: t - n,
|
|
67
|
+
hi: t + n
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return !Number.isFinite(e.lo) || !Number.isFinite(e.hi) ? null : {
|
|
71
|
+
lo: Math.min(e.lo, e.hi),
|
|
72
|
+
hi: Math.max(e.lo, e.hi)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
var o = [
|
|
76
|
+
"#2563eb",
|
|
77
|
+
"#16a34a",
|
|
78
|
+
"#f59e0b",
|
|
79
|
+
"#ef4444",
|
|
80
|
+
"#8b5cf6",
|
|
81
|
+
"#0ea5e9",
|
|
82
|
+
"#ec4899",
|
|
83
|
+
"#14b8a6"
|
|
84
|
+
];
|
|
85
|
+
function s(e) {
|
|
86
|
+
return Math.round(e * 100) / 100;
|
|
87
|
+
}
|
|
88
|
+
function c(e, t) {
|
|
89
|
+
if (e <= 0) return 1;
|
|
90
|
+
let n = Math.floor(Math.log10(e)), r = e / 10 ** n, i;
|
|
91
|
+
return i = t ? r < 1.5 ? 1 : r < 3 ? 2 : r < 7 ? 5 : 10 : r <= 1 ? 1 : r <= 2 ? 2 : r <= 5 ? 5 : 10, i * 10 ** n;
|
|
92
|
+
}
|
|
93
|
+
var l = [
|
|
94
|
+
"#eff6ff",
|
|
95
|
+
"#bfdbfe",
|
|
96
|
+
"#60a5fa",
|
|
97
|
+
"#2563eb",
|
|
98
|
+
"#1e3a8a"
|
|
99
|
+
], u = [
|
|
100
|
+
"#b91c1c",
|
|
101
|
+
"#fca5a5",
|
|
102
|
+
"#f1f5f9",
|
|
103
|
+
"#93c5fd",
|
|
104
|
+
"#1d4ed8"
|
|
105
|
+
], d = [
|
|
106
|
+
"#1c2c4d",
|
|
107
|
+
"#1d4ed8",
|
|
108
|
+
"#3b82f6",
|
|
109
|
+
"#60a5fa",
|
|
110
|
+
"#bae6fd"
|
|
111
|
+
], f = [
|
|
112
|
+
"#f87171",
|
|
113
|
+
"#b91c1c",
|
|
114
|
+
"#222b3d",
|
|
115
|
+
"#1d4ed8",
|
|
116
|
+
"#60a5fa"
|
|
117
|
+
];
|
|
118
|
+
function p(e, t, n, r = "light") {
|
|
119
|
+
if (Array.isArray(e) && e.length >= 2) return e;
|
|
120
|
+
let i = r === "dark";
|
|
121
|
+
return e === "diverging" || e == null && t < 0 && n > 0 ? i ? f : u : i ? d : l;
|
|
122
|
+
}
|
|
123
|
+
function m(e, t) {
|
|
124
|
+
if (!e.length) return "#888";
|
|
125
|
+
let n = Math.max(0, Math.min(1, t));
|
|
126
|
+
if (e.length === 1) return e[0];
|
|
127
|
+
let r = n * (e.length - 1), i = Math.floor(r), a = r - i, o = h(e[i]), s = h(e[Math.min(e.length - 1, i + 1)]);
|
|
128
|
+
if (!o || !s) return e[i] ?? "#888";
|
|
129
|
+
let c = (e, t) => Math.round(e + (t - e) * a), l = (e) => e.toString(16).padStart(2, "0");
|
|
130
|
+
return "#" + l(c(o.r, s.r)) + l(c(o.g, s.g)) + l(c(o.b, s.b));
|
|
131
|
+
}
|
|
132
|
+
function h(e) {
|
|
133
|
+
let t = /^#?([0-9a-f]{6})$/i.exec(e.trim());
|
|
134
|
+
if (!t) return null;
|
|
135
|
+
let n = parseInt(t[1], 16);
|
|
136
|
+
return {
|
|
137
|
+
r: n >> 16 & 255,
|
|
138
|
+
g: n >> 8 & 255,
|
|
139
|
+
b: n & 255
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function g(e) {
|
|
143
|
+
let t = h(e);
|
|
144
|
+
if (!t) return "#0f172a";
|
|
145
|
+
let n = (e) => {
|
|
146
|
+
let t = e / 255;
|
|
147
|
+
return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
148
|
+
};
|
|
149
|
+
return .2126 * n(t.r) + .7152 * n(t.g) + .0722 * n(t.b) > .5 ? "#0f172a" : "#ffffff";
|
|
150
|
+
}
|
|
151
|
+
function _(e, t) {
|
|
152
|
+
(!Number.isFinite(e) || e <= 0) && (e = 1), (!Number.isFinite(t) || t <= e) && (t = e * 10);
|
|
153
|
+
let n = Math.floor(Math.log10(e)), r = Math.ceil(Math.log10(t)), i = [];
|
|
154
|
+
for (let e = n; e <= r; e += 1) i.push(10 ** e);
|
|
155
|
+
return {
|
|
156
|
+
min: 10 ** n,
|
|
157
|
+
max: 10 ** r,
|
|
158
|
+
step: 10,
|
|
159
|
+
ticks: i
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function v(e, t, n, r) {
|
|
163
|
+
return Number.isFinite(e) ? r ? e <= 0 || t <= 0 ? null : (Math.log10(e) - Math.log10(t)) / (Math.log10(n) - Math.log10(t)) : (e - t) / (n - t) : null;
|
|
164
|
+
}
|
|
165
|
+
function y(e) {
|
|
166
|
+
let t = e.axes;
|
|
167
|
+
if (!t) return null;
|
|
168
|
+
let { x: n, y: r, h: i } = e.plot, a = (e) => (t) => {
|
|
169
|
+
let n = v(t, e.min, e.max, e.log);
|
|
170
|
+
return n === null ? NaN : r + i - n * i;
|
|
171
|
+
}, o = a(t.y), s = t.y2 ? a(t.y2) : o, c = (e) => (t) => {
|
|
172
|
+
let n = i === 0 ? 0 : (r + i - t) / i;
|
|
173
|
+
if (!e.log) return e.min + n * (e.max - e.min);
|
|
174
|
+
let a = Math.log10(e.min);
|
|
175
|
+
return 10 ** (a + n * (Math.log10(e.max) - a));
|
|
176
|
+
};
|
|
177
|
+
return {
|
|
178
|
+
xOf: (e) => n + t.slot * e + t.slot / 2,
|
|
179
|
+
yOf: (e, t) => t === "right" ? s(e) : o(e),
|
|
180
|
+
xInvert: (e) => Math.max(0, Math.min(t.count - 1, Math.floor((e - n) / (t.slot || 1)))),
|
|
181
|
+
yInvert: (e, n) => n === "right" && t.y2 ? c(t.y2)(e) : c(t.y)(e)
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function b(e, t) {
|
|
185
|
+
if (!t) {
|
|
186
|
+
let t = "", n = !1;
|
|
187
|
+
for (let r of e) {
|
|
188
|
+
if (!r.defined) {
|
|
189
|
+
n = !1;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
t += `${n ? "L" : "M"}${r.x},${r.y} `, n = !0;
|
|
193
|
+
}
|
|
194
|
+
return t.trim();
|
|
195
|
+
}
|
|
196
|
+
let n = [], r = [];
|
|
197
|
+
for (let t of e) t.defined ? r.push({
|
|
198
|
+
x: t.x,
|
|
199
|
+
y: t.y
|
|
200
|
+
}) : r.length && (n.push(r), r = []);
|
|
201
|
+
return r.length && n.push(r), n.map(x).filter(Boolean).join(" ");
|
|
202
|
+
}
|
|
203
|
+
function x(e) {
|
|
204
|
+
let t = e.length;
|
|
205
|
+
if (t === 0) return "";
|
|
206
|
+
if (t === 1) return `M${e[0].x},${e[0].y}`;
|
|
207
|
+
if (t === 2) return `M${e[0].x},${e[0].y} L${e[1].x},${e[1].y}`;
|
|
208
|
+
let n = Array(t - 1), r = Array(t - 1);
|
|
209
|
+
for (let i = 0; i < t - 1; i += 1) {
|
|
210
|
+
let t = e[i + 1].x - e[i].x;
|
|
211
|
+
n[i] = t, r[i] = t === 0 ? 0 : (e[i + 1].y - e[i].y) / t;
|
|
212
|
+
}
|
|
213
|
+
let i = Array(t);
|
|
214
|
+
i[0] = r[0], i[t - 1] = r[t - 2];
|
|
215
|
+
for (let e = 1; e < t - 1; e += 1) r[e - 1] * r[e] <= 0 ? i[e] = 0 : i[e] = (r[e - 1] + r[e]) / 2;
|
|
216
|
+
for (let e = 0; e < t - 1; e += 1) {
|
|
217
|
+
if (r[e] === 0) {
|
|
218
|
+
i[e] = 0, i[e + 1] = 0;
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
let t = i[e] / r[e], n = i[e + 1] / r[e], a = Math.hypot(t, n);
|
|
222
|
+
a > 3 && (i[e] = 3 / a * t * r[e], i[e + 1] = 3 / a * n * r[e]);
|
|
223
|
+
}
|
|
224
|
+
let a = `M${e[0].x},${e[0].y}`;
|
|
225
|
+
for (let r = 0; r < t - 1; r += 1) {
|
|
226
|
+
let t = n[r], o = e[r].x + t / 3, s = e[r].y + i[r] * t / 3, c = e[r + 1].x - t / 3, l = e[r + 1].y - i[r + 1] * t / 3;
|
|
227
|
+
a += ` C${o},${s} ${c},${l} ${e[r + 1].x},${e[r + 1].y}`;
|
|
228
|
+
}
|
|
229
|
+
return a;
|
|
230
|
+
}
|
|
231
|
+
function S(e) {
|
|
232
|
+
let t = 0, n = 0, r = 0, i = 0, a = 0;
|
|
233
|
+
for (let o = 0; o < e.length; o += 1) {
|
|
234
|
+
let s = e[o];
|
|
235
|
+
Number.isFinite(s) && (t += 1, n += o, r += s, i += o * o, a += o * s);
|
|
236
|
+
}
|
|
237
|
+
if (t < 2) return e.map(() => NaN);
|
|
238
|
+
let o = t * i - n * n;
|
|
239
|
+
if (o === 0) return e.map(() => r / t);
|
|
240
|
+
let s = (t * a - n * r) / o, c = (r - s * n) / t;
|
|
241
|
+
return e.map((e, t) => s * t + c);
|
|
242
|
+
}
|
|
243
|
+
function C(e, t) {
|
|
244
|
+
if (t < 1) return e.slice();
|
|
245
|
+
let n = Array(e.length).fill(NaN), r = 0, i = 0;
|
|
246
|
+
for (let a = 0; a < e.length; a += 1) {
|
|
247
|
+
let o = e[a];
|
|
248
|
+
if (Number.isFinite(o) && (r += o, i += 1), a >= t) {
|
|
249
|
+
let n = e[a - t];
|
|
250
|
+
Number.isFinite(n) && (r -= n, --i);
|
|
251
|
+
}
|
|
252
|
+
a >= t - 1 && i > 0 && (n[a] = r / i);
|
|
253
|
+
}
|
|
254
|
+
return n;
|
|
255
|
+
}
|
|
256
|
+
function w(e, t) {
|
|
257
|
+
let n = 2 / (Math.max(1, t) + 1), r = Array(e.length).fill(NaN), i = null;
|
|
258
|
+
for (let t = 0; t < e.length; t += 1) {
|
|
259
|
+
let a = e[t];
|
|
260
|
+
if (!Number.isFinite(a)) {
|
|
261
|
+
r[t] = i ?? NaN;
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
i = i == null ? a : n * a + (1 - n) * i, r[t] = i;
|
|
265
|
+
}
|
|
266
|
+
return r;
|
|
267
|
+
}
|
|
268
|
+
function T(e, t) {
|
|
269
|
+
if (t === "linear") return S(e);
|
|
270
|
+
let n = /^(sma|ema):(\d+)$/.exec(t);
|
|
271
|
+
if (!n) return e.map(() => NaN);
|
|
272
|
+
let r = Number(n[2]);
|
|
273
|
+
return n[1] === "ema" ? w(e, r) : C(e, r);
|
|
274
|
+
}
|
|
275
|
+
function E(e, t, n = 4) {
|
|
276
|
+
(!Number.isFinite(e) || !Number.isFinite(t)) && (e = 0, t = 1), e === t && (e === 0 ? t = 1 : (e = Math.min(0, e), t = Math.max(0, t)), e === t && (t = e + 1));
|
|
277
|
+
let r = c(c(t - e, !1) / Math.max(1, n), !0), i = Math.floor(e / r) * r, a = Math.ceil(t / r) * r, o = [];
|
|
278
|
+
for (let e = i; e <= a + r * .5; e += r) o.push(s(e));
|
|
279
|
+
return {
|
|
280
|
+
min: i,
|
|
281
|
+
max: a,
|
|
282
|
+
step: r,
|
|
283
|
+
ticks: o
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function D(e) {
|
|
287
|
+
let t = Math.abs(e);
|
|
288
|
+
return t >= 1e6 ? `${(e / 1e6).toFixed(t % 1e6 ? 1 : 0)}M` : t >= 1e3 ? `${(e / 1e3).toFixed(t % 1e3 ? 1 : 0)}k` : String(Math.round(e * 100) / 100);
|
|
289
|
+
}
|
|
290
|
+
function O(t, n, r) {
|
|
291
|
+
if (!Number.isFinite(t)) return "";
|
|
292
|
+
if (r && (r.locale || r.currency)) {
|
|
293
|
+
let i = n === "currency" ? "currency" : n === "percent" ? "percent" : "decimal", a = {
|
|
294
|
+
notation: "compact",
|
|
295
|
+
maximumFractionDigits: 1
|
|
296
|
+
};
|
|
297
|
+
return i === "currency" ? (a.style = "currency", a.currency = r.currency || "USD") : i === "percent" && (a.style = "percent"), e(r.locale, a).format(t);
|
|
298
|
+
}
|
|
299
|
+
if (n === "currency") return `${t < 0 ? "-" : ""}$${D(Math.abs(t))}`;
|
|
300
|
+
if (n === "percent") {
|
|
301
|
+
let e = t * 100;
|
|
302
|
+
return `${Math.round(e * 10) / 10}%`;
|
|
303
|
+
}
|
|
304
|
+
return D(t);
|
|
305
|
+
}
|
|
306
|
+
var k = 864e5;
|
|
307
|
+
function A(e, t) {
|
|
308
|
+
let n = t - e, r = n <= 7 * k ? k : n <= 70 * k ? 7 * k : n <= 800 * k ? 30 * k : 365 * k, i = [];
|
|
309
|
+
for (let n = Math.ceil(e / r) * r; n <= t + 1; n += r) i.push(n);
|
|
310
|
+
return i.length || i.push(e, t), i;
|
|
311
|
+
}
|
|
312
|
+
function ee(e, t = 6) {
|
|
313
|
+
if (e.length <= 1) return e.length ? [0] : [];
|
|
314
|
+
let n = {
|
|
315
|
+
day: (e) => `${e.getUTCFullYear()}-${e.getUTCMonth()}-${e.getUTCDate()}`,
|
|
316
|
+
week: (e) => Math.floor((Date.UTC(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate()) / k + 4) / 7),
|
|
317
|
+
month: (e) => `${e.getUTCFullYear()}-${e.getUTCMonth()}`,
|
|
318
|
+
year: (e) => e.getUTCFullYear()
|
|
319
|
+
}, r = null;
|
|
320
|
+
for (let i of [
|
|
321
|
+
"day",
|
|
322
|
+
"week",
|
|
323
|
+
"month",
|
|
324
|
+
"year"
|
|
325
|
+
]) {
|
|
326
|
+
let a = [], o = null;
|
|
327
|
+
for (let t = 0; t < e.length; t += 1) {
|
|
328
|
+
let r = e[t];
|
|
329
|
+
if (!Number.isFinite(r)) continue;
|
|
330
|
+
let s = n[i](new Date(r));
|
|
331
|
+
s !== o && a.push(t), o = s;
|
|
332
|
+
}
|
|
333
|
+
if (r = a, a.length <= t * 2) break;
|
|
334
|
+
}
|
|
335
|
+
let i = r ?? [];
|
|
336
|
+
if (i.length > t) {
|
|
337
|
+
let e = Math.ceil(i.length / t);
|
|
338
|
+
i = i.filter((t, n) => n % e === 0);
|
|
339
|
+
}
|
|
340
|
+
if (i.length < 2) {
|
|
341
|
+
let n = Math.max(1, Math.ceil(e.length / t));
|
|
342
|
+
i = e.map((e, t) => t).filter((e) => e % n === 0);
|
|
343
|
+
}
|
|
344
|
+
return i;
|
|
345
|
+
}
|
|
346
|
+
function te(e, t) {
|
|
347
|
+
let n = new Date(e);
|
|
348
|
+
return t <= 70 * k ? n.toLocaleDateString(void 0, {
|
|
349
|
+
month: "short",
|
|
350
|
+
day: "numeric"
|
|
351
|
+
}) : t <= 800 * k ? n.toLocaleDateString(void 0, {
|
|
352
|
+
month: "short",
|
|
353
|
+
year: "2-digit"
|
|
354
|
+
}) : String(n.getFullYear());
|
|
355
|
+
}
|
|
356
|
+
function ne(e, t) {
|
|
357
|
+
let n = e.type ?? t;
|
|
358
|
+
return n === "candlestick" || n === "ohlc" || e.ohlc ? "candle" : n === "boxplot" || e.boxes ? "box" : n === "line" || n === "area" ? n : "bar";
|
|
359
|
+
}
|
|
360
|
+
function j(e, t, n, r = [], i = !1) {
|
|
361
|
+
let o = Infinity, s = -Infinity, c = (e) => {
|
|
362
|
+
Number.isFinite(e) && (i && e <= 0 || (e < o && (o = e), e > s && (s = e)));
|
|
363
|
+
};
|
|
364
|
+
for (let e of r) c(e);
|
|
365
|
+
let l = e.filter((e) => e.kind === "bar" || e.kind === "area"), u = e.filter((e) => e.kind === "line");
|
|
366
|
+
if (n && l.length) for (let e = 0; e < t.length; e += 1) {
|
|
367
|
+
let t = 0, n = 0;
|
|
368
|
+
for (let r of l) {
|
|
369
|
+
let i = r.values[e] ?? 0;
|
|
370
|
+
i >= 0 ? t += i : n += i;
|
|
371
|
+
}
|
|
372
|
+
c(t), c(n);
|
|
373
|
+
}
|
|
374
|
+
else for (let e of l) for (let t of e.values) c(t);
|
|
375
|
+
for (let e of u) for (let t of e.values) c(t);
|
|
376
|
+
for (let t of e) if (t.kind === "candle") for (let e of t.ohlc ?? []) e && (c(e.h), c(e.l));
|
|
377
|
+
for (let t of e) if (t.kind === "box") {
|
|
378
|
+
for (let e of t.boxes ?? []) if (e) {
|
|
379
|
+
c(e.min), c(e.max);
|
|
380
|
+
for (let t of e.outliers ?? []) c(t);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
for (let t of e) t.errors && t.errors.forEach((e, n) => {
|
|
384
|
+
let r = a(e, t.values[n] ?? 0);
|
|
385
|
+
r && (c(r.lo), c(r.hi));
|
|
386
|
+
});
|
|
387
|
+
return o === Infinity && (o = +!!i, s = i ? 10 : 1), l.length && !i && (o = Math.min(o, 0), s = Math.max(s, 0)), i ? _(o, s) : E(o, s);
|
|
388
|
+
}
|
|
389
|
+
function M(e, t = "light") {
|
|
390
|
+
let n = e.width ?? 520, r = e.height ?? 300, c = e.palette ?? o, l = !!(e.stacked || e.stacked100), u = e.series.map((t, n) => ({
|
|
391
|
+
...t,
|
|
392
|
+
color: t.color ?? c[n % c.length],
|
|
393
|
+
kind: ne(t, e.type),
|
|
394
|
+
axis: t.axis ?? "left"
|
|
395
|
+
})), d = u.map((e) => ({
|
|
396
|
+
label: e.label,
|
|
397
|
+
color: e.color
|
|
398
|
+
})), f = {
|
|
399
|
+
type: e.type,
|
|
400
|
+
width: n,
|
|
401
|
+
height: r,
|
|
402
|
+
plot: {
|
|
403
|
+
x: 0,
|
|
404
|
+
y: 0,
|
|
405
|
+
w: n,
|
|
406
|
+
h: r
|
|
407
|
+
},
|
|
408
|
+
axes: null,
|
|
409
|
+
bars: [],
|
|
410
|
+
candles: [],
|
|
411
|
+
boxes: [],
|
|
412
|
+
errorBars: [],
|
|
413
|
+
lines: [],
|
|
414
|
+
slices: [],
|
|
415
|
+
yTicks: [],
|
|
416
|
+
y2Ticks: [],
|
|
417
|
+
hasRightAxis: !1,
|
|
418
|
+
xTicks: [],
|
|
419
|
+
categoryGroupTicks: [],
|
|
420
|
+
xLabelRotated: !1,
|
|
421
|
+
legend: d,
|
|
422
|
+
donut: null,
|
|
423
|
+
referenceLines: [],
|
|
424
|
+
scatterPoints: [],
|
|
425
|
+
orientation: "vertical",
|
|
426
|
+
valueTicks: [],
|
|
427
|
+
catTicks: [],
|
|
428
|
+
referenceLinesV: [],
|
|
429
|
+
overlays: [],
|
|
430
|
+
annotations: [],
|
|
431
|
+
heatmapCells: [],
|
|
432
|
+
heatmapRowTicks: [],
|
|
433
|
+
heatmapColTicks: [],
|
|
434
|
+
heatmapLegend: [],
|
|
435
|
+
funnelSegments: [],
|
|
436
|
+
radarRings: [],
|
|
437
|
+
radarAxes: [],
|
|
438
|
+
radarSeries: [],
|
|
439
|
+
radarCenter: null,
|
|
440
|
+
treemapCells: [],
|
|
441
|
+
calendarCells: [],
|
|
442
|
+
calendarMonthTicks: [],
|
|
443
|
+
calendarLegend: [],
|
|
444
|
+
gauge: null,
|
|
445
|
+
sankeyNodes: [],
|
|
446
|
+
sankeyLinks: []
|
|
447
|
+
};
|
|
448
|
+
if (e.type === "waterfall") {
|
|
449
|
+
let t = u[0];
|
|
450
|
+
if (!t) return { ...f };
|
|
451
|
+
let i = e.waterfallColors ?? {}, a = i.positive ?? "#16a34a", o = i.negative ?? "#ef4444", c = i.total ?? "#475569", l = e.categories.reduce((e, t) => Math.max(e, t.length), 0), d = e.categories.length > 8 || l > 9, p = 48 + (e.yAxisTitle ? 16 : 0), m = (d ? 54 : 28) + (e.xAxisTitle ? 16 : 0), h = Math.max(1, n - p - 12), g = Math.max(1, r - 10 - m), _ = {
|
|
452
|
+
x: p,
|
|
453
|
+
y: 10,
|
|
454
|
+
w: h,
|
|
455
|
+
h: g
|
|
456
|
+
}, v = e.waterfallTotals ?? [], y = [], b = 0;
|
|
457
|
+
e.categories.forEach((e, n) => {
|
|
458
|
+
let r = t.values[n] ?? 0;
|
|
459
|
+
v[n] ? y.push({
|
|
460
|
+
from: 0,
|
|
461
|
+
to: b,
|
|
462
|
+
value: b,
|
|
463
|
+
isTotal: !0
|
|
464
|
+
}) : (y.push({
|
|
465
|
+
from: b,
|
|
466
|
+
to: b + r,
|
|
467
|
+
value: r,
|
|
468
|
+
isTotal: !1
|
|
469
|
+
}), b += r);
|
|
470
|
+
});
|
|
471
|
+
let x = 0, S = 0;
|
|
472
|
+
for (let e of y) e.from < x && (x = e.from), e.to < x && (x = e.to), e.from > S && (S = e.from), e.to > S && (S = e.to);
|
|
473
|
+
let C = E(x, S), w = (e) => s(10 + g - (e - C.min) / (C.max - C.min || 1) * g), T = h / Math.max(1, e.categories.length), D = T * .2, k = Math.max(1, T - D), A = y.map((n, r) => {
|
|
474
|
+
let i = w(Math.max(n.from, n.to)), l = w(Math.min(n.from, n.to)), u = p + T * r + D / 2, d = n.isTotal ? c : n.value >= 0 ? a : o;
|
|
475
|
+
return {
|
|
476
|
+
x: s(u),
|
|
477
|
+
y: i,
|
|
478
|
+
w: s(k),
|
|
479
|
+
h: Math.max(1, l - i),
|
|
480
|
+
color: d,
|
|
481
|
+
label: e.categories[r] ?? String(r),
|
|
482
|
+
series: t.label,
|
|
483
|
+
value: n.value
|
|
484
|
+
};
|
|
485
|
+
}), ee = [{
|
|
486
|
+
path: y.map((e, t) => {
|
|
487
|
+
let n = p + T * t + D / 2 + k, r = w(e.to), i = p + T * (t + 1) + D / 2;
|
|
488
|
+
return t < y.length - 1 ? `M${n},${r} L${i},${r}` : "";
|
|
489
|
+
}).filter(Boolean).join(" "),
|
|
490
|
+
areaPath: "",
|
|
491
|
+
color: "var(--sg-muted, #94a3b8)",
|
|
492
|
+
label: "",
|
|
493
|
+
points: []
|
|
494
|
+
}], te = e.categories.map((e, t) => ({
|
|
495
|
+
label: e,
|
|
496
|
+
x: s(p + T * t + T / 2)
|
|
497
|
+
})), ne = C.ticks.map((t) => ({
|
|
498
|
+
value: t,
|
|
499
|
+
y: w(t),
|
|
500
|
+
label: O(t, e.valueFormat, e)
|
|
501
|
+
}));
|
|
502
|
+
return {
|
|
503
|
+
...f,
|
|
504
|
+
plot: _,
|
|
505
|
+
bars: A,
|
|
506
|
+
lines: ee,
|
|
507
|
+
yTicks: ne,
|
|
508
|
+
xTicks: te,
|
|
509
|
+
xLabelRotated: d
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
if (e.type === "funnel") {
|
|
513
|
+
let t = u[0];
|
|
514
|
+
if (!t || !t.values.length) return { ...f };
|
|
515
|
+
let i = Math.max(1, n - 20 - 20), a = Math.max(1, r - 16 - 16), s = {
|
|
516
|
+
x: 20,
|
|
517
|
+
y: 16,
|
|
518
|
+
w: i,
|
|
519
|
+
h: a
|
|
520
|
+
}, c = a / t.values.length, l = Math.max(...t.values.map((e) => Number.isFinite(e) ? e : 0)), d = t.values[0] ?? 0, p = (e) => l > 0 ? e / l * i : 0, m = 20 + i / 2, h = e.palette ?? o, _ = t.values.map((n, r) => {
|
|
521
|
+
let i = t.values[r + 1] ?? n * .8, a = p(n), o = p(i), s = 16 + c * r, l = s + c, u = `M${m - a / 2},${s} L${m + a / 2},${s} L${m + o / 2},${l} L${m - o / 2},${l} Z`, f = t.color ?? h[r % h.length];
|
|
522
|
+
return {
|
|
523
|
+
path: u,
|
|
524
|
+
color: f,
|
|
525
|
+
label: e.categories[r] ?? t.label,
|
|
526
|
+
value: n,
|
|
527
|
+
conversion: d > 0 ? n / d : 0,
|
|
528
|
+
dropoff: r === 0 ? 0 : (t.values[r - 1] ?? n) > 0 ? 1 - n / (t.values[r - 1] ?? n) : 0,
|
|
529
|
+
cx: m,
|
|
530
|
+
cy: (s + l) / 2,
|
|
531
|
+
textColor: g(f)
|
|
532
|
+
};
|
|
533
|
+
});
|
|
534
|
+
return {
|
|
535
|
+
...f,
|
|
536
|
+
plot: s,
|
|
537
|
+
funnelSegments: _
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
if (e.type === "radar") {
|
|
541
|
+
if (!u.length || !e.categories.length) return { ...f };
|
|
542
|
+
let t = Math.max(1, n - 30 - 30), i = Math.max(1, r - 24 - 24), a = {
|
|
543
|
+
x: 30,
|
|
544
|
+
y: 24,
|
|
545
|
+
w: t,
|
|
546
|
+
h: i
|
|
547
|
+
}, c = 30 + t / 2, l = 24 + i / 2, d = Math.max(20, Math.min(t, i) / 2 - 20), p = e.categories, m = p.length, h = 0;
|
|
548
|
+
for (let e of u) for (let t of e.values) Number.isFinite(t) && t > h && (h = t);
|
|
549
|
+
h === 0 && (h = 1);
|
|
550
|
+
let g = Array.from({ length: 5 }, (e, t) => (t + 1) / 5 * h), _ = (e) => -Math.PI / 2 + e / m * Math.PI * 2, v = (e, t) => {
|
|
551
|
+
let n = t / h, r = _(e);
|
|
552
|
+
return {
|
|
553
|
+
x: s(c + d * n * Math.cos(r)),
|
|
554
|
+
y: s(l + d * n * Math.sin(r))
|
|
555
|
+
};
|
|
556
|
+
}, y = p.map((e, t) => {
|
|
557
|
+
let n = v(t, h);
|
|
558
|
+
return {
|
|
559
|
+
label: e,
|
|
560
|
+
x: n.x,
|
|
561
|
+
y: n.y
|
|
562
|
+
};
|
|
563
|
+
}), b = u.map((t, n) => {
|
|
564
|
+
let r = t.values.map((e, t) => {
|
|
565
|
+
let n = v(t, Number.isFinite(e) ? e : 0);
|
|
566
|
+
return {
|
|
567
|
+
x: n.x,
|
|
568
|
+
y: n.y,
|
|
569
|
+
value: e,
|
|
570
|
+
axis: p[t] ?? ""
|
|
571
|
+
};
|
|
572
|
+
}), i = r.length ? r.map((e, t) => `${t === 0 ? "M" : "L"}${e.x},${e.y}`).join(" ") + " Z" : "", a = e.palette ?? o;
|
|
573
|
+
return {
|
|
574
|
+
label: t.label,
|
|
575
|
+
color: t.color ?? a[n % a.length],
|
|
576
|
+
path: i,
|
|
577
|
+
points: r
|
|
578
|
+
};
|
|
579
|
+
});
|
|
580
|
+
return {
|
|
581
|
+
...f,
|
|
582
|
+
plot: a,
|
|
583
|
+
radarRings: g,
|
|
584
|
+
radarAxes: y,
|
|
585
|
+
radarSeries: b,
|
|
586
|
+
radarCenter: {
|
|
587
|
+
cx: c,
|
|
588
|
+
cy: l,
|
|
589
|
+
r: d
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
if (e.type === "calendar") {
|
|
594
|
+
let i = e.calendarValues ?? [];
|
|
595
|
+
if (!i.length && !e.calendarStart) return { ...f };
|
|
596
|
+
let a = /* @__PURE__ */ new Map(), o = Infinity, s = -Infinity;
|
|
597
|
+
for (let e of i) a.set(e.date, e.value), Number.isFinite(e.value) && (e.value < o && (o = e.value), e.value > s && (s = e.value));
|
|
598
|
+
o === Infinity && (o = 0, s = 1), o === s && (s = o + 1);
|
|
599
|
+
let c = p(e.colorScale, o, s, t), l = (e) => m(c, (e - o) / (s - o)), u = i.map((e) => e.date).sort(), d = e.calendarStart ?? u[0] ?? "2026-01-01", h = e.calendarEnd ?? u[u.length - 1] ?? d, g = /* @__PURE__ */ new Date(d + "T00:00:00Z"), _ = /* @__PURE__ */ new Date(h + "T00:00:00Z");
|
|
600
|
+
g.setUTCDate(g.getUTCDate() - g.getUTCDay()), _.setUTCDate(_.getUTCDate() + (6 - _.getUTCDay()));
|
|
601
|
+
let v = Math.round((_.getTime() - g.getTime()) / 864e5) + 1, y = Math.ceil(v / 7), b = Math.max(1, n - 36 - 80), x = Math.max(1, r - 26 - 16), S = Math.floor(b / y), C = Math.floor(x / 7), w = Math.max(6, Math.min(S, C)), T = {
|
|
602
|
+
x: 36,
|
|
603
|
+
y: 26,
|
|
604
|
+
w: w * y,
|
|
605
|
+
h: w * 7
|
|
606
|
+
}, E = [], D = -1, k = [];
|
|
607
|
+
for (let e = 0; e < v; e += 1) {
|
|
608
|
+
let t = new Date(g.getTime() + e * 864e5), n = Math.floor(e / 7), r = e % 7, i = t.toISOString().slice(0, 10), o = a.has(i), s = a.get(i) ?? 0;
|
|
609
|
+
E.push({
|
|
610
|
+
x: 36 + n * w,
|
|
611
|
+
y: 26 + r * w,
|
|
612
|
+
size: w,
|
|
613
|
+
date: i,
|
|
614
|
+
value: s,
|
|
615
|
+
defined: o,
|
|
616
|
+
color: o ? l(s) : "transparent"
|
|
617
|
+
}), t.getUTCDate() === 1 && t.getUTCMonth() !== D && (D = t.getUTCMonth(), k.push({
|
|
618
|
+
label: t.toLocaleDateString(void 0, { month: "short" }),
|
|
619
|
+
x: 36 + n * w
|
|
620
|
+
}));
|
|
621
|
+
}
|
|
622
|
+
let A = Array.from({ length: 5 }, (t, n) => {
|
|
623
|
+
let r = n / 4, i = o + (s - o) * r;
|
|
624
|
+
return {
|
|
625
|
+
value: i,
|
|
626
|
+
color: l(i),
|
|
627
|
+
label: O(i, e.valueFormat, e)
|
|
628
|
+
};
|
|
629
|
+
});
|
|
630
|
+
return {
|
|
631
|
+
...f,
|
|
632
|
+
plot: T,
|
|
633
|
+
calendarCells: E,
|
|
634
|
+
calendarMonthTicks: k,
|
|
635
|
+
calendarLegend: A
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
if (e.type === "gauge") {
|
|
639
|
+
let t = e.gaugeMin ?? 0, i = e.gaugeMax ?? 100, a = Math.max(t, Math.min(i, e.gaugeValue ?? 0)), o = e.gaugeTarget, c = n / 2, l = r * .78, u = Math.min(n * .42, r * .65), d = Math.PI, p = 2 * Math.PI, m = (e) => d + (e - t) / (i - t || 1) * (p - d), h = (e, t, n) => {
|
|
640
|
+
let r = c + n * Math.cos(e), i = l + n * Math.sin(e), a = c + n * Math.cos(t), o = l + n * Math.sin(t);
|
|
641
|
+
return `M${r},${i} A${n},${n} 0 ${+(t - e > Math.PI)} 1 ${a},${o}`;
|
|
642
|
+
}, g = h(d, p, u), _ = h(d, m(a), u), v = (e.gaugeRanges ?? []).map((e) => ({
|
|
643
|
+
path: h(m(e.from), m(e.to), u - 16),
|
|
644
|
+
color: e.color,
|
|
645
|
+
from: e.from,
|
|
646
|
+
to: e.to
|
|
647
|
+
})), y = null;
|
|
648
|
+
if (o != null && Number.isFinite(o)) {
|
|
649
|
+
let e = m(Math.max(t, Math.min(i, o))), n = u - 12, r = u + 4;
|
|
650
|
+
y = {
|
|
651
|
+
x1: c + n * Math.cos(e),
|
|
652
|
+
y1: l + n * Math.sin(e),
|
|
653
|
+
x2: c + r * Math.cos(e),
|
|
654
|
+
y2: l + r * Math.sin(e)
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
let b = [];
|
|
658
|
+
for (let e = 0; e <= 20; e++) {
|
|
659
|
+
let t = d + e / 20 * (p - d), n = e % 5 == 0, r = u + 9, i = u + (n ? 17 : 13);
|
|
660
|
+
b.push({
|
|
661
|
+
x1: c + r * Math.cos(t),
|
|
662
|
+
y1: l + r * Math.sin(t),
|
|
663
|
+
x2: c + i * Math.cos(t),
|
|
664
|
+
y2: l + i * Math.sin(t),
|
|
665
|
+
major: n
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
let x = m(a), S = u - 14, C = x + Math.PI / 2, w = (e, t) => `${s(c + e * Math.cos(t))},${s(l + e * Math.sin(t))}`, T = `M${w(9, C)} L${w(S, x)} L${w(9, C + Math.PI)} L${w(5, x + Math.PI)} Z`, E = null, D = e.gaugeRanges ?? [];
|
|
669
|
+
for (let e of D) if (a >= e.from && a < e.to) {
|
|
670
|
+
E = e.color;
|
|
671
|
+
break;
|
|
672
|
+
}
|
|
673
|
+
if (E == null) for (let e of D) a >= e.from && a <= e.to && (E = e.color);
|
|
674
|
+
return {
|
|
675
|
+
...f,
|
|
676
|
+
plot: {
|
|
677
|
+
x: 0,
|
|
678
|
+
y: 0,
|
|
679
|
+
w: n,
|
|
680
|
+
h: r
|
|
681
|
+
},
|
|
682
|
+
gauge: {
|
|
683
|
+
cx: c,
|
|
684
|
+
cy: l,
|
|
685
|
+
r: u,
|
|
686
|
+
trackPath: g,
|
|
687
|
+
valuePath: _,
|
|
688
|
+
rangePaths: v,
|
|
689
|
+
target: y,
|
|
690
|
+
ticks: b,
|
|
691
|
+
needle: {
|
|
692
|
+
path: T,
|
|
693
|
+
hubR: 6
|
|
694
|
+
},
|
|
695
|
+
valueColor: E,
|
|
696
|
+
minLabel: {
|
|
697
|
+
x: c - u,
|
|
698
|
+
y: l + 20
|
|
699
|
+
},
|
|
700
|
+
maxLabel: {
|
|
701
|
+
x: c + u,
|
|
702
|
+
y: l + 20
|
|
703
|
+
},
|
|
704
|
+
value: a,
|
|
705
|
+
min: t,
|
|
706
|
+
max: i,
|
|
707
|
+
unit: e.gaugeUnit ?? ""
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
if (e.type === "treemap") {
|
|
712
|
+
let t = e.treemap;
|
|
713
|
+
if (!t) return { ...f };
|
|
714
|
+
let i = Math.max(1, n - 4 - 4), a = Math.max(1, r - 4 - 4), c = {
|
|
715
|
+
x: 4,
|
|
716
|
+
y: 4,
|
|
717
|
+
w: i,
|
|
718
|
+
h: a
|
|
719
|
+
}, l = e.palette ?? o, u = [];
|
|
720
|
+
function d(e) {
|
|
721
|
+
return e.children?.length ? e.children.reduce((e, t) => e + d(t), 0) : Math.max(0, e.value ?? 0);
|
|
722
|
+
}
|
|
723
|
+
function p(e, t, n, r, i, a) {
|
|
724
|
+
if (!e.length || r <= 0 || i <= 0) return;
|
|
725
|
+
let o = e.map(d), c = o.reduce((e, t) => e + t, 0);
|
|
726
|
+
if (c <= 0) return;
|
|
727
|
+
let f = e.map((e, t) => ({
|
|
728
|
+
node: e,
|
|
729
|
+
value: o[t]
|
|
730
|
+
})).sort((e, t) => t.value - e.value), m = t, h = n, _ = r, v = i, y = c, b = [], x = (e, t, n, r) => {
|
|
731
|
+
if (n <= 0) return Infinity;
|
|
732
|
+
let i = n * r / t, a = 0;
|
|
733
|
+
for (let n of e) {
|
|
734
|
+
let e = n * r / i, o = Math.max(t / e, e / t);
|
|
735
|
+
o > a && (a = o);
|
|
736
|
+
}
|
|
737
|
+
return a;
|
|
738
|
+
};
|
|
739
|
+
function S() {
|
|
740
|
+
if (!b.length) return;
|
|
741
|
+
let e = b.reduce((e, t) => e + t.value, 0), t = _ * v / y, n = _ >= v, r = n ? v : _, i = e * t / r, o = 0;
|
|
742
|
+
for (let e of b) {
|
|
743
|
+
let r = e.value * t / i, c = n ? m : m + o, d = n ? h + o : h, f = n ? i : r, _ = n ? r : i, v = e.node.color ?? l[(a + u.length) % l.length];
|
|
744
|
+
if (e.node.children?.length) {
|
|
745
|
+
u.push({
|
|
746
|
+
x: s(c),
|
|
747
|
+
y: s(d),
|
|
748
|
+
w: s(f),
|
|
749
|
+
h: s(_),
|
|
750
|
+
color: v,
|
|
751
|
+
textColor: g(v),
|
|
752
|
+
name: e.node.name,
|
|
753
|
+
value: e.value,
|
|
754
|
+
depth: a
|
|
755
|
+
});
|
|
756
|
+
let t = Math.min(18, _ * .25);
|
|
757
|
+
p(e.node.children, c + 1, d + t, f - 2, _ - t - 1, a + 1);
|
|
758
|
+
} else u.push({
|
|
759
|
+
x: s(c),
|
|
760
|
+
y: s(d),
|
|
761
|
+
w: s(f),
|
|
762
|
+
h: s(_),
|
|
763
|
+
color: v,
|
|
764
|
+
textColor: g(v),
|
|
765
|
+
name: e.node.name,
|
|
766
|
+
value: e.value,
|
|
767
|
+
depth: a
|
|
768
|
+
});
|
|
769
|
+
o += r;
|
|
770
|
+
}
|
|
771
|
+
n ? (m += i, _ -= i) : (h += i, v -= i), y -= e, b = [];
|
|
772
|
+
}
|
|
773
|
+
for (let e of f) {
|
|
774
|
+
let t = _ * v / y, n = Math.min(_, v), r = b.reduce((e, t) => e + t.value, 0), i = x(b.map((e) => e.value), n, r, t), a = x([...b.map((e) => e.value), e.value], n, r + e.value, t);
|
|
775
|
+
b.length && a > i && S(), b.push(e);
|
|
776
|
+
}
|
|
777
|
+
S();
|
|
778
|
+
}
|
|
779
|
+
return p(t.children ?? [t], 4, 4, i, a, 0), {
|
|
780
|
+
...f,
|
|
781
|
+
plot: c,
|
|
782
|
+
treemapCells: u
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
if (e.type === "sankey") {
|
|
786
|
+
let t = e.sankeyNodes ?? [], i = e.sankeyLinks ?? [];
|
|
787
|
+
if (!t.length || !i.length) return { ...f };
|
|
788
|
+
let a = Math.max(1, n - 10 - 10), s = Math.max(1, r - 14 - 14), c = {
|
|
789
|
+
x: 10,
|
|
790
|
+
y: 14,
|
|
791
|
+
w: a,
|
|
792
|
+
h: s
|
|
793
|
+
}, l = e.palette ?? o, u = new Map(t.map((e) => [e.id, e])), d = new Set(i.map((e) => e.target)), p = t.filter((e) => !d.has(e.id)), m = /* @__PURE__ */ new Map();
|
|
794
|
+
function h(e, t, n) {
|
|
795
|
+
if (!n.has(e)) {
|
|
796
|
+
n.add(e), (t > (m.get(e) ?? 0) || !m.has(e)) && m.set(e, t);
|
|
797
|
+
for (let r of i) r.source === e && h(r.target, t + 1, n);
|
|
798
|
+
n.delete(e);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
for (let e of p) h(e.id, 0, /* @__PURE__ */ new Set());
|
|
802
|
+
for (let e of t) m.has(e.id) || m.set(e.id, 0);
|
|
803
|
+
let g = Math.max(...m.values()) + 1, _ = g > 1 ? (a - 14 * g) / (g - 1) : 0, v = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map();
|
|
804
|
+
for (let e of i) v.set(e.target, (v.get(e.target) ?? 0) + e.value), y.set(e.source, (y.get(e.source) ?? 0) + e.value);
|
|
805
|
+
let b = /* @__PURE__ */ new Map();
|
|
806
|
+
for (let e of t) {
|
|
807
|
+
let t = m.get(e.id) ?? 0, n = b.get(t) ?? [];
|
|
808
|
+
n.push(e.id), b.set(t, n);
|
|
809
|
+
}
|
|
810
|
+
let x = 0;
|
|
811
|
+
for (let e of b.values()) {
|
|
812
|
+
let t = e.reduce((e, t) => e + Math.max(v.get(t) ?? 0, y.get(t) ?? 0), 0);
|
|
813
|
+
t > x && (x = t);
|
|
814
|
+
}
|
|
815
|
+
if (x === 0) return {
|
|
816
|
+
...f,
|
|
817
|
+
plot: c
|
|
818
|
+
};
|
|
819
|
+
let S = (s - 64) / x, C = [];
|
|
820
|
+
for (let [e, t] of b) {
|
|
821
|
+
let n = t.map((e) => Math.max(8, Math.max(v.get(e) ?? 0, y.get(e) ?? 0) * S)), r = 14 + (s - (n.reduce((e, t) => e + t, 0) + 8 * (t.length - 1))) / 2, i = 10 + e * (14 + _);
|
|
822
|
+
t.forEach((t, a) => {
|
|
823
|
+
let o = u.get(t), s = n[a];
|
|
824
|
+
C.push({
|
|
825
|
+
id: t,
|
|
826
|
+
label: o.label ?? t,
|
|
827
|
+
color: o.color ?? l[C.length % l.length],
|
|
828
|
+
x: i,
|
|
829
|
+
y: r,
|
|
830
|
+
w: 14,
|
|
831
|
+
h: s,
|
|
832
|
+
column: e,
|
|
833
|
+
totalIn: v.get(t) ?? 0,
|
|
834
|
+
totalOut: y.get(t) ?? 0
|
|
835
|
+
}), r += s + 8;
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
let w = new Map(C.map((e) => [e.id, e])), T = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), D = [], O = i.slice().sort((e, t) => t.value - e.value);
|
|
839
|
+
for (let e of O) {
|
|
840
|
+
let t = w.get(e.source), n = w.get(e.target);
|
|
841
|
+
if (!t || !n) continue;
|
|
842
|
+
let r = Math.max(1, e.value * S), i = t.y + (E.get(t.id) ?? 0) + r / 2, a = n.y + (T.get(n.id) ?? 0) + r / 2;
|
|
843
|
+
E.set(t.id, (E.get(t.id) ?? 0) + r), T.set(n.id, (T.get(n.id) ?? 0) + r);
|
|
844
|
+
let o = t.x + t.w, s = n.x, c = (o + s) / 2, l = `M${o},${i} C${c},${i} ${c},${a} ${s},${a}`;
|
|
845
|
+
D.push({
|
|
846
|
+
path: l,
|
|
847
|
+
color: e.color ?? t.color,
|
|
848
|
+
width: r,
|
|
849
|
+
source: e.source,
|
|
850
|
+
target: e.target,
|
|
851
|
+
value: e.value
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
return {
|
|
855
|
+
...f,
|
|
856
|
+
plot: c,
|
|
857
|
+
sankeyNodes: C,
|
|
858
|
+
sankeyLinks: D
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
if (e.type === "heatmap") {
|
|
862
|
+
if (!u.length || !e.categories.length) return {
|
|
863
|
+
...f,
|
|
864
|
+
plot: {
|
|
865
|
+
x: 0,
|
|
866
|
+
y: 0,
|
|
867
|
+
w: n,
|
|
868
|
+
h: r
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
let i = u.reduce((e, t) => Math.max(e, t.label.length), 0), a = 12 + Math.min(180, Math.max(60, i * 7)), o = Math.max(1, n - a - 64), c = Math.max(1, r - 12 - 32), l = {
|
|
872
|
+
x: a,
|
|
873
|
+
y: 12,
|
|
874
|
+
w: o,
|
|
875
|
+
h: c
|
|
876
|
+
}, d = o / e.categories.length, h = c / u.length, _ = Infinity, v = -Infinity;
|
|
877
|
+
for (let e of u) for (let t of e.values) Number.isFinite(t) && (t < _ && (_ = t), t > v && (v = t));
|
|
878
|
+
_ === Infinity && (_ = 0, v = 1), _ === v && (v = _ + 1);
|
|
879
|
+
let y = p(e.colorScale, _, v, t), b = (e) => m(y, (e - _) / (v - _)), x = [];
|
|
880
|
+
u.forEach((t, n) => {
|
|
881
|
+
t.values.forEach((r, i) => {
|
|
882
|
+
if (!Number.isFinite(r)) return;
|
|
883
|
+
let o = b(r);
|
|
884
|
+
x.push({
|
|
885
|
+
x: s(a + d * i),
|
|
886
|
+
y: s(12 + h * n),
|
|
887
|
+
w: s(d),
|
|
888
|
+
h: s(h),
|
|
889
|
+
color: o,
|
|
890
|
+
textColor: g(o),
|
|
891
|
+
value: r,
|
|
892
|
+
rowLabel: t.label,
|
|
893
|
+
colLabel: e.categories[i] ?? ""
|
|
894
|
+
});
|
|
895
|
+
});
|
|
896
|
+
});
|
|
897
|
+
let S = u.map((e, t) => ({
|
|
898
|
+
value: t,
|
|
899
|
+
y: s(12 + h * t + h / 2),
|
|
900
|
+
label: e.label
|
|
901
|
+
})), C = e.categories.map((e, t) => ({
|
|
902
|
+
label: e,
|
|
903
|
+
x: s(a + d * t + d / 2)
|
|
904
|
+
})), w = Array.from({ length: 5 }, (t, n) => {
|
|
905
|
+
let r = n / 4, i = _ + (v - _) * r;
|
|
906
|
+
return {
|
|
907
|
+
value: i,
|
|
908
|
+
color: b(i),
|
|
909
|
+
label: O(i, e.valueFormat, e)
|
|
910
|
+
};
|
|
911
|
+
});
|
|
912
|
+
return {
|
|
913
|
+
...f,
|
|
914
|
+
plot: l,
|
|
915
|
+
heatmapCells: x,
|
|
916
|
+
heatmapRowTicks: S,
|
|
917
|
+
heatmapColTicks: C,
|
|
918
|
+
heatmapLegend: w
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
if (e.type === "pie") {
|
|
922
|
+
let t = u[0];
|
|
923
|
+
if (!t) return f;
|
|
924
|
+
let i = t.values.reduce((e, t) => e + Math.max(0, t), 0) || 1, a = n / 2, o = r / 2, l = Math.min(n, r) / 2 - 10, d = l * Math.min(.9, Math.max(0, e.innerRadius ?? 0)), p = -Math.PI / 2, m = t.values.map((t, n) => {
|
|
925
|
+
let r = Math.max(0, t) / i, u = p, f = p + r * Math.PI * 2;
|
|
926
|
+
p = f;
|
|
927
|
+
let m = +(f - u > Math.PI), h = (u + f) / 2, g = (l + d) / 2 || l * .6, _ = a + l * Math.cos(u), v = o + l * Math.sin(u), y = a + l * Math.cos(f), b = o + l * Math.sin(f), x;
|
|
928
|
+
if (r >= .999) x = d ? `M${s(a - l)},${s(o)} A${l},${l} 0 1 1 ${s(a + l)},${s(o)} A${l},${l} 0 1 1 ${s(a - l)},${s(o)} ZM${s(a - d)},${s(o)} A${d},${d} 0 1 0 ${s(a + d)},${s(o)} A${d},${d} 0 1 0 ${s(a - d)},${s(o)} Z` : `M${s(a - l)},${s(o)} A${l},${l} 0 1 1 ${s(a + l)},${s(o)} A${l},${l} 0 1 1 ${s(a - l)},${s(o)} Z`;
|
|
929
|
+
else if (d > 0) {
|
|
930
|
+
let e = a + d * Math.cos(u), t = o + d * Math.sin(u), n = a + d * Math.cos(f), r = o + d * Math.sin(f);
|
|
931
|
+
x = `M${s(_)},${s(v)} A${l},${l} 0 ${m} 1 ${s(y)},${s(b)} L${s(n)},${s(r)} A${d},${d} 0 ${m} 0 ${s(e)},${s(t)} Z`;
|
|
932
|
+
} else x = `M${s(a)},${s(o)} L${s(_)},${s(v)} A${l},${l} 0 ${m} 1 ${s(y)},${s(b)} Z`;
|
|
933
|
+
let S = e.categories[n] ?? String(n);
|
|
934
|
+
return {
|
|
935
|
+
path: x,
|
|
936
|
+
color: e.categoryColors?.[S] ?? c[n % c.length],
|
|
937
|
+
label: S,
|
|
938
|
+
value: t,
|
|
939
|
+
percent: r * 100,
|
|
940
|
+
cx: s(a + g * Math.cos(h)),
|
|
941
|
+
cy: s(o + g * Math.sin(h))
|
|
942
|
+
};
|
|
943
|
+
});
|
|
944
|
+
return {
|
|
945
|
+
...f,
|
|
946
|
+
slices: m,
|
|
947
|
+
legend: e.categories.map((t, n) => ({
|
|
948
|
+
label: t,
|
|
949
|
+
color: e.categoryColors?.[t] ?? c[n % c.length]
|
|
950
|
+
})),
|
|
951
|
+
donut: d > 0 ? {
|
|
952
|
+
cx: s(a),
|
|
953
|
+
cy: s(o),
|
|
954
|
+
r: s(d),
|
|
955
|
+
total: t.values.reduce((e, t) => e + Math.max(0, t), 0)
|
|
956
|
+
} : null
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
if (e.type === "scatter") {
|
|
960
|
+
let t = 48 + (e.yAxisTitle ? 16 : 0), i = 28 + (e.xAxisTitle ? 16 : 0), a = Math.max(1, n - t - 12), o = Math.max(1, r - 10 - i), c = {
|
|
961
|
+
x: t,
|
|
962
|
+
y: 10,
|
|
963
|
+
w: a,
|
|
964
|
+
h: o
|
|
965
|
+
}, l = Infinity, d = -Infinity, p = Infinity, m = -Infinity, h = Infinity, g = -Infinity;
|
|
966
|
+
for (let e of u) for (let t of e.points ?? []) Number.isFinite(t.x) && (l = Math.min(l, t.x), d = Math.max(d, t.x)), Number.isFinite(t.y) && (p = Math.min(p, t.y), m = Math.max(m, t.y)), t.r != null && Number.isFinite(t.r) && (h = Math.min(h, t.r), g = Math.max(g, t.r));
|
|
967
|
+
if (l === Infinity) return {
|
|
968
|
+
...f,
|
|
969
|
+
plot: c
|
|
970
|
+
};
|
|
971
|
+
let _ = E(l, d), v = E(p, m), y = g > h, b = (e) => s(t + (e - _.min) / (_.max - _.min || 1) * a), x = (e) => s(10 + o - (e - v.min) / (v.max - v.min || 1) * o), S = (e) => y && e != null && Number.isFinite(e) ? s(4 + (e - h) / (g - h || 1) * 14) : 5, C = [];
|
|
972
|
+
for (let e of u) for (let t of e.points ?? []) !Number.isFinite(t.x) || !Number.isFinite(t.y) || C.push({
|
|
973
|
+
cx: b(t.x),
|
|
974
|
+
cy: x(t.y),
|
|
975
|
+
r: S(t.r),
|
|
976
|
+
color: e.color,
|
|
977
|
+
label: t.label ?? "",
|
|
978
|
+
series: e.label,
|
|
979
|
+
x: t.x,
|
|
980
|
+
y: t.y
|
|
981
|
+
});
|
|
982
|
+
let w = (e.referenceLines ?? []).map((t) => ({
|
|
983
|
+
y: x(t.value),
|
|
984
|
+
label: t.label ?? O(t.value, e.valueFormat, e),
|
|
985
|
+
color: t.color ?? "#ef4444",
|
|
986
|
+
dashed: t.dashed !== !1
|
|
987
|
+
}));
|
|
988
|
+
return {
|
|
989
|
+
...f,
|
|
990
|
+
plot: c,
|
|
991
|
+
scatterPoints: C,
|
|
992
|
+
referenceLines: w,
|
|
993
|
+
yTicks: v.ticks.map((t) => ({
|
|
994
|
+
value: t,
|
|
995
|
+
y: x(t),
|
|
996
|
+
label: O(t, e.valueFormat, e)
|
|
997
|
+
})),
|
|
998
|
+
xTicks: _.ticks.map((e) => ({
|
|
999
|
+
label: D(e),
|
|
1000
|
+
x: b(e)
|
|
1001
|
+
}))
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
if (e.orientation === "horizontal" && u.length > 0 && u.every((e) => e.kind === "bar")) {
|
|
1005
|
+
let t = e.categories.reduce((e, t) => Math.max(e, t.length), 0), i = Math.min(150, 18 + t * 6.4) + (e.yAxisTitle ? 16 : 0), a = 26 + (e.xAxisTitle ? 16 : 0), o = Math.max(1, n - i - 16), c = Math.max(1, r - 8 - a), d = {
|
|
1006
|
+
x: i,
|
|
1007
|
+
y: 8,
|
|
1008
|
+
w: o,
|
|
1009
|
+
h: c
|
|
1010
|
+
}, p = (e.referenceLines ?? []).map((e) => e.value), m = e.stacked100 ? E(0, 100) : j(u, e.categories, l, p), h = (e) => s(i + (e - m.min) / (m.max - m.min || 1) * o), g = e.categories.length, _ = c / Math.max(1, g), v = _ * .2, y = _ - v, b = (e) => 8 + _ * e + v / 2, x = h(Math.min(Math.max(0, m.min), m.max)), S = [];
|
|
1011
|
+
if (l) {
|
|
1012
|
+
let t = e.stacked100 ? e.categories.map((e, t) => u.reduce((e, n) => e + Math.abs(Number.isFinite(n.values[t]) ? n.values[t] : 0), 0) || 1) : null, n = Array(g).fill(0), r = Array(g).fill(0);
|
|
1013
|
+
for (let i of u) i.values.forEach((a, o) => {
|
|
1014
|
+
if (!Number.isFinite(a)) return;
|
|
1015
|
+
let c = t ? a / t[o] * 100 : a, l, u;
|
|
1016
|
+
c >= 0 ? (l = h(n[o]), u = h(n[o] + c), n[o] += c) : (l = h(r[o] + c), u = h(r[o]), r[o] += c), S.push({
|
|
1017
|
+
x: Math.min(l, u),
|
|
1018
|
+
y: s(b(o)),
|
|
1019
|
+
w: s(Math.abs(u - l)),
|
|
1020
|
+
h: s(Math.max(1, y)),
|
|
1021
|
+
color: i.color,
|
|
1022
|
+
label: e.categories[o] ?? String(o),
|
|
1023
|
+
series: i.label,
|
|
1024
|
+
value: a
|
|
1025
|
+
});
|
|
1026
|
+
});
|
|
1027
|
+
} else {
|
|
1028
|
+
let t = y / u.length;
|
|
1029
|
+
u.forEach((n, r) => {
|
|
1030
|
+
n.values.forEach((i, a) => {
|
|
1031
|
+
if (!Number.isFinite(i)) return;
|
|
1032
|
+
let o = h(i);
|
|
1033
|
+
S.push({
|
|
1034
|
+
x: Math.min(o, x),
|
|
1035
|
+
y: s(b(a) + t * r),
|
|
1036
|
+
w: s(Math.max(1, Math.abs(o - x))),
|
|
1037
|
+
h: s(Math.max(1, t - 1)),
|
|
1038
|
+
color: n.color,
|
|
1039
|
+
label: e.categories[a] ?? String(a),
|
|
1040
|
+
series: n.label,
|
|
1041
|
+
value: i
|
|
1042
|
+
});
|
|
1043
|
+
});
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
let C = m.ticks.map((t) => ({
|
|
1047
|
+
label: e.stacked100 ? `${D(t)}%` : O(t, e.valueFormat, e),
|
|
1048
|
+
x: h(t)
|
|
1049
|
+
})), w = e.categories.map((e, t) => ({
|
|
1050
|
+
value: t,
|
|
1051
|
+
y: s(b(t) + y / 2),
|
|
1052
|
+
label: e
|
|
1053
|
+
})), T = (e.referenceLines ?? []).map((t) => ({
|
|
1054
|
+
x: h(t.value),
|
|
1055
|
+
label: t.label ?? O(t.value, e.valueFormat, e),
|
|
1056
|
+
color: t.color ?? "#ef4444",
|
|
1057
|
+
dashed: t.dashed !== !1
|
|
1058
|
+
}));
|
|
1059
|
+
return {
|
|
1060
|
+
...f,
|
|
1061
|
+
plot: d,
|
|
1062
|
+
bars: S,
|
|
1063
|
+
orientation: "horizontal",
|
|
1064
|
+
valueTicks: C,
|
|
1065
|
+
catTicks: w,
|
|
1066
|
+
referenceLinesV: T,
|
|
1067
|
+
xLabelRotated: !1
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
let h = u.filter((e) => e.axis === "left"), _ = u.filter((e) => e.axis === "right"), y = _.length > 0, S = e.categories.reduce((e, t) => Math.max(e, t.length), 0), C = e.categories.length > 8 || S > 9, w = e.categoryGroups && e.categoryGroups.length > 0 && e.xType !== "time" && e.orientation !== "horizontal" && e.categoryGroups.reduce((e, t) => e + t.span, 0) === e.categories.length ? e.categoryGroups : null, k = w ? 18 : 0, M = 48 + (e.yAxisTitle ? 16 : 0), N = (y ? 48 : 12) + (e.y2AxisTitle ? 16 : 0), re = (C ? 54 : 28) + (e.xAxisTitle ? 16 : 0) + k, P = Math.max(1, n - M - N), F = Math.max(1, r - 10 - re), ie = {
|
|
1071
|
+
x: M,
|
|
1072
|
+
y: 10,
|
|
1073
|
+
w: P,
|
|
1074
|
+
h: F
|
|
1075
|
+
}, ae = (e.referenceLines ?? []).filter((e) => e.axis !== "right").map((e) => e.value), I = (e.referenceLines ?? []).filter((e) => e.axis === "right").map((e) => e.value), L = e.yScale === "log", R = e.y2Scale === "log", z = e.stacked100 ? E(0, 100) : j(h, e.categories, l, ae, L), B = y ? e.stacked100 ? E(0, 100) : j(_, e.categories, l, I, R) : null, V = (e, t, n = !1) => {
|
|
1076
|
+
let r = v(t, e.min, e.max, n);
|
|
1077
|
+
return r === null ? NaN : s(10 + F - r * F);
|
|
1078
|
+
}, oe = (e) => V(z, e, L), se = (e) => V(B ?? z, e, R), H = (e) => e.axis === "right" ? B ?? z : z, U = (e) => e.axis === "right" ? R : L, W = e.categories.length, G = P / Math.max(1, W), K = e.xType === "time" || e.xType === "ordinal-time" ? e.categories.map((e) => Date.parse(e)) : null, q = !!K && K.some((e) => Number.isFinite(e)), ce = q && e.xType === "time", J = q ? Math.min(...K.filter(Number.isFinite)) : 0, Y = q && Math.max(...K.filter(Number.isFinite)) - J || 1, X = (e) => ce && Number.isFinite(K[e]) ? s(M + (K[e] - J) / Y * P) : s(M + G * e + G / 2), le = ce ? A(J, J + Y).map((e) => ({
|
|
1079
|
+
label: te(e, Y),
|
|
1080
|
+
x: s(M + (e - J) / Y * P)
|
|
1081
|
+
})) : q ? ee(K).map((e) => ({
|
|
1082
|
+
label: te(K[e], Y),
|
|
1083
|
+
x: X(e)
|
|
1084
|
+
})) : i(e.categories, X, G, C), ue = [];
|
|
1085
|
+
if (w && !q) {
|
|
1086
|
+
let e = 0;
|
|
1087
|
+
for (let t of w) {
|
|
1088
|
+
let n = s(M + G * e), r = s(M + G * (e + t.span));
|
|
1089
|
+
ue.push({
|
|
1090
|
+
label: t.label,
|
|
1091
|
+
x0: n,
|
|
1092
|
+
x1: r,
|
|
1093
|
+
xCenter: s((n + r) / 2)
|
|
1094
|
+
}), e += t.span;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
let Z = u.filter((e) => e.kind === "bar"), de = [];
|
|
1098
|
+
if (Z.length) {
|
|
1099
|
+
let t = G * .2;
|
|
1100
|
+
if (l) {
|
|
1101
|
+
let n = G - t, r = (e) => M + G * e + t / 2;
|
|
1102
|
+
for (let t of ["left", "right"]) {
|
|
1103
|
+
let i = Z.filter((e) => e.axis === t);
|
|
1104
|
+
if (!i.length) continue;
|
|
1105
|
+
let a = t === "right" ? se : oe, o = e.stacked100 ? e.categories.map((e, t) => i.reduce((e, n) => e + Math.abs(Number.isFinite(n.values[t]) ? n.values[t] : 0), 0) || 1) : null, c = Array(W).fill(0), l = Array(W).fill(0);
|
|
1106
|
+
for (let t of i) t.values.forEach((i, u) => {
|
|
1107
|
+
if (!Number.isFinite(i)) return;
|
|
1108
|
+
let d = o ? i / o[u] * 100 : i, f, p;
|
|
1109
|
+
d >= 0 ? (f = a(c[u] + d), p = a(c[u]), c[u] += d) : (f = a(l[u]), p = a(l[u] + d), l[u] += d), de.push({
|
|
1110
|
+
x: s(r(u)),
|
|
1111
|
+
y: Math.min(f, p),
|
|
1112
|
+
w: s(Math.max(1, n)),
|
|
1113
|
+
h: s(Math.abs(p - f)),
|
|
1114
|
+
color: t.color,
|
|
1115
|
+
label: e.categories[u] ?? String(u),
|
|
1116
|
+
series: t.label,
|
|
1117
|
+
value: i
|
|
1118
|
+
});
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
} else {
|
|
1122
|
+
let n = (G - t) / Z.length;
|
|
1123
|
+
Z.forEach((r, i) => {
|
|
1124
|
+
let a = H(r), o = U(r), c = o ? V(a, a.min, o) : V(a, Math.min(Math.max(0, a.min), a.max), o);
|
|
1125
|
+
r.values.forEach((l, u) => {
|
|
1126
|
+
if (!Number.isFinite(l) || o && l <= 0) return;
|
|
1127
|
+
let d = M + G * u + t / 2 + n * i, f = V(a, l, o);
|
|
1128
|
+
de.push({
|
|
1129
|
+
x: s(d),
|
|
1130
|
+
y: Math.min(f, c),
|
|
1131
|
+
w: s(Math.max(1, n - 1)),
|
|
1132
|
+
h: s(Math.max(1, Math.abs(f - c))),
|
|
1133
|
+
color: r.color,
|
|
1134
|
+
label: e.categories[u] ?? String(u),
|
|
1135
|
+
series: r.label,
|
|
1136
|
+
value: l
|
|
1137
|
+
});
|
|
1138
|
+
});
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
let Q = u.filter((e) => e.kind === "candle"), fe = [];
|
|
1143
|
+
if (Q.length) {
|
|
1144
|
+
let t = e.candleColors?.up ?? "#16a34a", n = e.candleColors?.down ?? "#ef4444", r = Math.max(1, G * .7 / Q.length);
|
|
1145
|
+
Q.forEach((i, a) => {
|
|
1146
|
+
let o = H(i), c = U(i);
|
|
1147
|
+
(i.ohlc ?? []).forEach((l, u) => {
|
|
1148
|
+
if (!l || ![
|
|
1149
|
+
l.o,
|
|
1150
|
+
l.h,
|
|
1151
|
+
l.l,
|
|
1152
|
+
l.c
|
|
1153
|
+
].every(Number.isFinite) || c && (l.o <= 0 || l.h <= 0 || l.l <= 0 || l.c <= 0)) return;
|
|
1154
|
+
let d = M + G * u + G / 2 - r * Q.length / 2 + r * a, f = V(o, l.o, c), p = V(o, l.c, c), m = l.c >= l.o;
|
|
1155
|
+
fe.push({
|
|
1156
|
+
x: s(d),
|
|
1157
|
+
w: s(r),
|
|
1158
|
+
xCenter: s(d + r / 2),
|
|
1159
|
+
yOpen: f,
|
|
1160
|
+
yClose: p,
|
|
1161
|
+
yHigh: V(o, l.h, c),
|
|
1162
|
+
yLow: V(o, l.l, c),
|
|
1163
|
+
bodyY: Math.min(f, p),
|
|
1164
|
+
bodyH: Math.max(1, Math.abs(p - f)),
|
|
1165
|
+
up: m,
|
|
1166
|
+
color: m ? t : n,
|
|
1167
|
+
label: e.categories[u] ?? String(u),
|
|
1168
|
+
series: i.label,
|
|
1169
|
+
o: l.o,
|
|
1170
|
+
h: l.h,
|
|
1171
|
+
l: l.l,
|
|
1172
|
+
c: l.c
|
|
1173
|
+
});
|
|
1174
|
+
});
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
let $ = u.filter((e) => e.kind === "box"), pe = [];
|
|
1178
|
+
if ($.length) {
|
|
1179
|
+
let t = Math.max(1, G * .6 / $.length);
|
|
1180
|
+
$.forEach((n, r) => {
|
|
1181
|
+
let i = H(n), a = U(n);
|
|
1182
|
+
(n.boxes ?? []).forEach((o, c) => {
|
|
1183
|
+
if (!o || ![
|
|
1184
|
+
o.min,
|
|
1185
|
+
o.q1,
|
|
1186
|
+
o.median,
|
|
1187
|
+
o.q3,
|
|
1188
|
+
o.max
|
|
1189
|
+
].every(Number.isFinite) || a && o.min <= 0) return;
|
|
1190
|
+
let l = M + G * c + G / 2 - t * $.length / 2 + t * r, u = V(i, o.q1, a), d = V(i, o.q3, a);
|
|
1191
|
+
pe.push({
|
|
1192
|
+
x: s(l),
|
|
1193
|
+
w: s(t),
|
|
1194
|
+
xCenter: s(l + t / 2),
|
|
1195
|
+
yMin: V(i, o.min, a),
|
|
1196
|
+
yQ1: u,
|
|
1197
|
+
yMedian: V(i, o.median, a),
|
|
1198
|
+
yQ3: d,
|
|
1199
|
+
yMax: V(i, o.max, a),
|
|
1200
|
+
boxY: Math.min(u, d),
|
|
1201
|
+
boxH: Math.max(1, Math.abs(u - d)),
|
|
1202
|
+
outliers: (o.outliers ?? []).filter((e) => Number.isFinite(e) && (!a || e > 0)).map((e) => ({
|
|
1203
|
+
y: V(i, e, a),
|
|
1204
|
+
value: e
|
|
1205
|
+
})),
|
|
1206
|
+
color: n.color,
|
|
1207
|
+
label: e.categories[c] ?? String(c),
|
|
1208
|
+
series: n.label,
|
|
1209
|
+
min: o.min,
|
|
1210
|
+
q1: o.q1,
|
|
1211
|
+
median: o.median,
|
|
1212
|
+
q3: o.q3,
|
|
1213
|
+
max: o.max
|
|
1214
|
+
});
|
|
1215
|
+
});
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
let me = [];
|
|
1219
|
+
for (let t of u) {
|
|
1220
|
+
if (!t.errors) continue;
|
|
1221
|
+
let n = H(t), r = U(t);
|
|
1222
|
+
t.errors.forEach((i, o) => {
|
|
1223
|
+
let c = t.values[o];
|
|
1224
|
+
if (!Number.isFinite(c)) return;
|
|
1225
|
+
let l = a(i, c);
|
|
1226
|
+
l && (r && l.lo <= 0 || me.push({
|
|
1227
|
+
xCenter: s(M + G * o + G / 2),
|
|
1228
|
+
yLo: V(n, l.lo, r),
|
|
1229
|
+
yHi: V(n, l.hi, r),
|
|
1230
|
+
cap: s(Math.min(6, G * .15)),
|
|
1231
|
+
color: t.color,
|
|
1232
|
+
label: e.categories[o] ?? String(o),
|
|
1233
|
+
series: t.label,
|
|
1234
|
+
lo: l.lo,
|
|
1235
|
+
hi: l.hi
|
|
1236
|
+
}));
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
let he = [], ge = {
|
|
1240
|
+
left: Array(W).fill(0),
|
|
1241
|
+
right: Array(W).fill(0)
|
|
1242
|
+
}, _e = {
|
|
1243
|
+
left: null,
|
|
1244
|
+
right: null
|
|
1245
|
+
};
|
|
1246
|
+
if (e.stacked100) for (let t of ["left", "right"]) {
|
|
1247
|
+
let n = u.filter((e) => e.kind === "area" && e.axis === t);
|
|
1248
|
+
n.length && (_e[t] = e.categories.map((e, t) => n.reduce((e, n) => e + Math.abs(Number.isFinite(n.values[t]) ? n.values[t] : 0), 0) || 1));
|
|
1249
|
+
}
|
|
1250
|
+
for (let t of u) {
|
|
1251
|
+
if (t.kind === "bar" || t.kind === "candle" || t.kind === "box") continue;
|
|
1252
|
+
let n = H(t), r = U(t), i = (e) => V(n, e, r), a = l && t.kind === "area", o = (e) => X(e), c, u = null;
|
|
1253
|
+
if (a) {
|
|
1254
|
+
let n = ge[t.axis], r = n.slice(), a = _e[t.axis];
|
|
1255
|
+
c = t.values.map((t, r) => {
|
|
1256
|
+
let s = Number.isFinite(t) ? t : 0, c = a ? s / a[r] * 100 : s, l = (n[r] ?? 0) + c;
|
|
1257
|
+
return n[r] = l, {
|
|
1258
|
+
x: o(r),
|
|
1259
|
+
y: i(l),
|
|
1260
|
+
label: e.categories[r] ?? String(r),
|
|
1261
|
+
value: t,
|
|
1262
|
+
defined: Number.isFinite(t)
|
|
1263
|
+
};
|
|
1264
|
+
}), u = r.map((e, t) => ({
|
|
1265
|
+
x: o(t),
|
|
1266
|
+
y: i(e)
|
|
1267
|
+
}));
|
|
1268
|
+
} else c = t.values.map((t, n) => {
|
|
1269
|
+
let r = Number.isFinite(t);
|
|
1270
|
+
return {
|
|
1271
|
+
x: o(n),
|
|
1272
|
+
y: r ? i(t) : NaN,
|
|
1273
|
+
label: e.categories[n] ?? String(n),
|
|
1274
|
+
value: t,
|
|
1275
|
+
defined: r
|
|
1276
|
+
};
|
|
1277
|
+
});
|
|
1278
|
+
let d = !!t.smooth, f = b(c, d), p = "";
|
|
1279
|
+
if (t.kind === "area" && c.length) {
|
|
1280
|
+
if (u) p = `${d ? x(c.map((e) => ({
|
|
1281
|
+
x: e.x,
|
|
1282
|
+
y: e.y
|
|
1283
|
+
}))) : c.map((e, t) => `${t === 0 ? "M" : "L"}${e.x},${e.y}`).join(" ")} ${d ? `L${u[u.length - 1].x},${u[u.length - 1].y} ` + x(u.slice().reverse()).replace(/^M[^ ]+ /, "") : u.slice().reverse().map((e) => `L${e.x},${e.y}`).join(" ")} Z`;
|
|
1284
|
+
else {
|
|
1285
|
+
let e = s(i(Math.min(Math.max(0, n.min), n.max))), t = [], r = [];
|
|
1286
|
+
for (let e of c) e.defined ? r.push(e) : r.length && (t.push(r), r = []);
|
|
1287
|
+
r.length && t.push(r), p = t.map((t) => `${d ? x(t.map((e) => ({
|
|
1288
|
+
x: e.x,
|
|
1289
|
+
y: e.y
|
|
1290
|
+
}))) : t.map((e, t) => `${t === 0 ? "M" : "L"}${e.x},${e.y}`).join(" ")} L${t[t.length - 1].x},${e} L${t[0].x},${e} Z`).join(" ");
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
let m = "";
|
|
1294
|
+
if (t.upperValues?.length === t.values.length && t.lowerValues?.length === t.values.length) {
|
|
1295
|
+
let e = [], n = [];
|
|
1296
|
+
for (let a = 0; a < t.values.length; a += 1) {
|
|
1297
|
+
let s = t.upperValues[a], c = t.lowerValues[a];
|
|
1298
|
+
!Number.isFinite(s) || !Number.isFinite(c) || r && (s <= 0 || c <= 0) || (e.push({
|
|
1299
|
+
x: o(a),
|
|
1300
|
+
y: i(s)
|
|
1301
|
+
}), n.push({
|
|
1302
|
+
x: o(a),
|
|
1303
|
+
y: i(c)
|
|
1304
|
+
}));
|
|
1305
|
+
}
|
|
1306
|
+
e.length >= 2 && (m = `${d ? x(e) : e.map((e, t) => `${t === 0 ? "M" : "L"}${e.x},${e.y}`).join(" ")} ${d ? `L${n[n.length - 1].x},${n[n.length - 1].y} ` + x(n.slice().reverse()).replace(/^M[^ ]+ /, "") : n.slice().reverse().map((e) => `L${e.x},${e.y}`).join(" ")} Z`);
|
|
1307
|
+
}
|
|
1308
|
+
he.push({
|
|
1309
|
+
path: f,
|
|
1310
|
+
areaPath: p,
|
|
1311
|
+
color: t.color,
|
|
1312
|
+
label: t.label,
|
|
1313
|
+
points: c,
|
|
1314
|
+
bandPath: m
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
let ve = (t, n) => t.ticks.map((r) => ({
|
|
1318
|
+
value: r,
|
|
1319
|
+
y: V(t, r, n),
|
|
1320
|
+
label: e.stacked100 ? `${s(r)}%` : O(r, e.valueFormat, e)
|
|
1321
|
+
})), ye = (e.referenceLines ?? []).map((t) => {
|
|
1322
|
+
let n = t.axis === "right", r = n ? B ?? z : z, i = n ? R : L;
|
|
1323
|
+
return {
|
|
1324
|
+
y: V(r, t.value, i),
|
|
1325
|
+
label: t.label ?? O(t.value, e.valueFormat, e),
|
|
1326
|
+
color: t.color ?? "#ef4444",
|
|
1327
|
+
dashed: t.dashed !== !1
|
|
1328
|
+
};
|
|
1329
|
+
}), be = [];
|
|
1330
|
+
for (let t of u) {
|
|
1331
|
+
if (!t.overlay) continue;
|
|
1332
|
+
let n = H(t), r = U(t), i = T(t.values, t.overlay), a = t.overlayColor ?? t.color, o = i.map((t, i) => {
|
|
1333
|
+
let a = Number.isFinite(t) && (!r || t > 0);
|
|
1334
|
+
return {
|
|
1335
|
+
x: X(i),
|
|
1336
|
+
y: a ? V(n, t, r) : NaN,
|
|
1337
|
+
label: e.categories[i] ?? String(i),
|
|
1338
|
+
value: t,
|
|
1339
|
+
defined: a
|
|
1340
|
+
};
|
|
1341
|
+
}), s = b(o, !!t.smooth);
|
|
1342
|
+
be.push({
|
|
1343
|
+
path: s,
|
|
1344
|
+
areaPath: "",
|
|
1345
|
+
color: a,
|
|
1346
|
+
label: `${t.label} (${t.overlay})`,
|
|
1347
|
+
points: o
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
let xe = [];
|
|
1351
|
+
for (let t of e.annotations ?? []) {
|
|
1352
|
+
let n = null, r = null;
|
|
1353
|
+
if ("category" in t.at) {
|
|
1354
|
+
let i = e.categories.indexOf(t.at.category);
|
|
1355
|
+
if (i < 0) continue;
|
|
1356
|
+
n = X(i);
|
|
1357
|
+
let a = t.at.series, o = a ? u.find((e) => e.label === a) : u[0];
|
|
1358
|
+
if (o) {
|
|
1359
|
+
let e = o.values[i];
|
|
1360
|
+
Number.isFinite(e) && (r = V(H(o), e, U(o)));
|
|
1361
|
+
}
|
|
1362
|
+
r ??= 10 + F / 2;
|
|
1363
|
+
} else n = M + P / 2, r = Number.isFinite(t.at.y) ? V(z, t.at.y, L) : 10 + F / 2;
|
|
1364
|
+
n != null && r != null && Number.isFinite(r) && xe.push({
|
|
1365
|
+
x: n,
|
|
1366
|
+
y: r,
|
|
1367
|
+
label: t.label,
|
|
1368
|
+
color: t.color ?? "#0f172a",
|
|
1369
|
+
placement: t.placement ?? "top"
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
return {
|
|
1373
|
+
...f,
|
|
1374
|
+
plot: ie,
|
|
1375
|
+
axes: {
|
|
1376
|
+
y: {
|
|
1377
|
+
min: z.min,
|
|
1378
|
+
max: z.max,
|
|
1379
|
+
log: L
|
|
1380
|
+
},
|
|
1381
|
+
y2: B ? {
|
|
1382
|
+
min: B.min,
|
|
1383
|
+
max: B.max,
|
|
1384
|
+
log: R
|
|
1385
|
+
} : null,
|
|
1386
|
+
slot: G,
|
|
1387
|
+
count: e.categories.length
|
|
1388
|
+
},
|
|
1389
|
+
bars: de,
|
|
1390
|
+
candles: fe,
|
|
1391
|
+
boxes: pe,
|
|
1392
|
+
errorBars: me,
|
|
1393
|
+
lines: he,
|
|
1394
|
+
yTicks: ve(z, L),
|
|
1395
|
+
y2Ticks: B ? ve(B, R) : [],
|
|
1396
|
+
hasRightAxis: y,
|
|
1397
|
+
xTicks: le,
|
|
1398
|
+
categoryGroupTicks: ue,
|
|
1399
|
+
xLabelRotated: !q && C,
|
|
1400
|
+
referenceLines: ye,
|
|
1401
|
+
overlays: be,
|
|
1402
|
+
annotations: xe
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
function N(e, t, n) {
|
|
1406
|
+
let r = Math.max(0, t), i = Math.min(e.categories.length - 1, n), a = (e) => e ? e.slice(r, i + 1) : void 0;
|
|
1407
|
+
return {
|
|
1408
|
+
...e,
|
|
1409
|
+
categories: e.categories.slice(r, i + 1),
|
|
1410
|
+
series: e.series.map((e) => ({
|
|
1411
|
+
...e,
|
|
1412
|
+
values: e.values.slice(r, i + 1),
|
|
1413
|
+
rowIds: a(e.rowIds),
|
|
1414
|
+
upperValues: a(e.upperValues),
|
|
1415
|
+
lowerValues: a(e.lowerValues),
|
|
1416
|
+
ohlc: a(e.ohlc),
|
|
1417
|
+
boxes: a(e.boxes),
|
|
1418
|
+
errors: a(e.errors)
|
|
1419
|
+
})),
|
|
1420
|
+
waterfallTotals: a(e.waterfallTotals)
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
function re(e, t) {
|
|
1424
|
+
let n = t.reduce ?? "sum", r = Array.isArray(t.value) ? t.value : [t.value], i = (e, t) => n === "count" ? t : n === "avg" ? t ? e / t : 0 : e, a = [], o = /* @__PURE__ */ new Map(), s = (e) => {
|
|
1425
|
+
let t = o.get(e);
|
|
1426
|
+
return t === void 0 && (t = a.length, o.set(e, t), a.push(e)), t;
|
|
1427
|
+
}, c = /* @__PURE__ */ new Map(), l = (e) => {
|
|
1428
|
+
let t = c.get(e);
|
|
1429
|
+
return t || (t = [], c.set(e, t)), t;
|
|
1430
|
+
}, u = t.idField !== void 0;
|
|
1431
|
+
for (let n of e) {
|
|
1432
|
+
let e = s(String(n[t.category] ?? "")), i = u ? n[t.idField] : void 0;
|
|
1433
|
+
if (t.series) {
|
|
1434
|
+
let a = l(String(n[t.series] ?? "")), o = Number(n[r[0]]), s = a[e] ?? (a[e] = {
|
|
1435
|
+
sum: 0,
|
|
1436
|
+
count: 0,
|
|
1437
|
+
rowIds: []
|
|
1438
|
+
});
|
|
1439
|
+
Number.isFinite(o) && (s.sum += o, s.count += 1, i !== void 0 && s.rowIds.push(i));
|
|
1440
|
+
} else for (let t of r) {
|
|
1441
|
+
let r = l(t), a = Number(n[t]), o = r[e] ?? (r[e] = {
|
|
1442
|
+
sum: 0,
|
|
1443
|
+
count: 0,
|
|
1444
|
+
rowIds: []
|
|
1445
|
+
});
|
|
1446
|
+
Number.isFinite(a) && (o.sum += a, o.count += 1, i !== void 0 && o.rowIds.push(i));
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
let d = [...c.entries()].map(([e, n]) => ({
|
|
1450
|
+
label: t.series ? e : t.seriesLabel && r.length === 1 ? t.seriesLabel : e,
|
|
1451
|
+
values: a.map((e, t) => {
|
|
1452
|
+
let r = n[t] ?? {
|
|
1453
|
+
sum: 0,
|
|
1454
|
+
count: 0,
|
|
1455
|
+
rowIds: []
|
|
1456
|
+
};
|
|
1457
|
+
return i(r.sum, r.count);
|
|
1458
|
+
}),
|
|
1459
|
+
rowIds: u ? a.map((e, t) => (n[t]?.rowIds ?? []).slice()) : void 0
|
|
1460
|
+
})), f = a.map((e, t) => d.reduce((e, n) => e + (Number.isFinite(n.values[t]) ? n.values[t] : 0), 0)), p = t.sort ?? (t.topN ? "value-desc" : "none"), m = a.map((e, t) => t);
|
|
1461
|
+
p === "value-desc" ? m.sort((e, t) => f[t] - f[e]) : p === "value-asc" ? m.sort((e, t) => f[e] - f[t]) : p === "category" && m.sort((e, t) => a[e].localeCompare(a[t]));
|
|
1462
|
+
let h, g;
|
|
1463
|
+
if (t.topN && m.length > t.topN) {
|
|
1464
|
+
let e = m.slice(0, t.topN), n = m.slice(t.topN);
|
|
1465
|
+
h = e.map((e) => a[e]).concat(t.otherLabel ?? "Other"), g = d.map((t) => ({
|
|
1466
|
+
label: t.label,
|
|
1467
|
+
values: e.map((e) => t.values[e]).concat(n.reduce((e, n) => e + (Number.isFinite(t.values[n]) ? t.values[n] : 0), 0)),
|
|
1468
|
+
rowIds: t.rowIds ? e.map((e) => t.rowIds[e]).concat([n.flatMap((e) => t.rowIds[e] ?? [])]) : void 0
|
|
1469
|
+
}));
|
|
1470
|
+
} else h = m.map((e) => a[e]), g = d.map((e) => ({
|
|
1471
|
+
label: e.label,
|
|
1472
|
+
values: m.map((t) => e.values[t]),
|
|
1473
|
+
rowIds: e.rowIds ? m.map((t) => e.rowIds[t]) : void 0
|
|
1474
|
+
}));
|
|
1475
|
+
return {
|
|
1476
|
+
type: t.type,
|
|
1477
|
+
categories: h,
|
|
1478
|
+
series: g,
|
|
1479
|
+
width: t.width,
|
|
1480
|
+
height: t.height,
|
|
1481
|
+
stacked: t.stacked,
|
|
1482
|
+
stacked100: t.stacked100,
|
|
1483
|
+
palette: t.palette
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
function P(e, t = "Total") {
|
|
1487
|
+
let n = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : 0;
|
|
1488
|
+
if (e.series.length <= 1) {
|
|
1489
|
+
let r = e.series[0];
|
|
1490
|
+
return {
|
|
1491
|
+
name: t,
|
|
1492
|
+
children: e.categories.map((e, t) => ({
|
|
1493
|
+
name: e,
|
|
1494
|
+
value: n(r?.values[t])
|
|
1495
|
+
})).filter((e) => e.value > 0)
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
return {
|
|
1499
|
+
name: t,
|
|
1500
|
+
children: e.categories.map((t, r) => ({
|
|
1501
|
+
name: t,
|
|
1502
|
+
children: e.series.map((e) => ({
|
|
1503
|
+
name: e.label,
|
|
1504
|
+
value: n(e.values[r])
|
|
1505
|
+
})).filter((e) => e.value > 0)
|
|
1506
|
+
})).filter((e) => e.children.length > 0)
|
|
1507
|
+
};
|
|
1508
|
+
}
|
|
1509
|
+
function F(e) {
|
|
1510
|
+
let t = e.series[0], n = [];
|
|
1511
|
+
return e.categories.forEach((e, r) => {
|
|
1512
|
+
let i = Date.parse(e);
|
|
1513
|
+
if (!Number.isFinite(i)) return;
|
|
1514
|
+
let a = t?.values[r];
|
|
1515
|
+
typeof a != "number" || !Number.isFinite(a) || n.push({
|
|
1516
|
+
date: new Date(i).toISOString().slice(0, 10),
|
|
1517
|
+
value: a
|
|
1518
|
+
});
|
|
1519
|
+
}), n;
|
|
1520
|
+
}
|
|
1521
|
+
function ie(e) {
|
|
1522
|
+
let t = [], n = /* @__PURE__ */ new Set();
|
|
1523
|
+
return e.categories.forEach((r, i) => {
|
|
1524
|
+
for (let a of e.series) {
|
|
1525
|
+
let e = a.values[i];
|
|
1526
|
+
if (typeof e != "number" || !Number.isFinite(e) || e <= 0) continue;
|
|
1527
|
+
let o = `from:${r}`, s = `to:${a.label}`;
|
|
1528
|
+
o !== s && (n.add(o), n.add(s), t.push({
|
|
1529
|
+
source: o,
|
|
1530
|
+
target: s,
|
|
1531
|
+
value: e
|
|
1532
|
+
}));
|
|
1533
|
+
}
|
|
1534
|
+
}), {
|
|
1535
|
+
nodes: [...n].map((e) => ({
|
|
1536
|
+
id: e,
|
|
1537
|
+
label: e.slice(e.indexOf(":") + 1)
|
|
1538
|
+
})),
|
|
1539
|
+
links: t
|
|
1540
|
+
};
|
|
1541
|
+
}
|
|
1542
|
+
function ae(e, t, n) {
|
|
1543
|
+
let r = n.category, i = n.value, a = n.series;
|
|
1544
|
+
if (e === "scatter") {
|
|
1545
|
+
let e = n.value2;
|
|
1546
|
+
return !i || !e ? null : L(t, {
|
|
1547
|
+
x: i,
|
|
1548
|
+
y: e,
|
|
1549
|
+
...a ? { series: a } : {},
|
|
1550
|
+
...n.palette ? { palette: n.palette } : {}
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
if (e === "gauge") return i ? R(t, {
|
|
1554
|
+
value: i,
|
|
1555
|
+
...n.reduce ? { reduce: n.reduce } : {}
|
|
1556
|
+
}) : null;
|
|
1557
|
+
if (e === "boxplot") {
|
|
1558
|
+
if (!r || !i) return null;
|
|
1559
|
+
let e = I(t, {
|
|
1560
|
+
category: r,
|
|
1561
|
+
value: i,
|
|
1562
|
+
...a ? { series: a } : {}
|
|
1563
|
+
});
|
|
1564
|
+
return n.palette && (e.palette = n.palette), e;
|
|
1565
|
+
}
|
|
1566
|
+
return null;
|
|
1567
|
+
}
|
|
1568
|
+
function I(e, t) {
|
|
1569
|
+
let n = [], i = /* @__PURE__ */ new Set();
|
|
1570
|
+
for (let r of e) {
|
|
1571
|
+
let e = String(r[t.category] ?? "");
|
|
1572
|
+
i.has(e) || (i.add(e), n.push(e));
|
|
1573
|
+
}
|
|
1574
|
+
let a = [], o = /* @__PURE__ */ new Set();
|
|
1575
|
+
if (t.series) for (let n of e) {
|
|
1576
|
+
let e = String(n[t.series] ?? "");
|
|
1577
|
+
o.has(e) || (o.add(e), a.push(e));
|
|
1578
|
+
}
|
|
1579
|
+
else a.push(t.seriesLabel ?? String(t.value));
|
|
1580
|
+
return {
|
|
1581
|
+
type: "boxplot",
|
|
1582
|
+
categories: n,
|
|
1583
|
+
series: a.map((i) => {
|
|
1584
|
+
let a = n.map((n) => {
|
|
1585
|
+
let a = [];
|
|
1586
|
+
for (let r of e) {
|
|
1587
|
+
if (String(r[t.category] ?? "") !== n || t.series && String(r[t.series] ?? "") !== i) continue;
|
|
1588
|
+
let e = r[t.value];
|
|
1589
|
+
if (e == null || e === "") continue;
|
|
1590
|
+
let o = Number(e);
|
|
1591
|
+
Number.isFinite(o) && a.push(o);
|
|
1592
|
+
}
|
|
1593
|
+
return r(a, t.whisker);
|
|
1594
|
+
});
|
|
1595
|
+
return {
|
|
1596
|
+
label: i,
|
|
1597
|
+
values: a.map((e) => e ? e.median : NaN),
|
|
1598
|
+
boxes: a
|
|
1599
|
+
};
|
|
1600
|
+
}),
|
|
1601
|
+
...t.width ? { width: t.width } : {},
|
|
1602
|
+
...t.height ? { height: t.height } : {}
|
|
1603
|
+
};
|
|
1604
|
+
}
|
|
1605
|
+
function L(e, t) {
|
|
1606
|
+
let n = /* @__PURE__ */ new Map();
|
|
1607
|
+
for (let r of e) {
|
|
1608
|
+
let e = Number(r[t.x]), i = Number(r[t.y]);
|
|
1609
|
+
if (!Number.isFinite(e) || !Number.isFinite(i)) continue;
|
|
1610
|
+
let a = t.series ? String(r[t.series] ?? "") : t.y, o = {
|
|
1611
|
+
x: e,
|
|
1612
|
+
y: i
|
|
1613
|
+
};
|
|
1614
|
+
if (t.r) {
|
|
1615
|
+
let e = Number(r[t.r]);
|
|
1616
|
+
Number.isFinite(e) && (o.r = e);
|
|
1617
|
+
}
|
|
1618
|
+
t.label && (o.label = String(r[t.label] ?? ""));
|
|
1619
|
+
let s = n.get(a);
|
|
1620
|
+
s ? s.push(o) : n.set(a, [o]);
|
|
1621
|
+
}
|
|
1622
|
+
return {
|
|
1623
|
+
type: "scatter",
|
|
1624
|
+
categories: [],
|
|
1625
|
+
series: [...n].map(([e, t]) => ({
|
|
1626
|
+
label: e,
|
|
1627
|
+
values: [],
|
|
1628
|
+
points: t
|
|
1629
|
+
})),
|
|
1630
|
+
palette: t.palette,
|
|
1631
|
+
width: t.width,
|
|
1632
|
+
height: t.height,
|
|
1633
|
+
xAxisTitle: t.x,
|
|
1634
|
+
yAxisTitle: t.y
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
function R(e, t) {
|
|
1638
|
+
let n = t.reduce ?? "sum", r = 0, i = 0;
|
|
1639
|
+
for (let n of e) {
|
|
1640
|
+
let e = Number(n[t.value]);
|
|
1641
|
+
Number.isFinite(e) && (r += e, i += 1);
|
|
1642
|
+
}
|
|
1643
|
+
let a = n === "count" ? i : n === "avg" ? i ? r / i : 0 : r, o = t.min ?? Math.min(0, a);
|
|
1644
|
+
return {
|
|
1645
|
+
type: "gauge",
|
|
1646
|
+
categories: [],
|
|
1647
|
+
series: [],
|
|
1648
|
+
gaugeValue: a,
|
|
1649
|
+
gaugeMin: o,
|
|
1650
|
+
gaugeMax: t.max ?? (a > o ? E(o, a).max : o + 1),
|
|
1651
|
+
gaugeTarget: t.target,
|
|
1652
|
+
gaugeUnit: t.unit,
|
|
1653
|
+
width: t.width,
|
|
1654
|
+
height: t.height
|
|
1655
|
+
};
|
|
1656
|
+
}
|
|
1657
|
+
//#endregion
|
|
1658
|
+
export { O as a, n as i, M as n, re as o, y as r, N as s, o as t };
|