@umriss-ui/charts 0.3.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +158 -0
- package/LICENSE +20 -0
- package/README.md +109 -0
- package/dist/charts.css +1 -0
- package/dist/charts.js +2820 -0
- package/dist/index.d.ts +1033 -0
- package/package.json +76 -0
package/dist/charts.js
ADDED
|
@@ -0,0 +1,2820 @@
|
|
|
1
|
+
var fe = Object.defineProperty;
|
|
2
|
+
var me = (n, t, e) => t in n ? fe(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var g = (n, t, e) => me(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { jsx as I, jsxs as B, Fragment as Nt } from "react/jsx-runtime";
|
|
5
|
+
import { useRef as Z, useEffect as D, createContext as pe, useContext as ye, useSyncExternalStore as Et, useCallback as ge, useState as be, useMemo as E } from "react";
|
|
6
|
+
function xe() {
|
|
7
|
+
var t;
|
|
8
|
+
const n = import.meta;
|
|
9
|
+
return typeof ((t = n.env) == null ? void 0 : t.DEV) == "boolean" ? n.env.DEV : typeof process < "u" && (process != null && process.env) ? process.env.NODE_ENV !== "production" : !1;
|
|
10
|
+
}
|
|
11
|
+
const st = xe();
|
|
12
|
+
function ut(n, t) {
|
|
13
|
+
if (st && !n)
|
|
14
|
+
throw new Error(`@umriss-ui/charts: ${t}`);
|
|
15
|
+
}
|
|
16
|
+
const Ot = /* @__PURE__ */ new Set();
|
|
17
|
+
function q(n, t) {
|
|
18
|
+
!st || Ot.has(n) || (Ot.add(n), console.warn(`@umriss-ui/charts: ${t}`));
|
|
19
|
+
}
|
|
20
|
+
const W = {
|
|
21
|
+
colorAxis: "rgba(23, 23, 23, 0.17)",
|
|
22
|
+
colorGrid: "rgba(23, 23, 23, 0.06)",
|
|
23
|
+
colorText: "#71717a",
|
|
24
|
+
colorBg: "#ffffff",
|
|
25
|
+
colorWarning: "#8a5c00",
|
|
26
|
+
colorAlarm: "#b13636",
|
|
27
|
+
colorOk: "#217a4b",
|
|
28
|
+
font: "system-ui, sans-serif",
|
|
29
|
+
fontMono: "ui-monospace, monospace",
|
|
30
|
+
series: ["#2563eb", "#db2777", "#059669", "#d97706", "#7c3aed", "#0891b2"]
|
|
31
|
+
}, Ht = /* @__PURE__ */ new WeakMap();
|
|
32
|
+
let wt = 0;
|
|
33
|
+
const It = /* @__PURE__ */ new Set();
|
|
34
|
+
let bt = null;
|
|
35
|
+
function _(n, t, e) {
|
|
36
|
+
const i = n.getPropertyValue(t).trim();
|
|
37
|
+
return i === "" ? e : i;
|
|
38
|
+
}
|
|
39
|
+
function ve(n) {
|
|
40
|
+
const t = getComputedStyle(n), e = [];
|
|
41
|
+
for (let i = 1; i <= 6; i++)
|
|
42
|
+
e.push(_(t, `--uc-series-${i}`, W.series[i - 1] ?? "#2563eb"));
|
|
43
|
+
return {
|
|
44
|
+
colorAxis: _(t, "--uc-color-axis", W.colorAxis),
|
|
45
|
+
colorGrid: _(t, "--uc-color-grid", W.colorGrid),
|
|
46
|
+
colorText: _(t, "--uc-color-text", W.colorText),
|
|
47
|
+
colorBg: _(t, "--uc-color-bg", W.colorBg),
|
|
48
|
+
colorWarning: _(t, "--uc-color-warning", W.colorWarning),
|
|
49
|
+
colorAlarm: _(t, "--uc-color-alarm", W.colorAlarm),
|
|
50
|
+
colorOk: _(t, "--uc-color-ok", W.colorOk),
|
|
51
|
+
font: _(t, "--uc-font", W.font),
|
|
52
|
+
fontMono: _(t, "--uc-font-mono", W.fontMono),
|
|
53
|
+
series: e
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function ke() {
|
|
57
|
+
bt === null && (typeof MutationObserver > "u" || typeof document > "u" || (bt = new MutationObserver(() => we()), bt.observe(document.documentElement, { attributes: !0 })));
|
|
58
|
+
}
|
|
59
|
+
function Ne(n) {
|
|
60
|
+
ke();
|
|
61
|
+
const t = Ht.get(n);
|
|
62
|
+
if (t !== void 0 && t.generation === wt) return t.theme;
|
|
63
|
+
const e = ve(n);
|
|
64
|
+
return Ht.set(n, { generation: wt, theme: e }), e;
|
|
65
|
+
}
|
|
66
|
+
function we() {
|
|
67
|
+
wt++;
|
|
68
|
+
for (const n of It) n();
|
|
69
|
+
}
|
|
70
|
+
function Ie(n) {
|
|
71
|
+
return It.add(n), () => {
|
|
72
|
+
It.delete(n);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const Se = { width: 0, height: 0 };
|
|
76
|
+
class Me {
|
|
77
|
+
constructor(t) {
|
|
78
|
+
g(this, "span", null);
|
|
79
|
+
g(this, "root");
|
|
80
|
+
g(this, "cache", /* @__PURE__ */ new Map());
|
|
81
|
+
this.root = t;
|
|
82
|
+
}
|
|
83
|
+
ensure() {
|
|
84
|
+
if (this.span !== null) return this.span;
|
|
85
|
+
if (typeof document > "u") return null;
|
|
86
|
+
const t = document.createElement("span");
|
|
87
|
+
return t.className = "kc-measure", t.setAttribute("aria-hidden", "true"), this.root.appendChild(t), this.span = t, t;
|
|
88
|
+
}
|
|
89
|
+
/** Width and height of a text in the presentation of the given class. */
|
|
90
|
+
measure(t, e) {
|
|
91
|
+
const i = `${e}|${t}`, s = this.cache.get(i);
|
|
92
|
+
if (s !== void 0) return s;
|
|
93
|
+
const r = this.ensure();
|
|
94
|
+
if (r === null) return Se;
|
|
95
|
+
r.className = `kc-measure ${e}`, r.textContent = t;
|
|
96
|
+
const o = r.getBoundingClientRect(), a = { width: o.width, height: o.height };
|
|
97
|
+
return this.cache.set(i, a), a;
|
|
98
|
+
}
|
|
99
|
+
clear() {
|
|
100
|
+
this.cache.clear();
|
|
101
|
+
}
|
|
102
|
+
remove() {
|
|
103
|
+
var t;
|
|
104
|
+
(t = this.span) == null || t.remove(), this.span = null, this.cache.clear();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function St(n) {
|
|
108
|
+
return Object.is(n, -0) ? 0 : n;
|
|
109
|
+
}
|
|
110
|
+
function pt(n, t) {
|
|
111
|
+
if (!Number.isFinite(n) || n <= 0) return 1;
|
|
112
|
+
const e = Math.max(1, Math.floor(t)), i = n / e, s = Math.pow(10, Math.floor(Math.log10(i))), r = i / s, o = 1e-9;
|
|
113
|
+
return (r <= 1 + o ? 1 : r <= 2 + o ? 2 : r <= 5 + o ? 5 : 10) * s;
|
|
114
|
+
}
|
|
115
|
+
function Dt(n) {
|
|
116
|
+
const t = Math.abs(n);
|
|
117
|
+
if (!Number.isFinite(t) || t === 0) return 0;
|
|
118
|
+
const e = Math.floor(Math.log10(t));
|
|
119
|
+
let i = e < 0 ? -e : 0;
|
|
120
|
+
const s = t * 1e-9;
|
|
121
|
+
for (; i < 12 && Math.abs(Number(t.toFixed(i)) - t) > s; )
|
|
122
|
+
i++;
|
|
123
|
+
return i;
|
|
124
|
+
}
|
|
125
|
+
function Mt(n, t) {
|
|
126
|
+
return t <= 0 || !Number.isFinite(n) || Math.abs(n) >= 1e21 ? St(n) : St(Number(n.toFixed(Math.min(20, t))));
|
|
127
|
+
}
|
|
128
|
+
function Te(n, t, e) {
|
|
129
|
+
if (!Number.isFinite(n) || !Number.isFinite(t)) return [0, 1];
|
|
130
|
+
if (n === t) return [n - 1, t + 1];
|
|
131
|
+
const i = pt(t - n, e), s = Dt(i);
|
|
132
|
+
return [
|
|
133
|
+
Mt(Math.floor(n / i) * i, s),
|
|
134
|
+
Mt(Math.ceil(t / i) * i, s)
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
function Rt(n, t) {
|
|
138
|
+
return !Number.isFinite(n) || !Number.isFinite(t) ? [0, 1] : n === t ? [n - 1, t + 1] : [n, t];
|
|
139
|
+
}
|
|
140
|
+
function ee(n, t, e) {
|
|
141
|
+
if (!Number.isFinite(n) || !Number.isFinite(t)) return [];
|
|
142
|
+
if (n === t) return [St(n)];
|
|
143
|
+
const [i, s] = n < t ? [n, t] : [t, n], r = pt(s - i, e), o = Dt(r), a = r * 1e-9, l = Math.ceil((i - a) / r), c = Math.floor((s + a) / r);
|
|
144
|
+
if (!Number.isFinite(l) || !Number.isFinite(c)) return [];
|
|
145
|
+
const u = [];
|
|
146
|
+
for (let h = l; h <= c; h++)
|
|
147
|
+
u.push(Mt(h * r, o));
|
|
148
|
+
return u;
|
|
149
|
+
}
|
|
150
|
+
class Vt {
|
|
151
|
+
constructor(t, e) {
|
|
152
|
+
g(this, "domain");
|
|
153
|
+
g(this, "range");
|
|
154
|
+
/** Pre-computed line equation px = v·m + b - the draw loop uses it directly. */
|
|
155
|
+
g(this, "m");
|
|
156
|
+
g(this, "b");
|
|
157
|
+
this.domain = t, this.range = e;
|
|
158
|
+
const i = t[1] - t[0];
|
|
159
|
+
i === 0 || !Number.isFinite(i) ? (this.m = 0, this.b = (e[0] + e[1]) / 2) : (this.m = (e[1] - e[0]) / i, this.b = e[0] - t[0] * this.m);
|
|
160
|
+
}
|
|
161
|
+
toPx(t) {
|
|
162
|
+
return t * this.m + this.b;
|
|
163
|
+
}
|
|
164
|
+
fromPx(t) {
|
|
165
|
+
return this.m === 0 ? this.domain[0] : (t - this.b) / this.m;
|
|
166
|
+
}
|
|
167
|
+
ticks(t) {
|
|
168
|
+
return ee(this.domain[0], this.domain[1], t);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
let at = null;
|
|
172
|
+
function ne() {
|
|
173
|
+
if (at !== null) return at;
|
|
174
|
+
const n = typeof navigator > "u" ? void 0 : navigator.language;
|
|
175
|
+
return at = typeof n == "string" && n !== "" ? n : "en-US", at;
|
|
176
|
+
}
|
|
177
|
+
const dt = /* @__PURE__ */ new Map();
|
|
178
|
+
function Ae(n) {
|
|
179
|
+
const t = ne(), e = `${t}|${n}`;
|
|
180
|
+
let i = dt.get(e);
|
|
181
|
+
return i === void 0 && (i = new Intl.NumberFormat(t, {
|
|
182
|
+
minimumFractionDigits: n,
|
|
183
|
+
maximumFractionDigits: n,
|
|
184
|
+
useGrouping: !0
|
|
185
|
+
}), dt.set(e, i)), i;
|
|
186
|
+
}
|
|
187
|
+
function Le(n, t) {
|
|
188
|
+
return Ae(Math.min(6, Dt(t))).format(n);
|
|
189
|
+
}
|
|
190
|
+
function _t(n) {
|
|
191
|
+
if (!Number.isFinite(n)) return "–";
|
|
192
|
+
const t = ne(), e = `${t}|value`;
|
|
193
|
+
let i = dt.get(e);
|
|
194
|
+
return i === void 0 && (i = new Intl.NumberFormat(t, { maximumFractionDigits: 3, useGrouping: !0 }), dt.set(e, i)), i.format(n);
|
|
195
|
+
}
|
|
196
|
+
const K = 1e3, U = 60 * K, Q = 60 * U, X = 24 * Q;
|
|
197
|
+
function Fe(n) {
|
|
198
|
+
const t = n.filter((r) => Number.isFinite(r.from) && Number.isFinite(r.to) && r.to > r.from).sort((r, o) => r.from - o.from), e = [];
|
|
199
|
+
for (const r of t) {
|
|
200
|
+
const o = e[e.length - 1];
|
|
201
|
+
o !== void 0 && r.from <= o.to ? r.to > o.to && (e[e.length - 1] = { from: o.from, to: r.to }) : e.push({ from: r.from, to: r.to });
|
|
202
|
+
}
|
|
203
|
+
const i = [];
|
|
204
|
+
let s = 0;
|
|
205
|
+
for (const r of e)
|
|
206
|
+
i.push(s), s += r.to - r.from;
|
|
207
|
+
return { intervals: e, offsets: i, total: s };
|
|
208
|
+
}
|
|
209
|
+
const Bt = /* @__PURE__ */ new WeakMap();
|
|
210
|
+
function G(n) {
|
|
211
|
+
if (!Array.isArray(n)) return n;
|
|
212
|
+
const t = n, e = Bt.get(t);
|
|
213
|
+
if (e !== void 0) return e;
|
|
214
|
+
const i = Fe(t);
|
|
215
|
+
return Bt.set(t, i), i;
|
|
216
|
+
}
|
|
217
|
+
function Pe(n, t) {
|
|
218
|
+
const e = n.intervals;
|
|
219
|
+
let i = 0, s = e.length - 1, r = -1;
|
|
220
|
+
for (; i <= s; ) {
|
|
221
|
+
const o = i + s >> 1;
|
|
222
|
+
e[o].from <= t ? (r = o, i = o + 1) : s = o - 1;
|
|
223
|
+
}
|
|
224
|
+
return r < 0 ? -1 : t <= e[r].to ? r : -1;
|
|
225
|
+
}
|
|
226
|
+
function yt(n, t) {
|
|
227
|
+
const e = G(t);
|
|
228
|
+
if (e.intervals.length === 0) return n;
|
|
229
|
+
const i = Pe(e, n);
|
|
230
|
+
return i < 0 ? Number.NaN : e.offsets[i] + (n - e.intervals[i].from);
|
|
231
|
+
}
|
|
232
|
+
function ft(n, t) {
|
|
233
|
+
const e = G(t), i = e.intervals;
|
|
234
|
+
if (i.length === 0) return n;
|
|
235
|
+
if (!(n >= 0) || n > e.total) return Number.NaN;
|
|
236
|
+
if (n === e.total)
|
|
237
|
+
return i[i.length - 1].to;
|
|
238
|
+
let s = 0, r = i.length - 1, o = 0;
|
|
239
|
+
for (; s <= r; ) {
|
|
240
|
+
const a = s + r >> 1;
|
|
241
|
+
e.offsets[a] <= n ? (o = a, s = a + 1) : r = a - 1;
|
|
242
|
+
}
|
|
243
|
+
return i[o].from + (n - e.offsets[o]);
|
|
244
|
+
}
|
|
245
|
+
function Un(n, t, e, i) {
|
|
246
|
+
const s = G(n);
|
|
247
|
+
for (let r = 0; r < e; r++)
|
|
248
|
+
i[r] = yt(t[r], s);
|
|
249
|
+
}
|
|
250
|
+
function Ee(n, t) {
|
|
251
|
+
const e = G(t);
|
|
252
|
+
if (e.intervals.length === 0) return n;
|
|
253
|
+
const i = yt(n, e);
|
|
254
|
+
if (!Number.isNaN(i)) return i;
|
|
255
|
+
if (!Number.isFinite(n)) return Number.NaN;
|
|
256
|
+
for (let s = 0; s < e.intervals.length; s++) {
|
|
257
|
+
const r = e.intervals[s];
|
|
258
|
+
if (n < r.from) return e.offsets[s];
|
|
259
|
+
}
|
|
260
|
+
return e.total;
|
|
261
|
+
}
|
|
262
|
+
function De(n, t) {
|
|
263
|
+
const e = G(t);
|
|
264
|
+
return e.intervals.length === 0 ? !1 : Number.isNaN(yt(n, e));
|
|
265
|
+
}
|
|
266
|
+
function $e(n) {
|
|
267
|
+
const t = G(n), e = [];
|
|
268
|
+
for (let i = 1; i < t.intervals.length; i++)
|
|
269
|
+
e.push({
|
|
270
|
+
from: t.intervals[i - 1].to,
|
|
271
|
+
to: t.intervals[i].from,
|
|
272
|
+
operatingTime: t.offsets[i]
|
|
273
|
+
});
|
|
274
|
+
return e;
|
|
275
|
+
}
|
|
276
|
+
function Ce(n, t, e) {
|
|
277
|
+
return $e(n).map((i) => i.operatingTime).filter((i) => i >= t && i <= e);
|
|
278
|
+
}
|
|
279
|
+
const Yt = [
|
|
280
|
+
K,
|
|
281
|
+
2 * K,
|
|
282
|
+
5 * K,
|
|
283
|
+
10 * K,
|
|
284
|
+
15 * K,
|
|
285
|
+
30 * K,
|
|
286
|
+
U,
|
|
287
|
+
2 * U,
|
|
288
|
+
5 * U,
|
|
289
|
+
10 * U,
|
|
290
|
+
15 * U,
|
|
291
|
+
30 * U,
|
|
292
|
+
Q,
|
|
293
|
+
2 * Q,
|
|
294
|
+
3 * Q,
|
|
295
|
+
6 * Q,
|
|
296
|
+
12 * Q,
|
|
297
|
+
X,
|
|
298
|
+
2 * X,
|
|
299
|
+
7 * X,
|
|
300
|
+
14 * X,
|
|
301
|
+
28 * X
|
|
302
|
+
];
|
|
303
|
+
function We(n, t) {
|
|
304
|
+
const e = Yt[0];
|
|
305
|
+
if (!Number.isFinite(n) || n <= 0) return e;
|
|
306
|
+
const i = n / Math.max(1, Math.floor(t));
|
|
307
|
+
for (const s of Yt) if (s >= i) return s;
|
|
308
|
+
return X * pt(i / X, 1);
|
|
309
|
+
}
|
|
310
|
+
function Oe(n, t, e, i, s = 0) {
|
|
311
|
+
const r = G(n), o = [];
|
|
312
|
+
if (!Number.isFinite(t) || !Number.isFinite(e) || !(i > 0)) return o;
|
|
313
|
+
const a = Math.ceil((t - s) / i), l = Math.floor((e - s) / i);
|
|
314
|
+
if (!Number.isFinite(a) || !Number.isFinite(l)) return o;
|
|
315
|
+
let c = Number.NaN;
|
|
316
|
+
for (let u = a; u <= l; u++) {
|
|
317
|
+
const h = s + u * i, p = yt(h, r);
|
|
318
|
+
Number.isNaN(p) || p === c || (o.push({ wallClock: h, operatingTime: p }), c = p);
|
|
319
|
+
}
|
|
320
|
+
return o;
|
|
321
|
+
}
|
|
322
|
+
function He(n, t, e, i, s = 0) {
|
|
323
|
+
const r = G(n);
|
|
324
|
+
if (r.intervals.length === 0 || !(e > t)) return [];
|
|
325
|
+
const o = Math.max(0, Math.min(r.total, t)), a = Math.max(0, Math.min(r.total, e)), l = We(e - t, i);
|
|
326
|
+
return Oe(
|
|
327
|
+
r,
|
|
328
|
+
ft(o, r),
|
|
329
|
+
ft(a, r),
|
|
330
|
+
l,
|
|
331
|
+
s
|
|
332
|
+
).map((u) => u.operatingTime).filter((u) => u >= t && u <= e);
|
|
333
|
+
}
|
|
334
|
+
const Tt = 5, At = 4, xt = 8, zt = 4, Re = 8, ht = "kc-tick-label", lt = "kc-axis-title", ie = {
|
|
335
|
+
width: 0,
|
|
336
|
+
height: 0,
|
|
337
|
+
plot: { x: 0, y: 0, width: 0, height: 0 },
|
|
338
|
+
axes: []
|
|
339
|
+
};
|
|
340
|
+
function Gt(n, t, e) {
|
|
341
|
+
const i = Math.ceil(t), s = e.get(n);
|
|
342
|
+
return s === void 0 || i > s || s - i >= Re ? (e.set(n, i), i) : s;
|
|
343
|
+
}
|
|
344
|
+
function qt(n, t) {
|
|
345
|
+
const e = n.domainMode;
|
|
346
|
+
if (Array.isArray(e)) {
|
|
347
|
+
const r = e;
|
|
348
|
+
return r[0] === r[1] ? [r[0] - 1, r[1] + 1] : r;
|
|
349
|
+
}
|
|
350
|
+
const [i, s] = n.extent;
|
|
351
|
+
return n.calendar !== void 0 && n.calendar.length > 0 || e === "data" ? Rt(i, s) : Te(i, s, t);
|
|
352
|
+
}
|
|
353
|
+
function Ve(n) {
|
|
354
|
+
if (!Number.isFinite(n)) return "";
|
|
355
|
+
const t = new Date(n), e = (i) => String(i).padStart(2, "0");
|
|
356
|
+
return `${e(t.getDate())}.${e(t.getMonth() + 1)}. ${e(t.getHours())}:${e(t.getMinutes())}`;
|
|
357
|
+
}
|
|
358
|
+
function Kt(n, t, e) {
|
|
359
|
+
if (n.tickValues !== void 0)
|
|
360
|
+
return n.tickValues.filter((s) => s >= t[0] && s <= t[1]);
|
|
361
|
+
const i = n.calendar;
|
|
362
|
+
return i !== void 0 && i.length > 0 ? He(i, t[0], t[1], e) : ee(t[0], t[1], e);
|
|
363
|
+
}
|
|
364
|
+
function Ut(n, t, e) {
|
|
365
|
+
const i = n.calendar;
|
|
366
|
+
if (i !== void 0 && i.length > 0) {
|
|
367
|
+
const r = n.tickFormat;
|
|
368
|
+
return r === void 0 ? (o) => Ve(ft(o, i)) : (o) => r(ft(o, i));
|
|
369
|
+
}
|
|
370
|
+
if (n.tickFormat !== void 0) return n.tickFormat;
|
|
371
|
+
const s = pt(Math.abs(t[1] - t[0]), e);
|
|
372
|
+
return (r) => Le(r, s);
|
|
373
|
+
}
|
|
374
|
+
function _e(n) {
|
|
375
|
+
const { width: t, height: e, padding: i, axes: s, measure: r, hysteresis: o } = n, a = s.filter((v) => v.position === "left"), l = s.filter((v) => v.position === "right"), c = s.filter((v) => v.position === "top"), u = s.filter((v) => v.position === "bottom"), h = Math.ceil(r("0", ht).height) || 14, p = /* @__PURE__ */ new Map();
|
|
376
|
+
for (const v of [...c, ...u]) {
|
|
377
|
+
const M = v.label === void 0 || v.label === "" ? 0 : Math.ceil(r(v.label, lt).height) + zt;
|
|
378
|
+
p.set(v.key, Gt(v.key, Tt + At + h + M, o));
|
|
379
|
+
}
|
|
380
|
+
const d = (v, M) => {
|
|
381
|
+
let x = 0;
|
|
382
|
+
for (let A = 0; A < v.length; A++) {
|
|
383
|
+
const $ = v[A];
|
|
384
|
+
$ !== void 0 && (x += M.get($.key) ?? 0, A > 0 && (x += xt));
|
|
385
|
+
}
|
|
386
|
+
return x;
|
|
387
|
+
}, m = i.top + d(c, p), y = e - i.bottom - d(u, p), f = Math.max(0, y - m), b = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map();
|
|
388
|
+
for (const v of [...a, ...l]) {
|
|
389
|
+
const M = v.tickCount ?? Math.max(2, Math.round(f / 50)), x = qt(v, M), A = Kt(v, x, M), $ = Ut(v, x, M), T = A.map($), O = T.map((V) => r(V, ht).width);
|
|
390
|
+
let C = 0;
|
|
391
|
+
for (const V of O) V > C && (C = V);
|
|
392
|
+
const et = v.label === void 0 || v.label === "" ? 0 : Math.ceil(r(v.label, lt).height) + zt;
|
|
393
|
+
b.set(v.key, { axis: v, domain: x, values: A, labels: T, widths: O, format: $ }), k.set(
|
|
394
|
+
v.key,
|
|
395
|
+
Gt(v.key, Tt + At + C + et, o)
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
const N = i.left + d(a, k), w = t - i.right - d(l, k), L = Math.max(0, w - N), F = { x: N, y: m, width: L, height: f }, P = (v, M, x, A) => {
|
|
399
|
+
switch (v.position) {
|
|
400
|
+
case "left":
|
|
401
|
+
return { x: N - x - A, y: m, width: A, height: f };
|
|
402
|
+
case "right":
|
|
403
|
+
return { x: w + x, y: m, width: A, height: f };
|
|
404
|
+
case "top":
|
|
405
|
+
return { x: N, y: m - x - A, width: L, height: A };
|
|
406
|
+
default:
|
|
407
|
+
return { x: N, y: y + x, width: L, height: A };
|
|
408
|
+
}
|
|
409
|
+
}, S = [], H = (v) => {
|
|
410
|
+
let M = 0;
|
|
411
|
+
v.forEach((x, A) => {
|
|
412
|
+
const $ = k.get(x.key) ?? 0, T = b.get(x.key), O = P(x, A, M, $);
|
|
413
|
+
M += $ + xt;
|
|
414
|
+
const C = (T == null ? void 0 : T.domain) ?? [0, 1], et = (T == null ? void 0 : T.format) ?? ((j) => String(j)), V = new Vt(C, [m + f, m]), nt = ((T == null ? void 0 : T.values) ?? []).map((j, Y) => ({
|
|
415
|
+
value: j,
|
|
416
|
+
label: (T == null ? void 0 : T.labels[Y]) ?? "",
|
|
417
|
+
px: V.toPx(j),
|
|
418
|
+
labelLeft: 0,
|
|
419
|
+
labelWidth: (T == null ? void 0 : T.widths[Y]) ?? 0
|
|
420
|
+
}));
|
|
421
|
+
S.push({
|
|
422
|
+
key: x.key,
|
|
423
|
+
id: x.id,
|
|
424
|
+
orientation: "y",
|
|
425
|
+
position: x.position,
|
|
426
|
+
label: x.label,
|
|
427
|
+
grid: x.grid,
|
|
428
|
+
band: O,
|
|
429
|
+
size: $,
|
|
430
|
+
stack: A,
|
|
431
|
+
domain: C,
|
|
432
|
+
scale: V,
|
|
433
|
+
ticks: nt,
|
|
434
|
+
format: et,
|
|
435
|
+
titleSize: x.label === void 0 || x.label === "" ? 0 : Math.ceil(r(x.label, lt).height),
|
|
436
|
+
breaks: []
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
};
|
|
440
|
+
H(a), H(l);
|
|
441
|
+
const R = (v) => {
|
|
442
|
+
let M = 0;
|
|
443
|
+
v.forEach((x, A) => {
|
|
444
|
+
const $ = p.get(x.key) ?? 0, T = P(x, A, M, $);
|
|
445
|
+
M += $ + xt;
|
|
446
|
+
const O = x.tickCount ?? Math.max(2, Math.round(L / 80)), C = qt(x, O), et = Kt(x, C, O), V = Ut(x, C, O), nt = new Vt(C, [N, N + L]), j = et.map((Y) => {
|
|
447
|
+
const Ct = V(Y), gt = r(Ct, ht).width, Wt = nt.toPx(Y), he = Wt - gt / 2, de = Math.min(Math.max(he, 0), Math.max(0, t - gt));
|
|
448
|
+
return { value: Y, label: Ct, px: Wt, labelLeft: de, labelWidth: gt };
|
|
449
|
+
});
|
|
450
|
+
S.push({
|
|
451
|
+
key: x.key,
|
|
452
|
+
id: x.id,
|
|
453
|
+
orientation: "x",
|
|
454
|
+
position: x.position,
|
|
455
|
+
label: x.label,
|
|
456
|
+
grid: x.grid,
|
|
457
|
+
band: T,
|
|
458
|
+
size: $,
|
|
459
|
+
stack: A,
|
|
460
|
+
domain: C,
|
|
461
|
+
scale: nt,
|
|
462
|
+
ticks: j,
|
|
463
|
+
format: V,
|
|
464
|
+
titleSize: x.label === void 0 || x.label === "" ? 0 : Math.ceil(r(x.label, lt).height),
|
|
465
|
+
breaks: x.calendar === void 0 || x.calendar.length === 0 ? [] : Ce(x.calendar, C[0], C[1]).map((Y) => nt.toPx(Y))
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
};
|
|
469
|
+
return R(c), R(u), { width: t, height: e, plot: F, axes: S };
|
|
470
|
+
}
|
|
471
|
+
function Be(n, t, e) {
|
|
472
|
+
if (t <= 0 || !(e >= n[0])) return -1;
|
|
473
|
+
let i = 0, s = t - 1;
|
|
474
|
+
if (n[s] <= e) return s;
|
|
475
|
+
for (; s - i > 1; ) {
|
|
476
|
+
const r = i + s >> 1;
|
|
477
|
+
n[r] <= e ? i = r : s = r;
|
|
478
|
+
}
|
|
479
|
+
return i;
|
|
480
|
+
}
|
|
481
|
+
function se(n, t, e, i) {
|
|
482
|
+
return e + 1 < t ? n[e + 1] : i;
|
|
483
|
+
}
|
|
484
|
+
function rt(n, t) {
|
|
485
|
+
return Number.isFinite(n) ? n : t;
|
|
486
|
+
}
|
|
487
|
+
function re(n) {
|
|
488
|
+
return !Number.isFinite(n);
|
|
489
|
+
}
|
|
490
|
+
function Xt(n, t) {
|
|
491
|
+
return n < t;
|
|
492
|
+
}
|
|
493
|
+
function Ye(n, t, e, i) {
|
|
494
|
+
const s = new Int32Array(e);
|
|
495
|
+
for (let r = 0; r < e; r++) {
|
|
496
|
+
const o = n[r], a = rt(t[r], i);
|
|
497
|
+
if (!Xt(o, a)) continue;
|
|
498
|
+
let l = 0;
|
|
499
|
+
for (let c = 0; c < r; c++) {
|
|
500
|
+
const u = n[c], h = rt(t[c], i);
|
|
501
|
+
Xt(u, h) && o < h && u < a && l++;
|
|
502
|
+
}
|
|
503
|
+
s[r] = l;
|
|
504
|
+
}
|
|
505
|
+
return s;
|
|
506
|
+
}
|
|
507
|
+
function ze(n, t, e, i, s, r, o, a) {
|
|
508
|
+
const l = o / 2;
|
|
509
|
+
for (let c = i - 1; c >= 0; c--) {
|
|
510
|
+
const u = e[c];
|
|
511
|
+
if (!(Math.abs(u - r) <= l)) continue;
|
|
512
|
+
const h = n[c], p = rt(t[c], a);
|
|
513
|
+
if (s >= h && s < p) return c;
|
|
514
|
+
}
|
|
515
|
+
return -1;
|
|
516
|
+
}
|
|
517
|
+
function ot(n) {
|
|
518
|
+
return Math.round(n) + 0.5;
|
|
519
|
+
}
|
|
520
|
+
function Ge(n, t) {
|
|
521
|
+
const { plot: e, axes: i, theme: s } = t, r = e.x, o = e.x + e.width, a = e.y, l = e.y + e.height;
|
|
522
|
+
n.lineWidth = 1;
|
|
523
|
+
for (const c of i)
|
|
524
|
+
if (c.grid)
|
|
525
|
+
for (const u of [0, 1]) {
|
|
526
|
+
const h = u === 1;
|
|
527
|
+
n.beginPath();
|
|
528
|
+
let p = !1;
|
|
529
|
+
for (const d of c.ticks)
|
|
530
|
+
if ((c.orientation === "y" && d.value === 0) === h)
|
|
531
|
+
if (p = !0, c.orientation === "y") {
|
|
532
|
+
const y = ot(d.px);
|
|
533
|
+
n.moveTo(r, y), n.lineTo(o, y);
|
|
534
|
+
} else {
|
|
535
|
+
const y = ot(d.px);
|
|
536
|
+
n.moveTo(y, a), n.lineTo(y, l);
|
|
537
|
+
}
|
|
538
|
+
p && (n.strokeStyle = h ? s.colorAxis : s.colorGrid, n.stroke());
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
function qe(n, t) {
|
|
542
|
+
const e = t.length, i = t.xScale.m, s = t.xScale.b, r = t.yScale.m, o = t.yScale.b, a = t.x, l = t.y, c = new Path2D();
|
|
543
|
+
let u = !1;
|
|
544
|
+
for (let h = 0; h < e; h++) {
|
|
545
|
+
const p = l[h];
|
|
546
|
+
if (Number.isNaN(p)) {
|
|
547
|
+
u = !1;
|
|
548
|
+
continue;
|
|
549
|
+
}
|
|
550
|
+
const d = a[h] * i + s, m = p * r + o;
|
|
551
|
+
u ? c.lineTo(d, m) : (c.moveTo(d, m), u = !0);
|
|
552
|
+
}
|
|
553
|
+
if (n.strokeStyle = t.color, n.lineWidth = t.strokeWidth, t.dash !== void 0 && t.dash.length > 0 ? n.setLineDash(t.dash) : n.setLineDash([]), n.stroke(c), n.setLineDash([]), t.marker) {
|
|
554
|
+
const h = t.strokeWidth + 1.5, p = new Path2D();
|
|
555
|
+
for (let d = 0; d < e; d++) {
|
|
556
|
+
const m = l[d];
|
|
557
|
+
if (Number.isNaN(m)) continue;
|
|
558
|
+
const y = a[d] * i + s, f = m * r + o;
|
|
559
|
+
p.moveTo(y + h, f), p.arc(y, f, h, 0, Math.PI * 2);
|
|
560
|
+
}
|
|
561
|
+
n.fillStyle = t.color, n.fill(p);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
function Ke(n, t) {
|
|
565
|
+
const e = t.length, i = t.xScale.m, s = t.xScale.b, r = t.yScale.m, o = t.yScale.b, a = t.x, l = t.y, c = t.y0, u = t.baseline * r + o, h = new Path2D(), p = new Path2D();
|
|
566
|
+
let d = 0;
|
|
567
|
+
for (; d < e; ) {
|
|
568
|
+
for (; d < e && (Number.isNaN(l[d]) || c !== null && Number.isNaN(c[d])); )
|
|
569
|
+
d++;
|
|
570
|
+
if (d >= e) break;
|
|
571
|
+
const m = d;
|
|
572
|
+
for (; d < e && !Number.isNaN(l[d]) && (c === null || !Number.isNaN(c[d])); )
|
|
573
|
+
d++;
|
|
574
|
+
const y = d - 1;
|
|
575
|
+
for (let f = m; f <= y; f++) {
|
|
576
|
+
const b = a[f] * i + s, k = l[f] * r + o;
|
|
577
|
+
f === m ? (h.moveTo(b, k), p.moveTo(b, k)) : (h.lineTo(b, k), p.lineTo(b, k));
|
|
578
|
+
}
|
|
579
|
+
if (c === null)
|
|
580
|
+
h.lineTo(a[y] * i + s, u), h.lineTo(a[m] * i + s, u);
|
|
581
|
+
else
|
|
582
|
+
for (let f = y; f >= m; f--)
|
|
583
|
+
h.lineTo(a[f] * i + s, c[f] * r + o);
|
|
584
|
+
h.closePath();
|
|
585
|
+
}
|
|
586
|
+
n.globalAlpha = t.alpha * t.fillOpacity, n.fillStyle = t.color, n.fill(h), t.strokeWidth > 0 && (n.globalAlpha = t.alpha, n.strokeStyle = t.color, n.lineWidth = t.strokeWidth, n.setLineDash([]), n.stroke(p));
|
|
587
|
+
}
|
|
588
|
+
function Ue(n, t) {
|
|
589
|
+
const e = t.length, i = t.xScale.m, s = t.xScale.b, r = t.yScale.m, o = t.yScale.b, a = t.x, l = t.y, c = t.baseline * r + o, u = t.offset * i, h = t.width * i, p = new Path2D();
|
|
590
|
+
for (let d = 0; d < e; d++) {
|
|
591
|
+
const m = l[d];
|
|
592
|
+
if (Number.isNaN(m)) continue;
|
|
593
|
+
const y = a[d] * i + s + u, f = m * r + o;
|
|
594
|
+
p.rect(y, f, h, c - f);
|
|
595
|
+
}
|
|
596
|
+
n.fillStyle = t.color, n.fill(p);
|
|
597
|
+
}
|
|
598
|
+
function Xe(n, t) {
|
|
599
|
+
const e = t.length, i = t.xScale.m, s = t.xScale.b, r = t.yScale.m, o = t.yScale.b, a = t.x, l = t.y, c = t.radius, u = new Path2D();
|
|
600
|
+
for (let h = 0; h < e; h++) {
|
|
601
|
+
const p = l[h];
|
|
602
|
+
if (Number.isNaN(p)) continue;
|
|
603
|
+
const d = a[h] * i + s, m = p * r + o;
|
|
604
|
+
u.moveTo(d + c, m), u.arc(d, m, c, 0, Math.PI * 2);
|
|
605
|
+
}
|
|
606
|
+
n.fillStyle = t.color, n.fill(u);
|
|
607
|
+
}
|
|
608
|
+
function Ze(n, t) {
|
|
609
|
+
const e = t.length, i = t.xScale.m, s = t.xScale.b, r = t.x, o = t.y, a = t.laneTop, l = t.laneBottom - t.laneTop, c = t.colors.length;
|
|
610
|
+
if (c === 0 || l <= 0) return;
|
|
611
|
+
const u = [];
|
|
612
|
+
for (let p = 0; p < c; p++) u.push(new Path2D());
|
|
613
|
+
let h = !1;
|
|
614
|
+
for (let p = 0; p < e; p++) {
|
|
615
|
+
const d = o[p];
|
|
616
|
+
if (Number.isNaN(d)) continue;
|
|
617
|
+
const m = d | 0, y = u[m];
|
|
618
|
+
if (y === void 0) continue;
|
|
619
|
+
const f = r[p], b = se(r, e, p, t.domainEnd);
|
|
620
|
+
b > f && (y.rect(f * i + s, a, (b - f) * i, l), h = !0);
|
|
621
|
+
}
|
|
622
|
+
if (h)
|
|
623
|
+
for (let p = 0; p < c; p++)
|
|
624
|
+
n.fillStyle = t.colors[p], n.fill(u[p]);
|
|
625
|
+
}
|
|
626
|
+
function Je(n, t) {
|
|
627
|
+
const e = t.length, i = t.xScale.m, s = t.xScale.b, r = t.yScale.m, o = t.yScale.b, a = t.x, l = t.y, c = t.buckets, u = t.colors.length;
|
|
628
|
+
if (u === 0) return;
|
|
629
|
+
const h = t.width * i, p = Math.abs(t.height * r), d = [];
|
|
630
|
+
for (let m = 0; m < u; m++) d.push(new Path2D());
|
|
631
|
+
for (let m = 0; m < e; m++) {
|
|
632
|
+
const y = c[m];
|
|
633
|
+
if (y < 0) continue;
|
|
634
|
+
const f = d[y];
|
|
635
|
+
if (f === void 0) continue;
|
|
636
|
+
const b = a[m] * i + s - h / 2, k = l[m] * r + o - p / 2;
|
|
637
|
+
f.rect(b, k, h, p);
|
|
638
|
+
}
|
|
639
|
+
for (let m = 0; m < u; m++)
|
|
640
|
+
n.fillStyle = t.colors[m], n.fill(d[m]);
|
|
641
|
+
}
|
|
642
|
+
function je(n, t) {
|
|
643
|
+
const e = t.length, i = t.xScale.m, s = t.xScale.b, r = t.yScale.m, o = t.yScale.b, a = t.x, l = t.y, c = t.x1, u = t.depth, h = Math.abs(t.height * r), p = h * 0.28, d = new Path2D(), m = new Path2D();
|
|
644
|
+
for (let y = 0; y < e; y++) {
|
|
645
|
+
const f = l[y];
|
|
646
|
+
if (Number.isNaN(f)) continue;
|
|
647
|
+
const b = a[y];
|
|
648
|
+
if (Number.isNaN(b)) continue;
|
|
649
|
+
const k = c[y], N = rt(k, t.domainEnd);
|
|
650
|
+
if (!(N >= b)) continue;
|
|
651
|
+
const w = b * i + s, L = Math.max(1, (N - b) * i), F = f * r + o + u[y] * p;
|
|
652
|
+
(re(k) ? m : d).rect(w, F - h / 2, L, h);
|
|
653
|
+
}
|
|
654
|
+
n.fillStyle = t.color, n.fill(d), n.save(), n.globalAlpha = n.globalAlpha * 0.45, n.fill(m), n.restore(), n.strokeStyle = t.color, n.lineWidth = 1, n.setLineDash([3, 2]), n.stroke(m), n.setLineDash([]);
|
|
655
|
+
}
|
|
656
|
+
function Zt(n, t, e) {
|
|
657
|
+
for (const i of e) {
|
|
658
|
+
if (i.band) {
|
|
659
|
+
const s = Math.min(i.fromPx, i.toPx), r = Math.max(i.fromPx, i.toPx);
|
|
660
|
+
n.fillStyle = i.color, n.save(), n.globalAlpha = 0.12, i.orientation === "y" ? n.fillRect(t.x, s, t.width, r - s) : n.fillRect(s, t.y, r - s, t.height), n.restore();
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
if (n.beginPath(), i.orientation === "y") {
|
|
664
|
+
const s = ot(i.fromPx);
|
|
665
|
+
n.moveTo(t.x, s), n.lineTo(t.x + t.width, s);
|
|
666
|
+
} else {
|
|
667
|
+
const s = ot(i.fromPx);
|
|
668
|
+
n.moveTo(s, t.y), n.lineTo(s, t.y + t.height);
|
|
669
|
+
}
|
|
670
|
+
n.strokeStyle = i.color, n.lineWidth = 1, n.setLineDash(i.dash), n.stroke(), n.setLineDash([]);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
function Qe(n, t) {
|
|
674
|
+
const { width: e, height: i, plot: s, series: r } = t;
|
|
675
|
+
if (n.clearRect(0, 0, e, i), !(s.width <= 0 || s.height <= 0)) {
|
|
676
|
+
Ge(n, t), n.save(), n.beginPath(), n.rect(s.x, s.y, s.width, s.height), n.clip(), n.lineJoin = "round", n.lineCap = "round", n.globalAlpha = 1, Zt(n, s, t.limitBands);
|
|
677
|
+
for (const o of r)
|
|
678
|
+
if (o.length !== 0)
|
|
679
|
+
switch (n.globalAlpha = o.alpha, o.kind) {
|
|
680
|
+
case "line":
|
|
681
|
+
qe(n, o);
|
|
682
|
+
break;
|
|
683
|
+
case "area":
|
|
684
|
+
Ke(n, o);
|
|
685
|
+
break;
|
|
686
|
+
case "bar":
|
|
687
|
+
Ue(n, o);
|
|
688
|
+
break;
|
|
689
|
+
case "scatter":
|
|
690
|
+
Xe(n, o);
|
|
691
|
+
break;
|
|
692
|
+
case "state":
|
|
693
|
+
Ze(n, o);
|
|
694
|
+
break;
|
|
695
|
+
case "matrix":
|
|
696
|
+
Je(n, o);
|
|
697
|
+
break;
|
|
698
|
+
case "span":
|
|
699
|
+
je(n, o);
|
|
700
|
+
break;
|
|
701
|
+
}
|
|
702
|
+
n.globalAlpha = 1, Zt(n, s, t.limitLines), n.restore();
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
function tn(n, t) {
|
|
706
|
+
const { width: e, height: i, plot: s, theme: r, hover: o } = t;
|
|
707
|
+
if (n.clearRect(0, 0, e, i), o === null || s.width <= 0 || s.height <= 0) return;
|
|
708
|
+
const a = ot(o.hit.xPx);
|
|
709
|
+
a >= s.x && a <= s.x + s.width && (n.beginPath(), n.moveTo(a, s.y), n.lineTo(a, s.y + s.height), n.lineWidth = 1, n.strokeStyle = r.colorAxis, n.setLineDash([]), n.stroke());
|
|
710
|
+
for (const l of o.marker)
|
|
711
|
+
n.beginPath(), n.arc(l.x, l.y, 5.5, 0, Math.PI * 2), n.fillStyle = r.colorBg, n.fill(), n.beginPath(), n.arc(l.x, l.y, 3.5, 0, Math.PI * 2), n.fillStyle = l.color, n.fill();
|
|
712
|
+
}
|
|
713
|
+
function en(n, t, e) {
|
|
714
|
+
if (t <= 0) return -1;
|
|
715
|
+
if (t === 1) return 0;
|
|
716
|
+
let i = 0, s = t - 1;
|
|
717
|
+
if (e <= n[i]) return i;
|
|
718
|
+
if (e >= n[s]) return s;
|
|
719
|
+
for (; s - i > 1; ) {
|
|
720
|
+
const a = i + s >> 1;
|
|
721
|
+
n[a] <= e ? i = a : s = a;
|
|
722
|
+
}
|
|
723
|
+
const r = e - n[i];
|
|
724
|
+
return n[s] - e < r ? s : i;
|
|
725
|
+
}
|
|
726
|
+
function Jt(n, t) {
|
|
727
|
+
if (t < 2) return 0;
|
|
728
|
+
const e = n.slice(0, t).sort();
|
|
729
|
+
let i = Number.POSITIVE_INFINITY;
|
|
730
|
+
for (let s = 1; s < t; s++) {
|
|
731
|
+
const r = e[s] - e[s - 1];
|
|
732
|
+
r > 0 && r < i && (i = r);
|
|
733
|
+
}
|
|
734
|
+
return Number.isFinite(i) ? i : 0;
|
|
735
|
+
}
|
|
736
|
+
function ct(n, t) {
|
|
737
|
+
return n > 0 ? n : t;
|
|
738
|
+
}
|
|
739
|
+
function nn(n, t, e, i, s, r, o) {
|
|
740
|
+
const a = r / 2, l = o / 2;
|
|
741
|
+
for (let c = 0; c < e; c++) {
|
|
742
|
+
const u = i - n[c];
|
|
743
|
+
if (!(u >= -a && u < a)) continue;
|
|
744
|
+
const h = s - t[c];
|
|
745
|
+
if (h >= -l && h < l)
|
|
746
|
+
return c;
|
|
747
|
+
}
|
|
748
|
+
return -1;
|
|
749
|
+
}
|
|
750
|
+
const sn = {
|
|
751
|
+
ok: 0,
|
|
752
|
+
unknown: 1,
|
|
753
|
+
warning: 2,
|
|
754
|
+
alarm: 3
|
|
755
|
+
};
|
|
756
|
+
function Xn(n) {
|
|
757
|
+
return sn[n];
|
|
758
|
+
}
|
|
759
|
+
const jt = { warning: 2, alarm: 3 };
|
|
760
|
+
function rn(n, t = {}) {
|
|
761
|
+
if (n == null || !Number.isFinite(n))
|
|
762
|
+
return { verdict: "unknown" };
|
|
763
|
+
const e = t.target, i = e !== void 0 && Number.isFinite(e) ? n - e : void 0;
|
|
764
|
+
let s, r = 0;
|
|
765
|
+
for (const a of t.limits ?? []) {
|
|
766
|
+
const l = a.side === "upper" ? n - a.value : a.value - n;
|
|
767
|
+
l > 0 && (s === void 0 || jt[a.severity] > jt[s.severity] || a.severity === s.severity && l > r) && (s = a, r = l);
|
|
768
|
+
}
|
|
769
|
+
if (s === void 0)
|
|
770
|
+
return i === void 0 ? { verdict: "ok" } : { verdict: "ok", deviation: i };
|
|
771
|
+
const o = {
|
|
772
|
+
verdict: s.severity,
|
|
773
|
+
limit: s,
|
|
774
|
+
excess: r
|
|
775
|
+
};
|
|
776
|
+
return i === void 0 ? o : { ...o, deviation: i };
|
|
777
|
+
}
|
|
778
|
+
function on(n, t, e, i, s) {
|
|
779
|
+
const r = n.length, o = new Float64Array(r), a = new Float64Array(r), l = typeof i == "function" ? i : null, c = l === null ? null : new Float64Array(r), u = (s == null ? void 0 : s.value) ?? null, h = u === null ? null : new Float64Array(r), p = (s == null ? void 0 : s.xEnd) ?? null, d = p === null ? null : new Float64Array(r), m = (s == null ? void 0 : s.xMap) ?? null, y = (s == null ? void 0 : s.xGap) ?? null;
|
|
780
|
+
let f = Number.POSITIVE_INFINITY, b = Number.NEGATIVE_INFINITY, k = Number.POSITIVE_INFINITY, N = Number.NEGATIVE_INFINITY;
|
|
781
|
+
typeof i == "number" && r > 0 && (k = i, N = i);
|
|
782
|
+
for (let w = 0; w < r; w++) {
|
|
783
|
+
const L = n[w], F = t(L, w), P = m === null ? F : m(F);
|
|
784
|
+
o[w] = P;
|
|
785
|
+
const S = y !== null && y(F);
|
|
786
|
+
if (S || (P < f && (f = P), P > b && (b = P)), p !== null) {
|
|
787
|
+
const v = p(L, w), M = v ?? Number.NaN, x = !Number.isFinite(M) || m === null ? M : m(M);
|
|
788
|
+
d[w] = x, Number.isFinite(x) && (x < f && (f = x), x > b && (b = x));
|
|
789
|
+
}
|
|
790
|
+
const H = S ? null : e(L, w), R = H ?? Number.NaN;
|
|
791
|
+
if (a[w] = R, R < k && (k = R), R > N && (N = R), u !== null) {
|
|
792
|
+
const v = S ? null : u(L, w);
|
|
793
|
+
h[w] = v ?? Number.NaN;
|
|
794
|
+
}
|
|
795
|
+
if (l !== null) {
|
|
796
|
+
const v = S ? null : l(L, w), M = v ?? Number.NaN;
|
|
797
|
+
c[w] = M, M < k && (k = M), M > N && (N = M);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
return { series: { x: o, y: a, y0: c, w: h, x1: d, length: r }, extent: { xMin: f, xMax: b, yMin: k, yMax: N } };
|
|
801
|
+
}
|
|
802
|
+
function an(n, t) {
|
|
803
|
+
for (let e = 1; e < t; e++)
|
|
804
|
+
if (n[e] < n[e - 1]) return e;
|
|
805
|
+
return -1;
|
|
806
|
+
}
|
|
807
|
+
function ln(n, t, e, i) {
|
|
808
|
+
let s = Number.POSITIVE_INFINITY, r = Number.NEGATIVE_INFINITY;
|
|
809
|
+
for (const o of e) {
|
|
810
|
+
const a = o.extent;
|
|
811
|
+
if (a === null || !(n === "x" ? o.xAxisId === t : o.yAxisId === t)) continue;
|
|
812
|
+
const c = n === "x" ? a.xMin : a.yMin, u = n === "x" ? a.xMax : a.yMax;
|
|
813
|
+
c < s && (s = c), u > r && (r = u);
|
|
814
|
+
}
|
|
815
|
+
if (i !== void 0)
|
|
816
|
+
for (const o of i)
|
|
817
|
+
Number.isFinite(o) && (o < s && (s = o), o > r && (r = o));
|
|
818
|
+
return !Number.isFinite(s) || !Number.isFinite(r) ? [0, 1] : [s, r];
|
|
819
|
+
}
|
|
820
|
+
function cn(n, t) {
|
|
821
|
+
let e = Number.POSITIVE_INFINITY;
|
|
822
|
+
for (let i = 1; i < t; i++) {
|
|
823
|
+
const s = n[i] - n[i - 1];
|
|
824
|
+
s > 0 && s < e && (e = s);
|
|
825
|
+
}
|
|
826
|
+
return Number.isFinite(e) ? e : 0;
|
|
827
|
+
}
|
|
828
|
+
function un(n, t) {
|
|
829
|
+
return n > 0 ? n : t;
|
|
830
|
+
}
|
|
831
|
+
function hn(n, t, e, i) {
|
|
832
|
+
const s = n * t, r = s / i;
|
|
833
|
+
return { offset: -s / 2 + e * r, width: r };
|
|
834
|
+
}
|
|
835
|
+
function dn(n) {
|
|
836
|
+
const t = /* @__PURE__ */ new Map();
|
|
837
|
+
for (const i of n) {
|
|
838
|
+
if (i.kind !== "bar") continue;
|
|
839
|
+
const s = t.get(i.xAxisId);
|
|
840
|
+
s === void 0 ? t.set(i.xAxisId, [i]) : s.push(i);
|
|
841
|
+
}
|
|
842
|
+
const e = /* @__PURE__ */ new Map();
|
|
843
|
+
for (const i of t.values()) {
|
|
844
|
+
let s = Number.POSITIVE_INFINITY;
|
|
845
|
+
for (const a of i)
|
|
846
|
+
a.step > 0 && a.step < s && (s = a.step);
|
|
847
|
+
const r = Number.isFinite(s) ? s : 0, o = i[0].fraction;
|
|
848
|
+
i.forEach((a, l) => {
|
|
849
|
+
e.set(a.order, {
|
|
850
|
+
index: l,
|
|
851
|
+
size: i.length,
|
|
852
|
+
step: r,
|
|
853
|
+
fraction: o
|
|
854
|
+
});
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
return e;
|
|
858
|
+
}
|
|
859
|
+
const Qt = {
|
|
860
|
+
version: 0,
|
|
861
|
+
layout: ie,
|
|
862
|
+
legend: null,
|
|
863
|
+
series: [],
|
|
864
|
+
limits: []
|
|
865
|
+
}, te = {
|
|
866
|
+
version: 0,
|
|
867
|
+
hover: null,
|
|
868
|
+
tooltip: null,
|
|
869
|
+
xLabel: ""
|
|
870
|
+
}, fn = 4, mn = 60;
|
|
871
|
+
let vt = 0;
|
|
872
|
+
const pn = new Float64Array(0), yn = new Int32Array(0);
|
|
873
|
+
function z(n, t) {
|
|
874
|
+
return n === t ? !0 : typeof n != "function" || typeof t != "function" ? !1 : String(n) === String(t);
|
|
875
|
+
}
|
|
876
|
+
function mt(n, t) {
|
|
877
|
+
if (n === t) return !0;
|
|
878
|
+
if (n === void 0 || t === void 0 || n.length !== t.length) return !1;
|
|
879
|
+
for (let e = 0; e < n.length; e++) if (n[e] !== t[e]) return !1;
|
|
880
|
+
return !0;
|
|
881
|
+
}
|
|
882
|
+
function gn(n, t) {
|
|
883
|
+
return n.kind === t.kind && z(n.accessor, t.accessor) && n.data === t.data && z(Pt(n), Pt(t)) && z(Lt(n), Lt(t)) && z(Ft(n), Ft(t));
|
|
884
|
+
}
|
|
885
|
+
function Lt(n) {
|
|
886
|
+
return n.kind === "matrix" ? n.value : void 0;
|
|
887
|
+
}
|
|
888
|
+
function Ft(n) {
|
|
889
|
+
return n.kind === "span" ? n.to : void 0;
|
|
890
|
+
}
|
|
891
|
+
function Pt(n) {
|
|
892
|
+
switch (n.kind) {
|
|
893
|
+
case "line":
|
|
894
|
+
case "scatter":
|
|
895
|
+
return;
|
|
896
|
+
case "area":
|
|
897
|
+
return n.baseline ?? 0;
|
|
898
|
+
case "bar":
|
|
899
|
+
return 0;
|
|
900
|
+
case "state":
|
|
901
|
+
case "matrix":
|
|
902
|
+
case "span":
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
function bn(n, t) {
|
|
907
|
+
if (n.kind !== t.kind) return !1;
|
|
908
|
+
switch (t.kind) {
|
|
909
|
+
case "line": {
|
|
910
|
+
const e = n;
|
|
911
|
+
return e.strokeWidth === t.strokeWidth && e.markers === t.markers && mt(e.dash, t.dash);
|
|
912
|
+
}
|
|
913
|
+
case "area": {
|
|
914
|
+
const e = n;
|
|
915
|
+
return z(e.baseline, t.baseline) && e.fillOpacity === t.fillOpacity && e.strokeWidth === t.strokeWidth;
|
|
916
|
+
}
|
|
917
|
+
case "bar":
|
|
918
|
+
return n.barWidth === t.barWidth;
|
|
919
|
+
case "scatter":
|
|
920
|
+
return n.radius === t.radius;
|
|
921
|
+
case "state": {
|
|
922
|
+
const e = n;
|
|
923
|
+
return e.laneFrom === t.laneFrom && e.laneTo === t.laneTo && xn(e.states, t.states);
|
|
924
|
+
}
|
|
925
|
+
case "matrix":
|
|
926
|
+
return vn(n.coloring, t.coloring);
|
|
927
|
+
case "span":
|
|
928
|
+
return n.height === t.height;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
function xn(n, t) {
|
|
932
|
+
var e, i, s, r;
|
|
933
|
+
if (n === t) return !0;
|
|
934
|
+
if (n.length !== t.length) return !1;
|
|
935
|
+
for (let o = 0; o < n.length; o++)
|
|
936
|
+
if (((e = n[o]) == null ? void 0 : e.label) !== ((i = t[o]) == null ? void 0 : i.label) || ((s = n[o]) == null ? void 0 : s.color) !== ((r = t[o]) == null ? void 0 : r.color)) return !1;
|
|
937
|
+
return !0;
|
|
938
|
+
}
|
|
939
|
+
function vn(n, t) {
|
|
940
|
+
return n === t ? !0 : n.kind !== t.kind ? !1 : n.kind === "assessment" && t.kind === "assessment" ? n.limits === t.limits : n.kind === "gradient" && t.kind === "gradient" ? mt(n.stops, t.stops) && mt(n.range, t.range) : !1;
|
|
941
|
+
}
|
|
942
|
+
function kn(n, t) {
|
|
943
|
+
return n.kind === "assessment" ? [t.colorOk, t.colorWarning, t.colorAlarm] : n.stops;
|
|
944
|
+
}
|
|
945
|
+
function Nn(n, t, e) {
|
|
946
|
+
var c, u;
|
|
947
|
+
const i = n.length, s = new Int32Array(i), r = n.w;
|
|
948
|
+
if (r === null || e === 0)
|
|
949
|
+
return s.fill(-1), s;
|
|
950
|
+
if (t.kind === "assessment") {
|
|
951
|
+
for (let h = 0; h < i; h++) {
|
|
952
|
+
const p = rn(r[h], t.limits);
|
|
953
|
+
s[h] = p.verdict === "alarm" ? 2 : p.verdict === "warning" ? 1 : p.verdict === "ok" ? 0 : -1;
|
|
954
|
+
}
|
|
955
|
+
return s;
|
|
956
|
+
}
|
|
957
|
+
let o = (c = t.range) == null ? void 0 : c[0], a = (u = t.range) == null ? void 0 : u[1];
|
|
958
|
+
if (o === void 0 || a === void 0) {
|
|
959
|
+
o = Number.POSITIVE_INFINITY, a = Number.NEGATIVE_INFINITY;
|
|
960
|
+
for (let h = 0; h < i; h++) {
|
|
961
|
+
const p = r[h];
|
|
962
|
+
Number.isFinite(p) && (p < o && (o = p), p > a && (a = p));
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
const l = a - o;
|
|
966
|
+
for (let h = 0; h < i; h++) {
|
|
967
|
+
const p = r[h];
|
|
968
|
+
if (!Number.isFinite(p)) {
|
|
969
|
+
s[h] = -1;
|
|
970
|
+
continue;
|
|
971
|
+
}
|
|
972
|
+
const d = l > 0 ? (p - o) / l : 0.5, m = Math.floor(d * e);
|
|
973
|
+
s[h] = m < 0 ? 0 : m >= e ? e - 1 : m;
|
|
974
|
+
}
|
|
975
|
+
return s;
|
|
976
|
+
}
|
|
977
|
+
function wn(n, t) {
|
|
978
|
+
return n === t ? !0 : Array.isArray(n) && Array.isArray(t) ? n[0] === t[0] && n[1] === t[1] : !1;
|
|
979
|
+
}
|
|
980
|
+
class oe {
|
|
981
|
+
constructor() {
|
|
982
|
+
/* ---------- Registration ---------- */
|
|
983
|
+
g(this, "series", /* @__PURE__ */ new Map());
|
|
984
|
+
g(this, "axes", /* @__PURE__ */ new Map());
|
|
985
|
+
g(this, "legend", null);
|
|
986
|
+
g(this, "tooltip", null);
|
|
987
|
+
g(this, "limits", /* @__PURE__ */ new Map());
|
|
988
|
+
/* ---------- Data and layout inputs ---------- */
|
|
989
|
+
g(this, "data", []);
|
|
990
|
+
g(this, "padding", { top: 8, right: 8, bottom: 8, left: 8 });
|
|
991
|
+
/* ---------- DOM binding ---------- */
|
|
992
|
+
g(this, "container", null);
|
|
993
|
+
g(this, "seriesCanvas", null);
|
|
994
|
+
g(this, "overlayCanvas", null);
|
|
995
|
+
g(this, "seriesCtx", null);
|
|
996
|
+
g(this, "overlayCtx", null);
|
|
997
|
+
g(this, "tooltipEl", null);
|
|
998
|
+
g(this, "measurer", null);
|
|
999
|
+
/* ---------- Size and DPR ---------- */
|
|
1000
|
+
g(this, "cssWidth", 0);
|
|
1001
|
+
g(this, "cssHeight", 0);
|
|
1002
|
+
g(this, "pendingWidth", null);
|
|
1003
|
+
g(this, "pendingHeight", null);
|
|
1004
|
+
g(this, "dpr", 1);
|
|
1005
|
+
g(this, "dprMedia", null);
|
|
1006
|
+
g(this, "onDprChange", () => {
|
|
1007
|
+
this.rebindDprWatch(), this.pendingWidth = this.cssWidth, this.pendingHeight = this.cssHeight, this.markLayoutDirty();
|
|
1008
|
+
});
|
|
1009
|
+
/* ---------- Scheduling ---------- */
|
|
1010
|
+
g(this, "seriesDirty", !1);
|
|
1011
|
+
g(this, "overlayDirty", !1);
|
|
1012
|
+
g(this, "layoutDirty", !0);
|
|
1013
|
+
g(this, "materialsDirty", !1);
|
|
1014
|
+
g(this, "frameHandle", null);
|
|
1015
|
+
/* ---------- Theme ---------- */
|
|
1016
|
+
g(this, "theme", null);
|
|
1017
|
+
g(this, "unsubscribeTheme", null);
|
|
1018
|
+
/* ---------- Layout and interaction ---------- */
|
|
1019
|
+
g(this, "layout", ie);
|
|
1020
|
+
g(this, "hysteresis", /* @__PURE__ */ new Map());
|
|
1021
|
+
g(this, "hover", null);
|
|
1022
|
+
g(this, "hoverKey", "");
|
|
1023
|
+
g(this, "hoverXLabel", "");
|
|
1024
|
+
g(this, "highlight", null);
|
|
1025
|
+
/* ---------- Snapshots for the HTML layer ---------- */
|
|
1026
|
+
g(this, "layoutSnapshot", Qt);
|
|
1027
|
+
g(this, "hoverSnapshot", te);
|
|
1028
|
+
g(this, "layoutSubscribers", /* @__PURE__ */ new Set());
|
|
1029
|
+
g(this, "hoverSubscribers", /* @__PURE__ */ new Set());
|
|
1030
|
+
/* ---------- Instrumentation (R-5.1) ---------- */
|
|
1031
|
+
g(this, "perf", { materializeMs: 0, seriesDrawMs: 0, points: 0 });
|
|
1032
|
+
/* The palette follows the name (library-audit 05). The table only grows: a name
|
|
1033
|
+
that goes away keeps its place, so that it finds it again on its return and
|
|
1034
|
+
no other name gets it in the meantime. */
|
|
1035
|
+
g(this, "slotsByName", /* @__PURE__ */ new Map());
|
|
1036
|
+
g(this, "nextSlot", 0);
|
|
1037
|
+
g(this, "onPerf", null);
|
|
1038
|
+
/* ================= Materialisation (R-2.6, R-2.7) ================= */
|
|
1039
|
+
g(this, "sortednessChecked", !1);
|
|
1040
|
+
g(this, "themeRoot", null);
|
|
1041
|
+
g(this, "subscribeLayout", (t) => (this.layoutSubscribers.add(t), () => {
|
|
1042
|
+
this.layoutSubscribers.delete(t);
|
|
1043
|
+
}));
|
|
1044
|
+
g(this, "getLayoutSnapshot", () => this.layoutSnapshot);
|
|
1045
|
+
g(this, "getLayoutServerSnapshot", () => Qt);
|
|
1046
|
+
g(this, "subscribeHover", (t) => (this.hoverSubscribers.add(t), () => {
|
|
1047
|
+
this.hoverSubscribers.delete(t);
|
|
1048
|
+
}));
|
|
1049
|
+
g(this, "getHoverSnapshot", () => this.hoverSnapshot);
|
|
1050
|
+
g(this, "getHoverServerSnapshot", () => te);
|
|
1051
|
+
}
|
|
1052
|
+
setOnPerf(t) {
|
|
1053
|
+
this.onPerf = t;
|
|
1054
|
+
}
|
|
1055
|
+
/* ================= Registration model (R-2.1, R-2.2) ================= */
|
|
1056
|
+
/** The palette place for a new registration. On the first mount, in JSX order,
|
|
1057
|
+
it is the same number as the index in the registration - every registration
|
|
1058
|
+
counts on, named or not. */
|
|
1059
|
+
slotFor(t) {
|
|
1060
|
+
if (t === void 0) return this.nextSlot++;
|
|
1061
|
+
const e = this.slotsByName.get(t);
|
|
1062
|
+
if (e !== void 0 && !this.slotTaken(e)) return e;
|
|
1063
|
+
const i = this.nextSlot++;
|
|
1064
|
+
return e === void 0 && this.slotsByName.set(t, i), i;
|
|
1065
|
+
}
|
|
1066
|
+
/** Is a named series currently standing on this palette place? A taken place is
|
|
1067
|
+
not assigned a second time: two series of the same name standing at once
|
|
1068
|
+
share no colour, and a name that a rename has left behind does not get the
|
|
1069
|
+
colour of the renamed series. */
|
|
1070
|
+
slotTaken(t, e) {
|
|
1071
|
+
for (const i of this.series.values())
|
|
1072
|
+
if (i !== e && i.config.name !== void 0 && i.slot === t) return !0;
|
|
1073
|
+
return !1;
|
|
1074
|
+
}
|
|
1075
|
+
registerSeries(t) {
|
|
1076
|
+
const e = vt++;
|
|
1077
|
+
return this.series.set(e, {
|
|
1078
|
+
order: e,
|
|
1079
|
+
config: t,
|
|
1080
|
+
slot: this.slotFor(t.name),
|
|
1081
|
+
lastSlot: null,
|
|
1082
|
+
materialized: null,
|
|
1083
|
+
extent: null,
|
|
1084
|
+
step: null,
|
|
1085
|
+
cellHeight: null,
|
|
1086
|
+
depth: null
|
|
1087
|
+
}), this.materialsDirty = !0, this.markLayoutDirty(), e;
|
|
1088
|
+
}
|
|
1089
|
+
updateSeries(t, e) {
|
|
1090
|
+
const i = this.series.get(t);
|
|
1091
|
+
if (i === void 0) return;
|
|
1092
|
+
const s = i.config, r = gn(s, e), o = r && s.xAxisId === e.xAxisId && s.yAxisId === e.yAxisId && s.name === e.name && s.color === e.color && s.tone === e.tone && bn(s, e);
|
|
1093
|
+
if (s.name !== e.name && e.name !== void 0) {
|
|
1094
|
+
const a = this.slotsByName.get(e.name);
|
|
1095
|
+
a === void 0 ? this.slotsByName.set(e.name, i.slot) : this.slotTaken(a, i) || (i.slot = a);
|
|
1096
|
+
}
|
|
1097
|
+
i.config = e, !o && (r || (i.materialized = null, i.extent = null, i.step = null, i.cellHeight = null, i.depth = null, this.materialsDirty = !0), this.markLayoutDirty());
|
|
1098
|
+
}
|
|
1099
|
+
unregisterSeries(t) {
|
|
1100
|
+
this.series.delete(t) && (this.materialsDirty = !0, this.markLayoutDirty());
|
|
1101
|
+
}
|
|
1102
|
+
registerAxis(t) {
|
|
1103
|
+
const e = vt++;
|
|
1104
|
+
return this.axes.set(e, { order: e, config: t }), this.materialsDirty = !0, this.markLayoutDirty(), e;
|
|
1105
|
+
}
|
|
1106
|
+
updateAxis(t, e) {
|
|
1107
|
+
const i = this.axes.get(t);
|
|
1108
|
+
if (i === void 0) return;
|
|
1109
|
+
const s = i.config, r = z(s.accessor, e.accessor) && s.calendar === e.calendar, o = r && s.id === e.id && s.orientation === e.orientation && s.position === e.position && s.label === e.label && s.tickCount === e.tickCount && s.grid === e.grid && mt(s.ticks, e.ticks) && wn(s.domain, e.domain) && z(s.tickFormat, e.tickFormat);
|
|
1110
|
+
if (i.config = e, !o) {
|
|
1111
|
+
if (!r || s.id !== e.id) {
|
|
1112
|
+
for (const a of this.series.values())
|
|
1113
|
+
a.materialized = null, a.extent = null, a.step = null, a.cellHeight = null, a.depth = null;
|
|
1114
|
+
this.materialsDirty = !0;
|
|
1115
|
+
}
|
|
1116
|
+
this.markLayoutDirty();
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
unregisterAxis(t) {
|
|
1120
|
+
this.axes.delete(t) && (this.materialsDirty = !0, this.markLayoutDirty());
|
|
1121
|
+
}
|
|
1122
|
+
/* Limits register themselves like series - that is the only way a child says
|
|
1123
|
+
anything in this library. They are therefore not series: no accessor, no
|
|
1124
|
+
data, no legend entry, no hit. */
|
|
1125
|
+
registerLimit(t) {
|
|
1126
|
+
const e = vt++;
|
|
1127
|
+
return this.limits.set(e, { order: e, config: t }), this.markLayoutDirty(), e;
|
|
1128
|
+
}
|
|
1129
|
+
updateLimit(t, e) {
|
|
1130
|
+
const i = this.limits.get(t);
|
|
1131
|
+
if (i === void 0) return;
|
|
1132
|
+
const s = i.config;
|
|
1133
|
+
i.config = e, !(s.kind === e.kind && s.axisId === e.axisId && s.orientation === e.orientation && s.severity === e.severity && s.role === e.role && s.label === e.label && s.color === e.color && s.inExtent === e.inExtent && (s.kind === "line" && e.kind === "line" ? s.value === e.value : s.kind === "band" && e.kind === "band" && s.from === e.from && s.to === e.to)) && this.markLayoutDirty();
|
|
1134
|
+
}
|
|
1135
|
+
unregisterLimit(t) {
|
|
1136
|
+
this.limits.delete(t) && this.markLayoutDirty();
|
|
1137
|
+
}
|
|
1138
|
+
limitsInOrder() {
|
|
1139
|
+
return [...this.limits.values()].sort((t, e) => t.order - e.order);
|
|
1140
|
+
}
|
|
1141
|
+
registerLegend(t) {
|
|
1142
|
+
this.legend = t, this.markLayoutDirty();
|
|
1143
|
+
}
|
|
1144
|
+
updateLegend(t) {
|
|
1145
|
+
this.legend !== null && this.legend.placement === t.placement || (this.legend = t, this.markLayoutDirty());
|
|
1146
|
+
}
|
|
1147
|
+
unregisterLegend() {
|
|
1148
|
+
this.legend = null, this.markLayoutDirty();
|
|
1149
|
+
}
|
|
1150
|
+
registerTooltip(t) {
|
|
1151
|
+
this.tooltip = t, this.pushHoverSnapshot();
|
|
1152
|
+
}
|
|
1153
|
+
updateTooltip(t) {
|
|
1154
|
+
const e = this.tooltip;
|
|
1155
|
+
if (e !== null && e.mode === t.mode && z(e.render, t.render)) {
|
|
1156
|
+
this.tooltip = t;
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
this.tooltip = t, this.pushHoverSnapshot();
|
|
1160
|
+
}
|
|
1161
|
+
unregisterTooltip() {
|
|
1162
|
+
this.tooltip = null, this.hover = null, this.hoverKey = "", this.markOverlayDirty(), this.pushHoverSnapshot();
|
|
1163
|
+
}
|
|
1164
|
+
/** Series in registration order - the drawing order. The palette follows it
|
|
1165
|
+
only on the first mount; after that it follows the name. */
|
|
1166
|
+
seriesInOrder() {
|
|
1167
|
+
return [...this.series.values()].sort((t, e) => t.order - e.order);
|
|
1168
|
+
}
|
|
1169
|
+
axesInOrder() {
|
|
1170
|
+
return [...this.axes.values()].sort((t, e) => t.order - e.order);
|
|
1171
|
+
}
|
|
1172
|
+
/* ================= Data and container configuration ================= */
|
|
1173
|
+
setData(t) {
|
|
1174
|
+
if (t !== this.data) {
|
|
1175
|
+
this.data = t, this.materialsDirty = !0, this.sortednessChecked = !1;
|
|
1176
|
+
for (const e of this.series.values())
|
|
1177
|
+
e.materialized = null, e.extent = null, e.step = null, e.cellHeight = null, e.depth = null;
|
|
1178
|
+
this.markLayoutDirty();
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
setPadding(t) {
|
|
1182
|
+
const e = this.padding;
|
|
1183
|
+
e.top === t.top && e.right === t.right && e.bottom === t.bottom && e.left === t.left || (this.padding = t, this.markLayoutDirty());
|
|
1184
|
+
}
|
|
1185
|
+
/* ================= Checks (R-4.12, R-4.13) ================= */
|
|
1186
|
+
/** Called from the Chart after the child effects; DEV only. */
|
|
1187
|
+
validate() {
|
|
1188
|
+
if (!st) return;
|
|
1189
|
+
const t = /* @__PURE__ */ new Set();
|
|
1190
|
+
for (const { config: r } of this.axesInOrder()) {
|
|
1191
|
+
const o = `${r.orientation}:${r.id}`, a = r.orientation === "x" ? "XAxis" : "YAxis";
|
|
1192
|
+
ut(
|
|
1193
|
+
!t.has(o),
|
|
1194
|
+
`Two <${a}> with the same id "${r.id}". A second ${a} needs an own id (R-4.12).`
|
|
1195
|
+
), t.add(o);
|
|
1196
|
+
}
|
|
1197
|
+
const e = /* @__PURE__ */ new Set();
|
|
1198
|
+
for (const { config: r } of this.series.values())
|
|
1199
|
+
ut(
|
|
1200
|
+
t.has(`x:${r.xAxisId}`),
|
|
1201
|
+
`Series "${r.name ?? "?"}" refers to the unknown x axis "${r.xAxisId}" (R-4.12).`
|
|
1202
|
+
), ut(
|
|
1203
|
+
t.has(`y:${r.yAxisId}`),
|
|
1204
|
+
`Series "${r.name ?? "?"}" refers to the unknown y axis "${r.yAxisId}" (R-4.12).`
|
|
1205
|
+
), e.add(`x:${r.xAxisId}`), e.add(`y:${r.yAxisId}`);
|
|
1206
|
+
for (const r of t)
|
|
1207
|
+
!e.has(r) && this.series.size > 0 && q(
|
|
1208
|
+
`axis-without-series-${r}`,
|
|
1209
|
+
`Axis "${r}" has no bound series; it is drawn with the domain [0, 1] (R-4.13).`
|
|
1210
|
+
);
|
|
1211
|
+
const i = /* @__PURE__ */ new Map();
|
|
1212
|
+
for (const { config: r } of this.seriesInOrder()) {
|
|
1213
|
+
if (r.kind !== "bar") continue;
|
|
1214
|
+
const o = i.get(r.xAxisId);
|
|
1215
|
+
o === void 0 ? i.set(r.xAxisId, r.barWidth) : o !== r.barWidth && q(
|
|
1216
|
+
`bar-width-${r.xAxisId}`,
|
|
1217
|
+
`Bars on the x axis "${r.xAxisId}" give different barWidth. A group shares one width fraction; that of the first (${o}) applies (ADR-0002).`
|
|
1218
|
+
);
|
|
1219
|
+
}
|
|
1220
|
+
let s = 0;
|
|
1221
|
+
for (const r of this.axesInOrder()) r.config.grid === !0 && s++;
|
|
1222
|
+
s > 1 && q(
|
|
1223
|
+
"multiple-grids",
|
|
1224
|
+
"More than one axis draws grid. Unaligned grids compete visually; there is no tick alignment between axes in V0 (R-4.15)."
|
|
1225
|
+
);
|
|
1226
|
+
}
|
|
1227
|
+
findXAxis(t) {
|
|
1228
|
+
for (const { config: e } of this.axes.values())
|
|
1229
|
+
if (e.orientation === "x" && e.id === t) return e;
|
|
1230
|
+
return null;
|
|
1231
|
+
}
|
|
1232
|
+
materialize() {
|
|
1233
|
+
const t = typeof performance > "u" ? 0 : performance.now();
|
|
1234
|
+
let e = 0;
|
|
1235
|
+
for (const i of this.series.values()) {
|
|
1236
|
+
if (i.materialized !== null) {
|
|
1237
|
+
e += i.materialized.length;
|
|
1238
|
+
continue;
|
|
1239
|
+
}
|
|
1240
|
+
const s = i.config, r = s.data ?? this.data, o = this.findXAxis(s.xAxisId);
|
|
1241
|
+
if (o === null) continue;
|
|
1242
|
+
const a = on(
|
|
1243
|
+
r,
|
|
1244
|
+
o.accessor,
|
|
1245
|
+
s.accessor,
|
|
1246
|
+
Pt(s),
|
|
1247
|
+
{
|
|
1248
|
+
value: Lt(s),
|
|
1249
|
+
xEnd: Ft(s),
|
|
1250
|
+
xMap: this.mapFor(o),
|
|
1251
|
+
xGap: this.gapFor(o)
|
|
1252
|
+
}
|
|
1253
|
+
);
|
|
1254
|
+
if (i.materialized = a.series, e += a.series.length, s.kind === "bar") {
|
|
1255
|
+
const l = cn(a.series.x, a.series.length);
|
|
1256
|
+
i.step = l;
|
|
1257
|
+
const c = l / 2;
|
|
1258
|
+
i.extent = {
|
|
1259
|
+
...a.extent,
|
|
1260
|
+
xMin: a.extent.xMin - c,
|
|
1261
|
+
xMax: a.extent.xMax + c
|
|
1262
|
+
};
|
|
1263
|
+
} else if (s.kind === "matrix") {
|
|
1264
|
+
const l = Jt(a.series.x, a.series.length), c = Jt(a.series.y, a.series.length);
|
|
1265
|
+
i.step = l, i.cellHeight = c, i.extent = {
|
|
1266
|
+
xMin: a.extent.xMin - l / 2,
|
|
1267
|
+
xMax: a.extent.xMax + l / 2,
|
|
1268
|
+
yMin: a.extent.yMin - c / 2,
|
|
1269
|
+
yMax: a.extent.yMax + c / 2
|
|
1270
|
+
};
|
|
1271
|
+
} else if (s.kind === "state")
|
|
1272
|
+
i.step = null, i.extent = {
|
|
1273
|
+
...a.extent,
|
|
1274
|
+
yMin: Number.POSITIVE_INFINITY,
|
|
1275
|
+
yMax: Number.NEGATIVE_INFINITY
|
|
1276
|
+
};
|
|
1277
|
+
else if (s.kind === "span") {
|
|
1278
|
+
i.depth = Ye(
|
|
1279
|
+
a.series.x,
|
|
1280
|
+
a.series.x1 ?? new Float64Array(a.series.length),
|
|
1281
|
+
a.series.length,
|
|
1282
|
+
// The end of the domain is not yet fixed at materialisation time. The
|
|
1283
|
+
// covering of an open span reaches to the end of everything there is -
|
|
1284
|
+
// and that is exactly the value it gets here.
|
|
1285
|
+
a.extent.xMax
|
|
1286
|
+
);
|
|
1287
|
+
const l = (s.height ?? 0.6) / 2;
|
|
1288
|
+
i.step = null, i.extent = {
|
|
1289
|
+
...a.extent,
|
|
1290
|
+
yMin: a.extent.yMin - l,
|
|
1291
|
+
yMax: a.extent.yMax + l
|
|
1292
|
+
};
|
|
1293
|
+
} else
|
|
1294
|
+
i.step = null, i.extent = a.extent;
|
|
1295
|
+
if (!this.sortednessChecked && st) {
|
|
1296
|
+
this.sortednessChecked = !0;
|
|
1297
|
+
const l = an(a.series.x, a.series.length);
|
|
1298
|
+
l >= 0 && q(
|
|
1299
|
+
"x-unsorted",
|
|
1300
|
+
`X values are not sorted ascending (index ${l}). Binary search and path building assume sortedness; there is no automatic sorting (R-2.6).`
|
|
1301
|
+
);
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
this.materialsDirty = !1, this.perf.materializeMs = (typeof performance > "u" ? 0 : performance.now()) - t, this.perf.points = e;
|
|
1305
|
+
}
|
|
1306
|
+
/* ================= DOM binding, DPR, resize ================= */
|
|
1307
|
+
bind(t, e, i, s) {
|
|
1308
|
+
this.container = t, this.themeRoot = s, this.seriesCanvas = e, this.overlayCanvas = i, this.seriesCtx = e.getContext("2d"), this.overlayCtx = i.getContext("2d"), this.measurer = new Me(s), this.dpr = typeof devicePixelRatio == "number" ? devicePixelRatio : 1, this.rebindDprWatch(), this.unsubscribeTheme = Ie(() => {
|
|
1309
|
+
var r;
|
|
1310
|
+
this.theme = null, (r = this.measurer) == null || r.clear(), this.markLayoutDirty();
|
|
1311
|
+
}), this.theme = null, this.markLayoutDirty();
|
|
1312
|
+
}
|
|
1313
|
+
bindTooltip(t) {
|
|
1314
|
+
this.tooltipEl = t;
|
|
1315
|
+
}
|
|
1316
|
+
unbind() {
|
|
1317
|
+
var t, e, i;
|
|
1318
|
+
this.frameHandle !== null && typeof cancelAnimationFrame == "function" && (cancelAnimationFrame(this.frameHandle), this.frameHandle = null), (t = this.dprMedia) == null || t.removeEventListener("change", this.onDprChange), this.dprMedia = null, (e = this.unsubscribeTheme) == null || e.call(this), this.unsubscribeTheme = null, (i = this.measurer) == null || i.remove(), this.measurer = null, this.container = null, this.themeRoot = null, this.seriesCanvas = null, this.overlayCanvas = null, this.seriesCtx = null, this.overlayCtx = null, this.tooltipEl = null;
|
|
1319
|
+
}
|
|
1320
|
+
/** Detect a change of DPR (a change of monitor): rebind matchMedia (R-2.9). */
|
|
1321
|
+
rebindDprWatch() {
|
|
1322
|
+
var t;
|
|
1323
|
+
typeof matchMedia == "function" && ((t = this.dprMedia) == null || t.removeEventListener("change", this.onDprChange), this.dpr = typeof devicePixelRatio == "number" ? devicePixelRatio : 1, this.dprMedia = matchMedia(`(resolution: ${this.dpr}dppx)`), this.dprMedia.addEventListener("change", this.onDprChange));
|
|
1324
|
+
}
|
|
1325
|
+
/** Called by the ResizeObserver; coalesced onto one rAF (R-2.10). */
|
|
1326
|
+
requestResize(t, e) {
|
|
1327
|
+
t === this.cssWidth && e === this.cssHeight || (this.pendingWidth = t, this.pendingHeight = e, this.markLayoutDirty());
|
|
1328
|
+
}
|
|
1329
|
+
applyPendingSize() {
|
|
1330
|
+
if (this.pendingWidth === null || this.pendingHeight === null) return;
|
|
1331
|
+
this.cssWidth = this.pendingWidth, this.cssHeight = this.pendingHeight, this.pendingWidth = null, this.pendingHeight = null;
|
|
1332
|
+
const { seriesCanvas: t, overlayCanvas: e, seriesCtx: i, overlayCtx: s, dpr: r } = this;
|
|
1333
|
+
if (!t || !e || !i || !s) return;
|
|
1334
|
+
const o = Math.max(0, Math.round(this.cssWidth * r)), a = Math.max(0, Math.round(this.cssHeight * r));
|
|
1335
|
+
for (const l of [t, e])
|
|
1336
|
+
l.width = o, l.height = a, l.style.width = `${this.cssWidth}px`, l.style.height = `${this.cssHeight}px`;
|
|
1337
|
+
i.setTransform(r, 0, 0, r, 0, 0), s.setTransform(r, 0, 0, r, 0, 0);
|
|
1338
|
+
}
|
|
1339
|
+
/* ================= Scheduling (R-2.11) ================= */
|
|
1340
|
+
markSeriesDirty() {
|
|
1341
|
+
this.seriesDirty = !0, this.requestFrame();
|
|
1342
|
+
}
|
|
1343
|
+
markOverlayDirty() {
|
|
1344
|
+
this.overlayDirty = !0, this.requestFrame();
|
|
1345
|
+
}
|
|
1346
|
+
/** A layout-relevant change: it pulls the series and the overlay layer with
|
|
1347
|
+
it. */
|
|
1348
|
+
markLayoutDirty() {
|
|
1349
|
+
this.layoutDirty = !0, this.seriesDirty = !0, this.overlayDirty = !0, this.requestFrame();
|
|
1350
|
+
}
|
|
1351
|
+
requestFrame() {
|
|
1352
|
+
this.frameHandle === null && this.container !== null && typeof requestAnimationFrame == "function" && (this.frameHandle = requestAnimationFrame(() => {
|
|
1353
|
+
this.frameHandle = null, this.frame();
|
|
1354
|
+
}));
|
|
1355
|
+
}
|
|
1356
|
+
frame() {
|
|
1357
|
+
if (this.applyPendingSize(), this.theme === null && this.themeRoot !== null && (this.theme = Ne(this.themeRoot)), this.cssWidth <= 0 || this.cssHeight <= 0) {
|
|
1358
|
+
this.layoutDirty && this.pushLayoutSnapshot();
|
|
1359
|
+
return;
|
|
1360
|
+
}
|
|
1361
|
+
this.materialsDirty && this.materialize(), this.layoutDirty && (this.updateLayout(), this.layoutDirty = !1, this.pushLayoutSnapshot()), this.seriesDirty && (this.drawSeriesLayer(), this.seriesDirty = !1), this.overlayDirty && (this.drawOverlayLayer(), this.overlayDirty = !1);
|
|
1362
|
+
}
|
|
1363
|
+
/* ================= Layout ================= */
|
|
1364
|
+
/** The effective grid default: only the first registered axis per orientation
|
|
1365
|
+
(R-4.15). */
|
|
1366
|
+
gridDefault() {
|
|
1367
|
+
const t = /* @__PURE__ */ new Map();
|
|
1368
|
+
let e = !0, i = !0;
|
|
1369
|
+
for (const [s, r] of [...this.axes.entries()].sort((o, a) => o[1].order - a[1].order)) {
|
|
1370
|
+
const o = r.config.orientation === "x" ? e : i;
|
|
1371
|
+
t.set(s, r.config.grid ?? o), r.config.orientation === "x" ? e = !1 : i = !1;
|
|
1372
|
+
}
|
|
1373
|
+
return t;
|
|
1374
|
+
}
|
|
1375
|
+
/** Extent of an axis out of the series bound to it (R-4.13).
|
|
1376
|
+
|
|
1377
|
+
Materialises on demand and manages without the DOM - that is the seam at
|
|
1378
|
+
which extents across series kinds can be tested without asking a canvas.
|
|
1379
|
+
The layout path calls extentFor directly. */
|
|
1380
|
+
axisExtent(t, e) {
|
|
1381
|
+
this.materialsDirty && this.materialize();
|
|
1382
|
+
const i = [...this.series.values()].map((s) => ({
|
|
1383
|
+
xAxisId: s.config.xAxisId,
|
|
1384
|
+
yAxisId: s.config.yAxisId,
|
|
1385
|
+
extent: s.extent
|
|
1386
|
+
}));
|
|
1387
|
+
return ln(t, e, i, this.limitValues(t, e));
|
|
1388
|
+
}
|
|
1389
|
+
/** The values of the limits that are to pull this axis along. */
|
|
1390
|
+
limitValues(t, e) {
|
|
1391
|
+
const i = [];
|
|
1392
|
+
for (const { config: s } of this.limits.values())
|
|
1393
|
+
s.inExtent && (s.orientation !== t || s.axisId !== e || (s.kind === "line" ? i.push(s.value) : i.push(s.from, s.to)));
|
|
1394
|
+
return i;
|
|
1395
|
+
}
|
|
1396
|
+
/** Pre-mapping of the x values of an axis with an operating calendar. The scale
|
|
1397
|
+
stays affine; the mapping happens beforehand, once per point, in
|
|
1398
|
+
materialisation - exactly the route ADR-0001 prescribes for a non-affine
|
|
1399
|
+
axis. */
|
|
1400
|
+
mapFor(t) {
|
|
1401
|
+
const e = t.calendar;
|
|
1402
|
+
if (!(e === void 0 || e.length === 0))
|
|
1403
|
+
return (i) => Ee(i, e);
|
|
1404
|
+
}
|
|
1405
|
+
gapFor(t) {
|
|
1406
|
+
const e = t.calendar;
|
|
1407
|
+
if (!(e === void 0 || e.length === 0))
|
|
1408
|
+
return (i) => De(i, e);
|
|
1409
|
+
}
|
|
1410
|
+
extentFor(t) {
|
|
1411
|
+
return this.axisExtent(t.orientation, t.id);
|
|
1412
|
+
}
|
|
1413
|
+
updateLayout() {
|
|
1414
|
+
const t = this.measurer, e = this.gridDefault(), i = [];
|
|
1415
|
+
for (const [s, r] of [...this.axes.entries()].sort((o, a) => o[1].order - a[1].order)) {
|
|
1416
|
+
const o = r.config;
|
|
1417
|
+
i.push({
|
|
1418
|
+
key: `${o.orientation}:${o.id}`,
|
|
1419
|
+
id: o.id,
|
|
1420
|
+
orientation: o.orientation,
|
|
1421
|
+
position: o.position,
|
|
1422
|
+
label: o.label,
|
|
1423
|
+
grid: e.get(s) ?? !1,
|
|
1424
|
+
extent: this.extentFor(o),
|
|
1425
|
+
domainMode: o.domain,
|
|
1426
|
+
tickCount: o.tickCount,
|
|
1427
|
+
tickFormat: o.tickFormat,
|
|
1428
|
+
tickValues: o.ticks,
|
|
1429
|
+
calendar: o.calendar
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
this.layout = _e({
|
|
1433
|
+
width: this.cssWidth,
|
|
1434
|
+
height: this.cssHeight,
|
|
1435
|
+
padding: this.padding,
|
|
1436
|
+
axes: i,
|
|
1437
|
+
measure: (s, r) => t === null ? { width: 0, height: 0 } : t.measure(s, r),
|
|
1438
|
+
hysteresis: this.hysteresis
|
|
1439
|
+
});
|
|
1440
|
+
}
|
|
1441
|
+
findAxis(t, e) {
|
|
1442
|
+
for (const i of this.layout.axes)
|
|
1443
|
+
if (i.orientation === t && i.id === e) return i;
|
|
1444
|
+
return null;
|
|
1445
|
+
}
|
|
1446
|
+
/* ================= Series colours and legend entries ================= */
|
|
1447
|
+
colorFor(t, e) {
|
|
1448
|
+
var r;
|
|
1449
|
+
if (t.config.color !== void 0) return t.config.color;
|
|
1450
|
+
const i = t.config.tone;
|
|
1451
|
+
if (i !== void 0) {
|
|
1452
|
+
const o = this.theme ?? W;
|
|
1453
|
+
return i === "alarm" ? o.colorAlarm : i === "warning" ? o.colorWarning : o.colorOk;
|
|
1454
|
+
}
|
|
1455
|
+
const s = ((r = this.theme) == null ? void 0 : r.series) ?? W.series;
|
|
1456
|
+
return s[this.paletteSlot(t, e) % Math.max(1, s.length)] ?? W.series[0] ?? "#2563eb";
|
|
1457
|
+
}
|
|
1458
|
+
/** Named: the place of the name. Nameless: the index in the registration, as
|
|
1459
|
+
before - and a warning as soon as that shifts underneath it. */
|
|
1460
|
+
paletteSlot(t, e) {
|
|
1461
|
+
return t.config.name !== void 0 ? t.slot : (t.lastSlot !== null && t.lastSlot !== e && q(
|
|
1462
|
+
"series-without-name-colour",
|
|
1463
|
+
"a series without a name has changed its colour, because a series before it went away - with `name` it keeps it."
|
|
1464
|
+
), t.lastSlot = e, e);
|
|
1465
|
+
}
|
|
1466
|
+
nameFor(t, e) {
|
|
1467
|
+
return t.config.name !== void 0 ? t.config.name : (q(
|
|
1468
|
+
"series-without-name",
|
|
1469
|
+
`a series without a name is called "Series ${e + 1}" in the legend and the tooltip - the name belongs in \`name\`.`
|
|
1470
|
+
), `Series ${e + 1}`);
|
|
1471
|
+
}
|
|
1472
|
+
legendItems() {
|
|
1473
|
+
const t = [], e = /* @__PURE__ */ new Set();
|
|
1474
|
+
return this.seriesInOrder().forEach((i, s) => {
|
|
1475
|
+
const r = i.config;
|
|
1476
|
+
if (r.kind === "state") {
|
|
1477
|
+
r.states.forEach((o, a) => {
|
|
1478
|
+
const l = `${o.label}\0${o.color}`;
|
|
1479
|
+
e.has(l) || (e.add(l), t.push({
|
|
1480
|
+
id: `${i.order}:${a}`,
|
|
1481
|
+
name: o.label,
|
|
1482
|
+
color: o.color,
|
|
1483
|
+
seriesId: i.order
|
|
1484
|
+
}));
|
|
1485
|
+
});
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1488
|
+
t.push({
|
|
1489
|
+
id: String(i.order),
|
|
1490
|
+
name: this.nameFor(i, s),
|
|
1491
|
+
color: this.colorFor(i, s),
|
|
1492
|
+
seriesId: i.order
|
|
1493
|
+
});
|
|
1494
|
+
}), t;
|
|
1495
|
+
}
|
|
1496
|
+
/* ---------- Limits, ready in pixels ---------- */
|
|
1497
|
+
limitColor(t, e) {
|
|
1498
|
+
return t.color !== void 0 ? t.color : t.role === "control" ? e.colorAxis : t.role === "zone" ? e.colorGrid : t.severity === "alarm" ? e.colorAlarm : e.colorWarning;
|
|
1499
|
+
}
|
|
1500
|
+
/** Dash pattern per role. The reader has to be able to see at a glance whether
|
|
1501
|
+
the problem is the process or the tolerance. */
|
|
1502
|
+
limitDash(t) {
|
|
1503
|
+
switch (t.role) {
|
|
1504
|
+
case "control":
|
|
1505
|
+
return [];
|
|
1506
|
+
case "zone":
|
|
1507
|
+
return [2, 3];
|
|
1508
|
+
default:
|
|
1509
|
+
return [4, 3];
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
limitItems(t) {
|
|
1513
|
+
const e = this.theme ?? W, i = [];
|
|
1514
|
+
for (const { config: s } of this.limitsInOrder()) {
|
|
1515
|
+
if (s.kind === "band" !== t) continue;
|
|
1516
|
+
const r = this.findAxis(s.orientation, s.axisId);
|
|
1517
|
+
if (r === null) continue;
|
|
1518
|
+
const o = this.limitColor(s, e), a = this.limitDash(s);
|
|
1519
|
+
if (s.kind === "band")
|
|
1520
|
+
i.push({
|
|
1521
|
+
orientation: s.orientation,
|
|
1522
|
+
fromPx: r.scale.toPx(s.from),
|
|
1523
|
+
toPx: r.scale.toPx(s.to),
|
|
1524
|
+
color: o,
|
|
1525
|
+
band: !0,
|
|
1526
|
+
dash: a
|
|
1527
|
+
});
|
|
1528
|
+
else {
|
|
1529
|
+
const l = r.scale.toPx(s.value);
|
|
1530
|
+
i.push({
|
|
1531
|
+
orientation: s.orientation,
|
|
1532
|
+
fromPx: l,
|
|
1533
|
+
toPx: l,
|
|
1534
|
+
color: o,
|
|
1535
|
+
band: !1,
|
|
1536
|
+
dash: a
|
|
1537
|
+
});
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
return i;
|
|
1541
|
+
}
|
|
1542
|
+
/** Labelled limits for the HTML layer: position and colour, ready. */
|
|
1543
|
+
limitLabels() {
|
|
1544
|
+
const t = [];
|
|
1545
|
+
for (const { order: e, config: i } of this.limitsInOrder()) {
|
|
1546
|
+
if (i.label === void 0 || i.label === "") continue;
|
|
1547
|
+
const s = this.findAxis(i.orientation, i.axisId);
|
|
1548
|
+
if (s === null) continue;
|
|
1549
|
+
const r = i.kind === "line" ? i.value : (i.from + i.to) / 2;
|
|
1550
|
+
t.push({
|
|
1551
|
+
id: e,
|
|
1552
|
+
axisKey: s.key,
|
|
1553
|
+
px: s.scale.toPx(r),
|
|
1554
|
+
label: i.label,
|
|
1555
|
+
severity: i.severity,
|
|
1556
|
+
role: i.role
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
return t;
|
|
1560
|
+
}
|
|
1561
|
+
/* ================= Drawing ================= */
|
|
1562
|
+
drawItems() {
|
|
1563
|
+
const t = [], e = this.seriesInOrder(), i = dn(
|
|
1564
|
+
e.map((s) => ({
|
|
1565
|
+
order: s.order,
|
|
1566
|
+
kind: s.config.kind,
|
|
1567
|
+
xAxisId: s.config.xAxisId,
|
|
1568
|
+
step: s.step ?? 0,
|
|
1569
|
+
fraction: s.config.kind === "bar" ? s.config.barWidth : 0
|
|
1570
|
+
}))
|
|
1571
|
+
);
|
|
1572
|
+
return e.forEach((s, r) => {
|
|
1573
|
+
const o = s.materialized;
|
|
1574
|
+
if (o === null) return;
|
|
1575
|
+
const a = this.findAxis("x", s.config.xAxisId), l = this.findAxis("y", s.config.yAxisId);
|
|
1576
|
+
if (a === null || l === null) return;
|
|
1577
|
+
const c = this.highlight !== null && this.highlight !== s.order, u = {
|
|
1578
|
+
x: o.x,
|
|
1579
|
+
y: o.y,
|
|
1580
|
+
length: o.length,
|
|
1581
|
+
xScale: a.scale,
|
|
1582
|
+
yScale: l.scale,
|
|
1583
|
+
color: this.colorFor(s, r),
|
|
1584
|
+
alpha: c ? 0.25 : 1
|
|
1585
|
+
}, h = s.config;
|
|
1586
|
+
switch (h.kind) {
|
|
1587
|
+
case "line":
|
|
1588
|
+
t.push({
|
|
1589
|
+
...u,
|
|
1590
|
+
kind: "line",
|
|
1591
|
+
strokeWidth: h.strokeWidth,
|
|
1592
|
+
dash: h.dash,
|
|
1593
|
+
marker: h.markers === "always" || h.markers === "auto" && o.length <= mn
|
|
1594
|
+
});
|
|
1595
|
+
break;
|
|
1596
|
+
case "area":
|
|
1597
|
+
t.push({
|
|
1598
|
+
...u,
|
|
1599
|
+
kind: "area",
|
|
1600
|
+
y0: o.y0,
|
|
1601
|
+
baseline: 0,
|
|
1602
|
+
fillOpacity: h.fillOpacity,
|
|
1603
|
+
strokeWidth: h.strokeWidth
|
|
1604
|
+
});
|
|
1605
|
+
break;
|
|
1606
|
+
case "bar": {
|
|
1607
|
+
const p = i.get(s.order) ?? {
|
|
1608
|
+
index: 0,
|
|
1609
|
+
size: 1,
|
|
1610
|
+
step: s.step ?? 0,
|
|
1611
|
+
fraction: h.barWidth
|
|
1612
|
+
}, d = a.scale.domain, m = hn(
|
|
1613
|
+
un(p.step, d[1] - d[0]),
|
|
1614
|
+
p.fraction,
|
|
1615
|
+
p.index,
|
|
1616
|
+
p.size
|
|
1617
|
+
);
|
|
1618
|
+
t.push({
|
|
1619
|
+
...u,
|
|
1620
|
+
kind: "bar",
|
|
1621
|
+
baseline: 0,
|
|
1622
|
+
offset: m.offset,
|
|
1623
|
+
width: m.width
|
|
1624
|
+
});
|
|
1625
|
+
break;
|
|
1626
|
+
}
|
|
1627
|
+
case "scatter":
|
|
1628
|
+
t.push({ ...u, kind: "scatter", radius: h.radius });
|
|
1629
|
+
break;
|
|
1630
|
+
case "state": {
|
|
1631
|
+
const p = this.lanePx(h, l);
|
|
1632
|
+
t.push({
|
|
1633
|
+
...u,
|
|
1634
|
+
kind: "state",
|
|
1635
|
+
colors: h.states.map((d) => d.color),
|
|
1636
|
+
laneTop: p.top,
|
|
1637
|
+
laneBottom: p.bottom,
|
|
1638
|
+
domainEnd: a.scale.domain[1]
|
|
1639
|
+
});
|
|
1640
|
+
break;
|
|
1641
|
+
}
|
|
1642
|
+
case "matrix": {
|
|
1643
|
+
const p = kn(h.coloring, this.theme ?? W);
|
|
1644
|
+
t.push({
|
|
1645
|
+
...u,
|
|
1646
|
+
kind: "matrix",
|
|
1647
|
+
buckets: Nn(o, h.coloring, p.length),
|
|
1648
|
+
colors: p,
|
|
1649
|
+
width: ct(
|
|
1650
|
+
s.step ?? 0,
|
|
1651
|
+
a.scale.domain[1] - a.scale.domain[0]
|
|
1652
|
+
),
|
|
1653
|
+
height: ct(
|
|
1654
|
+
s.cellHeight ?? 0,
|
|
1655
|
+
l.scale.domain[1] - l.scale.domain[0]
|
|
1656
|
+
)
|
|
1657
|
+
});
|
|
1658
|
+
break;
|
|
1659
|
+
}
|
|
1660
|
+
case "span": {
|
|
1661
|
+
t.push({
|
|
1662
|
+
...u,
|
|
1663
|
+
kind: "span",
|
|
1664
|
+
x1: o.x1 ?? pn,
|
|
1665
|
+
// Computed once per materialisation, not per frame: the calculation
|
|
1666
|
+
// is quadratic, and a schedule with five hundred spans is pushed and
|
|
1667
|
+
// pulled like any other chart.
|
|
1668
|
+
depth: s.depth ?? yn,
|
|
1669
|
+
height: h.height ?? 0.6,
|
|
1670
|
+
domainEnd: a.scale.domain[1]
|
|
1671
|
+
});
|
|
1672
|
+
break;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
}), t;
|
|
1676
|
+
}
|
|
1677
|
+
/** Lane of a state series in pixels. Without a value the whole domain of its y
|
|
1678
|
+
axis: a single series fills its band, a stack gets a domain with one unit per
|
|
1679
|
+
machine from the caller. */
|
|
1680
|
+
lanePx(t, e) {
|
|
1681
|
+
const i = e.scale.domain, s = e.scale.toPx(t.laneFrom ?? i[0]), r = e.scale.toPx(t.laneTo ?? i[1]);
|
|
1682
|
+
return { top: Math.min(s, r), bottom: Math.max(s, r) };
|
|
1683
|
+
}
|
|
1684
|
+
drawSeriesLayer() {
|
|
1685
|
+
var s;
|
|
1686
|
+
const t = this.seriesCtx, e = this.theme;
|
|
1687
|
+
if (!t || !e) return;
|
|
1688
|
+
const i = typeof performance > "u" ? 0 : performance.now();
|
|
1689
|
+
Qe(t, {
|
|
1690
|
+
width: this.cssWidth,
|
|
1691
|
+
height: this.cssHeight,
|
|
1692
|
+
plot: this.layout.plot,
|
|
1693
|
+
axes: this.layout.axes,
|
|
1694
|
+
theme: e,
|
|
1695
|
+
series: this.drawItems(),
|
|
1696
|
+
limitBands: this.limitItems(!0),
|
|
1697
|
+
limitLines: this.limitItems(!1)
|
|
1698
|
+
}), this.perf.seriesDrawMs = (typeof performance > "u" ? 0 : performance.now()) - i, (s = this.onPerf) == null || s.call(this, { ...this.perf });
|
|
1699
|
+
}
|
|
1700
|
+
drawOverlayLayer() {
|
|
1701
|
+
const t = this.overlayCtx, e = this.theme;
|
|
1702
|
+
!t || !e || (tn(t, {
|
|
1703
|
+
width: this.cssWidth,
|
|
1704
|
+
height: this.cssHeight,
|
|
1705
|
+
plot: this.layout.plot,
|
|
1706
|
+
theme: e,
|
|
1707
|
+
hover: this.hover
|
|
1708
|
+
}), this.positionTooltip());
|
|
1709
|
+
}
|
|
1710
|
+
/* ================= Interaction (4.4) ================= */
|
|
1711
|
+
setHighlight(t) {
|
|
1712
|
+
this.highlight !== t && (this.highlight = t, this.markSeriesDirty());
|
|
1713
|
+
}
|
|
1714
|
+
inPlot(t, e) {
|
|
1715
|
+
const i = this.layout.plot;
|
|
1716
|
+
return t >= i.x && t <= i.x + i.width && e >= i.y && e <= i.y + i.height;
|
|
1717
|
+
}
|
|
1718
|
+
pointerMove(t, e) {
|
|
1719
|
+
if (this.tooltip === null) return;
|
|
1720
|
+
if (!this.inPlot(t, e)) {
|
|
1721
|
+
this.pointerLeave();
|
|
1722
|
+
return;
|
|
1723
|
+
}
|
|
1724
|
+
const i = this.hitTest(t, e);
|
|
1725
|
+
if (i === null) {
|
|
1726
|
+
this.pointerLeave();
|
|
1727
|
+
return;
|
|
1728
|
+
}
|
|
1729
|
+
const s = i.key;
|
|
1730
|
+
this.hover = i.state, this.hover.mouseX = t, this.hover.mouseY = e, this.markOverlayDirty(), s !== this.hoverKey && (this.hoverKey = s, this.hoverXLabel = i.xLabel, this.pushHoverSnapshot());
|
|
1731
|
+
}
|
|
1732
|
+
pointerLeave() {
|
|
1733
|
+
this.hover === null && this.hoverKey === "" || (this.hover = null, this.hoverKey = "", this.markOverlayDirty(), this.pushHoverSnapshot());
|
|
1734
|
+
}
|
|
1735
|
+
hitTest(t, e) {
|
|
1736
|
+
var y;
|
|
1737
|
+
const i = ((y = this.tooltip) == null ? void 0 : y.mode) ?? "x", s = [];
|
|
1738
|
+
if (this.seriesInOrder().forEach((f, b) => {
|
|
1739
|
+
const k = f.materialized;
|
|
1740
|
+
if (k === null || k.length === 0) return;
|
|
1741
|
+
const N = f.config, w = this.findAxis("x", N.xAxisId), L = this.findAxis("y", N.yAxisId);
|
|
1742
|
+
if (w === null || L === null) return;
|
|
1743
|
+
const F = w.scale.fromPx(t), P = L.scale.fromPx(e), S = this.hitIn(f, k, w, L, e, F, P);
|
|
1744
|
+
S !== null && s.push({
|
|
1745
|
+
entry: f,
|
|
1746
|
+
index: S.index,
|
|
1747
|
+
color: S.color ?? this.colorFor(f, b),
|
|
1748
|
+
name: this.nameFor(f, b),
|
|
1749
|
+
px: S.px,
|
|
1750
|
+
py: S.py,
|
|
1751
|
+
xValue: S.xValue,
|
|
1752
|
+
yValue: S.yValue,
|
|
1753
|
+
marked: S.marked,
|
|
1754
|
+
areal: S.areal,
|
|
1755
|
+
value: S.value,
|
|
1756
|
+
segment: S.segment
|
|
1757
|
+
});
|
|
1758
|
+
}), s.length === 0) return null;
|
|
1759
|
+
const r = s.filter((f) => !f.areal), o = r.length > 0 ? r : s;
|
|
1760
|
+
let a = o[0];
|
|
1761
|
+
if (i === "nearest") {
|
|
1762
|
+
let f = Number.POSITIVE_INFINITY;
|
|
1763
|
+
for (const b of s) {
|
|
1764
|
+
const k = b.areal ? 0 : b.px - t, N = b.areal ? 0 : b.py - e, w = k * k + N * N;
|
|
1765
|
+
w < f && (f = w, a = b);
|
|
1766
|
+
}
|
|
1767
|
+
} else {
|
|
1768
|
+
let f = Number.POSITIVE_INFINITY;
|
|
1769
|
+
for (const b of o) {
|
|
1770
|
+
const k = Math.abs(b.px - t);
|
|
1771
|
+
k < f && (f = k, a = b);
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
const l = i === "nearest" ? [a] : s.filter(
|
|
1775
|
+
// An area is always included: it covers the pointer, otherwise it
|
|
1776
|
+
// would not have reported a hit at all. Only points have to share the
|
|
1777
|
+
// x position.
|
|
1778
|
+
(f) => f.areal || Math.abs(f.px - a.px) <= fn
|
|
1779
|
+
), c = l.map((f) => ({
|
|
1780
|
+
seriesName: f.name,
|
|
1781
|
+
color: f.color,
|
|
1782
|
+
yValue: f.yValue,
|
|
1783
|
+
datum: (f.entry.config.data ?? this.data)[f.index],
|
|
1784
|
+
index: f.index,
|
|
1785
|
+
value: f.value,
|
|
1786
|
+
segment: f.segment
|
|
1787
|
+
})), h = {
|
|
1788
|
+
hit: {
|
|
1789
|
+
xValue: a.xValue,
|
|
1790
|
+
points: c,
|
|
1791
|
+
xPx: a.px,
|
|
1792
|
+
yPx: a.py
|
|
1793
|
+
},
|
|
1794
|
+
marker: l.filter((f) => f.marked).map((f) => ({ x: f.px, y: f.py, color: f.color })),
|
|
1795
|
+
mouseX: t,
|
|
1796
|
+
mouseY: e
|
|
1797
|
+
}, p = l.map((f) => `${f.entry.order}:${f.index}`).join("|"), d = this.findAxis("x", a.entry.config.xAxisId), m = d === null ? String(a.xValue) : d.format(a.xValue);
|
|
1798
|
+
return { key: p, state: h, xLabel: m };
|
|
1799
|
+
}
|
|
1800
|
+
/** The hit of one series - one different question per kind.
|
|
1801
|
+
|
|
1802
|
+
Every mark that is a point asks "which point lies nearest". A band, a cell
|
|
1803
|
+
and a span ask "what lies under the pointer", and that is not the same
|
|
1804
|
+
question: for the right half of every segment the nearest point gives the
|
|
1805
|
+
wrong answer. */
|
|
1806
|
+
hitIn(t, e, i, s, r, o, a) {
|
|
1807
|
+
const l = t.config, c = e.length;
|
|
1808
|
+
if (l.kind === "state") {
|
|
1809
|
+
const d = this.lanePx(l, s);
|
|
1810
|
+
if (r < d.top || r > d.bottom) return null;
|
|
1811
|
+
const m = Be(e.x, c, o);
|
|
1812
|
+
if (m < 0) return null;
|
|
1813
|
+
const y = e.y[m];
|
|
1814
|
+
if (Number.isNaN(y)) return null;
|
|
1815
|
+
const f = e.x[m], b = se(e.x, c, m, i.scale.domain[1]), k = l.states[y | 0];
|
|
1816
|
+
return {
|
|
1817
|
+
index: m,
|
|
1818
|
+
px: i.scale.toPx(f),
|
|
1819
|
+
py: (d.top + d.bottom) / 2,
|
|
1820
|
+
xValue: f,
|
|
1821
|
+
yValue: y,
|
|
1822
|
+
marked: !1,
|
|
1823
|
+
areal: !0,
|
|
1824
|
+
color: k == null ? void 0 : k.color,
|
|
1825
|
+
segment: { from: f, to: b, label: (k == null ? void 0 : k.label) ?? "", open: !1 }
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
if (l.kind === "span") {
|
|
1829
|
+
const d = e.x1;
|
|
1830
|
+
if (d === null) return null;
|
|
1831
|
+
const m = i.scale.domain[1], y = l.height ?? 0.6, f = ze(
|
|
1832
|
+
e.x,
|
|
1833
|
+
d,
|
|
1834
|
+
e.y,
|
|
1835
|
+
c,
|
|
1836
|
+
o,
|
|
1837
|
+
a,
|
|
1838
|
+
y,
|
|
1839
|
+
m
|
|
1840
|
+
);
|
|
1841
|
+
if (f < 0) return null;
|
|
1842
|
+
const b = e.x[f], k = e.y[f], N = d[f];
|
|
1843
|
+
return {
|
|
1844
|
+
index: f,
|
|
1845
|
+
px: i.scale.toPx(b),
|
|
1846
|
+
py: s.scale.toPx(k),
|
|
1847
|
+
xValue: b,
|
|
1848
|
+
yValue: k,
|
|
1849
|
+
marked: !1,
|
|
1850
|
+
areal: !0,
|
|
1851
|
+
segment: {
|
|
1852
|
+
from: b,
|
|
1853
|
+
to: rt(N, m),
|
|
1854
|
+
label: "",
|
|
1855
|
+
open: re(N)
|
|
1856
|
+
}
|
|
1857
|
+
};
|
|
1858
|
+
}
|
|
1859
|
+
if (l.kind === "matrix") {
|
|
1860
|
+
const d = nn(
|
|
1861
|
+
e.x,
|
|
1862
|
+
e.y,
|
|
1863
|
+
c,
|
|
1864
|
+
o,
|
|
1865
|
+
a,
|
|
1866
|
+
ct(t.step ?? 0, i.scale.domain[1] - i.scale.domain[0]),
|
|
1867
|
+
ct(t.cellHeight ?? 0, s.scale.domain[1] - s.scale.domain[0])
|
|
1868
|
+
);
|
|
1869
|
+
if (d < 0) return null;
|
|
1870
|
+
const m = e.w, y = m === null ? Number.NaN : m[d];
|
|
1871
|
+
if (!Number.isFinite(y)) return null;
|
|
1872
|
+
const f = e.x[d], b = e.y[d];
|
|
1873
|
+
return {
|
|
1874
|
+
index: d,
|
|
1875
|
+
px: i.scale.toPx(f),
|
|
1876
|
+
py: s.scale.toPx(b),
|
|
1877
|
+
xValue: f,
|
|
1878
|
+
// yValue stays the position on the y axis; the value that carries the
|
|
1879
|
+
// colour stands in a field of its own. Colour alone can transport no
|
|
1880
|
+
// number - which is why the tooltip has to carry it.
|
|
1881
|
+
yValue: b,
|
|
1882
|
+
value: y,
|
|
1883
|
+
marked: !1,
|
|
1884
|
+
areal: !0
|
|
1885
|
+
};
|
|
1886
|
+
}
|
|
1887
|
+
const u = en(e.x, c, o);
|
|
1888
|
+
if (u < 0) return null;
|
|
1889
|
+
const h = e.y[u];
|
|
1890
|
+
if (Number.isNaN(h)) return null;
|
|
1891
|
+
const p = e.x[u];
|
|
1892
|
+
return {
|
|
1893
|
+
index: u,
|
|
1894
|
+
px: i.scale.toPx(p),
|
|
1895
|
+
py: s.scale.toPx(h),
|
|
1896
|
+
xValue: p,
|
|
1897
|
+
yValue: h,
|
|
1898
|
+
marked: !0,
|
|
1899
|
+
areal: !1
|
|
1900
|
+
};
|
|
1901
|
+
}
|
|
1902
|
+
/** R-4.9: 12 px to the right of the crosshair, flipping at the right edge,
|
|
1903
|
+
clamped vertically. */
|
|
1904
|
+
positionTooltip() {
|
|
1905
|
+
const t = this.tooltipEl;
|
|
1906
|
+
if (t === null) return;
|
|
1907
|
+
const e = this.hover;
|
|
1908
|
+
if (e === null) {
|
|
1909
|
+
t.style.opacity = "0";
|
|
1910
|
+
return;
|
|
1911
|
+
}
|
|
1912
|
+
const i = t.offsetWidth, s = t.offsetHeight;
|
|
1913
|
+
let r = e.hit.xPx + 12;
|
|
1914
|
+
r + i > this.cssWidth && (r = e.hit.xPx - 12 - i), r < 0 && (r = 0);
|
|
1915
|
+
let o = e.mouseY - s / 2;
|
|
1916
|
+
o = Math.min(Math.max(o, 0), Math.max(0, this.cssHeight - s)), t.style.transform = `translate3d(${Math.round(r)}px, ${Math.round(o)}px, 0)`, t.style.opacity = "1";
|
|
1917
|
+
}
|
|
1918
|
+
/* ================= Snapshots for the HTML layer ================= */
|
|
1919
|
+
pushLayoutSnapshot() {
|
|
1920
|
+
this.layoutSnapshot = {
|
|
1921
|
+
version: this.layoutSnapshot.version + 1,
|
|
1922
|
+
layout: this.layout,
|
|
1923
|
+
legend: this.legend,
|
|
1924
|
+
series: this.legendItems(),
|
|
1925
|
+
limits: this.limitLabels()
|
|
1926
|
+
};
|
|
1927
|
+
for (const t of this.layoutSubscribers) t();
|
|
1928
|
+
}
|
|
1929
|
+
pushHoverSnapshot() {
|
|
1930
|
+
this.hoverSnapshot = {
|
|
1931
|
+
version: this.hoverSnapshot.version + 1,
|
|
1932
|
+
hover: this.hover,
|
|
1933
|
+
tooltip: this.tooltip,
|
|
1934
|
+
xLabel: this.hoverXLabel
|
|
1935
|
+
};
|
|
1936
|
+
for (const t of this.hoverSubscribers) t();
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
/** Class name of the measuring span for tick labels - keeps the CSS and the
|
|
1940
|
+
layout in step. */
|
|
1941
|
+
g(oe, "classTick", ht);
|
|
1942
|
+
const ae = pe(null);
|
|
1943
|
+
function tt(n) {
|
|
1944
|
+
const t = ye(ae);
|
|
1945
|
+
if (t === null && st)
|
|
1946
|
+
throw new Error(
|
|
1947
|
+
`@umriss-ui/charts: <${n}> must be used inside a <Chart>.`
|
|
1948
|
+
);
|
|
1949
|
+
return t;
|
|
1950
|
+
}
|
|
1951
|
+
function J(n, t) {
|
|
1952
|
+
const e = tt(n), i = Z(null);
|
|
1953
|
+
D(() => {
|
|
1954
|
+
if (e !== null)
|
|
1955
|
+
return i.current = e.registerSeries(t), () => {
|
|
1956
|
+
i.current !== null && e.unregisterSeries(i.current), i.current = null;
|
|
1957
|
+
};
|
|
1958
|
+
}, [e]), D(() => {
|
|
1959
|
+
e !== null && i.current !== null && e.updateSeries(i.current, t);
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
function le(n, t) {
|
|
1963
|
+
const e = tt(n), i = Z(null);
|
|
1964
|
+
D(() => {
|
|
1965
|
+
if (e !== null)
|
|
1966
|
+
return i.current = e.registerAxis(t), () => {
|
|
1967
|
+
i.current !== null && e.unregisterAxis(i.current), i.current = null;
|
|
1968
|
+
};
|
|
1969
|
+
}, [e]), D(() => {
|
|
1970
|
+
e !== null && i.current !== null && e.updateAxis(i.current, t);
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
function ce(n, t) {
|
|
1974
|
+
const e = tt(n), i = Z(null);
|
|
1975
|
+
D(() => {
|
|
1976
|
+
if (e !== null)
|
|
1977
|
+
return i.current = e.registerLimit(t), () => {
|
|
1978
|
+
i.current !== null && e.unregisterLimit(i.current), i.current = null;
|
|
1979
|
+
};
|
|
1980
|
+
}, [e]), D(() => {
|
|
1981
|
+
e !== null && i.current !== null && e.updateLimit(i.current, t);
|
|
1982
|
+
});
|
|
1983
|
+
}
|
|
1984
|
+
function In(n, t) {
|
|
1985
|
+
const e = tt(n);
|
|
1986
|
+
D(() => {
|
|
1987
|
+
if (e !== null)
|
|
1988
|
+
return e.registerLegend(t), () => e.unregisterLegend();
|
|
1989
|
+
}, [e]), D(() => {
|
|
1990
|
+
e == null || e.updateLegend(t);
|
|
1991
|
+
});
|
|
1992
|
+
}
|
|
1993
|
+
function Sn(n, t) {
|
|
1994
|
+
const e = tt(n);
|
|
1995
|
+
D(() => {
|
|
1996
|
+
if (e !== null)
|
|
1997
|
+
return e.registerTooltip(t), () => e.unregisterTooltip();
|
|
1998
|
+
}, [e]), D(() => {
|
|
1999
|
+
e == null || e.updateTooltip(t);
|
|
2000
|
+
});
|
|
2001
|
+
}
|
|
2002
|
+
function Mn(n, t) {
|
|
2003
|
+
const { band: e, position: i, orientation: s } = n, r = {
|
|
2004
|
+
left: `${e.x}px`,
|
|
2005
|
+
top: `${e.y}px`,
|
|
2006
|
+
width: `${e.width}px`,
|
|
2007
|
+
height: `${e.height}px`
|
|
2008
|
+
}, o = Tt + At;
|
|
2009
|
+
return /* @__PURE__ */ B(
|
|
2010
|
+
"div",
|
|
2011
|
+
{
|
|
2012
|
+
className: `kc-axis kc-axis-${s} kc-axis-${i}`,
|
|
2013
|
+
style: r,
|
|
2014
|
+
"data-axis": n.id,
|
|
2015
|
+
children: [
|
|
2016
|
+
/* @__PURE__ */ I("span", { className: "kc-axis-line" }),
|
|
2017
|
+
n.ticks.map((a) => {
|
|
2018
|
+
if (s === "y") {
|
|
2019
|
+
const c = Math.round(a.px - e.y);
|
|
2020
|
+
return /* @__PURE__ */ B("span", { className: "kc-tick", style: { top: `${c}px` }, children: [
|
|
2021
|
+
/* @__PURE__ */ I("span", { className: "kc-tick-mark" }),
|
|
2022
|
+
/* @__PURE__ */ I(
|
|
2023
|
+
"span",
|
|
2024
|
+
{
|
|
2025
|
+
className: "kc-tick-label",
|
|
2026
|
+
style: { [i === "left" ? "right" : "left"]: `${o}px` },
|
|
2027
|
+
children: a.label
|
|
2028
|
+
}
|
|
2029
|
+
)
|
|
2030
|
+
] }, a.value);
|
|
2031
|
+
}
|
|
2032
|
+
const l = Math.round(a.px - e.x);
|
|
2033
|
+
return /* @__PURE__ */ B("span", { className: "kc-tick", style: { left: `${l}px` }, children: [
|
|
2034
|
+
/* @__PURE__ */ I("span", { className: "kc-tick-mark" }),
|
|
2035
|
+
/* @__PURE__ */ I(
|
|
2036
|
+
"span",
|
|
2037
|
+
{
|
|
2038
|
+
className: "kc-tick-label",
|
|
2039
|
+
style: {
|
|
2040
|
+
left: `${Math.round(a.labelLeft - e.x) - l}px`,
|
|
2041
|
+
[i === "top" ? "bottom" : "top"]: `${o}px`
|
|
2042
|
+
},
|
|
2043
|
+
children: a.label
|
|
2044
|
+
}
|
|
2045
|
+
)
|
|
2046
|
+
] }, a.value);
|
|
2047
|
+
}),
|
|
2048
|
+
n.breaks.map((a, l) => /* @__PURE__ */ I(
|
|
2049
|
+
"span",
|
|
2050
|
+
{
|
|
2051
|
+
className: "kc-break",
|
|
2052
|
+
style: { left: `${Math.round(a - e.x)}px` },
|
|
2053
|
+
"aria-hidden": "true"
|
|
2054
|
+
},
|
|
2055
|
+
`break-${l}`
|
|
2056
|
+
)),
|
|
2057
|
+
t.map(
|
|
2058
|
+
(a) => s === "y" ? /* @__PURE__ */ I(
|
|
2059
|
+
"span",
|
|
2060
|
+
{
|
|
2061
|
+
className: "kc-limit-label",
|
|
2062
|
+
"data-severity": a.severity,
|
|
2063
|
+
"data-role": a.role,
|
|
2064
|
+
style: { top: `${Math.round(a.px - e.y)}px` },
|
|
2065
|
+
children: a.label
|
|
2066
|
+
},
|
|
2067
|
+
`limit-${a.id}`
|
|
2068
|
+
) : /* @__PURE__ */ I(
|
|
2069
|
+
"span",
|
|
2070
|
+
{
|
|
2071
|
+
className: "kc-limit-label",
|
|
2072
|
+
"data-severity": a.severity,
|
|
2073
|
+
"data-role": a.role,
|
|
2074
|
+
style: {
|
|
2075
|
+
left: `${Math.round(a.px - e.x)}px`,
|
|
2076
|
+
[i === "top" ? "bottom" : "top"]: `${o}px`
|
|
2077
|
+
},
|
|
2078
|
+
children: a.label
|
|
2079
|
+
},
|
|
2080
|
+
`limit-${a.id}`
|
|
2081
|
+
)
|
|
2082
|
+
),
|
|
2083
|
+
n.label !== void 0 && n.label !== "" && /* @__PURE__ */ I("span", { className: "kc-axis-title", children: n.label })
|
|
2084
|
+
]
|
|
2085
|
+
},
|
|
2086
|
+
n.key
|
|
2087
|
+
);
|
|
2088
|
+
}
|
|
2089
|
+
function Tn({ scene: n }) {
|
|
2090
|
+
const t = Et(
|
|
2091
|
+
n.subscribeLayout,
|
|
2092
|
+
n.getLayoutSnapshot,
|
|
2093
|
+
n.getLayoutServerSnapshot
|
|
2094
|
+
), { layout: e } = t;
|
|
2095
|
+
return e.plot.width <= 0 || e.plot.height <= 0 ? null : /* @__PURE__ */ I("div", { className: "kc-axes", children: e.axes.map(
|
|
2096
|
+
(i) => Mn(
|
|
2097
|
+
i,
|
|
2098
|
+
t.limits.filter((s) => s.axisKey === i.key)
|
|
2099
|
+
)
|
|
2100
|
+
) });
|
|
2101
|
+
}
|
|
2102
|
+
function An(n) {
|
|
2103
|
+
var e;
|
|
2104
|
+
const t = (e = n.segment) == null ? void 0 : e.label;
|
|
2105
|
+
return t !== void 0 && t !== "" ? t : n.value !== void 0 ? _t(n.value) : _t(n.yValue);
|
|
2106
|
+
}
|
|
2107
|
+
function Ln({ scene: n }) {
|
|
2108
|
+
const t = Et(
|
|
2109
|
+
n.subscribeHover,
|
|
2110
|
+
n.getHoverSnapshot,
|
|
2111
|
+
n.getHoverServerSnapshot
|
|
2112
|
+
), e = ge(
|
|
2113
|
+
(s) => {
|
|
2114
|
+
n.bindTooltip(s);
|
|
2115
|
+
},
|
|
2116
|
+
[n]
|
|
2117
|
+
);
|
|
2118
|
+
if (D(() => {
|
|
2119
|
+
n.markOverlayDirty();
|
|
2120
|
+
}, [n, t.version]), t.tooltip === null) return null;
|
|
2121
|
+
const i = t.hover;
|
|
2122
|
+
return /* @__PURE__ */ I("div", { className: "kc-tooltip", ref: e, role: "presentation", children: i === null ? null : t.tooltip.render !== void 0 ? t.tooltip.render(i.hit) : /* @__PURE__ */ B(Nt, { children: [
|
|
2123
|
+
/* @__PURE__ */ I("div", { className: "kc-tooltip-head", children: t.xLabel }),
|
|
2124
|
+
/* @__PURE__ */ I("div", { className: "kc-tooltip-list", children: i.hit.points.map((s) => /* @__PURE__ */ B("div", { className: "kc-tooltip-row", children: [
|
|
2125
|
+
/* @__PURE__ */ I("span", { className: "kc-tooltip-chip", style: { background: s.color } }),
|
|
2126
|
+
/* @__PURE__ */ I("span", { className: "kc-tooltip-name", children: s.seriesName }),
|
|
2127
|
+
/* @__PURE__ */ I("span", { className: "kc-tooltip-value", children: An(s) })
|
|
2128
|
+
] }, `${s.seriesName}-${s.index}`)) })
|
|
2129
|
+
] }) });
|
|
2130
|
+
}
|
|
2131
|
+
function Zn(n) {
|
|
2132
|
+
const {
|
|
2133
|
+
data: t,
|
|
2134
|
+
width: e = "100%",
|
|
2135
|
+
height: i = 300,
|
|
2136
|
+
padding: s = 8,
|
|
2137
|
+
ariaLabel: r,
|
|
2138
|
+
className: o,
|
|
2139
|
+
style: a,
|
|
2140
|
+
onPerf: l,
|
|
2141
|
+
children: c
|
|
2142
|
+
} = n, [u] = be(() => new oe()), h = Z(null), p = Z(null), d = Z(null), m = Z(null), y = typeof s == "number" ? void 0 : s, f = typeof s == "number" ? s : void 0, b = f ?? (y == null ? void 0 : y.top), k = f ?? (y == null ? void 0 : y.right), N = f ?? (y == null ? void 0 : y.bottom), w = f ?? (y == null ? void 0 : y.left), L = E(
|
|
2143
|
+
() => ({
|
|
2144
|
+
top: b ?? 8,
|
|
2145
|
+
right: k ?? 8,
|
|
2146
|
+
bottom: N ?? 8,
|
|
2147
|
+
left: w ?? 8
|
|
2148
|
+
}),
|
|
2149
|
+
[b, k, N, w]
|
|
2150
|
+
);
|
|
2151
|
+
r === void 0 && q(
|
|
2152
|
+
"chart-arialabel",
|
|
2153
|
+
"Chart without ariaLabel - please set a meaningful description (R-7.6)."
|
|
2154
|
+
), D(() => {
|
|
2155
|
+
const S = h.current, H = p.current, R = d.current, v = m.current;
|
|
2156
|
+
if (!S || !H || !R || !v) return;
|
|
2157
|
+
u.bind(H, R, v, S);
|
|
2158
|
+
const M = H.getBoundingClientRect();
|
|
2159
|
+
u.requestResize(M.width, M.height);
|
|
2160
|
+
const x = new ResizeObserver(($) => {
|
|
2161
|
+
var C;
|
|
2162
|
+
const T = $[$.length - 1];
|
|
2163
|
+
if (T === void 0) return;
|
|
2164
|
+
const O = (C = T.contentBoxSize) == null ? void 0 : C[0];
|
|
2165
|
+
O !== void 0 ? u.requestResize(O.inlineSize, O.blockSize) : u.requestResize(T.contentRect.width, T.contentRect.height);
|
|
2166
|
+
});
|
|
2167
|
+
x.observe(H);
|
|
2168
|
+
const A = () => u.pointerLeave();
|
|
2169
|
+
return window.addEventListener("blur", A), () => {
|
|
2170
|
+
window.removeEventListener("blur", A), x.disconnect(), u.unbind();
|
|
2171
|
+
};
|
|
2172
|
+
}, [u]), D(() => {
|
|
2173
|
+
u.setData(t);
|
|
2174
|
+
}, [u, t]), D(() => {
|
|
2175
|
+
u.setPadding(L);
|
|
2176
|
+
}, [u, L]), D(() => {
|
|
2177
|
+
u.setOnPerf(l ?? null);
|
|
2178
|
+
}, [u, l]), D(() => {
|
|
2179
|
+
u.validate();
|
|
2180
|
+
});
|
|
2181
|
+
const F = {
|
|
2182
|
+
width: e === "100%" ? "100%" : `${e}px`,
|
|
2183
|
+
height: `${i}px`,
|
|
2184
|
+
...a
|
|
2185
|
+
}, P = (S) => {
|
|
2186
|
+
u.pointerMove(S.nativeEvent.offsetX, S.nativeEvent.offsetY);
|
|
2187
|
+
};
|
|
2188
|
+
return /* @__PURE__ */ I(ae.Provider, { value: u, children: /* @__PURE__ */ B(
|
|
2189
|
+
"div",
|
|
2190
|
+
{
|
|
2191
|
+
ref: h,
|
|
2192
|
+
className: o ? `kc-root ${o}` : "kc-root",
|
|
2193
|
+
style: F,
|
|
2194
|
+
children: [
|
|
2195
|
+
/* @__PURE__ */ B(
|
|
2196
|
+
"div",
|
|
2197
|
+
{
|
|
2198
|
+
ref: p,
|
|
2199
|
+
className: "kc-plot",
|
|
2200
|
+
role: "img",
|
|
2201
|
+
"aria-label": r,
|
|
2202
|
+
onPointerMove: P,
|
|
2203
|
+
onPointerLeave: () => u.pointerLeave(),
|
|
2204
|
+
children: [
|
|
2205
|
+
/* @__PURE__ */ I("canvas", { ref: d, className: "kc-layer-series", "aria-hidden": "true" }),
|
|
2206
|
+
/* @__PURE__ */ I("canvas", { ref: m, className: "kc-layer-overlay", "aria-hidden": "true" }),
|
|
2207
|
+
/* @__PURE__ */ I(Tn, { scene: u }),
|
|
2208
|
+
/* @__PURE__ */ I(Ln, { scene: u })
|
|
2209
|
+
]
|
|
2210
|
+
}
|
|
2211
|
+
),
|
|
2212
|
+
c
|
|
2213
|
+
]
|
|
2214
|
+
}
|
|
2215
|
+
) });
|
|
2216
|
+
}
|
|
2217
|
+
function Jn(n) {
|
|
2218
|
+
const {
|
|
2219
|
+
accessor: t,
|
|
2220
|
+
baseline: e,
|
|
2221
|
+
xAxisId: i = "x",
|
|
2222
|
+
yAxisId: s = "y",
|
|
2223
|
+
data: r,
|
|
2224
|
+
name: o,
|
|
2225
|
+
color: a,
|
|
2226
|
+
fillOpacity: l = 0.18,
|
|
2227
|
+
strokeWidth: c = 1.5
|
|
2228
|
+
} = n, u = E(
|
|
2229
|
+
() => ({
|
|
2230
|
+
kind: "area",
|
|
2231
|
+
accessor: t,
|
|
2232
|
+
baseline: e,
|
|
2233
|
+
xAxisId: i,
|
|
2234
|
+
yAxisId: s,
|
|
2235
|
+
data: r,
|
|
2236
|
+
name: o,
|
|
2237
|
+
color: a,
|
|
2238
|
+
fillOpacity: l,
|
|
2239
|
+
strokeWidth: c
|
|
2240
|
+
}),
|
|
2241
|
+
[t, e, i, s, r, o, a, l, c]
|
|
2242
|
+
);
|
|
2243
|
+
return J("Area", u), null;
|
|
2244
|
+
}
|
|
2245
|
+
function jn(n) {
|
|
2246
|
+
const {
|
|
2247
|
+
accessor: t,
|
|
2248
|
+
xAxisId: e = "x",
|
|
2249
|
+
yAxisId: i = "y",
|
|
2250
|
+
data: s,
|
|
2251
|
+
name: r,
|
|
2252
|
+
color: o,
|
|
2253
|
+
barWidth: a = 0.8
|
|
2254
|
+
} = n, l = E(
|
|
2255
|
+
() => ({
|
|
2256
|
+
kind: "bar",
|
|
2257
|
+
accessor: t,
|
|
2258
|
+
xAxisId: e,
|
|
2259
|
+
yAxisId: i,
|
|
2260
|
+
data: s,
|
|
2261
|
+
name: r,
|
|
2262
|
+
color: o,
|
|
2263
|
+
barWidth: a
|
|
2264
|
+
}),
|
|
2265
|
+
[t, e, i, s, r, o, a]
|
|
2266
|
+
);
|
|
2267
|
+
return J("Bar", l), null;
|
|
2268
|
+
}
|
|
2269
|
+
function Fn(n) {
|
|
2270
|
+
const {
|
|
2271
|
+
accessor: t,
|
|
2272
|
+
xAxisId: e = "x",
|
|
2273
|
+
yAxisId: i = "y",
|
|
2274
|
+
data: s,
|
|
2275
|
+
name: r,
|
|
2276
|
+
color: o,
|
|
2277
|
+
tone: a,
|
|
2278
|
+
strokeWidth: l = 1.5,
|
|
2279
|
+
dash: c,
|
|
2280
|
+
markers: u = "auto"
|
|
2281
|
+
} = n, h = E(
|
|
2282
|
+
() => ({
|
|
2283
|
+
kind: "line",
|
|
2284
|
+
accessor: t,
|
|
2285
|
+
xAxisId: e,
|
|
2286
|
+
yAxisId: i,
|
|
2287
|
+
data: s,
|
|
2288
|
+
name: r,
|
|
2289
|
+
color: o,
|
|
2290
|
+
tone: a,
|
|
2291
|
+
strokeWidth: l,
|
|
2292
|
+
dash: c,
|
|
2293
|
+
markers: u
|
|
2294
|
+
}),
|
|
2295
|
+
[t, e, i, s, r, o, a, l, c, u]
|
|
2296
|
+
);
|
|
2297
|
+
return J("Line", h), null;
|
|
2298
|
+
}
|
|
2299
|
+
function Pn(n) {
|
|
2300
|
+
const {
|
|
2301
|
+
accessor: t,
|
|
2302
|
+
xAxisId: e = "x",
|
|
2303
|
+
yAxisId: i = "y",
|
|
2304
|
+
data: s,
|
|
2305
|
+
name: r,
|
|
2306
|
+
color: o,
|
|
2307
|
+
tone: a,
|
|
2308
|
+
radius: l = 3
|
|
2309
|
+
} = n, c = E(
|
|
2310
|
+
() => ({
|
|
2311
|
+
kind: "scatter",
|
|
2312
|
+
accessor: t,
|
|
2313
|
+
xAxisId: e,
|
|
2314
|
+
yAxisId: i,
|
|
2315
|
+
data: s,
|
|
2316
|
+
name: r,
|
|
2317
|
+
color: o,
|
|
2318
|
+
tone: a,
|
|
2319
|
+
radius: l
|
|
2320
|
+
}),
|
|
2321
|
+
[t, e, i, s, r, o, a, l]
|
|
2322
|
+
);
|
|
2323
|
+
return J("Scatter", c), null;
|
|
2324
|
+
}
|
|
2325
|
+
function Qn(n) {
|
|
2326
|
+
const {
|
|
2327
|
+
accessor: t,
|
|
2328
|
+
states: e,
|
|
2329
|
+
xAxisId: i = "x",
|
|
2330
|
+
yAxisId: s = "y",
|
|
2331
|
+
data: r,
|
|
2332
|
+
name: o,
|
|
2333
|
+
laneFrom: a,
|
|
2334
|
+
laneTo: l
|
|
2335
|
+
} = n, c = E(
|
|
2336
|
+
() => ({
|
|
2337
|
+
kind: "state",
|
|
2338
|
+
accessor: t,
|
|
2339
|
+
states: e,
|
|
2340
|
+
xAxisId: i,
|
|
2341
|
+
yAxisId: s,
|
|
2342
|
+
data: r,
|
|
2343
|
+
name: o,
|
|
2344
|
+
laneFrom: a,
|
|
2345
|
+
laneTo: l
|
|
2346
|
+
}),
|
|
2347
|
+
[t, e, i, s, r, o, a, l]
|
|
2348
|
+
);
|
|
2349
|
+
return J("StateBand", c), null;
|
|
2350
|
+
}
|
|
2351
|
+
const En = [
|
|
2352
|
+
"#eef2ff",
|
|
2353
|
+
"#c7d2fe",
|
|
2354
|
+
"#a5b4fc",
|
|
2355
|
+
"#818cf8",
|
|
2356
|
+
"#6366f1",
|
|
2357
|
+
"#4f46e5",
|
|
2358
|
+
"#4338ca"
|
|
2359
|
+
];
|
|
2360
|
+
function ti(n) {
|
|
2361
|
+
const {
|
|
2362
|
+
accessor: t,
|
|
2363
|
+
value: e,
|
|
2364
|
+
coloring: i,
|
|
2365
|
+
xAxisId: s = "x",
|
|
2366
|
+
yAxisId: r = "y",
|
|
2367
|
+
data: o,
|
|
2368
|
+
name: a
|
|
2369
|
+
} = n, l = E(
|
|
2370
|
+
() => i ?? { kind: "gradient", stops: En },
|
|
2371
|
+
[i]
|
|
2372
|
+
), c = E(
|
|
2373
|
+
() => ({
|
|
2374
|
+
kind: "matrix",
|
|
2375
|
+
accessor: t,
|
|
2376
|
+
value: e,
|
|
2377
|
+
coloring: l,
|
|
2378
|
+
xAxisId: s,
|
|
2379
|
+
yAxisId: r,
|
|
2380
|
+
data: o,
|
|
2381
|
+
name: a
|
|
2382
|
+
}),
|
|
2383
|
+
[t, e, l, s, r, o, a]
|
|
2384
|
+
);
|
|
2385
|
+
return J("Matrix", c), null;
|
|
2386
|
+
}
|
|
2387
|
+
function ei(n) {
|
|
2388
|
+
const {
|
|
2389
|
+
accessor: t,
|
|
2390
|
+
to: e,
|
|
2391
|
+
xAxisId: i = "x",
|
|
2392
|
+
yAxisId: s = "y",
|
|
2393
|
+
data: r,
|
|
2394
|
+
name: o,
|
|
2395
|
+
color: a,
|
|
2396
|
+
height: l = 0.6
|
|
2397
|
+
} = n, c = E(
|
|
2398
|
+
() => ({
|
|
2399
|
+
kind: "span",
|
|
2400
|
+
accessor: t,
|
|
2401
|
+
to: e,
|
|
2402
|
+
xAxisId: i,
|
|
2403
|
+
yAxisId: s,
|
|
2404
|
+
data: r,
|
|
2405
|
+
name: o,
|
|
2406
|
+
color: a,
|
|
2407
|
+
height: l
|
|
2408
|
+
}),
|
|
2409
|
+
[t, e, i, s, r, o, a, l]
|
|
2410
|
+
);
|
|
2411
|
+
return J("Span", c), null;
|
|
2412
|
+
}
|
|
2413
|
+
function it(n) {
|
|
2414
|
+
const {
|
|
2415
|
+
value: t,
|
|
2416
|
+
axisId: e = "y",
|
|
2417
|
+
orientation: i = "y",
|
|
2418
|
+
severity: s = "alarm",
|
|
2419
|
+
label: r,
|
|
2420
|
+
color: o,
|
|
2421
|
+
inExtent: a = !0,
|
|
2422
|
+
role: l = "specification"
|
|
2423
|
+
} = n, c = E(
|
|
2424
|
+
() => ({
|
|
2425
|
+
kind: "line",
|
|
2426
|
+
value: t,
|
|
2427
|
+
axisId: e,
|
|
2428
|
+
orientation: i,
|
|
2429
|
+
severity: s,
|
|
2430
|
+
role: l,
|
|
2431
|
+
label: r,
|
|
2432
|
+
color: o,
|
|
2433
|
+
inExtent: a
|
|
2434
|
+
}),
|
|
2435
|
+
[t, e, i, s, l, r, o, a]
|
|
2436
|
+
);
|
|
2437
|
+
return ce("LimitLine", c), null;
|
|
2438
|
+
}
|
|
2439
|
+
function ni(n) {
|
|
2440
|
+
const {
|
|
2441
|
+
from: t,
|
|
2442
|
+
to: e,
|
|
2443
|
+
axisId: i = "y",
|
|
2444
|
+
orientation: s = "y",
|
|
2445
|
+
severity: r = "warning",
|
|
2446
|
+
label: o,
|
|
2447
|
+
color: a,
|
|
2448
|
+
inExtent: l = !0,
|
|
2449
|
+
role: c = "specification"
|
|
2450
|
+
} = n, u = E(
|
|
2451
|
+
() => ({
|
|
2452
|
+
kind: "band",
|
|
2453
|
+
from: t,
|
|
2454
|
+
to: e,
|
|
2455
|
+
axisId: i,
|
|
2456
|
+
orientation: s,
|
|
2457
|
+
severity: r,
|
|
2458
|
+
role: c,
|
|
2459
|
+
label: o,
|
|
2460
|
+
color: a,
|
|
2461
|
+
inExtent: l
|
|
2462
|
+
}),
|
|
2463
|
+
[t, e, i, s, r, c, o, a, l]
|
|
2464
|
+
);
|
|
2465
|
+
return ce("LimitBand", u), null;
|
|
2466
|
+
}
|
|
2467
|
+
const Dn = 1.128;
|
|
2468
|
+
function kt(n, t) {
|
|
2469
|
+
return {
|
|
2470
|
+
center: n,
|
|
2471
|
+
sigma: t,
|
|
2472
|
+
upper: n + 3 * t,
|
|
2473
|
+
lower: n - 3 * t
|
|
2474
|
+
};
|
|
2475
|
+
}
|
|
2476
|
+
function ii(n, t) {
|
|
2477
|
+
return (t - n) / 3;
|
|
2478
|
+
}
|
|
2479
|
+
function $n(n, t) {
|
|
2480
|
+
if (t.kind === "given")
|
|
2481
|
+
return kt(t.center, t.sigma);
|
|
2482
|
+
const e = Math.max(0, Math.trunc(t.from)), i = Math.min(n.length, Math.trunc(t.to));
|
|
2483
|
+
let s = 0, r = 0, o = 0, a = 0, l = Number.NaN;
|
|
2484
|
+
for (let u = e; u < i; u++) {
|
|
2485
|
+
const h = n[u];
|
|
2486
|
+
if (!Number.isFinite(h)) {
|
|
2487
|
+
l = Number.NaN;
|
|
2488
|
+
continue;
|
|
2489
|
+
}
|
|
2490
|
+
s += h, r++, Number.isFinite(l) && (o += Math.abs(h - l), a++), l = h;
|
|
2491
|
+
}
|
|
2492
|
+
if (r === 0) return kt(Number.NaN, Number.NaN);
|
|
2493
|
+
const c = a === 0 ? 0 : o / a / Dn;
|
|
2494
|
+
return kt(s / r, c);
|
|
2495
|
+
}
|
|
2496
|
+
function Cn(n, t = [1, 2]) {
|
|
2497
|
+
return t.map((e) => ({
|
|
2498
|
+
k: e,
|
|
2499
|
+
upper: n.center + e * n.sigma,
|
|
2500
|
+
lower: n.center - e * n.sigma
|
|
2501
|
+
}));
|
|
2502
|
+
}
|
|
2503
|
+
function Wn(n, t) {
|
|
2504
|
+
return Number.isFinite(n) ? n > t ? 1 : n < t ? -1 : 0 : 0;
|
|
2505
|
+
}
|
|
2506
|
+
function ue(n, t) {
|
|
2507
|
+
const e = [];
|
|
2508
|
+
if (t < 1) return e;
|
|
2509
|
+
let i = 0;
|
|
2510
|
+
for (let s = 1; s <= n.length; s++) {
|
|
2511
|
+
const r = s < n.length ? n[s] : Number.NaN, o = n[i];
|
|
2512
|
+
if (r !== o) {
|
|
2513
|
+
if (o !== 0 && s - i >= t)
|
|
2514
|
+
for (let a = i; a < s; a++) e.push(a);
|
|
2515
|
+
i = s;
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
return e;
|
|
2519
|
+
}
|
|
2520
|
+
const $t = {
|
|
2521
|
+
outlier: !0,
|
|
2522
|
+
run: !0,
|
|
2523
|
+
trend: !0,
|
|
2524
|
+
twoOfThree: !0,
|
|
2525
|
+
runLength: 9,
|
|
2526
|
+
trendLength: 6
|
|
2527
|
+
};
|
|
2528
|
+
function On(n, t) {
|
|
2529
|
+
const e = [];
|
|
2530
|
+
for (let i = 0; i < n.length; i++) {
|
|
2531
|
+
const s = n[i];
|
|
2532
|
+
(s > t.upper || s < t.lower) && e.push(i);
|
|
2533
|
+
}
|
|
2534
|
+
return e;
|
|
2535
|
+
}
|
|
2536
|
+
function Hn(n, t, e = $t.runLength) {
|
|
2537
|
+
return ue(
|
|
2538
|
+
n.map((i) => Wn(i, t.center)),
|
|
2539
|
+
e
|
|
2540
|
+
);
|
|
2541
|
+
}
|
|
2542
|
+
function Rn(n, t = $t.trendLength) {
|
|
2543
|
+
const e = [];
|
|
2544
|
+
for (let s = 1; s < n.length; s++) {
|
|
2545
|
+
const r = n[s - 1], o = n[s];
|
|
2546
|
+
e.push(Number.isFinite(r) && Number.isFinite(o) ? Math.sign(o - r) : 0);
|
|
2547
|
+
}
|
|
2548
|
+
const i = [];
|
|
2549
|
+
for (const s of ue(e, Math.max(1, t - 1)))
|
|
2550
|
+
i[i.length - 1] !== s && i.push(s), i.push(s + 1);
|
|
2551
|
+
return i;
|
|
2552
|
+
}
|
|
2553
|
+
function Vn(n, t) {
|
|
2554
|
+
const e = t.center + 2 * t.sigma, i = t.center - 2 * t.sigma, s = /* @__PURE__ */ new Set();
|
|
2555
|
+
for (let r = 0; r + 2 < n.length; r++)
|
|
2556
|
+
for (const o of [
|
|
2557
|
+
[r, r + 1, r + 2].filter((a) => n[a] > e),
|
|
2558
|
+
[r, r + 1, r + 2].filter((a) => n[a] < i)
|
|
2559
|
+
])
|
|
2560
|
+
if (o.length >= 2) for (const a of o) s.add(a);
|
|
2561
|
+
return [...s].sort((r, o) => r - o);
|
|
2562
|
+
}
|
|
2563
|
+
function _n(n, t, e = {}) {
|
|
2564
|
+
const i = { ...$t, ...e }, s = [], r = (o, a) => {
|
|
2565
|
+
a.length > 0 && s.push({ rule: o, indices: a });
|
|
2566
|
+
};
|
|
2567
|
+
return i.outlier && r("outlier", On(n, t)), i.run && r("run", Hn(n, t, i.runLength)), i.trend && r("trend", Rn(n, i.trendLength)), i.twoOfThree && r("twoOfThree", Vn(n, t)), s;
|
|
2568
|
+
}
|
|
2569
|
+
function Bn(n) {
|
|
2570
|
+
const t = /* @__PURE__ */ new Set();
|
|
2571
|
+
for (const e of n) for (const i of e.indices) t.add(i);
|
|
2572
|
+
return [...t].sort((e, i) => e - i);
|
|
2573
|
+
}
|
|
2574
|
+
function si(n) {
|
|
2575
|
+
const {
|
|
2576
|
+
accessor: t,
|
|
2577
|
+
data: e,
|
|
2578
|
+
origin: i,
|
|
2579
|
+
xAxisId: s = "x",
|
|
2580
|
+
yAxisId: r = "y",
|
|
2581
|
+
name: o,
|
|
2582
|
+
color: a,
|
|
2583
|
+
rules: l,
|
|
2584
|
+
zoneLines: c = !0,
|
|
2585
|
+
labelUpper: u,
|
|
2586
|
+
labelLower: h,
|
|
2587
|
+
violationName: p,
|
|
2588
|
+
onViolations: d
|
|
2589
|
+
} = n, m = E(() => {
|
|
2590
|
+
const F = [];
|
|
2591
|
+
for (let P = 0; P < e.length; P++) {
|
|
2592
|
+
const S = t(e[P], P);
|
|
2593
|
+
F.push(S ?? Number.NaN);
|
|
2594
|
+
}
|
|
2595
|
+
return F;
|
|
2596
|
+
}, [e, t]), y = E(() => $n(m, i), [m, i]), f = E(
|
|
2597
|
+
() => _n(m, y, l ?? {}),
|
|
2598
|
+
[m, y, l]
|
|
2599
|
+
), b = E(() => new Set(Bn(f)), [f]);
|
|
2600
|
+
D(() => {
|
|
2601
|
+
d == null || d(f);
|
|
2602
|
+
}, [f, d]);
|
|
2603
|
+
const k = E(
|
|
2604
|
+
() => (F, P) => b.has(P) ? t(F, P) : null,
|
|
2605
|
+
[b, t]
|
|
2606
|
+
), N = E(
|
|
2607
|
+
() => b.size === 0 ? e : e.slice(),
|
|
2608
|
+
[e, b]
|
|
2609
|
+
), w = E(
|
|
2610
|
+
() => c ? Cn(y, [1, 2]) : [],
|
|
2611
|
+
[c, y]
|
|
2612
|
+
), L = Number.isFinite(y.center);
|
|
2613
|
+
return /* @__PURE__ */ B(Nt, { children: [
|
|
2614
|
+
/* @__PURE__ */ I(Fn, { accessor: t, data: e, xAxisId: s, yAxisId: r, name: o, color: a }),
|
|
2615
|
+
L && /* @__PURE__ */ B(Nt, { children: [
|
|
2616
|
+
w.map((F) => /* @__PURE__ */ I(
|
|
2617
|
+
it,
|
|
2618
|
+
{
|
|
2619
|
+
value: F.upper,
|
|
2620
|
+
axisId: r,
|
|
2621
|
+
role: "zone",
|
|
2622
|
+
inExtent: !1
|
|
2623
|
+
},
|
|
2624
|
+
`zone-${F.k}-upper`
|
|
2625
|
+
)),
|
|
2626
|
+
w.map((F) => /* @__PURE__ */ I(
|
|
2627
|
+
it,
|
|
2628
|
+
{
|
|
2629
|
+
value: F.lower,
|
|
2630
|
+
axisId: r,
|
|
2631
|
+
role: "zone",
|
|
2632
|
+
inExtent: !1
|
|
2633
|
+
},
|
|
2634
|
+
`zone-${F.k}-lower`
|
|
2635
|
+
)),
|
|
2636
|
+
/* @__PURE__ */ I(it, { value: y.center, axisId: r, role: "control" }),
|
|
2637
|
+
/* @__PURE__ */ I(it, { value: y.upper, axisId: r, role: "control", label: u }),
|
|
2638
|
+
/* @__PURE__ */ I(it, { value: y.lower, axisId: r, role: "control", label: h })
|
|
2639
|
+
] }),
|
|
2640
|
+
/* @__PURE__ */ I(
|
|
2641
|
+
Pn,
|
|
2642
|
+
{
|
|
2643
|
+
accessor: k,
|
|
2644
|
+
data: N,
|
|
2645
|
+
xAxisId: s,
|
|
2646
|
+
yAxisId: r,
|
|
2647
|
+
name: p,
|
|
2648
|
+
tone: "alarm",
|
|
2649
|
+
radius: 4
|
|
2650
|
+
}
|
|
2651
|
+
)
|
|
2652
|
+
] });
|
|
2653
|
+
}
|
|
2654
|
+
function ri(n) {
|
|
2655
|
+
const {
|
|
2656
|
+
id: t = "x",
|
|
2657
|
+
position: e = "bottom",
|
|
2658
|
+
accessor: i,
|
|
2659
|
+
label: s,
|
|
2660
|
+
tickCount: r,
|
|
2661
|
+
tickFormat: o,
|
|
2662
|
+
domain: a = "nice",
|
|
2663
|
+
grid: l,
|
|
2664
|
+
ticks: c,
|
|
2665
|
+
calendar: u
|
|
2666
|
+
} = n, h = E(
|
|
2667
|
+
() => ({
|
|
2668
|
+
id: t,
|
|
2669
|
+
orientation: "x",
|
|
2670
|
+
position: e,
|
|
2671
|
+
accessor: i,
|
|
2672
|
+
label: s,
|
|
2673
|
+
tickCount: r,
|
|
2674
|
+
tickFormat: o,
|
|
2675
|
+
domain: a,
|
|
2676
|
+
grid: l,
|
|
2677
|
+
ticks: c,
|
|
2678
|
+
calendar: u
|
|
2679
|
+
}),
|
|
2680
|
+
[t, e, i, s, r, o, a, l, c, u]
|
|
2681
|
+
);
|
|
2682
|
+
return le("XAxis", h), null;
|
|
2683
|
+
}
|
|
2684
|
+
function oi(n) {
|
|
2685
|
+
const {
|
|
2686
|
+
id: t = "y",
|
|
2687
|
+
position: e = "left",
|
|
2688
|
+
accessor: i,
|
|
2689
|
+
label: s,
|
|
2690
|
+
tickCount: r,
|
|
2691
|
+
tickFormat: o,
|
|
2692
|
+
domain: a = "nice",
|
|
2693
|
+
grid: l,
|
|
2694
|
+
ticks: c
|
|
2695
|
+
} = n, u = E(
|
|
2696
|
+
() => ({
|
|
2697
|
+
id: t,
|
|
2698
|
+
orientation: "y",
|
|
2699
|
+
position: e,
|
|
2700
|
+
accessor: i,
|
|
2701
|
+
label: s,
|
|
2702
|
+
tickCount: r,
|
|
2703
|
+
tickFormat: o,
|
|
2704
|
+
domain: a,
|
|
2705
|
+
grid: l,
|
|
2706
|
+
ticks: c
|
|
2707
|
+
}),
|
|
2708
|
+
[t, e, i, s, r, o, a, l, c]
|
|
2709
|
+
);
|
|
2710
|
+
return le("YAxis", u), null;
|
|
2711
|
+
}
|
|
2712
|
+
function Yn({
|
|
2713
|
+
scene: n,
|
|
2714
|
+
placement: t
|
|
2715
|
+
}) {
|
|
2716
|
+
In("Legend", { placement: t });
|
|
2717
|
+
const e = Et(
|
|
2718
|
+
n.subscribeLayout,
|
|
2719
|
+
n.getLayoutSnapshot,
|
|
2720
|
+
n.getLayoutServerSnapshot
|
|
2721
|
+
);
|
|
2722
|
+
return e.series.length === 0 ? null : /* @__PURE__ */ I("div", { className: `kc-legend kc-legend-${t}`, children: e.series.map((i) => /* @__PURE__ */ B(
|
|
2723
|
+
"span",
|
|
2724
|
+
{
|
|
2725
|
+
className: "kc-legend-item",
|
|
2726
|
+
onPointerEnter: () => n.setHighlight(i.seriesId),
|
|
2727
|
+
onPointerLeave: () => n.setHighlight(null),
|
|
2728
|
+
children: [
|
|
2729
|
+
/* @__PURE__ */ I("span", { className: "kc-legend-chip", style: { background: i.color } }),
|
|
2730
|
+
i.name
|
|
2731
|
+
]
|
|
2732
|
+
},
|
|
2733
|
+
i.id
|
|
2734
|
+
)) });
|
|
2735
|
+
}
|
|
2736
|
+
function ai({ placement: n = "top" }) {
|
|
2737
|
+
const t = tt("Legend");
|
|
2738
|
+
return t === null ? null : /* @__PURE__ */ I(Yn, { scene: t, placement: n });
|
|
2739
|
+
}
|
|
2740
|
+
function li(n) {
|
|
2741
|
+
const { mode: t = "x", render: e } = n, i = E(
|
|
2742
|
+
() => ({ mode: t, render: e }),
|
|
2743
|
+
[t, e]
|
|
2744
|
+
);
|
|
2745
|
+
return Sn("Tooltip", i), null;
|
|
2746
|
+
}
|
|
2747
|
+
const zn = {
|
|
2748
|
+
cutoff: 0.8,
|
|
2749
|
+
collectRank: Number.POSITIVE_INFINITY
|
|
2750
|
+
};
|
|
2751
|
+
function ci(n, t = {}) {
|
|
2752
|
+
const e = { ...zn, ...t };
|
|
2753
|
+
ut(
|
|
2754
|
+
!Number.isFinite(e.collectRank) || e.remainderName !== void 0,
|
|
2755
|
+
"pareto: a collect rank needs `remainderName` - the package brings no name for the remainder."
|
|
2756
|
+
);
|
|
2757
|
+
const i = n.map((d, m) => ({ item: d, inputIndex: m })).sort((d, m) => m.item.value - d.item.value || d.inputIndex - m.inputIndex).map(({ item: d }) => d), s = Math.max(0, Math.min(i.length, Math.floor(e.collectRank))), r = i.slice(0, s), o = i.slice(s), a = o.length === 0 ? r : [...r, { name: e.remainderName ?? "", value: o.reduce((d, m) => d + m.value, 0) }], l = a.reduce((d, m) => d + m.value, 0), c = [];
|
|
2758
|
+
let u = 0;
|
|
2759
|
+
for (let d = 0; d < a.length; d++) {
|
|
2760
|
+
const m = a[d];
|
|
2761
|
+
u += m.value, c.push({
|
|
2762
|
+
name: m.name,
|
|
2763
|
+
value: m.value,
|
|
2764
|
+
index: d,
|
|
2765
|
+
share: l === 0 ? 0 : m.value / l,
|
|
2766
|
+
cumulative: l === 0 ? 0 : u / l,
|
|
2767
|
+
remainder: o.length > 0 && d === a.length - 1
|
|
2768
|
+
});
|
|
2769
|
+
}
|
|
2770
|
+
const h = Math.abs(e.cutoff) * 1e-12, p = c.findIndex((d) => d.cumulative >= e.cutoff - h);
|
|
2771
|
+
return { entries: c, total: l, cutoffIndex: p };
|
|
2772
|
+
}
|
|
2773
|
+
export {
|
|
2774
|
+
Jn as Area,
|
|
2775
|
+
jn as Bar,
|
|
2776
|
+
Zn as Chart,
|
|
2777
|
+
si as ControlChart,
|
|
2778
|
+
X as DAY,
|
|
2779
|
+
En as DEFAULT_GRADIENT,
|
|
2780
|
+
Q as HOUR,
|
|
2781
|
+
ai as Legend,
|
|
2782
|
+
ni as LimitBand,
|
|
2783
|
+
it as LimitLine,
|
|
2784
|
+
Fn as Line,
|
|
2785
|
+
Vt as LinearScale,
|
|
2786
|
+
U as MINUTE,
|
|
2787
|
+
ti as Matrix,
|
|
2788
|
+
K as SECOND,
|
|
2789
|
+
Pn as Scatter,
|
|
2790
|
+
ei as Span,
|
|
2791
|
+
Qn as StateBand,
|
|
2792
|
+
li as Tooltip,
|
|
2793
|
+
ri as XAxis,
|
|
2794
|
+
oi as YAxis,
|
|
2795
|
+
rn as assess,
|
|
2796
|
+
Ce as breaks,
|
|
2797
|
+
G as calendarFrom,
|
|
2798
|
+
$n as controlLimits,
|
|
2799
|
+
$t as defaultRules,
|
|
2800
|
+
we as invalidateTheme,
|
|
2801
|
+
Un as mapSeries,
|
|
2802
|
+
Fe as operatingCalendar,
|
|
2803
|
+
He as operatingTicks,
|
|
2804
|
+
Oe as operatingTimeTicks,
|
|
2805
|
+
ci as pareto,
|
|
2806
|
+
zn as paretoDefaults,
|
|
2807
|
+
$e as removedIntervals,
|
|
2808
|
+
On as ruleOutlier,
|
|
2809
|
+
Hn as ruleRun,
|
|
2810
|
+
Rn as ruleTrend,
|
|
2811
|
+
Vn as ruleTwoOfThree,
|
|
2812
|
+
ii as sigmaFromLimit,
|
|
2813
|
+
We as timeStep,
|
|
2814
|
+
yt as toOperatingTime,
|
|
2815
|
+
ft as toWallClock,
|
|
2816
|
+
Xn as verdictWeight,
|
|
2817
|
+
Bn as violatedIndices,
|
|
2818
|
+
_n as violations,
|
|
2819
|
+
Cn as zones
|
|
2820
|
+
};
|