uplot-plus 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -62
- package/package.json +1 -1
- package/dist/annotations.d.ts +0 -22
- package/dist/annotations.d.ts.map +0 -1
- package/dist/axes/layout.d.ts +0 -30
- package/dist/axes/layout.d.ts.map +0 -1
- package/dist/axes/ticks.d.ts +0 -47
- package/dist/axes/ticks.d.ts.map +0 -1
- package/dist/colors.d.ts +0 -32
- package/dist/colors.d.ts.map +0 -1
- package/dist/components/Axis.d.ts +0 -14
- package/dist/components/Axis.d.ts.map +0 -1
- package/dist/components/Band.d.ts +0 -10
- package/dist/components/Band.d.ts.map +0 -1
- package/dist/components/Chart.d.ts +0 -8
- package/dist/components/Chart.d.ts.map +0 -1
- package/dist/components/Legend.d.ts +0 -12
- package/dist/components/Legend.d.ts.map +0 -1
- package/dist/components/ResponsiveChart.d.ts +0 -18
- package/dist/components/ResponsiveChart.d.ts.map +0 -1
- package/dist/components/Scale.d.ts +0 -11
- package/dist/components/Scale.d.ts.map +0 -1
- package/dist/components/Series.d.ts +0 -11
- package/dist/components/Series.d.ts.map +0 -1
- package/dist/components/Sparkline.d.ts +0 -28
- package/dist/components/Sparkline.d.ts.map +0 -1
- package/dist/components/Timeline.d.ts +0 -8
- package/dist/components/Timeline.d.ts.map +0 -1
- package/dist/components/Tooltip.d.ts +0 -9
- package/dist/components/Tooltip.d.ts.map +0 -1
- package/dist/components/ZoomRanger.d.ts +0 -26
- package/dist/components/ZoomRanger.d.ts.map +0 -1
- package/dist/components/annotations/AnnotationLabel.d.ts +0 -26
- package/dist/components/annotations/AnnotationLabel.d.ts.map +0 -1
- package/dist/components/annotations/HLine.d.ts +0 -22
- package/dist/components/annotations/HLine.d.ts.map +0 -1
- package/dist/components/annotations/Region.d.ts +0 -22
- package/dist/components/annotations/Region.d.ts.map +0 -1
- package/dist/components/annotations/VLine.d.ts +0 -22
- package/dist/components/annotations/VLine.d.ts.map +0 -1
- package/dist/components/annotations/index.d.ts +0 -9
- package/dist/components/annotations/index.d.ts.map +0 -1
- package/dist/core/BlockMinMax.d.ts +0 -42
- package/dist/core/BlockMinMax.d.ts.map +0 -1
- package/dist/core/CursorManager.d.ts +0 -43
- package/dist/core/CursorManager.d.ts.map +0 -1
- package/dist/core/DataStore.d.ts +0 -51
- package/dist/core/DataStore.d.ts.map +0 -1
- package/dist/core/RenderScheduler.d.ts +0 -28
- package/dist/core/RenderScheduler.d.ts.map +0 -1
- package/dist/core/Scale.d.ts +0 -23
- package/dist/core/Scale.d.ts.map +0 -1
- package/dist/core/ScaleManager.d.ts +0 -45
- package/dist/core/ScaleManager.d.ts.map +0 -1
- package/dist/formatters.d.ts +0 -39
- package/dist/formatters.d.ts.map +0 -1
- package/dist/hooks/useChart.d.ts +0 -5
- package/dist/hooks/useChart.d.ts.map +0 -1
- package/dist/hooks/useChartStore.d.ts +0 -69
- package/dist/hooks/useChartStore.d.ts.map +0 -1
- package/dist/hooks/useDrawHook.d.ts +0 -14
- package/dist/hooks/useDrawHook.d.ts.map +0 -1
- package/dist/hooks/useInteraction.d.ts +0 -14
- package/dist/hooks/useInteraction.d.ts.map +0 -1
- package/dist/hooks/useStreamingData.d.ts +0 -35
- package/dist/hooks/useStreamingData.d.ts.map +0 -1
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +0 -47
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3203
- package/dist/math/align.d.ts +0 -10
- package/dist/math/align.d.ts.map +0 -1
- package/dist/math/increments.d.ts +0 -9
- package/dist/math/increments.d.ts.map +0 -1
- package/dist/math/stack.d.ts +0 -16
- package/dist/math/stack.d.ts.map +0 -1
- package/dist/math/utils.d.ts +0 -74
- package/dist/math/utils.d.ts.map +0 -1
- package/dist/paths/bars.d.ts +0 -9
- package/dist/paths/bars.d.ts.map +0 -1
- package/dist/paths/candlestick.d.ts +0 -35
- package/dist/paths/candlestick.d.ts.map +0 -1
- package/dist/paths/catmullRom.d.ts +0 -9
- package/dist/paths/catmullRom.d.ts.map +0 -1
- package/dist/paths/linear.d.ts +0 -10
- package/dist/paths/linear.d.ts.map +0 -1
- package/dist/paths/monotoneCubic.d.ts +0 -10
- package/dist/paths/monotoneCubic.d.ts.map +0 -1
- package/dist/paths/points.d.ts +0 -10
- package/dist/paths/points.d.ts.map +0 -1
- package/dist/paths/spline.d.ts +0 -9
- package/dist/paths/spline.d.ts.map +0 -1
- package/dist/paths/stepped.d.ts +0 -9
- package/dist/paths/stepped.d.ts.map +0 -1
- package/dist/paths/types.d.ts +0 -32
- package/dist/paths/types.d.ts.map +0 -1
- package/dist/paths/utils.d.ts +0 -19
- package/dist/paths/utils.d.ts.map +0 -1
- package/dist/rendering/CanvasRenderer.d.ts +0 -75
- package/dist/rendering/CanvasRenderer.d.ts.map +0 -1
- package/dist/rendering/drawAxes.d.ts +0 -8
- package/dist/rendering/drawAxes.d.ts.map +0 -1
- package/dist/rendering/drawBands.d.ts +0 -8
- package/dist/rendering/drawBands.d.ts.map +0 -1
- package/dist/rendering/drawCursor.d.ts +0 -22
- package/dist/rendering/drawCursor.d.ts.map +0 -1
- package/dist/rendering/drawPoints.d.ts +0 -13
- package/dist/rendering/drawPoints.d.ts.map +0 -1
- package/dist/rendering/drawSelect.d.ts +0 -14
- package/dist/rendering/drawSelect.d.ts.map +0 -1
- package/dist/rendering/drawSeries.d.ts +0 -7
- package/dist/rendering/drawSeries.d.ts.map +0 -1
- package/dist/sync/SyncGroup.d.ts +0 -33
- package/dist/sync/SyncGroup.d.ts.map +0 -1
- package/dist/sync/useSyncGroup.d.ts +0 -8
- package/dist/sync/useSyncGroup.d.ts.map +0 -1
- package/dist/time/fmtDate.d.ts +0 -15
- package/dist/time/fmtDate.d.ts.map +0 -1
- package/dist/time/timeIncrs.d.ts +0 -17
- package/dist/time/timeIncrs.d.ts.map +0 -1
- package/dist/time/timeSplits.d.ts +0 -6
- package/dist/time/timeSplits.d.ts.map +0 -1
- package/dist/time/timeVals.d.ts +0 -16
- package/dist/time/timeVals.d.ts.map +0 -1
- package/dist/types/axes.d.ts +0 -84
- package/dist/types/axes.d.ts.map +0 -1
- package/dist/types/bands.d.ts +0 -12
- package/dist/types/bands.d.ts.map +0 -1
- package/dist/types/chart.d.ts +0 -53
- package/dist/types/chart.d.ts.map +0 -1
- package/dist/types/common.d.ts +0 -62
- package/dist/types/common.d.ts.map +0 -1
- package/dist/types/cursor.d.ts +0 -22
- package/dist/types/cursor.d.ts.map +0 -1
- package/dist/types/data.d.ts +0 -32
- package/dist/types/data.d.ts.map +0 -1
- package/dist/types/events.d.ts +0 -57
- package/dist/types/events.d.ts.map +0 -1
- package/dist/types/hooks.d.ts +0 -28
- package/dist/types/hooks.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -10
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/legend.d.ts +0 -8
- package/dist/types/legend.d.ts.map +0 -1
- package/dist/types/scales.d.ts +0 -60
- package/dist/types/scales.d.ts.map +0 -1
- package/dist/types/series.d.ts +0 -76
- package/dist/types/series.d.ts.map +0 -1
- package/dist/types/timeline.d.ts +0 -30
- package/dist/types/timeline.d.ts.map +0 -1
- package/dist/types/tooltip.d.ts +0 -33
- package/dist/types/tooltip.d.ts.map +0 -1
- package/dist/utils/shallowEqual.d.ts +0 -10
- package/dist/utils/shallowEqual.d.ts.map +0 -1
package/dist/index.js
DELETED
|
@@ -1,3203 +0,0 @@
|
|
|
1
|
-
import { jsx as E, jsxs as J, Fragment as Ae } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as X, useContext as Pe, createContext as Le, useEffect as Y, useState as vt, useCallback as K, useSyncExternalStore as fe, memo as ze, useLayoutEffect as Dt } from "react";
|
|
3
|
-
var U = /* @__PURE__ */ ((t) => (t[t.Top = 0] = "Top", t[t.Right = 1] = "Right", t[t.Bottom = 2] = "Bottom", t[t.Left = 3] = "Left", t))(U || {}), G = /* @__PURE__ */ ((t) => (t[t.Horizontal = 0] = "Horizontal", t[t.Vertical = 1] = "Vertical", t))(G || {}), O = /* @__PURE__ */ ((t) => (t[t.Forward = 1] = "Forward", t[t.Backward = -1] = "Backward", t))(O || {}), N = /* @__PURE__ */ ((t) => (t[t.Linear = 1] = "Linear", t[t.Ordinal = 2] = "Ordinal", t[t.Log = 3] = "Log", t[t.Asinh = 4] = "Asinh", t))(N || {}), yt = /* @__PURE__ */ ((t) => (t[t.Ascending = 1] = "Ascending", t[t.Descending = -1] = "Descending", t[t.Unsorted = 0] = "Unsorted", t))(yt || {});
|
|
4
|
-
function Mt(t) {
|
|
5
|
-
return t % 2;
|
|
6
|
-
}
|
|
7
|
-
var Q = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.Scales = 1] = "Scales", t[t.Axes = 2] = "Axes", t[t.Paths = 4] = "Paths", t[t.Cursor = 8] = "Cursor", t[t.Select = 16] = "Select", t[t.Size = 32] = "Size", t[t.Full = 63] = "Full", t))(Q || {});
|
|
8
|
-
const q = Math, Vt = q.PI, gt = q.abs, nt = q.floor, H = q.round, Tt = q.ceil, qt = q.min, kt = q.max, wt = q.pow, Zt = q.sign, tt = q.log10, St = q.log2, De = (t, e = 1) => q.sinh(t) * e, Wt = (t, e = 1) => q.asinh(t / e), j = 1 / 0, he = Number.isInteger;
|
|
9
|
-
function Ht(t, e) {
|
|
10
|
-
return t[e] ?? 0;
|
|
11
|
-
}
|
|
12
|
-
function ct(t, e, n = 0, s = e.length - 1) {
|
|
13
|
-
let o;
|
|
14
|
-
const i = s <= 2147483647;
|
|
15
|
-
for (; s - n > 1; )
|
|
16
|
-
o = i ? n + s >> 1 : nt((n + s) / 2), Ht(e, o) < t ? n = o : s = o;
|
|
17
|
-
return t - Ht(e, n) <= Ht(e, s) - t ? n : s;
|
|
18
|
-
}
|
|
19
|
-
const de = (t) => t != null, ge = (t) => t != null && t > 0;
|
|
20
|
-
function pe(t) {
|
|
21
|
-
return (e, n, s) => {
|
|
22
|
-
let o = -1, i = -1;
|
|
23
|
-
for (let l = n; l <= s; l++)
|
|
24
|
-
if (t(e[l])) {
|
|
25
|
-
o = l;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
for (let l = s; l >= n; l--)
|
|
29
|
-
if (t(e[l])) {
|
|
30
|
-
i = l;
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
return [o, i];
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
const Ft = pe(de), me = pe(ge);
|
|
37
|
-
function Fe(t, e, n, s = yt.Unsorted, o = !1) {
|
|
38
|
-
const i = o ? me : Ft, l = o ? ge : de, [r, a] = i(t, e, n);
|
|
39
|
-
let c = t[r] ?? j, u = t[r] ?? -j;
|
|
40
|
-
if (r > -1)
|
|
41
|
-
if (s === yt.Ascending)
|
|
42
|
-
c = t[r] ?? j, u = t[a] ?? -j;
|
|
43
|
-
else if (s === yt.Descending)
|
|
44
|
-
c = t[a] ?? j, u = t[r] ?? -j;
|
|
45
|
-
else
|
|
46
|
-
for (let h = r; h <= a; h++) {
|
|
47
|
-
const f = t[h];
|
|
48
|
-
f != null && l(f) && (f < c ? c = f : f > u && (u = f));
|
|
49
|
-
}
|
|
50
|
-
return [c, u];
|
|
51
|
-
}
|
|
52
|
-
function ut(t, e = 0) {
|
|
53
|
-
if (he(t))
|
|
54
|
-
return t;
|
|
55
|
-
const n = 10 ** e, s = t * n * (1 + Number.EPSILON);
|
|
56
|
-
return H(s) / n;
|
|
57
|
-
}
|
|
58
|
-
const xt = /* @__PURE__ */ new Map();
|
|
59
|
-
function _e(t) {
|
|
60
|
-
return (String(t).split(".")[1] ?? "").length;
|
|
61
|
-
}
|
|
62
|
-
const Re = /\.\d*?(?=9{6,}|0{6,})/gm;
|
|
63
|
-
function It(t) {
|
|
64
|
-
if (he(t) || xt.has(t))
|
|
65
|
-
return t;
|
|
66
|
-
const e = `${t}`, n = e.match(Re);
|
|
67
|
-
if (n == null)
|
|
68
|
-
return t;
|
|
69
|
-
const s = n[0].length - 1;
|
|
70
|
-
if (e.indexOf("e-") !== -1) {
|
|
71
|
-
const o = e.split("e"), i = o[0] ?? "0", l = o[1] ?? "0";
|
|
72
|
-
return +`${It(+i)}e${l}`;
|
|
73
|
-
}
|
|
74
|
-
return ut(t, s);
|
|
75
|
-
}
|
|
76
|
-
function Xt(t, e, n = !0) {
|
|
77
|
-
return n ? It(Tt(It(t / e)) * e) : Tt(t / e) * e;
|
|
78
|
-
}
|
|
79
|
-
function we(t, e, n = !0) {
|
|
80
|
-
return n ? It(nt(It(t / e)) * e) : nt(t / e) * e;
|
|
81
|
-
}
|
|
82
|
-
function ve(t, e, n, s) {
|
|
83
|
-
const o = [], i = s.map(_e);
|
|
84
|
-
for (let l = e; l < n; l++) {
|
|
85
|
-
const r = gt(l);
|
|
86
|
-
for (let a = 0; a < s.length; a++) {
|
|
87
|
-
const c = s[a] ?? 0, u = i[a] ?? 0, h = +`${c}e${l}`, f = (l >= 0 ? 0 : r) + (l >= u ? 0 : u), d = h;
|
|
88
|
-
o.push(d), xt.set(d, f);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return o;
|
|
92
|
-
}
|
|
93
|
-
const Ge = new Intl.NumberFormat(), xe = (t) => Ge.format(t), Ve = 0.1, lt = {
|
|
94
|
-
mode: 3,
|
|
95
|
-
pad: Ve,
|
|
96
|
-
soft: null
|
|
97
|
-
}, Ct = { pad: 0, soft: null, mode: 0 }, He = { min: Ct, max: Ct };
|
|
98
|
-
function bt(t, e, n, s) {
|
|
99
|
-
let o;
|
|
100
|
-
typeof n == "number" ? (Ct.pad = n, Ct.soft = null, Ct.mode = 0, o = He) : o = n;
|
|
101
|
-
const i = o.min, l = o.max, r = i.pad, a = l.pad, c = i.hard ?? -j, u = l.hard ?? j, h = i.soft ?? j, f = l.soft ?? -j, d = i.mode, y = l.mode;
|
|
102
|
-
let S = e - t;
|
|
103
|
-
const p = tt(S), g = kt(gt(t), gt(e)), I = tt(g), L = gt(I - p);
|
|
104
|
-
(S < 1e-24 || L > 10) && (S = 0, (t === 0 || e === 0) && (S = 1e-24));
|
|
105
|
-
const P = S || g || 1e3, T = tt(P), M = wt(10, nt(T)), w = P * (S === 0 ? t === 0 ? 0.1 : 1 : r), b = ut(we(t - w, M / 10), 24), k = t >= h && (d === 1 || d === 3 && b <= h || d === 2 && b >= h) ? h : j, D = kt(c, b < k && t >= k ? k : qt(k, b)), m = P * (S === 0 ? e === 0 ? 0.1 : 1 : a), v = ut(Xt(e + m, M / 10), 24), x = e <= f && (y === 1 || y === 3 && v >= f || y === 2 && v <= f) ? f : -j, C = qt(u, v > x && e <= x ? x : kt(x, v));
|
|
106
|
-
return D === C && D === 0 ? [0, 100] : [D, C];
|
|
107
|
-
}
|
|
108
|
-
function Be(t, e, n, s) {
|
|
109
|
-
n === 2 && (s = !0);
|
|
110
|
-
const o = Zt(t), i = Zt(e);
|
|
111
|
-
t === e && (o === -1 ? (t *= n, e /= n) : (t /= n, e *= n));
|
|
112
|
-
const l = n === 10 ? tt : St, r = o === 1 ? nt : Tt, a = i === 1 ? Tt : nt, c = l(gt(t)), u = l(gt(e)), h = r(c), f = a(u);
|
|
113
|
-
let d = wt(n, h), y = wt(n, f);
|
|
114
|
-
return n === 10 && (h < 0 && (d = ut(d, -h)), f < 0 && (y = ut(y, -f))), s ? (t = d * o, e = y * i) : (t = we(t, wt(n, nt(c)), !1), e = Xt(e, wt(n, nt(u)), !1)), [t, e];
|
|
115
|
-
}
|
|
116
|
-
function Jt(t) {
|
|
117
|
-
return (tt((t ^ t >> 31) - (t >> 31)) | 0) + 1;
|
|
118
|
-
}
|
|
119
|
-
function Ee(t, e, n, s, o) {
|
|
120
|
-
const i = kt(Jt(t), Jt(e)), l = e - t;
|
|
121
|
-
let r = kt(0, ct(o / s * l, n) - 1);
|
|
122
|
-
do {
|
|
123
|
-
const a = n[r] ?? 0, c = s * a / l;
|
|
124
|
-
if (c >= o * 0.9 && i + (a < 5 ? xt.get(a) ?? 0 : 0) <= 17)
|
|
125
|
-
return [a, c];
|
|
126
|
-
} while (++r < n.length);
|
|
127
|
-
return [0, 0];
|
|
128
|
-
}
|
|
129
|
-
function We(t) {
|
|
130
|
-
return {
|
|
131
|
-
id: t.id,
|
|
132
|
-
min: t.min ?? null,
|
|
133
|
-
max: t.max ?? null,
|
|
134
|
-
distr: t.distr ?? N.Linear,
|
|
135
|
-
log: t.log ?? 10,
|
|
136
|
-
asinh: t.asinh ?? 1,
|
|
137
|
-
ori: t.ori ?? (t.id === "x" ? G.Horizontal : G.Vertical),
|
|
138
|
-
dir: t.dir ?? O.Forward,
|
|
139
|
-
time: t.time ?? !1,
|
|
140
|
-
auto: t.auto ?? !0,
|
|
141
|
-
range: t.range ?? null,
|
|
142
|
-
_min: null,
|
|
143
|
-
_max: null
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function at(t) {
|
|
147
|
-
t._min = null, t._max = null;
|
|
148
|
-
}
|
|
149
|
-
function Me(t) {
|
|
150
|
-
if (t._min != null) return t._min;
|
|
151
|
-
const { min: e, distr: n } = t;
|
|
152
|
-
if (e == null) return 0;
|
|
153
|
-
if (n === N.Log) {
|
|
154
|
-
const s = e > 0 ? e : 1e-10;
|
|
155
|
-
t._min = (t.log === 10 ? tt : St)(s);
|
|
156
|
-
} else n === N.Asinh ? t._min = Wt(e, t.asinh) : t._min = e;
|
|
157
|
-
return t._min;
|
|
158
|
-
}
|
|
159
|
-
function Se(t) {
|
|
160
|
-
if (t._max != null) return t._max;
|
|
161
|
-
const { max: e, distr: n } = t;
|
|
162
|
-
if (e == null) return 0;
|
|
163
|
-
if (n === N.Log) {
|
|
164
|
-
const s = e > 0 ? e : 1e-10;
|
|
165
|
-
t._max = (t.log === 10 ? tt : St)(s);
|
|
166
|
-
} else n === N.Asinh ? t._max = Wt(e, t.asinh) : t._max = e;
|
|
167
|
-
return t._max;
|
|
168
|
-
}
|
|
169
|
-
function Xe(t, e) {
|
|
170
|
-
if (e.min == null || e.max == null) return 0;
|
|
171
|
-
const n = Me(e), o = Se(e) - n;
|
|
172
|
-
if (o === 0) return 0;
|
|
173
|
-
const { distr: i } = e;
|
|
174
|
-
if (i === N.Log) {
|
|
175
|
-
const l = e.log === 10 ? tt : St, r = t > 0 ? t : 1e-10;
|
|
176
|
-
return (l(r) - n) / o;
|
|
177
|
-
}
|
|
178
|
-
return i === N.Asinh ? (Wt(t, e.asinh) - n) / o : (t - n) / o;
|
|
179
|
-
}
|
|
180
|
-
function $e(t, e) {
|
|
181
|
-
if (e.min == null || e.max == null) return 0;
|
|
182
|
-
const n = Me(e), s = Se(e);
|
|
183
|
-
if (s === n) return e.min;
|
|
184
|
-
const { distr: o } = e;
|
|
185
|
-
return o === N.Log ? Math.pow(e.log, n + t * (s - n)) : o === N.Asinh ? De(n + t * (s - n), e.asinh) : n + t * (s - n);
|
|
186
|
-
}
|
|
187
|
-
function V(t, e, n, s) {
|
|
188
|
-
const o = Xe(t, e);
|
|
189
|
-
let i;
|
|
190
|
-
return e.ori === G.Horizontal ? i = e.dir === O.Forward ? o : 1 - o : i = e.dir === O.Forward ? 1 - o : o, s + i * n;
|
|
191
|
-
}
|
|
192
|
-
function it(t, e, n, s) {
|
|
193
|
-
if (n === 0) return e.min ?? 0;
|
|
194
|
-
let o = (t - s) / n;
|
|
195
|
-
return e.ori === G.Horizontal ? e.dir === O.Backward && (o = 1 - o) : e.dir !== O.Backward && (o = 1 - o), $e(o, e);
|
|
196
|
-
}
|
|
197
|
-
class Ye {
|
|
198
|
-
constructor() {
|
|
199
|
-
this.scales = /* @__PURE__ */ new Map(), this.groupXScales = /* @__PURE__ */ new Map();
|
|
200
|
-
}
|
|
201
|
-
addScale(e) {
|
|
202
|
-
this.scales.set(e.id, We(e));
|
|
203
|
-
}
|
|
204
|
-
removeScale(e) {
|
|
205
|
-
this.scales.delete(e);
|
|
206
|
-
}
|
|
207
|
-
getScale(e) {
|
|
208
|
-
return this.scales.get(e);
|
|
209
|
-
}
|
|
210
|
-
/** Get all scale states (for zoom reset, iteration) */
|
|
211
|
-
getAllScales() {
|
|
212
|
-
return this.scales.values();
|
|
213
|
-
}
|
|
214
|
-
/** Assign a group index to an x-scale */
|
|
215
|
-
setGroupXScale(e, n) {
|
|
216
|
-
this.groupXScales.set(e, n);
|
|
217
|
-
}
|
|
218
|
-
/** Get the x-scale key for a group */
|
|
219
|
-
getGroupXScaleKey(e) {
|
|
220
|
-
return this.groupXScales.get(e);
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Set a scale's range directly (e.g., for zoom).
|
|
224
|
-
*/
|
|
225
|
-
setRange(e, n, s) {
|
|
226
|
-
const o = this.scales.get(e);
|
|
227
|
-
o && (o.min = n, o.max = s, at(o));
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Auto-range only x-scales from data (cheap: just reads first/last x values).
|
|
231
|
-
* Call before updateWindows() so the x-scale range is set for window clipping.
|
|
232
|
-
*/
|
|
233
|
-
autoRangeX(e) {
|
|
234
|
-
var s, o, i, l, r, a;
|
|
235
|
-
const n = /* @__PURE__ */ new Map();
|
|
236
|
-
for (const [c, u] of this.groupXScales) {
|
|
237
|
-
const h = this.scales.get(u);
|
|
238
|
-
if (!h || !h.auto) continue;
|
|
239
|
-
const f = e[c];
|
|
240
|
-
if (!f || f.x.length === 0) continue;
|
|
241
|
-
const d = f.x[0], y = f.x[f.x.length - 1];
|
|
242
|
-
if (d == null || y == null) continue;
|
|
243
|
-
const S = n.get(u);
|
|
244
|
-
S ? (S.dataMin = Math.min(S.dataMin, d), S.dataMax = Math.max(S.dataMax, y)) : n.set(u, { dataMin: d, dataMax: y });
|
|
245
|
-
}
|
|
246
|
-
for (const [c, { dataMin: u, dataMax: h }] of n) {
|
|
247
|
-
const f = this.scales.get(c);
|
|
248
|
-
if (f) {
|
|
249
|
-
if (f.range) {
|
|
250
|
-
const [d, y] = bt(u, h, {
|
|
251
|
-
min: { pad: ((s = f.range.min) == null ? void 0 : s.pad) ?? 0, soft: ((o = f.range.min) == null ? void 0 : o.soft) ?? null, mode: ((i = f.range.min) == null ? void 0 : i.mode) ?? 0 },
|
|
252
|
-
max: { pad: ((l = f.range.max) == null ? void 0 : l.pad) ?? 0, soft: ((r = f.range.max) == null ? void 0 : r.soft) ?? null, mode: ((a = f.range.max) == null ? void 0 : a.mode) ?? 0 }
|
|
253
|
-
});
|
|
254
|
-
f.min = d, f.max = y;
|
|
255
|
-
} else
|
|
256
|
-
u === h ? [f.min, f.max] = bt(u, h, {
|
|
257
|
-
min: { pad: 0.1, soft: null, mode: 0 },
|
|
258
|
-
max: { pad: 0.1, soft: null, mode: 0 }
|
|
259
|
-
}) : (f.min = u, f.max = h);
|
|
260
|
-
at(f);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Auto-range scales from data.
|
|
266
|
-
* For each x-scale: range from its group's x values.
|
|
267
|
-
* For each y-scale: range from all series that reference it, within the visible x-window.
|
|
268
|
-
*/
|
|
269
|
-
autoRange(e, n, s) {
|
|
270
|
-
var r, a, c, u, h, f, d, y, S, p, g, I;
|
|
271
|
-
const o = /* @__PURE__ */ new Map();
|
|
272
|
-
for (const [L, P] of this.groupXScales) {
|
|
273
|
-
const T = this.scales.get(P);
|
|
274
|
-
if (!T || !T.auto) continue;
|
|
275
|
-
const M = e[L];
|
|
276
|
-
if (!M || M.x.length === 0) continue;
|
|
277
|
-
const w = M.x[0], b = M.x[M.x.length - 1];
|
|
278
|
-
if (w == null || b == null) continue;
|
|
279
|
-
const k = o.get(P);
|
|
280
|
-
k ? (k.dataMin = Math.min(k.dataMin, w), k.dataMax = Math.max(k.dataMax, b)) : o.set(P, { dataMin: w, dataMax: b });
|
|
281
|
-
}
|
|
282
|
-
for (const [L, { dataMin: P, dataMax: T }] of o) {
|
|
283
|
-
const M = this.scales.get(L);
|
|
284
|
-
if (M) {
|
|
285
|
-
if (M.range) {
|
|
286
|
-
const [w, b] = bt(P, T, {
|
|
287
|
-
min: { pad: ((r = M.range.min) == null ? void 0 : r.pad) ?? 0, soft: ((a = M.range.min) == null ? void 0 : a.soft) ?? null, mode: ((c = M.range.min) == null ? void 0 : c.mode) ?? 0 },
|
|
288
|
-
max: { pad: ((u = M.range.max) == null ? void 0 : u.pad) ?? 0, soft: ((h = M.range.max) == null ? void 0 : h.soft) ?? null, mode: ((f = M.range.max) == null ? void 0 : f.mode) ?? 0 }
|
|
289
|
-
});
|
|
290
|
-
M.min = w, M.max = b;
|
|
291
|
-
} else
|
|
292
|
-
P === T ? [M.min, M.max] = bt(P, T, {
|
|
293
|
-
min: { pad: 0.1, soft: null, mode: 0 },
|
|
294
|
-
max: { pad: 0.1, soft: null, mode: 0 }
|
|
295
|
-
}) : (M.min = P, M.max = T);
|
|
296
|
-
at(M);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
const i = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
300
|
-
for (const { group: L, index: P, yScale: T } of n) {
|
|
301
|
-
const M = e[L];
|
|
302
|
-
if (!M) continue;
|
|
303
|
-
const w = M.series[P];
|
|
304
|
-
if (!w || w.length === 0) continue;
|
|
305
|
-
const b = s.windows.get(L), k = b ? b[0] : 0, D = b ? b[1] : w.length - 1, m = this.scales.get(T), v = (m == null ? void 0 : m.distr) === N.Log, [x, C] = s.getCachedMinMax(L, P, k, D, 0, v), z = i.get(T), A = l.get(T);
|
|
306
|
-
i.set(T, z != null ? Math.min(z, x) : x), l.set(T, A != null ? Math.max(A, C) : C);
|
|
307
|
-
}
|
|
308
|
-
for (const [L, P] of i) {
|
|
309
|
-
const T = this.scales.get(L);
|
|
310
|
-
if (!T || !T.auto) continue;
|
|
311
|
-
const M = l.get(L) ?? -j;
|
|
312
|
-
if (P === j) continue;
|
|
313
|
-
let w, b;
|
|
314
|
-
if (T.distr === N.Log)
|
|
315
|
-
[w, b] = Be(P, M, T.log, !1);
|
|
316
|
-
else {
|
|
317
|
-
const k = T.range ?? { min: lt, max: lt };
|
|
318
|
-
[w, b] = bt(P, M, {
|
|
319
|
-
min: { pad: ((d = k.min) == null ? void 0 : d.pad) ?? lt.pad, soft: ((y = k.min) == null ? void 0 : y.soft) ?? lt.soft, mode: ((S = k.min) == null ? void 0 : S.mode) ?? lt.mode },
|
|
320
|
-
max: { pad: ((p = k.max) == null ? void 0 : p.pad) ?? lt.pad, soft: ((g = k.max) == null ? void 0 : g.soft) ?? lt.soft, mode: ((I = k.max) == null ? void 0 : I.mode) ?? lt.mode }
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
T.min = w, T.max = b, at(T);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
const Ue = 1024;
|
|
328
|
-
class Oe {
|
|
329
|
-
constructor(e, n = Ue) {
|
|
330
|
-
this.data = e, this.len = e.length, this.blockSize = n, this.nBlocks = Math.ceil(e.length / n), this.blocks = new Float64Array(this.nBlocks * 2), this.buildAll();
|
|
331
|
-
}
|
|
332
|
-
/** Build min/max for all blocks */
|
|
333
|
-
buildAll() {
|
|
334
|
-
const { data: e, blockSize: n, nBlocks: s, blocks: o, len: i } = this;
|
|
335
|
-
for (let l = 0; l < s; l++) {
|
|
336
|
-
const r = l * n, a = Math.min(r + n, i);
|
|
337
|
-
let c = 1 / 0, u = -1 / 0;
|
|
338
|
-
for (let h = r; h < a; h++) {
|
|
339
|
-
const f = e[h];
|
|
340
|
-
f != null && (f < c && (c = f), f > u && (u = f));
|
|
341
|
-
}
|
|
342
|
-
o[l * 2] = c, o[l * 2 + 1] = u;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Query min/max over index range [i0, i1] (inclusive).
|
|
347
|
-
* Returns [Infinity, -Infinity] if no valid data in range.
|
|
348
|
-
*/
|
|
349
|
-
rangeMinMax(e, n) {
|
|
350
|
-
const { data: s, blockSize: o, blocks: i } = this;
|
|
351
|
-
let l = 1 / 0, r = -1 / 0;
|
|
352
|
-
const a = Math.floor(e / o), c = Math.floor(n / o);
|
|
353
|
-
if (a === c) {
|
|
354
|
-
for (let f = e; f <= n; f++) {
|
|
355
|
-
const d = s[f];
|
|
356
|
-
d != null && (d < l && (l = d), d > r && (r = d));
|
|
357
|
-
}
|
|
358
|
-
return [l, r];
|
|
359
|
-
}
|
|
360
|
-
const u = (a + 1) * o - 1;
|
|
361
|
-
for (let f = e; f <= u; f++) {
|
|
362
|
-
const d = s[f];
|
|
363
|
-
d != null && (d < l && (l = d), d > r && (r = d));
|
|
364
|
-
}
|
|
365
|
-
for (let f = a + 1; f < c; f++) {
|
|
366
|
-
const d = i[f * 2] ?? 1 / 0, y = i[f * 2 + 1] ?? -1 / 0;
|
|
367
|
-
d < l && (l = d), y > r && (r = y);
|
|
368
|
-
}
|
|
369
|
-
const h = c * o;
|
|
370
|
-
for (let f = h; f <= n; f++) {
|
|
371
|
-
const d = s[f];
|
|
372
|
-
d != null && (d < l && (l = d), d > r && (r = d));
|
|
373
|
-
}
|
|
374
|
-
return [l, r];
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Rebuild a single block (for incremental append).
|
|
378
|
-
* @param blockIdx - index of the block to rebuild
|
|
379
|
-
*/
|
|
380
|
-
updateBlock(e) {
|
|
381
|
-
const { data: n, blockSize: s, blocks: o, len: i } = this;
|
|
382
|
-
if (e >= this.nBlocks) return;
|
|
383
|
-
const l = e * s, r = Math.min(l + s, i);
|
|
384
|
-
let a = 1 / 0, c = -1 / 0;
|
|
385
|
-
for (let u = l; u < r; u++) {
|
|
386
|
-
const h = n[u];
|
|
387
|
-
h != null && (h < a && (a = h), h > c && (c = h));
|
|
388
|
-
}
|
|
389
|
-
o[e * 2] = a, o[e * 2 + 1] = c;
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Grow the tree to accommodate new data length.
|
|
393
|
-
* Only rebuilds newly added blocks.
|
|
394
|
-
*/
|
|
395
|
-
grow(e) {
|
|
396
|
-
const n = this.nBlocks;
|
|
397
|
-
if (this.len = e, this.nBlocks = Math.ceil(e / this.blockSize), this.nBlocks > n) {
|
|
398
|
-
const o = new Float64Array(this.nBlocks * 2);
|
|
399
|
-
o.set(this.blocks), this.blocks = o;
|
|
400
|
-
}
|
|
401
|
-
const s = Math.max(0, n - 1);
|
|
402
|
-
for (let o = s; o < this.nBlocks; o++)
|
|
403
|
-
this.updateBlock(o);
|
|
404
|
-
}
|
|
405
|
-
/** Update data reference (for when the backing array changes, e.g. append with realloc) */
|
|
406
|
-
setData(e) {
|
|
407
|
-
this.data = e;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
class Ne {
|
|
411
|
-
constructor() {
|
|
412
|
-
this.data = [], this.windows = /* @__PURE__ */ new Map(), this.minMaxCache = /* @__PURE__ */ new Map(), this.blockTrees = /* @__PURE__ */ new Map();
|
|
413
|
-
}
|
|
414
|
-
setData(e) {
|
|
415
|
-
this.data = e, this.windows.clear();
|
|
416
|
-
for (const n of this.minMaxCache.values()) n.clear();
|
|
417
|
-
this.minMaxCache.clear(), this.blockTrees.clear();
|
|
418
|
-
}
|
|
419
|
-
/** Get or lazily build a block min-max tree for a series */
|
|
420
|
-
getOrBuildTree(e, n) {
|
|
421
|
-
const s = `${e}:${n}`;
|
|
422
|
-
let o = this.blockTrees.get(s);
|
|
423
|
-
if (o) return o;
|
|
424
|
-
const i = this.data[e];
|
|
425
|
-
if (!i) return;
|
|
426
|
-
const l = i.series[n];
|
|
427
|
-
if (!(!l || l.length === 0))
|
|
428
|
-
return o = new Oe(l), this.blockTrees.set(s, o), o;
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Update the visible window for each xGroup based on its x-scale range.
|
|
432
|
-
* @param getXScale - function to look up the x-scale for a group index
|
|
433
|
-
*/
|
|
434
|
-
/** Update windows and return true if any window actually changed */
|
|
435
|
-
updateWindows(e) {
|
|
436
|
-
var s;
|
|
437
|
-
let n = !1;
|
|
438
|
-
for (let o = 0; o < this.data.length; o++) {
|
|
439
|
-
const i = this.data[o], l = e(o), r = this.windows.get(o);
|
|
440
|
-
let a, c;
|
|
441
|
-
if (!i || !l || l.min == null || l.max == null)
|
|
442
|
-
a = 0, c = Math.max(0, ((i == null ? void 0 : i.x.length) ?? 1) - 1);
|
|
443
|
-
else {
|
|
444
|
-
const u = i.x;
|
|
445
|
-
if (u.length === 0)
|
|
446
|
-
a = 0, c = 0;
|
|
447
|
-
else {
|
|
448
|
-
a = ct(l.min, u), c = ct(l.max, u);
|
|
449
|
-
const h = u[a], f = u[c];
|
|
450
|
-
a > 0 && h != null && h > l.min && a--, c < u.length - 1 && f != null && f < l.max && c++;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
(!r || r[0] !== a || r[1] !== c) && (n = !0, (s = this.minMaxCache.get(o)) == null || s.clear()), this.windows.set(o, [a, c]);
|
|
454
|
-
}
|
|
455
|
-
return n;
|
|
456
|
-
}
|
|
457
|
-
/** Get the visible window for a group */
|
|
458
|
-
getWindow(e) {
|
|
459
|
-
var n;
|
|
460
|
-
return this.windows.get(e) ?? [0, (((n = this.data[e]) == null ? void 0 : n.x.length) || 1) - 1];
|
|
461
|
-
}
|
|
462
|
-
/** Get x values for a group */
|
|
463
|
-
getXValues(e) {
|
|
464
|
-
var n;
|
|
465
|
-
return ((n = this.data[e]) == null ? void 0 : n.x) ?? [];
|
|
466
|
-
}
|
|
467
|
-
/** Get y values for a specific series */
|
|
468
|
-
getYValues(e, n) {
|
|
469
|
-
var s;
|
|
470
|
-
return ((s = this.data[e]) == null ? void 0 : s.series[n]) ?? [];
|
|
471
|
-
}
|
|
472
|
-
/** Get cached min/max for a series within a window range */
|
|
473
|
-
getCachedMinMax(e, n, s, o, i, l) {
|
|
474
|
-
let r = this.minMaxCache.get(e);
|
|
475
|
-
const a = `${n}:${s}:${o}`;
|
|
476
|
-
if (r) {
|
|
477
|
-
const d = r.get(a);
|
|
478
|
-
if (d != null) return d;
|
|
479
|
-
} else
|
|
480
|
-
r = /* @__PURE__ */ new Map(), this.minMaxCache.set(e, r);
|
|
481
|
-
const c = this.data[e];
|
|
482
|
-
if (!c) return [1 / 0, -1 / 0];
|
|
483
|
-
const u = c.series[n];
|
|
484
|
-
if (!u || u.length === 0) return [1 / 0, -1 / 0];
|
|
485
|
-
let h;
|
|
486
|
-
const f = !l && i === yt.Unsorted ? this.getOrBuildTree(e, n) : void 0;
|
|
487
|
-
return f ? h = f.rangeMinMax(s, o) : h = Fe(u, s, o, i, l), r.set(a, h), h;
|
|
488
|
-
}
|
|
489
|
-
/** Get block tree for a series (exposed for incremental append) */
|
|
490
|
-
getBlockTree(e, n) {
|
|
491
|
-
return this.getOrBuildTree(e, n);
|
|
492
|
-
}
|
|
493
|
-
/**
|
|
494
|
-
* Append new data points to an existing group.
|
|
495
|
-
* Much cheaper than setData() for streaming scenarios — O(newPoints) instead of O(totalPoints).
|
|
496
|
-
*
|
|
497
|
-
* Only works with regular arrays (not Float64Array) since arrays need to grow.
|
|
498
|
-
* Block trees are incrementally updated, and only the affected group's cache is invalidated.
|
|
499
|
-
*/
|
|
500
|
-
appendData(e, n, s) {
|
|
501
|
-
var l;
|
|
502
|
-
const o = this.data[e];
|
|
503
|
-
if (!o) return;
|
|
504
|
-
const i = o.x;
|
|
505
|
-
if (Array.isArray(i)) {
|
|
506
|
-
for (let r = 0; r < n.length; r++) {
|
|
507
|
-
const a = n[r];
|
|
508
|
-
a != null && i.push(a);
|
|
509
|
-
}
|
|
510
|
-
for (let r = 0; r < o.series.length; r++) {
|
|
511
|
-
const a = o.series[r];
|
|
512
|
-
if (!a || !Array.isArray(a)) continue;
|
|
513
|
-
const c = s[r];
|
|
514
|
-
if (c)
|
|
515
|
-
for (let h = 0; h < c.length; h++)
|
|
516
|
-
a.push(c[h] ?? null);
|
|
517
|
-
const u = this.blockTrees.get(`${e}:${r}`);
|
|
518
|
-
u && (u.setData(a), u.grow(a.length));
|
|
519
|
-
}
|
|
520
|
-
(l = this.minMaxCache.get(e)) == null || l.clear();
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* Convert x-arrays in chart data to Float64Array for optimal memory layout.
|
|
525
|
-
* Call before setData() when not using appendData() (Float64Array is fixed-length).
|
|
526
|
-
*/
|
|
527
|
-
static toTypedX(e) {
|
|
528
|
-
for (const n of e)
|
|
529
|
-
Array.isArray(n.x) && (n.x = Float64Array.from(n.x));
|
|
530
|
-
return e;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
class Ke {
|
|
534
|
-
constructor() {
|
|
535
|
-
this.state = {
|
|
536
|
-
left: -10,
|
|
537
|
-
top: -10,
|
|
538
|
-
activeGroup: -1,
|
|
539
|
-
activeSeriesIdx: -1,
|
|
540
|
-
activeDataIdx: -1
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
/** Hide the cursor (move off-screen) */
|
|
544
|
-
hide() {
|
|
545
|
-
this.state.left = -10, this.state.top = -10, this.state.activeGroup = -1, this.state.activeSeriesIdx = -1, this.state.activeDataIdx = -1;
|
|
546
|
-
}
|
|
547
|
-
/**
|
|
548
|
-
* Update cursor position and snap to nearest data point.
|
|
549
|
-
*
|
|
550
|
-
* @param cssX - cursor X in CSS pixels relative to plot area left
|
|
551
|
-
* @param cssY - cursor Y in CSS pixels relative to plot area top
|
|
552
|
-
* @param plotBox - current plot bounding box
|
|
553
|
-
* @param data - chart data groups
|
|
554
|
-
* @param seriesConfigs - all series configs
|
|
555
|
-
* @param getScale - scale lookup
|
|
556
|
-
*/
|
|
557
|
-
update(e, n, s, o, i, l, r, a) {
|
|
558
|
-
this.state.left = e, this.state.top = n;
|
|
559
|
-
let c = 1 / 0, u = -1, h = -1, f = -1;
|
|
560
|
-
for (let d = 0; d < o.length; d++) {
|
|
561
|
-
const y = o[d];
|
|
562
|
-
if (y == null) continue;
|
|
563
|
-
const S = y.x;
|
|
564
|
-
if (S.length === 0) continue;
|
|
565
|
-
const p = a(d);
|
|
566
|
-
if (p == null) continue;
|
|
567
|
-
const g = l(p);
|
|
568
|
-
if (g == null || g.min == null || g.max == null) continue;
|
|
569
|
-
const [I, L] = r(d), P = s.width, T = s.left, M = it(e + T, g, P, T), w = ct(M, S, I, L), b = [w];
|
|
570
|
-
w > I && b.push(w - 1), w < L && b.push(w + 1);
|
|
571
|
-
const k = /* @__PURE__ */ new Map();
|
|
572
|
-
for (const D of b) {
|
|
573
|
-
const m = S[D];
|
|
574
|
-
if (m == null) continue;
|
|
575
|
-
const v = V(m, g, P, T);
|
|
576
|
-
for (const x of i) {
|
|
577
|
-
if (x.group !== d || x.show === !1) continue;
|
|
578
|
-
const C = y.series[x.index];
|
|
579
|
-
if (C == null) continue;
|
|
580
|
-
const z = C[D];
|
|
581
|
-
if (z == null) continue;
|
|
582
|
-
let A = k.get(x.yScale);
|
|
583
|
-
if (A == null && !k.has(x.yScale) && (A = l(x.yScale), k.set(x.yScale, A)), A == null || A.min == null || A.max == null) continue;
|
|
584
|
-
const F = s.height, _ = s.top, R = V(z, A, F, _), B = e + T - v, $ = n + _ - R, W = B * B + $ * $;
|
|
585
|
-
if (W < c && (c = W, u = d, h = x.index, f = D, W === 0))
|
|
586
|
-
break;
|
|
587
|
-
}
|
|
588
|
-
if (c === 0) break;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
this.state.activeGroup = u, this.state.activeSeriesIdx = h, this.state.activeDataIdx = f;
|
|
592
|
-
}
|
|
593
|
-
/**
|
|
594
|
-
* Sync cursor to a specific x-value (from another chart in a sync group).
|
|
595
|
-
* Finds the closest data index and positions the cursor there.
|
|
596
|
-
*/
|
|
597
|
-
syncToValue(e, n) {
|
|
598
|
-
const s = n.dataStore.data;
|
|
599
|
-
if (s.length === 0) return;
|
|
600
|
-
const o = s[0];
|
|
601
|
-
if (o == null) return;
|
|
602
|
-
const i = n.scaleManager.getGroupXScaleKey(0);
|
|
603
|
-
if (i == null) return;
|
|
604
|
-
const l = n.scaleManager.getScale(i);
|
|
605
|
-
if (l == null || l.min == null || l.max == null) return;
|
|
606
|
-
const [r, a] = n.dataStore.getWindow(0), c = ct(e, o.x, r, a), u = o.x[c];
|
|
607
|
-
if (u == null) return;
|
|
608
|
-
const h = V(u, l, n.plotBox.width, n.plotBox.left);
|
|
609
|
-
this.state.left = h - n.plotBox.left, this.state.activeGroup = 0, this.state.activeDataIdx = c;
|
|
610
|
-
let f = 0, d = n.plotBox.height / 2;
|
|
611
|
-
for (const y of n.seriesConfigs) {
|
|
612
|
-
if (y.group !== 0 || y.show === !1) continue;
|
|
613
|
-
const S = o.series[y.index];
|
|
614
|
-
if (S == null) continue;
|
|
615
|
-
const p = S[c];
|
|
616
|
-
if (p == null) continue;
|
|
617
|
-
const g = n.scaleManager.getScale(y.yScale);
|
|
618
|
-
if (!(g == null || g.min == null || g.max == null)) {
|
|
619
|
-
d = V(p, g, n.plotBox.height, n.plotBox.top) - n.plotBox.top, f = y.index;
|
|
620
|
-
break;
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
this.state.top = d, this.state.activeSeriesIdx = f;
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
class je {
|
|
627
|
-
constructor() {
|
|
628
|
-
this.flags = Q.None, this.frameId = null, this.callback = null;
|
|
629
|
-
}
|
|
630
|
-
/** Mark one or more dirty flags */
|
|
631
|
-
mark(e) {
|
|
632
|
-
this.flags |= e, this.scheduleFrame();
|
|
633
|
-
}
|
|
634
|
-
/** Check if a specific flag is set */
|
|
635
|
-
has(e) {
|
|
636
|
-
return (this.flags & e) !== 0;
|
|
637
|
-
}
|
|
638
|
-
/** Get current flags value */
|
|
639
|
-
get dirty() {
|
|
640
|
-
return this.flags;
|
|
641
|
-
}
|
|
642
|
-
/** Clear all flags (called after a redraw) */
|
|
643
|
-
clear() {
|
|
644
|
-
this.flags = Q.None;
|
|
645
|
-
}
|
|
646
|
-
/** Set the redraw callback */
|
|
647
|
-
onRedraw(e) {
|
|
648
|
-
this.callback = e;
|
|
649
|
-
}
|
|
650
|
-
/** Schedule a frame if not already pending */
|
|
651
|
-
scheduleFrame() {
|
|
652
|
-
this.frameId == null && (this.frameId = requestAnimationFrame(() => {
|
|
653
|
-
this.frameId = null;
|
|
654
|
-
const e = this.callback;
|
|
655
|
-
e != null && e(), this.clear();
|
|
656
|
-
}));
|
|
657
|
-
}
|
|
658
|
-
/** Cancel any pending frame */
|
|
659
|
-
cancel() {
|
|
660
|
-
this.frameId != null && (cancelAnimationFrame(this.frameId), this.frameId = null);
|
|
661
|
-
}
|
|
662
|
-
/** Clean up */
|
|
663
|
-
dispose() {
|
|
664
|
-
this.cancel(), this.callback = null, this.flags = Q.None;
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
function _t(t, e, n) {
|
|
668
|
-
t.lineTo(e, n);
|
|
669
|
-
}
|
|
670
|
-
function Rt(t, e, n) {
|
|
671
|
-
t.lineTo(n, e);
|
|
672
|
-
}
|
|
673
|
-
function $t(t, e, n, s, o, i) {
|
|
674
|
-
const l = [];
|
|
675
|
-
let r = -1;
|
|
676
|
-
const a = o === O.Forward ? n : s, c = o === O.Forward ? s : n, u = o;
|
|
677
|
-
for (let h = a; o === O.Forward ? h <= c : h >= c; h += u)
|
|
678
|
-
if (e[h] === null || e[h] === void 0) {
|
|
679
|
-
if (r === -1) {
|
|
680
|
-
const f = Math.max(n, Math.min(h - o, s));
|
|
681
|
-
r = i(t[f]);
|
|
682
|
-
}
|
|
683
|
-
} else
|
|
684
|
-
r !== -1 && (l.push([r, i(t[h])]), r = -1);
|
|
685
|
-
return r !== -1 && l.push([r, i(t[s])]), l;
|
|
686
|
-
}
|
|
687
|
-
function Yt(t, e, n, s, o, i) {
|
|
688
|
-
const l = new Path2D();
|
|
689
|
-
let r = e === G.Horizontal ? n : s;
|
|
690
|
-
const a = e === G.Horizontal ? n + o : s + i, c = e === G.Horizontal ? s : n, u = e === G.Horizontal ? i : o;
|
|
691
|
-
for (const [h, f] of t)
|
|
692
|
-
h > r && (e === G.Horizontal ? l.rect(r, c, h - r, u) : l.rect(c, r, u, h - r)), r = f;
|
|
693
|
-
return r < a && (e === G.Horizontal ? l.rect(r, c, a - r, u) : l.rect(c, r, u, a - r)), l;
|
|
694
|
-
}
|
|
695
|
-
function be(t) {
|
|
696
|
-
return (e, n, s, o, i, l) => {
|
|
697
|
-
s !== o && (i !== s && l !== s && t(e, n, s), i !== o && l !== o && t(e, n, o), t(e, n, l));
|
|
698
|
-
};
|
|
699
|
-
}
|
|
700
|
-
const qe = be(_t), Ze = be(Rt);
|
|
701
|
-
function Je() {
|
|
702
|
-
return (t, e, n, s, o, i, l, r, a, c, u, h, f) => {
|
|
703
|
-
const d = (f == null ? void 0 : f.spanGaps) ?? !1;
|
|
704
|
-
if ([a, c] = (s.distr === N.Log ? me : Ft)(e, a, c), a === -1)
|
|
705
|
-
return {
|
|
706
|
-
stroke: new Path2D(),
|
|
707
|
-
fill: null,
|
|
708
|
-
clip: null,
|
|
709
|
-
band: null,
|
|
710
|
-
gaps: null
|
|
711
|
-
};
|
|
712
|
-
const S = (w) => h(V(w, n, o, l)), p = (w) => h(V(w, s, i, r));
|
|
713
|
-
let g, I;
|
|
714
|
-
n.ori === G.Horizontal ? (g = _t, I = qe) : (g = Rt, I = Ze);
|
|
715
|
-
const L = {
|
|
716
|
-
stroke: new Path2D(),
|
|
717
|
-
fill: null,
|
|
718
|
-
clip: null,
|
|
719
|
-
band: null,
|
|
720
|
-
gaps: null
|
|
721
|
-
}, P = L.stroke;
|
|
722
|
-
let T = !1;
|
|
723
|
-
if (c - a >= o * 4) {
|
|
724
|
-
const w = (A) => it(A, n, o, l);
|
|
725
|
-
let b = null, k = 0, D = 0, m = 0, v = S(t[u === O.Forward ? a : c]);
|
|
726
|
-
const x = S(t[a]), C = S(t[c]);
|
|
727
|
-
let z = w(u === O.Forward ? x + 1 : C - 1);
|
|
728
|
-
for (let A = u === O.Forward ? a : c; A >= a && A <= c; A += u) {
|
|
729
|
-
const F = t[A], R = (u === O.Forward ? F < z : F > z) ? v : S(F), B = e[A];
|
|
730
|
-
R === v ? B != null ? (m = B, b == null ? (g(P, R, p(m)), D = b = k = m) : m < b ? b = m : m > k && (k = m)) : B === null && !d && (T = !0) : (b != null && I(P, v, p(b), p(k), p(D), p(m)), B != null ? (m = B, g(P, R, p(m)), b = k = D = m) : (b = null, k = 0, B === null && !d && (T = !0)), v = R, z = w(v + u));
|
|
731
|
-
}
|
|
732
|
-
b != null && (b !== k ? I(P, v, p(b), p(k), p(D), p(m)) : g(P, v, p(m)));
|
|
733
|
-
} else
|
|
734
|
-
for (let w = u === O.Forward ? a : c; w >= a && w <= c; w += u) {
|
|
735
|
-
const b = e[w];
|
|
736
|
-
b === null && !d ? T = !0 : b != null && g(P, S(t[w]), p(b));
|
|
737
|
-
}
|
|
738
|
-
{
|
|
739
|
-
const w = L.fill = new Path2D(P), b = (f == null ? void 0 : f.fillTo) ?? s.min ?? 0, k = p(b);
|
|
740
|
-
let D = l, m = l + o;
|
|
741
|
-
u === O.Backward && ([m, D] = [D, m]), g(w, m, k), g(w, D, k);
|
|
742
|
-
}
|
|
743
|
-
if (T) {
|
|
744
|
-
const w = $t(t, e, a, c, u, S);
|
|
745
|
-
L.gaps = w, L.clip = Yt(w, n.ori, l, r, o, i);
|
|
746
|
-
}
|
|
747
|
-
return L;
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
function Qt(t, e, n) {
|
|
751
|
-
return typeof e == "string" ? e : Qe(t, e, n);
|
|
752
|
-
}
|
|
753
|
-
function Qe(t, e, n) {
|
|
754
|
-
const s = t.createLinearGradient(0, n.top, 0, n.top + n.height);
|
|
755
|
-
for (const [o, i] of e.stops)
|
|
756
|
-
s.addColorStop(o, i);
|
|
757
|
-
return s;
|
|
758
|
-
}
|
|
759
|
-
function tn(t, e, n, s, o) {
|
|
760
|
-
if (e.show === !1) return;
|
|
761
|
-
const i = e.alpha ?? 1;
|
|
762
|
-
t.save(), i < 1 && (t.globalAlpha = i), n.clip && t.clip(n.clip);
|
|
763
|
-
const l = o ?? { top: 0, width: t.canvas.width / s, height: t.canvas.height / s };
|
|
764
|
-
if (e.fill && n.fill && (t.fillStyle = Qt(t, e.fill, l), t.fill(n.fill)), e.stroke) {
|
|
765
|
-
const r = (e.width ?? 1) * s;
|
|
766
|
-
t.strokeStyle = Qt(t, e.stroke, l), t.lineWidth = r, t.lineJoin = e.join ?? "round", t.lineCap = e.cap ?? "butt", e.dash && t.setLineDash(e.dash.map((h) => h * s));
|
|
767
|
-
const a = e.pxAlign ?? 1, c = r % 2 / 2;
|
|
768
|
-
a === 1 && c > 0 && t.translate(c, c), t.stroke(n.stroke);
|
|
769
|
-
}
|
|
770
|
-
t.restore();
|
|
771
|
-
}
|
|
772
|
-
const en = Je(), te = 64;
|
|
773
|
-
class nn {
|
|
774
|
-
constructor() {
|
|
775
|
-
this.ctx = null, this.pxRatio = 1, this.pathCache = /* @__PURE__ */ new Map(), this.pathCacheSize = 0, this.lruOrder = [], this.snapshotCanvas = null, this.snapshotValid = !1, this.cachedFillStyle = "", this.cachedStrokeStyle = "", this.cachedLineWidth = -1, this.cachedFont = "", this.cachedTextAlign = "", this.cachedTextBaseline = "", this.cachedGlobalAlpha = -1;
|
|
776
|
-
}
|
|
777
|
-
setContext(e, n) {
|
|
778
|
-
this.ctx = e, this.pxRatio = n, this.resetPropertyCache();
|
|
779
|
-
}
|
|
780
|
-
/** Reset cached property values (after context change) */
|
|
781
|
-
resetPropertyCache() {
|
|
782
|
-
this.cachedFillStyle = "", this.cachedStrokeStyle = "", this.cachedLineWidth = -1, this.cachedFont = "", this.cachedTextAlign = "", this.cachedTextBaseline = "", this.cachedGlobalAlpha = -1;
|
|
783
|
-
}
|
|
784
|
-
/** Set fillStyle only if changed */
|
|
785
|
-
setFillStyle(e, n) {
|
|
786
|
-
n !== this.cachedFillStyle && (e.fillStyle = n, this.cachedFillStyle = n);
|
|
787
|
-
}
|
|
788
|
-
/** Set strokeStyle only if changed */
|
|
789
|
-
setStrokeStyle(e, n) {
|
|
790
|
-
n !== this.cachedStrokeStyle && (e.strokeStyle = n, this.cachedStrokeStyle = n);
|
|
791
|
-
}
|
|
792
|
-
/** Set lineWidth only if changed */
|
|
793
|
-
setLineWidth(e, n) {
|
|
794
|
-
n !== this.cachedLineWidth && (e.lineWidth = n, this.cachedLineWidth = n);
|
|
795
|
-
}
|
|
796
|
-
/** Set font only if changed */
|
|
797
|
-
setFont(e, n) {
|
|
798
|
-
n !== this.cachedFont && (e.font = n, this.cachedFont = n);
|
|
799
|
-
}
|
|
800
|
-
/** Set textAlign only if changed */
|
|
801
|
-
setTextAlign(e, n) {
|
|
802
|
-
n !== this.cachedTextAlign && (e.textAlign = n, this.cachedTextAlign = n);
|
|
803
|
-
}
|
|
804
|
-
/** Set textBaseline only if changed */
|
|
805
|
-
setTextBaseline(e, n) {
|
|
806
|
-
n !== this.cachedTextBaseline && (e.textBaseline = n, this.cachedTextBaseline = n);
|
|
807
|
-
}
|
|
808
|
-
/** Set globalAlpha only if changed */
|
|
809
|
-
setGlobalAlpha(e, n) {
|
|
810
|
-
n !== this.cachedGlobalAlpha && (e.globalAlpha = n, this.cachedGlobalAlpha = n);
|
|
811
|
-
}
|
|
812
|
-
// --- Offscreen canvas snapshot ---
|
|
813
|
-
/** Save a snapshot of the current canvas using an offscreen canvas (much cheaper than getImageData) */
|
|
814
|
-
saveSnapshot(e, n, s) {
|
|
815
|
-
const o = e.canvas;
|
|
816
|
-
(this.snapshotCanvas == null || this.snapshotCanvas.width !== n || this.snapshotCanvas.height !== s) && (this.snapshotCanvas = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(n, s) : document.createElement("canvas"), this.snapshotCanvas.width = n, this.snapshotCanvas.height = s);
|
|
817
|
-
const i = this.snapshotCanvas.getContext("2d");
|
|
818
|
-
i != null && typeof i.drawImage == "function" && (i.clearRect(0, 0, n, s), i.drawImage(o, 0, 0), this.snapshotValid = !0);
|
|
819
|
-
}
|
|
820
|
-
/** Restore a previously saved snapshot. Returns false if no snapshot exists. */
|
|
821
|
-
restoreSnapshot(e) {
|
|
822
|
-
return !this.snapshotValid || this.snapshotCanvas == null || typeof e.drawImage != "function" ? !1 : (e.clearRect(0, 0, e.canvas.width, e.canvas.height), e.drawImage(this.snapshotCanvas, 0, 0), !0);
|
|
823
|
-
}
|
|
824
|
-
/** Invalidate the saved snapshot */
|
|
825
|
-
invalidateSnapshot() {
|
|
826
|
-
this.snapshotValid = !1;
|
|
827
|
-
}
|
|
828
|
-
// --- Two-level path cache ---
|
|
829
|
-
windowKey(e, n) {
|
|
830
|
-
return `${e}:${n}`;
|
|
831
|
-
}
|
|
832
|
-
/** Get cached paths for a series, promoting to most-recently-used */
|
|
833
|
-
getCachedPaths(e, n, s, o) {
|
|
834
|
-
const i = this.pathCache.get(e);
|
|
835
|
-
if (i == null) return;
|
|
836
|
-
const l = i.get(n);
|
|
837
|
-
if (l == null) return;
|
|
838
|
-
const r = this.windowKey(s, o), a = l.get(r);
|
|
839
|
-
if (a != null) {
|
|
840
|
-
const c = this.lruOrder.findIndex((u) => u.group === e && u.index === n && u.key === r);
|
|
841
|
-
if (c >= 0) {
|
|
842
|
-
const u = this.lruOrder.splice(c, 1)[0];
|
|
843
|
-
u != null && this.lruOrder.push(u);
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
return a;
|
|
847
|
-
}
|
|
848
|
-
/** Store paths in cache, evicting oldest 25% when at capacity */
|
|
849
|
-
setCachedPaths(e, n, s, o, i) {
|
|
850
|
-
if (this.pathCacheSize >= te) {
|
|
851
|
-
const c = te >> 2, u = this.lruOrder.splice(0, c);
|
|
852
|
-
for (const h of u) {
|
|
853
|
-
const f = this.pathCache.get(h.group);
|
|
854
|
-
if (f == null) continue;
|
|
855
|
-
const d = f.get(h.index);
|
|
856
|
-
d != null && (d.delete(h.key), this.pathCacheSize--, d.size === 0 && f.delete(h.index), f.size === 0 && this.pathCache.delete(h.group));
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
let l = this.pathCache.get(e);
|
|
860
|
-
l == null && (l = /* @__PURE__ */ new Map(), this.pathCache.set(e, l));
|
|
861
|
-
let r = l.get(n);
|
|
862
|
-
r == null && (r = /* @__PURE__ */ new Map(), l.set(n, r));
|
|
863
|
-
const a = this.windowKey(s, o);
|
|
864
|
-
r.has(a) || (this.pathCacheSize++, this.lruOrder.push({ group: e, index: n, key: a })), r.set(a, i);
|
|
865
|
-
}
|
|
866
|
-
/** Invalidate paths for a specific series (all windows) */
|
|
867
|
-
invalidateSeries(e, n) {
|
|
868
|
-
const s = this.pathCache.get(e);
|
|
869
|
-
if (s == null) return;
|
|
870
|
-
const o = s.get(n);
|
|
871
|
-
o != null && (this.pathCacheSize -= o.size, s.delete(n), this.lruOrder = this.lruOrder.filter((i) => !(i.group === e && i.index === n)));
|
|
872
|
-
}
|
|
873
|
-
/** Invalidate cached paths for a specific group */
|
|
874
|
-
clearGroupCache(e) {
|
|
875
|
-
const n = this.pathCache.get(e);
|
|
876
|
-
if (n != null) {
|
|
877
|
-
for (const s of n.values())
|
|
878
|
-
this.pathCacheSize -= s.size;
|
|
879
|
-
this.pathCache.delete(e), this.lruOrder = this.lruOrder.filter((s) => s.group !== e);
|
|
880
|
-
}
|
|
881
|
-
this.snapshotValid = !1;
|
|
882
|
-
}
|
|
883
|
-
/** Invalidate all cached paths (e.g. on scale change) */
|
|
884
|
-
clearCache() {
|
|
885
|
-
this.pathCache.clear(), this.pathCacheSize = 0, this.lruOrder.length = 0, this.snapshotValid = !1;
|
|
886
|
-
}
|
|
887
|
-
/**
|
|
888
|
-
* Draw a single series onto the canvas (assumes context is already clipped).
|
|
889
|
-
* Builds/caches paths and delegates to drawSeriesPath.
|
|
890
|
-
*/
|
|
891
|
-
drawSeries(e, n, s) {
|
|
892
|
-
const o = this.ctx;
|
|
893
|
-
if (o == null || e.config.show === !1) return;
|
|
894
|
-
const i = e.config.group, l = e.config.index, [r, a] = e.window;
|
|
895
|
-
let c = this.getCachedPaths(i, l, r, a);
|
|
896
|
-
if (c == null) {
|
|
897
|
-
const u = e.config.paths ?? en, h = e.xScale.dir, f = (S) => H(S), d = e.config.fillTo, y = typeof d == "function" ? d(e.yScale.min ?? 0, e.yScale.max ?? 0) : d;
|
|
898
|
-
c = u(
|
|
899
|
-
e.dataX,
|
|
900
|
-
e.dataY,
|
|
901
|
-
e.xScale,
|
|
902
|
-
e.yScale,
|
|
903
|
-
n.width,
|
|
904
|
-
n.height,
|
|
905
|
-
n.left,
|
|
906
|
-
n.top,
|
|
907
|
-
r,
|
|
908
|
-
a,
|
|
909
|
-
h,
|
|
910
|
-
f,
|
|
911
|
-
{ fillTo: y, spanGaps: e.config.spanGaps }
|
|
912
|
-
), this.setCachedPaths(i, l, r, a, c);
|
|
913
|
-
}
|
|
914
|
-
tn(o, e.config, c, s, n);
|
|
915
|
-
}
|
|
916
|
-
/**
|
|
917
|
-
* Full draw cycle: clear canvas and draw all series.
|
|
918
|
-
*/
|
|
919
|
-
draw(e, n, s, o) {
|
|
920
|
-
const i = this.ctx;
|
|
921
|
-
if (i == null) return;
|
|
922
|
-
const l = this.pxRatio;
|
|
923
|
-
i.clearRect(0, 0, e * l, n * l), i.save(), i.scale(l, l), i.beginPath(), i.rect(s.left, s.top, s.width, s.height), i.clip();
|
|
924
|
-
for (const r of o)
|
|
925
|
-
this.drawSeries(r, s, 1);
|
|
926
|
-
i.restore(), this.resetPropertyCache();
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
const ye = [1, 2, 2.5, 5], sn = ve(10, -32, 0, ye), on = ve(10, 0, 32, ye), ft = sn.concat(on);
|
|
930
|
-
function ln(t, e, n, s, o) {
|
|
931
|
-
if (n <= 0 || e < t) return [];
|
|
932
|
-
const i = [], l = xt.get(n) ?? 0, r = o ? t : ut(Xt(t, n), l);
|
|
933
|
-
for (let a = r; a <= e; a = ut(a + n, l))
|
|
934
|
-
i.push(Object.is(a, -0) ? 0 : a);
|
|
935
|
-
return i;
|
|
936
|
-
}
|
|
937
|
-
function ee(t) {
|
|
938
|
-
return t.map((e) => xe(e));
|
|
939
|
-
}
|
|
940
|
-
function rn(t, e, n) {
|
|
941
|
-
if (t <= 0 || e <= 0 || t >= e) return [];
|
|
942
|
-
const s = [], i = nt((n === 10 ? tt : St)(t));
|
|
943
|
-
let l = wt(n, i);
|
|
944
|
-
n === 10 && (l = ft[ct(l, ft)] ?? l);
|
|
945
|
-
let r = l, a = l * n;
|
|
946
|
-
n === 10 && (a = ft[ct(a, ft)] ?? a);
|
|
947
|
-
let c = 0;
|
|
948
|
-
do {
|
|
949
|
-
if (r >= t && s.push(r), r = r + l, n === 10 && !xt.has(r)) {
|
|
950
|
-
const u = xt.get(l) ?? 0;
|
|
951
|
-
r = ut(r, u);
|
|
952
|
-
}
|
|
953
|
-
r >= a * (1 - 1e-10) && (l = r, a = l * n, n === 10 && (a = ft[ct(a, ft)] ?? a));
|
|
954
|
-
} while (r <= e && ++c < 1e4);
|
|
955
|
-
return s;
|
|
956
|
-
}
|
|
957
|
-
function an(t, e) {
|
|
958
|
-
const n = e === 10 ? tt : St;
|
|
959
|
-
return t.map((s) => {
|
|
960
|
-
if (s === 0) return !0;
|
|
961
|
-
if (s < 0) return !1;
|
|
962
|
-
const o = n(s);
|
|
963
|
-
return gt(o - Math.round(o)) < 1e-10;
|
|
964
|
-
});
|
|
965
|
-
}
|
|
966
|
-
function cn(t, e) {
|
|
967
|
-
const s = xe(Math.max(Math.abs(t), Math.abs(e))).length * 7;
|
|
968
|
-
return Math.max(50, s + 16);
|
|
969
|
-
}
|
|
970
|
-
function un(t, e, n, s) {
|
|
971
|
-
if (s <= 0)
|
|
972
|
-
return [0, 0];
|
|
973
|
-
const o = Mt(t.side) === G.Vertical, i = t.space ?? (o ? 30 : cn(e, n)), l = t.incrs ?? ft;
|
|
974
|
-
return Ee(e, n, l, s, i);
|
|
975
|
-
}
|
|
976
|
-
const fn = 50;
|
|
977
|
-
function hn(t, e, n) {
|
|
978
|
-
var r, a;
|
|
979
|
-
if (t.size != null)
|
|
980
|
-
return t.size;
|
|
981
|
-
const s = ((r = t.ticks) == null ? void 0 : r.show) !== !1 ? ((a = t.ticks) == null ? void 0 : a.size) ?? 10 : 0, o = t.gap ?? 5, i = 12;
|
|
982
|
-
if (Mt(t.side) === G.Vertical && e != null) {
|
|
983
|
-
let c = 0;
|
|
984
|
-
for (const h of e)
|
|
985
|
-
h.length > c && (c = h.length);
|
|
986
|
-
const u = c * 7;
|
|
987
|
-
return Math.max(50, s + o + u + 4);
|
|
988
|
-
}
|
|
989
|
-
return Math.max(50, s + o + i + 3);
|
|
990
|
-
}
|
|
991
|
-
function dn(t) {
|
|
992
|
-
return {
|
|
993
|
-
config: t,
|
|
994
|
-
_show: t.show !== !1,
|
|
995
|
-
_size: t.size ?? fn,
|
|
996
|
-
_pos: 0,
|
|
997
|
-
_lpos: 0,
|
|
998
|
-
_splits: null,
|
|
999
|
-
_values: null,
|
|
1000
|
-
_incr: 0,
|
|
1001
|
-
_space: 0,
|
|
1002
|
-
_rotate: 0
|
|
1003
|
-
};
|
|
1004
|
-
}
|
|
1005
|
-
const mt = 60, ht = 3600, rt = 86400, dt = 2592e3, At = 31536e3, gn = [
|
|
1006
|
-
// Seconds
|
|
1007
|
-
1,
|
|
1008
|
-
5,
|
|
1009
|
-
10,
|
|
1010
|
-
15,
|
|
1011
|
-
30,
|
|
1012
|
-
// Minutes
|
|
1013
|
-
mt,
|
|
1014
|
-
5 * mt,
|
|
1015
|
-
10 * mt,
|
|
1016
|
-
15 * mt,
|
|
1017
|
-
30 * mt,
|
|
1018
|
-
// Hours
|
|
1019
|
-
ht,
|
|
1020
|
-
2 * ht,
|
|
1021
|
-
3 * ht,
|
|
1022
|
-
4 * ht,
|
|
1023
|
-
6 * ht,
|
|
1024
|
-
12 * ht,
|
|
1025
|
-
// Days
|
|
1026
|
-
rt,
|
|
1027
|
-
2 * rt,
|
|
1028
|
-
3 * rt,
|
|
1029
|
-
7 * rt,
|
|
1030
|
-
14 * rt,
|
|
1031
|
-
// Months (approximate)
|
|
1032
|
-
dt,
|
|
1033
|
-
2 * dt,
|
|
1034
|
-
3 * dt,
|
|
1035
|
-
6 * dt,
|
|
1036
|
-
// Years
|
|
1037
|
-
At
|
|
1038
|
-
];
|
|
1039
|
-
function pn(t, e, n, s) {
|
|
1040
|
-
const o = [];
|
|
1041
|
-
if (n <= 0 || t >= e) return o;
|
|
1042
|
-
let i;
|
|
1043
|
-
if (n >= At) {
|
|
1044
|
-
const l = new Date(t * 1e3);
|
|
1045
|
-
for (l.setUTCMonth(0, 1), l.setUTCHours(0, 0, 0, 0), i = l.getTime() / 1e3, i < t && (l.setUTCFullYear(l.getUTCFullYear() + 1), i = l.getTime() / 1e3); i <= e; )
|
|
1046
|
-
o.push(i), l.setUTCFullYear(l.getUTCFullYear() + Math.round(n / At)), i = l.getTime() / 1e3;
|
|
1047
|
-
return o;
|
|
1048
|
-
}
|
|
1049
|
-
if (n >= dt) {
|
|
1050
|
-
const l = new Date(t * 1e3);
|
|
1051
|
-
l.setUTCDate(1), l.setUTCHours(0, 0, 0, 0), i = l.getTime() / 1e3;
|
|
1052
|
-
const r = Math.max(1, Math.round(n / dt));
|
|
1053
|
-
if (i < t && (l.setUTCMonth(l.getUTCMonth() + 1), i = l.getTime() / 1e3), r > 1) {
|
|
1054
|
-
const a = l.getUTCMonth(), c = Math.ceil((a + 1) / r) * r;
|
|
1055
|
-
l.setUTCMonth(c - 1), i = l.getTime() / 1e3;
|
|
1056
|
-
}
|
|
1057
|
-
for (; i <= e; )
|
|
1058
|
-
o.push(i), l.setUTCMonth(l.getUTCMonth() + r), i = l.getTime() / 1e3;
|
|
1059
|
-
return o;
|
|
1060
|
-
}
|
|
1061
|
-
if (n >= rt) {
|
|
1062
|
-
const l = new Date(t * 1e3);
|
|
1063
|
-
l.setUTCHours(0, 0, 0, 0), i = l.getTime() / 1e3, i < t && (i += rt);
|
|
1064
|
-
} else
|
|
1065
|
-
i = Math.ceil(t / n) * n;
|
|
1066
|
-
for (let l = 0; ; l++) {
|
|
1067
|
-
const r = i + l * n;
|
|
1068
|
-
if (r > e) break;
|
|
1069
|
-
o.push(r);
|
|
1070
|
-
}
|
|
1071
|
-
return o;
|
|
1072
|
-
}
|
|
1073
|
-
const ne = /* @__PURE__ */ new Map();
|
|
1074
|
-
function mn(t, e) {
|
|
1075
|
-
const n = JSON.stringify(t) + (e ?? "");
|
|
1076
|
-
let s = ne.get(n);
|
|
1077
|
-
return s == null && (s = new Intl.DateTimeFormat(void 0, { ...t, timeZone: e }), ne.set(n, s)), s;
|
|
1078
|
-
}
|
|
1079
|
-
function et(t, e, n) {
|
|
1080
|
-
const s = new Date(t * 1e3);
|
|
1081
|
-
return mn(e, n).format(s);
|
|
1082
|
-
}
|
|
1083
|
-
function wn(t, e) {
|
|
1084
|
-
return et(t, { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit", hour12: !1 }, e);
|
|
1085
|
-
}
|
|
1086
|
-
function vn(t, e) {
|
|
1087
|
-
return et(t, { hour: "2-digit", minute: "2-digit", second: "2-digit", hour12: !1 }, e);
|
|
1088
|
-
}
|
|
1089
|
-
function xn(t, e) {
|
|
1090
|
-
return et(t, { hour: "2-digit", minute: "2-digit", hour12: !1 }, e);
|
|
1091
|
-
}
|
|
1092
|
-
function Mn(t, e) {
|
|
1093
|
-
return et(t, { month: "short", day: "numeric" }, e);
|
|
1094
|
-
}
|
|
1095
|
-
function Sn(t, e) {
|
|
1096
|
-
return et(t, { year: "numeric" }, e);
|
|
1097
|
-
}
|
|
1098
|
-
function bn(t, e) {
|
|
1099
|
-
return et(t, { year: "numeric", month: "short" }, e);
|
|
1100
|
-
}
|
|
1101
|
-
function yn(t, e, n) {
|
|
1102
|
-
let s;
|
|
1103
|
-
return e >= At ? s = Sn : e >= dt ? s = bn : e >= rt ? s = Mn : e >= ht ? s = xn : e >= mt ? s = vn : s = wn, t.map((o) => s(o, n));
|
|
1104
|
-
}
|
|
1105
|
-
function kn(t, e, n, s, o) {
|
|
1106
|
-
const i = e - t;
|
|
1107
|
-
if (i <= 0 || s <= 0) return [0, 0];
|
|
1108
|
-
for (const r of n) {
|
|
1109
|
-
const a = i / r, c = s / a;
|
|
1110
|
-
if (c >= o)
|
|
1111
|
-
return [r, c];
|
|
1112
|
-
}
|
|
1113
|
-
const l = n[n.length - 1] ?? At;
|
|
1114
|
-
return [l, s / (i / l)];
|
|
1115
|
-
}
|
|
1116
|
-
const Cn = 3;
|
|
1117
|
-
function Tn(t, e, n, s, o) {
|
|
1118
|
-
let i = !0;
|
|
1119
|
-
for (const l of t) {
|
|
1120
|
-
const r = l.config;
|
|
1121
|
-
if (r.show === !1)
|
|
1122
|
-
continue;
|
|
1123
|
-
const a = e(r.scale);
|
|
1124
|
-
if (!a || a.min == null || a.max == null) {
|
|
1125
|
-
l._show && (i = !1, l._show = !1);
|
|
1126
|
-
continue;
|
|
1127
|
-
} else
|
|
1128
|
-
l._show || (i = !1, l._show = !0);
|
|
1129
|
-
const c = r.side, h = Mt(c) === G.Horizontal ? n : s, { min: f, max: d } = a;
|
|
1130
|
-
let y, S;
|
|
1131
|
-
if (a.time) {
|
|
1132
|
-
const g = r.space ?? 80;
|
|
1133
|
-
[y, S] = kn(f, d, gn, h, g);
|
|
1134
|
-
} else
|
|
1135
|
-
[y, S] = un(r, f, d, h);
|
|
1136
|
-
if (l._incr = y, l._space = S, S === 0)
|
|
1137
|
-
continue;
|
|
1138
|
-
if (r.splits)
|
|
1139
|
-
l._splits = r.splits(f, d, y, S);
|
|
1140
|
-
else if (a.time)
|
|
1141
|
-
l._splits = pn(f, d, y);
|
|
1142
|
-
else if (a.distr === N.Log)
|
|
1143
|
-
l._splits = rn(f, d, a.log);
|
|
1144
|
-
else {
|
|
1145
|
-
const g = a.distr === N.Ordinal;
|
|
1146
|
-
l._splits = ln(f, d, y, S, g);
|
|
1147
|
-
}
|
|
1148
|
-
if (r.values)
|
|
1149
|
-
l._values = r.values(l._splits, S, y);
|
|
1150
|
-
else if (a.time)
|
|
1151
|
-
l._values = yn(l._splits, y);
|
|
1152
|
-
else if (a.distr === N.Log) {
|
|
1153
|
-
const g = an(l._splits, a.log), I = ee(l._splits);
|
|
1154
|
-
l._values = I.map((L, P) => g[P] ? L : "");
|
|
1155
|
-
} else
|
|
1156
|
-
l._values = ee(l._splits);
|
|
1157
|
-
l._rotate = c === U.Bottom ? r.rotate ?? 0 : 0;
|
|
1158
|
-
const p = l._size;
|
|
1159
|
-
l._size = Tt(hn(r, l._values)), p !== l._size && (i = !1);
|
|
1160
|
-
}
|
|
1161
|
-
return i;
|
|
1162
|
-
}
|
|
1163
|
-
function se(t, e, n) {
|
|
1164
|
-
let s = t, o = e, i = 0, l = 0;
|
|
1165
|
-
for (const r of n) {
|
|
1166
|
-
if (!r._show)
|
|
1167
|
-
continue;
|
|
1168
|
-
const a = r.config.side, c = Mt(a) === G.Vertical, u = r.config.label != null ? r.config.labelSize ?? 20 : 0, h = r._size + u;
|
|
1169
|
-
h > 0 && (c ? (s -= h, a === U.Left && (i += h)) : (o -= h, a === U.Top && (l += h)));
|
|
1170
|
-
}
|
|
1171
|
-
return {
|
|
1172
|
-
left: i,
|
|
1173
|
-
top: l,
|
|
1174
|
-
width: Math.max(s, 0),
|
|
1175
|
-
height: Math.max(o, 0)
|
|
1176
|
-
};
|
|
1177
|
-
}
|
|
1178
|
-
function In(t, e) {
|
|
1179
|
-
let n = e.top, s = e.left + e.width, o = e.top + e.height, i = e.left;
|
|
1180
|
-
function l(r, a) {
|
|
1181
|
-
switch (r) {
|
|
1182
|
-
case U.Top:
|
|
1183
|
-
return n -= a, n + a;
|
|
1184
|
-
case U.Right: {
|
|
1185
|
-
const c = s;
|
|
1186
|
-
return s += a, c;
|
|
1187
|
-
}
|
|
1188
|
-
case U.Bottom: {
|
|
1189
|
-
const c = o;
|
|
1190
|
-
return o += a, c;
|
|
1191
|
-
}
|
|
1192
|
-
case U.Left:
|
|
1193
|
-
return i -= a, i + a;
|
|
1194
|
-
default:
|
|
1195
|
-
return 0;
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
for (const r of t) {
|
|
1199
|
-
if (!r._show)
|
|
1200
|
-
continue;
|
|
1201
|
-
const a = r.config.side;
|
|
1202
|
-
if (r._pos = l(a, r._size), r.config.label != null) {
|
|
1203
|
-
const c = r.config.labelSize ?? 20;
|
|
1204
|
-
r._lpos = l(a, c);
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
function An(t, e, n, s) {
|
|
1209
|
-
for (const r of n)
|
|
1210
|
-
r._size = 0;
|
|
1211
|
-
let o = !1, i = 0, l = { left: 0, top: 0, width: t, height: e };
|
|
1212
|
-
for (; !o; ) {
|
|
1213
|
-
i++;
|
|
1214
|
-
const r = Tn(
|
|
1215
|
-
n,
|
|
1216
|
-
s,
|
|
1217
|
-
l.width,
|
|
1218
|
-
l.height
|
|
1219
|
-
);
|
|
1220
|
-
o = i === Cn || r, o || (l = se(t, e, n));
|
|
1221
|
-
}
|
|
1222
|
-
return l = se(t, e, n), In(n, l), l;
|
|
1223
|
-
}
|
|
1224
|
-
const oe = "top", le = "bottom", Pn = "left", Ln = "right";
|
|
1225
|
-
function ie(t, e) {
|
|
1226
|
-
return e === 1 ? t : t.replace(/(\d+(?:\.\d+)?)px/, (n, s) => `${Math.round(Number(s) * e)}px`);
|
|
1227
|
-
}
|
|
1228
|
-
function re(t, e, n, s, o, i, l, r, a, c, u) {
|
|
1229
|
-
const h = r % 2 / 2;
|
|
1230
|
-
t.save(), t.translate(h, h), t.strokeStyle = a, t.lineWidth = r, c.length > 0 && t.setLineDash(c), t.beginPath();
|
|
1231
|
-
let f = 0, d = 0, y = 0, S = 0;
|
|
1232
|
-
const p = i + (o === U.Top || o === U.Left ? -l : l);
|
|
1233
|
-
s === G.Horizontal ? (d = i, S = p) : (f = i, y = p);
|
|
1234
|
-
for (let g = 0; g < e.length; g++)
|
|
1235
|
-
n[g] != null && (s === G.Horizontal ? f = y = e[g] ?? 0 : d = S = e[g] ?? 0, t.moveTo(f, d), t.lineTo(y, S));
|
|
1236
|
-
t.stroke(), t.restore();
|
|
1237
|
-
}
|
|
1238
|
-
function zn(t, e, n, s, o) {
|
|
1239
|
-
const i = H(s.left * o), l = H(s.top * o), r = H(s.width * o), a = H(s.height * o);
|
|
1240
|
-
for (const c of e) {
|
|
1241
|
-
if (!c._show)
|
|
1242
|
-
continue;
|
|
1243
|
-
const u = c.config, h = u.side, f = Mt(h), d = n(u.scale);
|
|
1244
|
-
if (!d || d.min == null || d.max == null)
|
|
1245
|
-
continue;
|
|
1246
|
-
const y = u.stroke ?? "#000", S = h === U.Top || h === U.Left ? -1 : 1, p = c._splits, g = c._values;
|
|
1247
|
-
if (!p || !g || c._space === 0)
|
|
1248
|
-
continue;
|
|
1249
|
-
const I = f === G.Horizontal ? s.width : s.height, L = f === G.Horizontal ? s.left : s.top, P = p.map((k) => H(V(k, d, I, L) * o)), T = g.map((k) => k === "" ? null : k), M = u.grid;
|
|
1250
|
-
if ((M == null ? void 0 : M.show) !== !1) {
|
|
1251
|
-
const k = (M == null ? void 0 : M.stroke) ?? "rgba(0,0,0,0.12)", D = H(((M == null ? void 0 : M.width) ?? 2) * o), m = ((M == null ? void 0 : M.dash) ?? []).map((C) => C * o), v = f === G.Horizontal ? l : i, x = f === G.Horizontal ? a : r;
|
|
1252
|
-
re(t, P, T, f, 2, v, x, D, k, m);
|
|
1253
|
-
}
|
|
1254
|
-
const w = u.ticks;
|
|
1255
|
-
if ((w == null ? void 0 : w.show) !== !1) {
|
|
1256
|
-
const k = (w == null ? void 0 : w.stroke) ?? y, D = H(((w == null ? void 0 : w.width) ?? 1) * o), m = H(((w == null ? void 0 : w.size) ?? 10) * o), v = ((w == null ? void 0 : w.dash) ?? []).map((C) => C * o), x = H(c._pos * o);
|
|
1257
|
-
re(t, P, T, f, h, x, m, D, k, v);
|
|
1258
|
-
}
|
|
1259
|
-
{
|
|
1260
|
-
const k = (w == null ? void 0 : w.show) !== !1 ? ((w == null ? void 0 : w.size) ?? 10) * o : 0, D = H((u.gap ?? 5) * o), m = H(c._pos * o), v = (k + D) * S, x = m + v, C = ie(u.font ?? "12px system-ui, sans-serif", o), z = f === G.Horizontal ? "center" : h === U.Left ? Ln : Pn, A = f === G.Horizontal ? h === U.Bottom ? oe : le : "middle";
|
|
1261
|
-
t.font = C, t.fillStyle = y, t.textAlign = z, t.textBaseline = A;
|
|
1262
|
-
const F = c._rotate * -Vt / 180;
|
|
1263
|
-
for (let _ = 0; _ < g.length; _++) {
|
|
1264
|
-
const R = g[_];
|
|
1265
|
-
if (R == null || R === "")
|
|
1266
|
-
continue;
|
|
1267
|
-
const B = P[_] ?? 0;
|
|
1268
|
-
if (F !== 0)
|
|
1269
|
-
t.save(), t.translate(B, x), t.rotate(F), t.fillText(R, 0, 0), t.restore();
|
|
1270
|
-
else {
|
|
1271
|
-
const $ = f === G.Horizontal ? B : x, W = f === G.Horizontal ? x : B;
|
|
1272
|
-
t.fillText(R, $, W);
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
if (u.label != null) {
|
|
1277
|
-
const k = ie(u.labelFont ?? "bold 12px system-ui, sans-serif", o);
|
|
1278
|
-
t.font = k, t.fillStyle = y, t.textAlign = "center", t.textBaseline = h === U.Bottom ? oe : le;
|
|
1279
|
-
const D = H((c._lpos + (u.labelGap ?? 0) * S) * o);
|
|
1280
|
-
f === G.Vertical ? (t.save(), t.translate(
|
|
1281
|
-
D,
|
|
1282
|
-
H(l + a / 2)
|
|
1283
|
-
), t.rotate((h === U.Left ? -Vt : Vt) / 2), t.fillText(u.label, 0, 0), t.restore()) : t.fillText(u.label, H(i + r / 2), D);
|
|
1284
|
-
}
|
|
1285
|
-
const b = u.border;
|
|
1286
|
-
if ((b == null ? void 0 : b.show) !== !1 && b != null) {
|
|
1287
|
-
const k = b.stroke ?? y, D = H((b.width ?? 1) * o), m = (b.dash ?? []).map((x) => x * o), v = H(c._pos * o);
|
|
1288
|
-
t.strokeStyle = k, t.lineWidth = D, m.length > 0 && t.setLineDash(m), t.beginPath(), f === G.Horizontal ? (t.moveTo(i, v), t.lineTo(i + r, v)) : (t.moveTo(v, l), t.lineTo(v, l + a)), t.stroke(), m.length > 0 && t.setLineDash([]);
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
const Dn = {
|
|
1293
|
-
stroke: "#607D8B",
|
|
1294
|
-
width: 1,
|
|
1295
|
-
dash: [5, 3],
|
|
1296
|
-
pointRadius: 4,
|
|
1297
|
-
showX: !0,
|
|
1298
|
-
showY: !0
|
|
1299
|
-
};
|
|
1300
|
-
function ae(t, e, n, s, o, i, l, r, a) {
|
|
1301
|
-
var L;
|
|
1302
|
-
if (e.left < 0 || e.top < 0) return;
|
|
1303
|
-
const c = { ...Dn, ...a }, u = s, h = H(n.left * u), f = H(n.top * u), d = H(n.width * u), y = H(n.height * u), S = H(c.width * u), p = S % 2 / 2, g = H((n.left + e.left) * u) + p, I = H((n.top + e.top) * u) + p;
|
|
1304
|
-
if (t.save(), t.strokeStyle = c.stroke, t.lineWidth = S, t.setLineDash(c.dash.map((P) => P * u)), c.showX && (t.beginPath(), t.moveTo(g, f), t.lineTo(g, f + y), t.stroke()), c.showY && (t.beginPath(), t.moveTo(h, I), t.lineTo(h + d, I), t.stroke()), t.setLineDash([]), e.activeGroup >= 0 && e.activeDataIdx >= 0) {
|
|
1305
|
-
const P = e.activeGroup, T = e.activeSeriesIdx, M = e.activeDataIdx, w = o[P];
|
|
1306
|
-
if (w != null && T >= 0 && T < w.series.length && M < w.x.length) {
|
|
1307
|
-
const b = w.x[M], k = w.series[T], D = k != null ? k[M] : null;
|
|
1308
|
-
if (b != null && D != null) {
|
|
1309
|
-
let m = c.stroke, v = !0;
|
|
1310
|
-
for (const x of i)
|
|
1311
|
-
if (x.group === P && x.index === T) {
|
|
1312
|
-
const C = x.stroke;
|
|
1313
|
-
m = (typeof C == "string" ? C : void 0) ?? c.stroke, v = ((L = x.cursor) == null ? void 0 : L.show) !== !1;
|
|
1314
|
-
break;
|
|
1315
|
-
}
|
|
1316
|
-
if (v) {
|
|
1317
|
-
const x = r(P), C = x != null ? l(x) : void 0, z = Fn(i, P, T), A = z != null ? l(z) : void 0;
|
|
1318
|
-
if (C != null && A != null && C.min != null && C.max != null && A.min != null && A.max != null) {
|
|
1319
|
-
const F = H(V(b, C, n.width, n.left) * u), _ = H(V(D, A, n.height, n.top) * u), R = c.pointRadius * u, B = H(2 * u);
|
|
1320
|
-
t.beginPath(), t.arc(F, _, R, 0, Math.PI * 2), t.fillStyle = "#fff", t.fill(), t.strokeStyle = m, t.lineWidth = B, t.stroke();
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
t.restore();
|
|
1327
|
-
}
|
|
1328
|
-
function Fn(t, e, n) {
|
|
1329
|
-
for (const s of t)
|
|
1330
|
-
if (s.group === e && s.index === n)
|
|
1331
|
-
return s.yScale;
|
|
1332
|
-
}
|
|
1333
|
-
const _n = {
|
|
1334
|
-
fill: "rgba(0,0,0,0.07)",
|
|
1335
|
-
stroke: "rgba(0,0,0,0.15)",
|
|
1336
|
-
width: 1
|
|
1337
|
-
};
|
|
1338
|
-
function ce(t, e, n, s, o) {
|
|
1339
|
-
if (!e.show || e.width <= 0) return;
|
|
1340
|
-
const i = { ..._n, ...o }, l = s, r = H((n.left + e.left) * l), a = H((n.top + e.top) * l), c = H(e.width * l), u = H(e.height * l);
|
|
1341
|
-
t.save(), t.fillStyle = i.fill, t.fillRect(r, a, c, u), i.width > 0 && (t.strokeStyle = i.stroke, t.lineWidth = H(i.width * l), t.strokeRect(r, a, c, u)), t.restore();
|
|
1342
|
-
}
|
|
1343
|
-
function Rn(t, e, n, s, o, i, l, r, a, c, u, h) {
|
|
1344
|
-
const f = u / 2 * l, d = Math.max(1, H(u * 0.2)) * l, y = (c == null ? void 0 : c.stroke) ?? h, S = (c == null ? void 0 : c.fill) ?? "#fff";
|
|
1345
|
-
t.save(), t.strokeStyle = y, t.fillStyle = S, t.lineWidth = d, (c == null ? void 0 : c.dash) != null && t.setLineDash(c.dash.map((p) => p * l));
|
|
1346
|
-
for (let p = r; p <= a; p++) {
|
|
1347
|
-
const g = n[p];
|
|
1348
|
-
if (g == null) continue;
|
|
1349
|
-
const I = e[p];
|
|
1350
|
-
if (I == null) continue;
|
|
1351
|
-
const L = H(V(I, s, i.width, i.left) * l), P = H(V(g, o, i.height, i.top) * l);
|
|
1352
|
-
t.beginPath(), t.arc(L, P, f, 0, Math.PI * 2), t.fill(), t.stroke();
|
|
1353
|
-
}
|
|
1354
|
-
t.restore();
|
|
1355
|
-
}
|
|
1356
|
-
function Gn(t, e, n, s, o, i, l) {
|
|
1357
|
-
if (typeof t == "function")
|
|
1358
|
-
return t(e, n, s, o, i);
|
|
1359
|
-
if (t === !0) return !0;
|
|
1360
|
-
if (t === !1) return !1;
|
|
1361
|
-
const r = o - s;
|
|
1362
|
-
return r > 0 && r <= i / l;
|
|
1363
|
-
}
|
|
1364
|
-
function Vn(t, e, n, s, o, i, l, r, a, c, u) {
|
|
1365
|
-
if (c > u || c < 0) return;
|
|
1366
|
-
const h = e.fill ?? "rgba(0, 120, 255, 0.1)", f = (S) => V(S, i, r.width, r.left) * a, d = (S) => V(S, l, r.height, r.top) * a;
|
|
1367
|
-
t.save(), t.fillStyle = h, t.beginPath();
|
|
1368
|
-
let y = !1;
|
|
1369
|
-
for (let S = c; S <= u; S++) {
|
|
1370
|
-
const p = s[S], g = n[S];
|
|
1371
|
-
if (p == null || g == null) continue;
|
|
1372
|
-
const I = f(g), L = d(p);
|
|
1373
|
-
y ? t.lineTo(I, L) : (t.moveTo(I, L), y = !0);
|
|
1374
|
-
}
|
|
1375
|
-
if (!y) {
|
|
1376
|
-
t.restore();
|
|
1377
|
-
return;
|
|
1378
|
-
}
|
|
1379
|
-
for (let S = u; S >= c; S--) {
|
|
1380
|
-
const p = o[S], g = n[S];
|
|
1381
|
-
p == null || g == null || t.lineTo(f(g), d(p));
|
|
1382
|
-
}
|
|
1383
|
-
t.closePath(), t.fill(), t.restore();
|
|
1384
|
-
}
|
|
1385
|
-
function Bt(t, e, n, s) {
|
|
1386
|
-
return { ctx: t, plotBox: e, pxRatio: n, getScale: s, valToX: (l, r = "x") => {
|
|
1387
|
-
const a = s(r);
|
|
1388
|
-
return a == null || a.min == null || a.max == null ? null : V(l, a, e.width, e.left);
|
|
1389
|
-
}, valToY: (l, r) => {
|
|
1390
|
-
const a = s(r);
|
|
1391
|
-
return a == null || a.min == null || a.max == null ? null : V(l, a, e.height, e.top);
|
|
1392
|
-
} };
|
|
1393
|
-
}
|
|
1394
|
-
function Hn() {
|
|
1395
|
-
const t = {
|
|
1396
|
-
scaleManager: new Ye(),
|
|
1397
|
-
dataStore: new Ne(),
|
|
1398
|
-
renderer: new nn(),
|
|
1399
|
-
cursorManager: new Ke(),
|
|
1400
|
-
selectState: { show: !1, left: 0, top: 0, width: 0, height: 0 },
|
|
1401
|
-
scaleConfigs: [],
|
|
1402
|
-
seriesConfigs: [],
|
|
1403
|
-
axisConfigs: [],
|
|
1404
|
-
bandConfigs: [],
|
|
1405
|
-
axisStates: [],
|
|
1406
|
-
width: 0,
|
|
1407
|
-
height: 0,
|
|
1408
|
-
pxRatio: typeof window < "u" && window.devicePixelRatio || 1,
|
|
1409
|
-
plotBox: { left: 0, top: 0, width: 0, height: 0 },
|
|
1410
|
-
canvas: null,
|
|
1411
|
-
listeners: /* @__PURE__ */ new Set(),
|
|
1412
|
-
scheduler: new je(),
|
|
1413
|
-
drawHooks: /* @__PURE__ */ new Set(),
|
|
1414
|
-
cursorDrawHooks: /* @__PURE__ */ new Set(),
|
|
1415
|
-
focusedSeries: null,
|
|
1416
|
-
focusAlpha: 0.15,
|
|
1417
|
-
wheelZoom: !1,
|
|
1418
|
-
revision: 0,
|
|
1419
|
-
eventCallbacks: {},
|
|
1420
|
-
_prevScaleRanges: /* @__PURE__ */ new Map(),
|
|
1421
|
-
registerScale(e) {
|
|
1422
|
-
t.scaleConfigs = t.scaleConfigs.filter((n) => n.id !== e.id), t.scaleConfigs.push(e), t.scaleManager.addScale(e);
|
|
1423
|
-
},
|
|
1424
|
-
unregisterScale(e) {
|
|
1425
|
-
t.scaleConfigs = t.scaleConfigs.filter((n) => n.id !== e), t.scaleManager.removeScale(e);
|
|
1426
|
-
},
|
|
1427
|
-
registerSeries(e) {
|
|
1428
|
-
t.seriesConfigs = t.seriesConfigs.filter(
|
|
1429
|
-
(n) => !(n.group === e.group && n.index === e.index)
|
|
1430
|
-
), t.seriesConfigs.push(e);
|
|
1431
|
-
},
|
|
1432
|
-
unregisterSeries(e, n) {
|
|
1433
|
-
t.seriesConfigs = t.seriesConfigs.filter(
|
|
1434
|
-
(s) => !(s.group === e && s.index === n)
|
|
1435
|
-
);
|
|
1436
|
-
},
|
|
1437
|
-
toggleSeries(e, n) {
|
|
1438
|
-
const s = t.seriesConfigs.find((o) => o.group === e && o.index === n);
|
|
1439
|
-
s != null && (s.show = s.show === !1, t.revision++, t.renderer.invalidateSeries(e, n), t.scheduleRedraw());
|
|
1440
|
-
},
|
|
1441
|
-
setFocus(e) {
|
|
1442
|
-
t.focusedSeries = e, t.scheduleRedraw();
|
|
1443
|
-
},
|
|
1444
|
-
setSize(e, n) {
|
|
1445
|
-
t.width = e, t.height = n, t.canvas && (t.canvas.width = e * t.pxRatio, t.canvas.height = n * t.pxRatio, t.canvas.style.width = `${e}px`, t.canvas.style.height = `${n}px`), t.renderer.clearCache(), t.scheduleRedraw();
|
|
1446
|
-
},
|
|
1447
|
-
scheduleRedraw() {
|
|
1448
|
-
t.scheduler.mark(Q.Full);
|
|
1449
|
-
},
|
|
1450
|
-
scheduleCursorRedraw() {
|
|
1451
|
-
t.scheduler.mark(Q.Cursor);
|
|
1452
|
-
},
|
|
1453
|
-
subscribe(e) {
|
|
1454
|
-
return t.listeners.add(e), () => {
|
|
1455
|
-
t.listeners.delete(e);
|
|
1456
|
-
};
|
|
1457
|
-
},
|
|
1458
|
-
redraw() {
|
|
1459
|
-
const { scaleManager: e, dataStore: n, renderer: s, seriesConfigs: o, width: i, height: l, pxRatio: r, canvas: a, scheduler: c } = t;
|
|
1460
|
-
if (a == null || i === 0 || l === 0) return;
|
|
1461
|
-
const u = a.getContext("2d");
|
|
1462
|
-
if (u == null) return;
|
|
1463
|
-
s.setContext(u, r);
|
|
1464
|
-
const f = (c.dirty & ~(Q.Cursor | Q.Select)) === 0, d = (p) => e.getScale(p);
|
|
1465
|
-
if (f && s.restoreSnapshot(u)) {
|
|
1466
|
-
if (ae(
|
|
1467
|
-
u,
|
|
1468
|
-
t.cursorManager.state,
|
|
1469
|
-
t.plotBox,
|
|
1470
|
-
r,
|
|
1471
|
-
n.data,
|
|
1472
|
-
o,
|
|
1473
|
-
d,
|
|
1474
|
-
(p) => e.getGroupXScaleKey(p)
|
|
1475
|
-
), ce(u, t.selectState, t.plotBox, r), t.cursorDrawHooks.size > 0) {
|
|
1476
|
-
u.save(), u.scale(r, r);
|
|
1477
|
-
const p = Bt(u, t.plotBox, r, d);
|
|
1478
|
-
for (const g of t.cursorDrawHooks)
|
|
1479
|
-
try {
|
|
1480
|
-
g(p, t.cursorManager.state);
|
|
1481
|
-
} catch (I) {
|
|
1482
|
-
console.warn("[uPlot+] draw hook error:", I);
|
|
1483
|
-
}
|
|
1484
|
-
u.restore();
|
|
1485
|
-
}
|
|
1486
|
-
for (const p of t.listeners) p();
|
|
1487
|
-
return;
|
|
1488
|
-
}
|
|
1489
|
-
e.autoRangeX(n.data), n.updateWindows((p) => {
|
|
1490
|
-
const g = e.getGroupXScaleKey(p);
|
|
1491
|
-
return g != null ? e.getScale(g) : void 0;
|
|
1492
|
-
});
|
|
1493
|
-
const y = o.map((p) => ({
|
|
1494
|
-
group: p.group,
|
|
1495
|
-
index: p.index,
|
|
1496
|
-
yScale: p.yScale
|
|
1497
|
-
}));
|
|
1498
|
-
e.autoRange(n.data, y, n), Bn(t), t.axisStates.length > 0 ? t.plotBox = An(i, l, t.axisStates, d) : t.plotBox = {
|
|
1499
|
-
left: 10,
|
|
1500
|
-
top: 10,
|
|
1501
|
-
width: i - 20,
|
|
1502
|
-
height: l - 20
|
|
1503
|
-
}, u.clearRect(0, 0, i * r, l * r), t.axisStates.length > 0 && zn(u, t.axisStates, d, t.plotBox, r);
|
|
1504
|
-
const S = [];
|
|
1505
|
-
for (const p of o) {
|
|
1506
|
-
const g = e.getGroupXScaleKey(p.group), I = g != null ? e.getScale(g) : void 0, L = e.getScale(p.yScale);
|
|
1507
|
-
I == null || L == null || S.push({
|
|
1508
|
-
config: p,
|
|
1509
|
-
dataX: n.getXValues(p.group),
|
|
1510
|
-
dataY: n.getYValues(p.group, p.index),
|
|
1511
|
-
xScale: I,
|
|
1512
|
-
yScale: L,
|
|
1513
|
-
window: n.getWindow(p.group)
|
|
1514
|
-
});
|
|
1515
|
-
}
|
|
1516
|
-
u.save(), u.scale(r, r), u.beginPath(), u.rect(t.plotBox.left, t.plotBox.top, t.plotBox.width, t.plotBox.height), u.clip();
|
|
1517
|
-
for (let p = 0; p < S.length; p++) {
|
|
1518
|
-
const g = S[p];
|
|
1519
|
-
g != null && (t.focusedSeries != null && p !== t.focusedSeries ? (u.globalAlpha = t.focusAlpha, s.drawSeries(g, t.plotBox, 1), u.globalAlpha = 1) : s.drawSeries(g, t.plotBox, 1));
|
|
1520
|
-
}
|
|
1521
|
-
for (const p of t.bandConfigs) {
|
|
1522
|
-
const g = e.getGroupXScaleKey(p.group), I = g != null ? e.getScale(g) : void 0, L = o.find((b) => b.group === p.group && b.index === p.series[0]), P = o.find((b) => b.group === p.group && b.index === p.series[1]);
|
|
1523
|
-
if (I == null || L == null || P == null) continue;
|
|
1524
|
-
const T = e.getScale(L.yScale);
|
|
1525
|
-
if (T == null) continue;
|
|
1526
|
-
const [M, w] = n.getWindow(p.group);
|
|
1527
|
-
Vn(
|
|
1528
|
-
u,
|
|
1529
|
-
p,
|
|
1530
|
-
n.getXValues(p.group),
|
|
1531
|
-
n.getYValues(p.group, p.series[0]),
|
|
1532
|
-
n.getYValues(p.group, p.series[1]),
|
|
1533
|
-
I,
|
|
1534
|
-
T,
|
|
1535
|
-
t.plotBox,
|
|
1536
|
-
r,
|
|
1537
|
-
M,
|
|
1538
|
-
w
|
|
1539
|
-
);
|
|
1540
|
-
}
|
|
1541
|
-
for (const p of S) {
|
|
1542
|
-
const g = p.config;
|
|
1543
|
-
if (g.show === !1) continue;
|
|
1544
|
-
const I = g.points, L = g.width ?? 1, P = (I == null ? void 0 : I.size) ?? 3 + L * 2, T = (I == null ? void 0 : I.space) ?? P * 2, [M, w] = p.window;
|
|
1545
|
-
Gn(I == null ? void 0 : I.show, g.group, g.index, M, w, t.plotBox.width, T) && Rn(
|
|
1546
|
-
u,
|
|
1547
|
-
p.dataX,
|
|
1548
|
-
p.dataY,
|
|
1549
|
-
p.xScale,
|
|
1550
|
-
p.yScale,
|
|
1551
|
-
t.plotBox,
|
|
1552
|
-
r,
|
|
1553
|
-
M,
|
|
1554
|
-
w,
|
|
1555
|
-
I,
|
|
1556
|
-
P,
|
|
1557
|
-
(typeof g.stroke == "string" ? g.stroke : null) ?? "#000"
|
|
1558
|
-
);
|
|
1559
|
-
}
|
|
1560
|
-
if (u.restore(), t.drawHooks.size > 0) {
|
|
1561
|
-
u.save(), u.beginPath(), u.rect(
|
|
1562
|
-
t.plotBox.left * r,
|
|
1563
|
-
t.plotBox.top * r,
|
|
1564
|
-
t.plotBox.width * r,
|
|
1565
|
-
t.plotBox.height * r
|
|
1566
|
-
), u.clip(), u.scale(r, r);
|
|
1567
|
-
const p = Bt(u, t.plotBox, r, d);
|
|
1568
|
-
for (const g of t.drawHooks)
|
|
1569
|
-
try {
|
|
1570
|
-
g(p);
|
|
1571
|
-
} catch (I) {
|
|
1572
|
-
console.warn("[uPlot+] draw hook error:", I);
|
|
1573
|
-
}
|
|
1574
|
-
u.restore();
|
|
1575
|
-
}
|
|
1576
|
-
if (t.cursorManager.state.left >= 0 && (s.saveSnapshot(u, i * r, l * r), t.cursorManager.update(
|
|
1577
|
-
t.cursorManager.state.left,
|
|
1578
|
-
t.cursorManager.state.top,
|
|
1579
|
-
t.plotBox,
|
|
1580
|
-
n.data,
|
|
1581
|
-
o,
|
|
1582
|
-
d,
|
|
1583
|
-
(p) => n.getWindow(p),
|
|
1584
|
-
(p) => e.getGroupXScaleKey(p)
|
|
1585
|
-
)), ae(
|
|
1586
|
-
u,
|
|
1587
|
-
t.cursorManager.state,
|
|
1588
|
-
t.plotBox,
|
|
1589
|
-
r,
|
|
1590
|
-
n.data,
|
|
1591
|
-
o,
|
|
1592
|
-
d,
|
|
1593
|
-
(p) => e.getGroupXScaleKey(p)
|
|
1594
|
-
), ce(u, t.selectState, t.plotBox, r), t.cursorDrawHooks.size > 0) {
|
|
1595
|
-
u.save(), u.scale(r, r);
|
|
1596
|
-
const p = Bt(u, t.plotBox, r, d);
|
|
1597
|
-
for (const g of t.cursorDrawHooks)
|
|
1598
|
-
try {
|
|
1599
|
-
g(p, t.cursorManager.state);
|
|
1600
|
-
} catch (I) {
|
|
1601
|
-
console.warn("[uPlot+] draw hook error:", I);
|
|
1602
|
-
}
|
|
1603
|
-
u.restore();
|
|
1604
|
-
}
|
|
1605
|
-
for (const p of t.listeners) p();
|
|
1606
|
-
if (t._prevScaleRanges.size > 0 && t.eventCallbacks.onScaleChange != null)
|
|
1607
|
-
for (const p of e.getAllScales()) {
|
|
1608
|
-
if (p.min == null || p.max == null) continue;
|
|
1609
|
-
const g = t._prevScaleRanges.get(p.id);
|
|
1610
|
-
if (g == null || g.min !== p.min || g.max !== p.max)
|
|
1611
|
-
try {
|
|
1612
|
-
t.eventCallbacks.onScaleChange(p.id, p.min, p.max);
|
|
1613
|
-
} catch (I) {
|
|
1614
|
-
console.warn("[uPlot+] event callback error:", I);
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
t._prevScaleRanges.clear();
|
|
1618
|
-
for (const p of e.getAllScales())
|
|
1619
|
-
p.min != null && p.max != null && t._prevScaleRanges.set(p.id, { min: p.min, max: p.max });
|
|
1620
|
-
}
|
|
1621
|
-
};
|
|
1622
|
-
return t.scheduler.onRedraw(() => t.redraw()), t;
|
|
1623
|
-
}
|
|
1624
|
-
function Bn(t) {
|
|
1625
|
-
const { axisConfigs: e, axisStates: n } = t, s = /* @__PURE__ */ new Map();
|
|
1626
|
-
for (const o of n)
|
|
1627
|
-
s.set(`${o.config.scale}:${o.config.side}`, o);
|
|
1628
|
-
t.axisStates = e.map((o) => {
|
|
1629
|
-
const i = `${o.scale}:${o.side}`, l = s.get(i);
|
|
1630
|
-
return l != null ? (l.config = o, l) : dn(o);
|
|
1631
|
-
});
|
|
1632
|
-
}
|
|
1633
|
-
function En() {
|
|
1634
|
-
const t = X(null);
|
|
1635
|
-
return t.current === null && (t.current = Hn()), t.current;
|
|
1636
|
-
}
|
|
1637
|
-
const ke = Le(null);
|
|
1638
|
-
function st() {
|
|
1639
|
-
const t = Pe(ke);
|
|
1640
|
-
if (!t)
|
|
1641
|
-
throw new Error("useChart must be used within a <Chart> component");
|
|
1642
|
-
return t;
|
|
1643
|
-
}
|
|
1644
|
-
function Wn(t, e) {
|
|
1645
|
-
Y(() => {
|
|
1646
|
-
if (e != null)
|
|
1647
|
-
return Xn(t, e);
|
|
1648
|
-
}, [t, e]);
|
|
1649
|
-
}
|
|
1650
|
-
function Xn(t, e) {
|
|
1651
|
-
let n = null;
|
|
1652
|
-
const s = { show: !1, left: 0, top: 0, width: 0, height: 0 };
|
|
1653
|
-
let o = null, i = null, l = !1;
|
|
1654
|
-
function r(m) {
|
|
1655
|
-
const v = e.getBoundingClientRect(), x = t.plotBox, C = m.clientX - v.left - x.left, z = m.clientY - v.top - x.top;
|
|
1656
|
-
return { cx: C, cy: z };
|
|
1657
|
-
}
|
|
1658
|
-
function a(m, v) {
|
|
1659
|
-
const x = t.plotBox;
|
|
1660
|
-
return m >= 0 && m <= x.width && v >= 0 && v <= x.height;
|
|
1661
|
-
}
|
|
1662
|
-
function c(m, v) {
|
|
1663
|
-
const x = e.getBoundingClientRect(), C = m - x.left, z = v - x.top, A = t.plotBox;
|
|
1664
|
-
for (const F of t.axisStates) {
|
|
1665
|
-
const _ = F.config, R = _.side;
|
|
1666
|
-
if (F._size <= 0) continue;
|
|
1667
|
-
const $ = z >= A.top && z <= A.top + A.height, W = C >= A.left && C <= A.left + A.width;
|
|
1668
|
-
if (R === U.Left && C < A.left && $ || R === U.Right && C > A.left + A.width && $ || R === U.Top && z < A.top && W || R === U.Bottom && z > A.top + A.height && W) {
|
|
1669
|
-
const Z = Mt(R);
|
|
1670
|
-
return { scaleId: _.scale, ori: Z };
|
|
1671
|
-
}
|
|
1672
|
-
}
|
|
1673
|
-
return null;
|
|
1674
|
-
}
|
|
1675
|
-
function u(m, v, x) {
|
|
1676
|
-
const C = t.cursorManager.state;
|
|
1677
|
-
let z = null;
|
|
1678
|
-
if (C.activeGroup >= 0 && C.activeDataIdx >= 0) {
|
|
1679
|
-
const A = t.dataStore.data[C.activeGroup];
|
|
1680
|
-
if (A != null) {
|
|
1681
|
-
const F = A.x[C.activeDataIdx], _ = A.series[C.activeSeriesIdx], R = _ != null ? _[C.activeDataIdx] : void 0;
|
|
1682
|
-
if (F != null && R != null) {
|
|
1683
|
-
const B = t.plotBox, $ = t.scaleManager.getGroupXScaleKey(C.activeGroup), W = $ != null ? t.scaleManager.getScale($) : void 0, ot = t.seriesConfigs.find(
|
|
1684
|
-
(jt) => jt.group === C.activeGroup && jt.index === C.activeSeriesIdx
|
|
1685
|
-
), Z = ot != null ? t.scaleManager.getScale(ot.yScale) : void 0;
|
|
1686
|
-
let pt = v, Gt = x;
|
|
1687
|
-
(W == null ? void 0 : W.min) != null && W.max != null && (pt = V(F, W, B.width, B.left) - B.left), (Z == null ? void 0 : Z.min) != null && Z.max != null && (Gt = V(R, Z, B.height, B.top) - B.top);
|
|
1688
|
-
const Nt = v - pt, Kt = x - Gt;
|
|
1689
|
-
z = {
|
|
1690
|
-
group: C.activeGroup,
|
|
1691
|
-
seriesIdx: C.activeSeriesIdx,
|
|
1692
|
-
dataIdx: C.activeDataIdx,
|
|
1693
|
-
xVal: F,
|
|
1694
|
-
yVal: R,
|
|
1695
|
-
pxX: pt,
|
|
1696
|
-
pxY: Gt,
|
|
1697
|
-
dist: Math.sqrt(Nt * Nt + Kt * Kt)
|
|
1698
|
-
};
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
return { plotX: v, plotY: x, point: z, srcEvent: m };
|
|
1703
|
-
}
|
|
1704
|
-
function h(m) {
|
|
1705
|
-
const v = t.plotBox, x = m.left / v.width, C = (m.left + m.width) / v.width, z = {};
|
|
1706
|
-
for (const A of t.scaleManager.getAllScales()) {
|
|
1707
|
-
if (A.ori !== G.Horizontal || A.min == null || A.max == null) continue;
|
|
1708
|
-
const F = it(
|
|
1709
|
-
v.left + x * v.width,
|
|
1710
|
-
A,
|
|
1711
|
-
v.width,
|
|
1712
|
-
v.left
|
|
1713
|
-
), _ = it(
|
|
1714
|
-
v.left + C * v.width,
|
|
1715
|
-
A,
|
|
1716
|
-
v.width,
|
|
1717
|
-
v.left
|
|
1718
|
-
);
|
|
1719
|
-
z[A.id] = {
|
|
1720
|
-
min: Math.min(F, _),
|
|
1721
|
-
max: Math.max(F, _)
|
|
1722
|
-
};
|
|
1723
|
-
}
|
|
1724
|
-
return { left: x, right: C, ranges: z };
|
|
1725
|
-
}
|
|
1726
|
-
function f() {
|
|
1727
|
-
const m = t.eventCallbacks.onScaleChange;
|
|
1728
|
-
if (m != null)
|
|
1729
|
-
for (const v of t.scaleManager.getAllScales()) {
|
|
1730
|
-
if (v.min == null || v.max == null) continue;
|
|
1731
|
-
const x = t._prevScaleRanges.get(v.id);
|
|
1732
|
-
(x == null || x.min !== v.min || x.max !== v.max) && m(v.id, v.min, v.max);
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
function d(m, v) {
|
|
1736
|
-
if (i != null) {
|
|
1737
|
-
const A = e.getBoundingClientRect(), F = m.clientY - A.top, _ = t.plotBox, R = (F - i.startY) / _.height, B = i.startMax - i.startMin, $ = t.scaleManager.getScale(i.scaleId);
|
|
1738
|
-
$ != null && ($.min = i.startMin + R * B, $.max = i.startMax + R * B, $.auto = !1, at($), t.renderer.clearCache(), t.scheduleRedraw());
|
|
1739
|
-
return;
|
|
1740
|
-
}
|
|
1741
|
-
const x = r(m);
|
|
1742
|
-
if (x == null) return;
|
|
1743
|
-
const { cx: C, cy: z } = x;
|
|
1744
|
-
if (!a(C, z) && n == null) {
|
|
1745
|
-
t.cursorManager.hide(), t.focusedSeries != null && t.setFocus(null), t.scheduleCursorRedraw();
|
|
1746
|
-
return;
|
|
1747
|
-
}
|
|
1748
|
-
if (t.cursorManager.update(
|
|
1749
|
-
C,
|
|
1750
|
-
z,
|
|
1751
|
-
t.plotBox,
|
|
1752
|
-
t.dataStore.data,
|
|
1753
|
-
t.seriesConfigs,
|
|
1754
|
-
(A) => t.scaleManager.getScale(A),
|
|
1755
|
-
(A) => t.dataStore.getWindow(A),
|
|
1756
|
-
(A) => t.scaleManager.getGroupXScaleKey(A)
|
|
1757
|
-
), t.focusAlpha < 1) {
|
|
1758
|
-
const A = t.cursorManager.state;
|
|
1759
|
-
if (A.activeGroup >= 0 && A.activeSeriesIdx >= 0) {
|
|
1760
|
-
const F = t.seriesConfigs.findIndex(
|
|
1761
|
-
(_) => _.group === A.activeGroup && _.index === A.activeSeriesIdx
|
|
1762
|
-
);
|
|
1763
|
-
F >= 0 && t.focusedSeries !== F && (t.focusedSeries = F, t.renderer.clearCache(), t.scheduleRedraw());
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
|
-
if (v != null && t.eventCallbacks.onCursorMove != null && a(C, z))
|
|
1767
|
-
try {
|
|
1768
|
-
t.eventCallbacks.onCursorMove(u(v, C, z));
|
|
1769
|
-
} catch (A) {
|
|
1770
|
-
console.warn("[uPlot+] event callback error:", A);
|
|
1771
|
-
}
|
|
1772
|
-
if (n != null) {
|
|
1773
|
-
const A = n.x, F = t.plotBox, _ = Math.max(0, Math.min(C, F.width));
|
|
1774
|
-
s.show = !0, s.left = Math.min(A, _), s.top = 0, s.width = Math.abs(_ - A), s.height = F.height, t.selectState = s;
|
|
1775
|
-
}
|
|
1776
|
-
n != null ? t.scheduler.mark(Q.Cursor | Q.Select) : t.scheduleCursorRedraw();
|
|
1777
|
-
}
|
|
1778
|
-
function y(m) {
|
|
1779
|
-
d(m, m);
|
|
1780
|
-
}
|
|
1781
|
-
function S(m) {
|
|
1782
|
-
if (m.button !== 0) return;
|
|
1783
|
-
const v = c(m.clientX, m.clientY);
|
|
1784
|
-
if (v != null && v.ori === G.Vertical) {
|
|
1785
|
-
const C = t.scaleManager.getScale(v.scaleId);
|
|
1786
|
-
if (C != null && C.min != null && C.max != null) {
|
|
1787
|
-
const z = e.getBoundingClientRect();
|
|
1788
|
-
i = {
|
|
1789
|
-
scaleId: v.scaleId,
|
|
1790
|
-
startY: m.clientY - z.top,
|
|
1791
|
-
startMin: C.min,
|
|
1792
|
-
startMax: C.max
|
|
1793
|
-
}, m.preventDefault();
|
|
1794
|
-
return;
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
const x = r(m);
|
|
1798
|
-
x != null && a(x.cx, x.cy) && (n = { x: x.cx, y: x.cy }, l = !1, s.show = !1, s.left = 0, s.width = 0, t.selectState = s);
|
|
1799
|
-
}
|
|
1800
|
-
function p(m) {
|
|
1801
|
-
if (i != null) {
|
|
1802
|
-
f(), i = null;
|
|
1803
|
-
return;
|
|
1804
|
-
}
|
|
1805
|
-
if (n != null) {
|
|
1806
|
-
if (s.width > 5) {
|
|
1807
|
-
l = !0;
|
|
1808
|
-
let v = !0;
|
|
1809
|
-
if (t.eventCallbacks.onSelect != null) {
|
|
1810
|
-
const x = h(s);
|
|
1811
|
-
let C;
|
|
1812
|
-
try {
|
|
1813
|
-
C = t.eventCallbacks.onSelect(x);
|
|
1814
|
-
} catch (z) {
|
|
1815
|
-
console.warn("[uPlot+] event callback error:", z);
|
|
1816
|
-
}
|
|
1817
|
-
C === !1 && (v = !1);
|
|
1818
|
-
}
|
|
1819
|
-
v && (w(s), f());
|
|
1820
|
-
}
|
|
1821
|
-
n = null, s.show = !1, s.left = 0, s.width = 0, t.selectState = s, t.scheduleRedraw();
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
function g(m) {
|
|
1825
|
-
p();
|
|
1826
|
-
}
|
|
1827
|
-
function I(m) {
|
|
1828
|
-
if (l) {
|
|
1829
|
-
l = !1;
|
|
1830
|
-
return;
|
|
1831
|
-
}
|
|
1832
|
-
const v = t.eventCallbacks.onClick;
|
|
1833
|
-
if (v == null) return;
|
|
1834
|
-
const x = r(m);
|
|
1835
|
-
if (x != null && a(x.cx, x.cy))
|
|
1836
|
-
try {
|
|
1837
|
-
v(u(m, x.cx, x.cy));
|
|
1838
|
-
} catch (C) {
|
|
1839
|
-
console.warn("[uPlot+] event callback error:", C);
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
function L(m) {
|
|
1843
|
-
const v = t.eventCallbacks.onContextMenu;
|
|
1844
|
-
if (v == null) return;
|
|
1845
|
-
const x = r(m);
|
|
1846
|
-
if (x != null && a(x.cx, x.cy)) {
|
|
1847
|
-
m.preventDefault();
|
|
1848
|
-
try {
|
|
1849
|
-
v(u(m, x.cx, x.cy));
|
|
1850
|
-
} catch (C) {
|
|
1851
|
-
console.warn("[uPlot+] event callback error:", C);
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
function P(m) {
|
|
1856
|
-
var v, x;
|
|
1857
|
-
t.cursorManager.hide(), t.focusedSeries != null && t.setFocus(null), n != null && (n = null, s.show = !1, s.width = 0, t.selectState = s), i != null && (i = null), t.scheduleCursorRedraw();
|
|
1858
|
-
try {
|
|
1859
|
-
(x = (v = t.eventCallbacks).onCursorLeave) == null || x.call(v);
|
|
1860
|
-
} catch (C) {
|
|
1861
|
-
console.warn("[uPlot+] event callback error:", C);
|
|
1862
|
-
}
|
|
1863
|
-
}
|
|
1864
|
-
function T(m) {
|
|
1865
|
-
if (t.eventCallbacks.onDblClick != null) {
|
|
1866
|
-
const v = r(m);
|
|
1867
|
-
if (v != null && a(v.cx, v.cy)) {
|
|
1868
|
-
let x;
|
|
1869
|
-
try {
|
|
1870
|
-
x = t.eventCallbacks.onDblClick(u(m, v.cx, v.cy));
|
|
1871
|
-
} catch (C) {
|
|
1872
|
-
console.warn("[uPlot+] event callback error:", C);
|
|
1873
|
-
}
|
|
1874
|
-
if (x === !1)
|
|
1875
|
-
return;
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
for (const v of t.scaleConfigs)
|
|
1879
|
-
t.scaleManager.addScale(v);
|
|
1880
|
-
t.renderer.clearCache(), t.scheduleRedraw();
|
|
1881
|
-
}
|
|
1882
|
-
function M(m) {
|
|
1883
|
-
if (!t.wheelZoom) return;
|
|
1884
|
-
const v = r(m);
|
|
1885
|
-
if (v == null || !a(v.cx, v.cy)) return;
|
|
1886
|
-
m.preventDefault();
|
|
1887
|
-
const x = Math.max(0.1, Math.min(10, 1 - m.deltaY * 1e-3)), C = t.plotBox;
|
|
1888
|
-
for (const z of t.scaleManager.getAllScales()) {
|
|
1889
|
-
if (z.ori !== G.Horizontal || z.min == null || z.max == null) continue;
|
|
1890
|
-
const A = it(v.cx + C.left, z, C.width, C.left), F = A - (A - z.min) * x, _ = A + (z.max - A) * x;
|
|
1891
|
-
z.min = Math.min(F, _), z.max = Math.max(F, _), z.auto = !1, at(z);
|
|
1892
|
-
}
|
|
1893
|
-
t.renderer.clearCache(), t.scheduleRedraw(), f();
|
|
1894
|
-
}
|
|
1895
|
-
function w(m) {
|
|
1896
|
-
const v = t.plotBox, x = m.left / v.width, C = (m.left + m.width) / v.width;
|
|
1897
|
-
for (const z of t.scaleManager.getAllScales()) {
|
|
1898
|
-
if (z.ori !== G.Horizontal || z.min == null || z.max == null) continue;
|
|
1899
|
-
const A = it(
|
|
1900
|
-
v.left + x * v.width,
|
|
1901
|
-
z,
|
|
1902
|
-
v.width,
|
|
1903
|
-
v.left
|
|
1904
|
-
), F = it(
|
|
1905
|
-
v.left + C * v.width,
|
|
1906
|
-
z,
|
|
1907
|
-
v.width,
|
|
1908
|
-
v.left
|
|
1909
|
-
);
|
|
1910
|
-
z.min = Math.min(A, F), z.max = Math.max(A, F), z.auto = !1, at(z);
|
|
1911
|
-
}
|
|
1912
|
-
t.renderer.clearCache();
|
|
1913
|
-
}
|
|
1914
|
-
function b(m) {
|
|
1915
|
-
if (m.touches.length === 2) {
|
|
1916
|
-
const C = m.touches[0], z = m.touches[1], A = z.clientX - C.clientX, F = z.clientY - C.clientY;
|
|
1917
|
-
o = {
|
|
1918
|
-
dist: Math.sqrt(A * A + F * F),
|
|
1919
|
-
midX: (C.clientX + z.clientX) / 2,
|
|
1920
|
-
midY: (C.clientY + z.clientY) / 2
|
|
1921
|
-
}, n = null;
|
|
1922
|
-
return;
|
|
1923
|
-
}
|
|
1924
|
-
const v = m.touches[0];
|
|
1925
|
-
if (v == null) return;
|
|
1926
|
-
const x = r(v);
|
|
1927
|
-
x != null && a(x.cx, x.cy) && (n = { x: x.cx, y: x.cy }, l = !1);
|
|
1928
|
-
}
|
|
1929
|
-
function k(m) {
|
|
1930
|
-
if (m.touches.length === 2 && o != null) {
|
|
1931
|
-
m.preventDefault();
|
|
1932
|
-
const x = m.touches[0], C = m.touches[1], z = C.clientX - x.clientX, A = C.clientY - x.clientY, F = Math.sqrt(z * z + A * A), _ = F / o.dist, R = e.getBoundingClientRect(), B = t.plotBox, $ = o.midX - R.left - B.left;
|
|
1933
|
-
for (const W of t.scaleManager.getAllScales()) {
|
|
1934
|
-
if (W.ori !== G.Horizontal || W.min == null || W.max == null) continue;
|
|
1935
|
-
const ot = it($ + B.left, W, B.width, B.left), Z = ot - (ot - W.min) / _, pt = ot + (W.max - ot) / _;
|
|
1936
|
-
W.min = Math.min(Z, pt), W.max = Math.max(Z, pt), W.auto = !1, at(W);
|
|
1937
|
-
}
|
|
1938
|
-
o.dist = F, t.renderer.clearCache(), t.scheduleRedraw(), f();
|
|
1939
|
-
return;
|
|
1940
|
-
}
|
|
1941
|
-
const v = m.touches[0];
|
|
1942
|
-
v != null && (d(v, m), n != null && m.preventDefault());
|
|
1943
|
-
}
|
|
1944
|
-
function D(m) {
|
|
1945
|
-
if (o != null) {
|
|
1946
|
-
o = null;
|
|
1947
|
-
return;
|
|
1948
|
-
}
|
|
1949
|
-
m.changedTouches[0] != null && p();
|
|
1950
|
-
}
|
|
1951
|
-
return e.addEventListener("mousemove", y), e.addEventListener("mousedown", S), e.addEventListener("mouseup", g), e.addEventListener("click", I), e.addEventListener("contextmenu", L), e.addEventListener("mouseleave", P), e.addEventListener("dblclick", T), e.addEventListener("wheel", M, { passive: !1 }), e.addEventListener("touchstart", b, { passive: !0 }), e.addEventListener("touchmove", k, { passive: !1 }), e.addEventListener("touchend", D), () => {
|
|
1952
|
-
e.removeEventListener("mousemove", y), e.removeEventListener("mousedown", S), e.removeEventListener("mouseup", g), e.removeEventListener("click", I), e.removeEventListener("contextmenu", L), e.removeEventListener("mouseleave", P), e.removeEventListener("dblclick", T), e.removeEventListener("wheel", M), e.removeEventListener("touchstart", b), e.removeEventListener("touchmove", k), e.removeEventListener("touchend", D);
|
|
1953
|
-
};
|
|
1954
|
-
}
|
|
1955
|
-
const Et = /* @__PURE__ */ new Map();
|
|
1956
|
-
function $n(t) {
|
|
1957
|
-
let e = Et.get(t);
|
|
1958
|
-
return e == null && (e = new Yn(t), Et.set(t, e)), e;
|
|
1959
|
-
}
|
|
1960
|
-
class Yn {
|
|
1961
|
-
constructor(e) {
|
|
1962
|
-
this.members = /* @__PURE__ */ new Set(), this.publishing = !1, this.syncedStores = /* @__PURE__ */ new WeakSet(), this.key = e;
|
|
1963
|
-
}
|
|
1964
|
-
/** Add a chart to this sync group. */
|
|
1965
|
-
join(e) {
|
|
1966
|
-
this.members.add(e);
|
|
1967
|
-
}
|
|
1968
|
-
/** Remove a chart from this sync group. Cleans up empty groups. */
|
|
1969
|
-
leave(e) {
|
|
1970
|
-
this.members.delete(e), this.members.size === 0 && Et.delete(this.key);
|
|
1971
|
-
}
|
|
1972
|
-
/**
|
|
1973
|
-
* Publish cursor position from one chart to all others in the group.
|
|
1974
|
-
* Skips if the source was just synced-to (prevents async echo loops).
|
|
1975
|
-
*/
|
|
1976
|
-
pub(e) {
|
|
1977
|
-
if (this.publishing) return;
|
|
1978
|
-
if (this.syncedStores.has(e)) {
|
|
1979
|
-
this.syncedStores.delete(e);
|
|
1980
|
-
return;
|
|
1981
|
-
}
|
|
1982
|
-
this.publishing = !0;
|
|
1983
|
-
const n = e.cursorManager.state, { activeGroup: s, activeDataIdx: o } = n;
|
|
1984
|
-
if (s < 0 || o < 0) {
|
|
1985
|
-
for (const r of this.members)
|
|
1986
|
-
r !== e && (this.syncedStores.add(r), r.cursorManager.hide(), r.scheduleCursorRedraw());
|
|
1987
|
-
this.publishing = !1;
|
|
1988
|
-
return;
|
|
1989
|
-
}
|
|
1990
|
-
const l = e.dataStore.getXValues(s)[o];
|
|
1991
|
-
if (l == null) {
|
|
1992
|
-
this.publishing = !1;
|
|
1993
|
-
return;
|
|
1994
|
-
}
|
|
1995
|
-
for (const r of this.members)
|
|
1996
|
-
r !== e && (this.syncedStores.add(r), r.cursorManager.syncToValue(l, r), r.scheduleCursorRedraw());
|
|
1997
|
-
this.publishing = !1;
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
function Un(t, e) {
|
|
2001
|
-
Y(() => {
|
|
2002
|
-
if (e == null) return;
|
|
2003
|
-
const n = $n(e);
|
|
2004
|
-
n.join(t);
|
|
2005
|
-
let s = -1, o = -1;
|
|
2006
|
-
const i = t.subscribe(() => {
|
|
2007
|
-
const { activeGroup: l, activeDataIdx: r } = t.cursorManager.state;
|
|
2008
|
-
l === s && r === o || (s = l, o = r, n.pub(t));
|
|
2009
|
-
});
|
|
2010
|
-
return () => {
|
|
2011
|
-
i(), n.leave(t);
|
|
2012
|
-
};
|
|
2013
|
-
}, [t, e]);
|
|
2014
|
-
}
|
|
2015
|
-
function Ut({
|
|
2016
|
-
width: t,
|
|
2017
|
-
height: e,
|
|
2018
|
-
data: n,
|
|
2019
|
-
children: s,
|
|
2020
|
-
className: o,
|
|
2021
|
-
pxRatio: i,
|
|
2022
|
-
onDraw: l,
|
|
2023
|
-
onCursorDraw: r,
|
|
2024
|
-
syncKey: a,
|
|
2025
|
-
cursor: c,
|
|
2026
|
-
onClick: u,
|
|
2027
|
-
onContextMenu: h,
|
|
2028
|
-
onDblClick: f,
|
|
2029
|
-
onCursorMove: d,
|
|
2030
|
-
onCursorLeave: y,
|
|
2031
|
-
onScaleChange: S,
|
|
2032
|
-
onSelect: p
|
|
2033
|
-
}) {
|
|
2034
|
-
var v;
|
|
2035
|
-
const g = En(), [I, L] = vt(null), P = i ?? (typeof window < "u" && window.devicePixelRatio || 1), T = (c == null ? void 0 : c.wheelZoom) ?? !1, M = ((v = c == null ? void 0 : c.focus) == null ? void 0 : v.alpha) ?? ((c == null ? void 0 : c.focus) != null ? 0.15 : 1);
|
|
2036
|
-
Y(() => {
|
|
2037
|
-
g.wheelZoom = T, g.focusAlpha = M;
|
|
2038
|
-
}, [g, T, M]), g.eventCallbacks.onClick = u, g.eventCallbacks.onContextMenu = h, g.eventCallbacks.onDblClick = f, g.eventCallbacks.onCursorMove = d, g.eventCallbacks.onCursorLeave = y, g.eventCallbacks.onScaleChange = S, g.eventCallbacks.onSelect = p, Wn(g, I), Un(g, a);
|
|
2039
|
-
const w = K((x) => {
|
|
2040
|
-
g.canvas = x, x && g.scheduleRedraw();
|
|
2041
|
-
}, [g]), b = K((x) => {
|
|
2042
|
-
L(x);
|
|
2043
|
-
}, []);
|
|
2044
|
-
Y(() => {
|
|
2045
|
-
g.pxRatio = P, g.setSize(t, e);
|
|
2046
|
-
}, [g, t, e, P]), Y(() => () => {
|
|
2047
|
-
g.canvas = null, g.scheduler.cancel(), g.focusedSeries = null;
|
|
2048
|
-
}, [g]), Y(() => {
|
|
2049
|
-
if (I == null || typeof ResizeObserver > "u") return;
|
|
2050
|
-
const x = new ResizeObserver((C) => {
|
|
2051
|
-
const z = C[0];
|
|
2052
|
-
if (z == null) return;
|
|
2053
|
-
const { width: A, height: F } = z.contentRect;
|
|
2054
|
-
A > 0 && F > 0 && (A !== g.width || F !== g.height) && g.setSize(Math.round(A), Math.round(F));
|
|
2055
|
-
});
|
|
2056
|
-
return x.observe(I), () => {
|
|
2057
|
-
x.disconnect();
|
|
2058
|
-
};
|
|
2059
|
-
}, [g, I]);
|
|
2060
|
-
const k = X(n);
|
|
2061
|
-
Y(() => {
|
|
2062
|
-
if (n === k.current && g.dataStore.data.length > 0) return;
|
|
2063
|
-
k.current = n, g.dataStore.setData(n), g.renderer.clearCache();
|
|
2064
|
-
const x = "x";
|
|
2065
|
-
g.scaleManager.getScale(x) || g.registerScale({
|
|
2066
|
-
id: x,
|
|
2067
|
-
auto: !0
|
|
2068
|
-
});
|
|
2069
|
-
for (let C = 0; C < n.length; C++)
|
|
2070
|
-
g.scaleManager.setGroupXScale(C, x);
|
|
2071
|
-
g.scheduleRedraw();
|
|
2072
|
-
}, [g, n]);
|
|
2073
|
-
const D = X(l);
|
|
2074
|
-
D.current = l, Y(() => {
|
|
2075
|
-
const x = (C) => {
|
|
2076
|
-
var z;
|
|
2077
|
-
(z = D.current) == null || z.call(D, C);
|
|
2078
|
-
};
|
|
2079
|
-
return g.drawHooks.add(x), () => {
|
|
2080
|
-
g.drawHooks.delete(x);
|
|
2081
|
-
};
|
|
2082
|
-
}, [g]);
|
|
2083
|
-
const m = X(r);
|
|
2084
|
-
return m.current = r, Y(() => {
|
|
2085
|
-
const x = (C, z) => {
|
|
2086
|
-
var A;
|
|
2087
|
-
(A = m.current) == null || A.call(m, C, z);
|
|
2088
|
-
};
|
|
2089
|
-
return g.cursorDrawHooks.add(x), () => {
|
|
2090
|
-
g.cursorDrawHooks.delete(x);
|
|
2091
|
-
};
|
|
2092
|
-
}, [g]), /* @__PURE__ */ E(ke.Provider, { value: g, children: /* @__PURE__ */ J(
|
|
2093
|
-
"div",
|
|
2094
|
-
{
|
|
2095
|
-
className: o,
|
|
2096
|
-
style: {
|
|
2097
|
-
position: "relative",
|
|
2098
|
-
display: "flex",
|
|
2099
|
-
flexDirection: "column",
|
|
2100
|
-
width: `${t}px`
|
|
2101
|
-
},
|
|
2102
|
-
children: [
|
|
2103
|
-
/* @__PURE__ */ E(
|
|
2104
|
-
"div",
|
|
2105
|
-
{
|
|
2106
|
-
ref: b,
|
|
2107
|
-
style: {
|
|
2108
|
-
position: "relative",
|
|
2109
|
-
width: `${t}px`,
|
|
2110
|
-
height: `${e}px`,
|
|
2111
|
-
cursor: "crosshair",
|
|
2112
|
-
order: 0
|
|
2113
|
-
},
|
|
2114
|
-
children: /* @__PURE__ */ E(
|
|
2115
|
-
"canvas",
|
|
2116
|
-
{
|
|
2117
|
-
ref: w,
|
|
2118
|
-
style: {
|
|
2119
|
-
position: "absolute",
|
|
2120
|
-
left: 0,
|
|
2121
|
-
top: 0
|
|
2122
|
-
}
|
|
2123
|
-
}
|
|
2124
|
-
)
|
|
2125
|
-
}
|
|
2126
|
-
),
|
|
2127
|
-
s
|
|
2128
|
-
]
|
|
2129
|
-
}
|
|
2130
|
-
) });
|
|
2131
|
-
}
|
|
2132
|
-
function ue(t) {
|
|
2133
|
-
return t != null && typeof t == "object" && !Array.isArray(t);
|
|
2134
|
-
}
|
|
2135
|
-
function On(t, e) {
|
|
2136
|
-
const n = Object.keys(t), s = Object.keys(e);
|
|
2137
|
-
if (n.length !== s.length) return !1;
|
|
2138
|
-
for (const o of s)
|
|
2139
|
-
if (t[o] !== e[o]) return !1;
|
|
2140
|
-
return !0;
|
|
2141
|
-
}
|
|
2142
|
-
function Ot(t, e) {
|
|
2143
|
-
if (t === null) return !1;
|
|
2144
|
-
const n = t, s = e, o = Object.keys(n), i = Object.keys(s);
|
|
2145
|
-
if (o.length !== i.length) return !1;
|
|
2146
|
-
for (const l of i) {
|
|
2147
|
-
const r = n[l], a = s[l];
|
|
2148
|
-
if (r !== a)
|
|
2149
|
-
if (ue(r) && ue(a)) {
|
|
2150
|
-
if (!On(r, a)) return !1;
|
|
2151
|
-
} else
|
|
2152
|
-
return !1;
|
|
2153
|
-
}
|
|
2154
|
-
return !0;
|
|
2155
|
-
}
|
|
2156
|
-
function Lt(t) {
|
|
2157
|
-
const e = st(), n = X(t);
|
|
2158
|
-
n.current = t, Y(() => {
|
|
2159
|
-
const o = n.current;
|
|
2160
|
-
return e.registerScale({ ...o }), e.scheduleRedraw(), () => {
|
|
2161
|
-
e.unregisterScale(o.id), e.scheduleRedraw();
|
|
2162
|
-
};
|
|
2163
|
-
}, [e, t.id]);
|
|
2164
|
-
const s = X(null);
|
|
2165
|
-
return Y(() => {
|
|
2166
|
-
Ot(s.current, t) || (s.current = t, e.scaleConfigs = e.scaleConfigs.map(
|
|
2167
|
-
(o) => o.id === t.id ? { ...t } : o
|
|
2168
|
-
), e.scaleManager.addScale({ ...t }), e.scheduleRedraw());
|
|
2169
|
-
}), null;
|
|
2170
|
-
}
|
|
2171
|
-
function Ce(t) {
|
|
2172
|
-
const e = st(), n = X(t);
|
|
2173
|
-
n.current = t, Y(() => {
|
|
2174
|
-
const o = n.current;
|
|
2175
|
-
return e.registerSeries({ ...o, show: o.show ?? !0 }), e.renderer.clearCache(), e.scheduleRedraw(), () => {
|
|
2176
|
-
e.unregisterSeries(o.group, o.index), e.renderer.clearCache(), e.scheduleRedraw();
|
|
2177
|
-
};
|
|
2178
|
-
}, [e, t.group, t.index]);
|
|
2179
|
-
const s = X(null);
|
|
2180
|
-
return Y(() => {
|
|
2181
|
-
Ot(s.current, t) || (s.current = t, e.seriesConfigs = e.seriesConfigs.map(
|
|
2182
|
-
(o) => o.group === t.group && o.index === t.index ? { ...t, show: t.show ?? !0 } : o
|
|
2183
|
-
), e.renderer.invalidateSeries(t.group, t.index), e.scheduleRedraw());
|
|
2184
|
-
}), null;
|
|
2185
|
-
}
|
|
2186
|
-
function Nn(t) {
|
|
2187
|
-
return { ...t, side: t.side ?? (t.scale === "x" ? U.Bottom : U.Left), show: t.show ?? !0 };
|
|
2188
|
-
}
|
|
2189
|
-
function zt(t) {
|
|
2190
|
-
const e = st(), n = Nn(t), s = X(n);
|
|
2191
|
-
s.current = n, Y(() => {
|
|
2192
|
-
const i = s.current;
|
|
2193
|
-
return e.axisConfigs = e.axisConfigs.filter(
|
|
2194
|
-
(l) => !(l.scale === i.scale && l.side === i.side)
|
|
2195
|
-
), e.axisConfigs.push(i), e.scheduleRedraw(), () => {
|
|
2196
|
-
e.axisConfigs = e.axisConfigs.filter(
|
|
2197
|
-
(l) => !(l.scale === i.scale && l.side === i.side)
|
|
2198
|
-
), e.scheduleRedraw();
|
|
2199
|
-
};
|
|
2200
|
-
}, [e, n.scale, n.side]);
|
|
2201
|
-
const o = X(null);
|
|
2202
|
-
return Y(() => {
|
|
2203
|
-
Ot(o.current, t) || (o.current = t, e.axisConfigs = e.axisConfigs.map(
|
|
2204
|
-
(i) => i.scale === n.scale && i.side === n.side ? n : i
|
|
2205
|
-
), e.scheduleRedraw());
|
|
2206
|
-
}), null;
|
|
2207
|
-
}
|
|
2208
|
-
function rs({ series: t, group: e, fill: n, dir: s }) {
|
|
2209
|
-
const o = st(), i = X(null), l = t[0], r = t[1];
|
|
2210
|
-
return Y(() => {
|
|
2211
|
-
const a = { series: [l, r], group: e, fill: n, dir: s };
|
|
2212
|
-
return i.current != null && (o.bandConfigs = o.bandConfigs.filter((c) => c !== i.current)), i.current = a, o.bandConfigs.push(a), o.scheduleRedraw(), () => {
|
|
2213
|
-
o.bandConfigs = o.bandConfigs.filter((c) => c !== i.current), i.current = null, o.scheduleRedraw();
|
|
2214
|
-
};
|
|
2215
|
-
}, [o, l, r, e, n, s]), null;
|
|
2216
|
-
}
|
|
2217
|
-
const Kn = {
|
|
2218
|
-
width: 12,
|
|
2219
|
-
height: 3,
|
|
2220
|
-
borderRadius: 1,
|
|
2221
|
-
display: "inline-block"
|
|
2222
|
-
}, jn = { fontWeight: 600 }, qn = {
|
|
2223
|
-
display: "inline-flex",
|
|
2224
|
-
alignItems: "center",
|
|
2225
|
-
gap: 4,
|
|
2226
|
-
padding: "2px 8px",
|
|
2227
|
-
cursor: "pointer",
|
|
2228
|
-
fontSize: 12,
|
|
2229
|
-
fontFamily: "sans-serif"
|
|
2230
|
-
}, Zn = ze(function({ group: e, index: n, label: s, color: o, isHidden: i, valueStr: l, store: r }) {
|
|
2231
|
-
const a = K(() => {
|
|
2232
|
-
r.toggleSeries(e, n);
|
|
2233
|
-
}, [r, e, n]);
|
|
2234
|
-
return /* @__PURE__ */ J(
|
|
2235
|
-
"span",
|
|
2236
|
-
{
|
|
2237
|
-
onClick: a,
|
|
2238
|
-
style: { ...qn, opacity: i ? 0.4 : 1 },
|
|
2239
|
-
children: [
|
|
2240
|
-
/* @__PURE__ */ E("span", { style: { ...Kn, backgroundColor: o } }),
|
|
2241
|
-
/* @__PURE__ */ E("span", { children: s }),
|
|
2242
|
-
l && /* @__PURE__ */ E("span", { style: jn, children: l })
|
|
2243
|
-
]
|
|
2244
|
-
}
|
|
2245
|
-
);
|
|
2246
|
-
});
|
|
2247
|
-
function as({ show: t = !0, position: e = "bottom", className: n }) {
|
|
2248
|
-
const s = st(), o = X({ activeGroup: -1, activeDataIdx: -1, seriesCount: 0, revision: -1 }), i = K(
|
|
2249
|
-
(u) => s.subscribe(u),
|
|
2250
|
-
[s]
|
|
2251
|
-
), l = K(() => {
|
|
2252
|
-
const { activeGroup: u, activeDataIdx: h } = s.cursorManager.state, f = s.seriesConfigs.length, { revision: d } = s, y = o.current;
|
|
2253
|
-
if (y.activeGroup === u && y.activeDataIdx === h && y.seriesCount === f && y.revision === d)
|
|
2254
|
-
return y;
|
|
2255
|
-
const S = { activeGroup: u, activeDataIdx: h, seriesCount: f, revision: d };
|
|
2256
|
-
return o.current = S, S;
|
|
2257
|
-
}, [s]), r = fe(i, l);
|
|
2258
|
-
if (!t) return null;
|
|
2259
|
-
const { activeGroup: a, activeDataIdx: c } = r;
|
|
2260
|
-
return /* @__PURE__ */ E(
|
|
2261
|
-
"div",
|
|
2262
|
-
{
|
|
2263
|
-
className: n,
|
|
2264
|
-
style: {
|
|
2265
|
-
display: "flex",
|
|
2266
|
-
flexWrap: "wrap",
|
|
2267
|
-
justifyContent: "center",
|
|
2268
|
-
order: e === "top" ? -1 : 1,
|
|
2269
|
-
padding: "4px 0"
|
|
2270
|
-
},
|
|
2271
|
-
children: s.seriesConfigs.map((u) => {
|
|
2272
|
-
const h = typeof u.stroke == "string" ? u.stroke : "#000";
|
|
2273
|
-
let f = "";
|
|
2274
|
-
if (c >= 0 && a >= 0) {
|
|
2275
|
-
const y = s.dataStore.getYValues(u.group, u.index)[c];
|
|
2276
|
-
y != null && (f = typeof y == "number" ? y.toPrecision(4) : String(y));
|
|
2277
|
-
}
|
|
2278
|
-
return /* @__PURE__ */ E(
|
|
2279
|
-
Zn,
|
|
2280
|
-
{
|
|
2281
|
-
group: u.group,
|
|
2282
|
-
index: u.index,
|
|
2283
|
-
label: u.label ?? `Series ${u.index}`,
|
|
2284
|
-
color: h,
|
|
2285
|
-
isHidden: u.show === !1,
|
|
2286
|
-
valueStr: f,
|
|
2287
|
-
store: s
|
|
2288
|
-
},
|
|
2289
|
-
`${u.group}:${u.index}`
|
|
2290
|
-
);
|
|
2291
|
-
})
|
|
2292
|
-
}
|
|
2293
|
-
);
|
|
2294
|
-
}
|
|
2295
|
-
const Jn = 160;
|
|
2296
|
-
function cs({
|
|
2297
|
-
show: t = !0,
|
|
2298
|
-
className: e,
|
|
2299
|
-
children: n,
|
|
2300
|
-
offset: s = {}
|
|
2301
|
-
}) {
|
|
2302
|
-
const o = st(), i = X({ left: -10, top: -10, activeGroup: -1, activeDataIdx: -1, revision: -1 }), l = K(
|
|
2303
|
-
(w) => o.subscribe(w),
|
|
2304
|
-
[o]
|
|
2305
|
-
), r = K(() => {
|
|
2306
|
-
const w = o.cursorManager.state, { revision: b } = o, k = i.current;
|
|
2307
|
-
if (k.left === w.left && k.top === w.top && k.activeGroup === w.activeGroup && k.activeDataIdx === w.activeDataIdx && k.revision === b)
|
|
2308
|
-
return k;
|
|
2309
|
-
const D = {
|
|
2310
|
-
left: w.left,
|
|
2311
|
-
top: w.top,
|
|
2312
|
-
activeGroup: w.activeGroup,
|
|
2313
|
-
activeDataIdx: w.activeDataIdx,
|
|
2314
|
-
revision: b
|
|
2315
|
-
};
|
|
2316
|
-
return i.current = D, D;
|
|
2317
|
-
}, [o]), a = fe(l, r);
|
|
2318
|
-
if (!t || a.activeDataIdx < 0 || a.activeGroup < 0 || a.left < 0) return null;
|
|
2319
|
-
const { activeGroup: c, activeDataIdx: u } = a, h = o.plotBox, f = o.dataStore.data[c], d = f != null ? f.x[u] ?? null : null, y = d != null ? parseFloat(d.toPrecision(6)).toString() : "", S = [];
|
|
2320
|
-
for (const w of o.seriesConfigs) {
|
|
2321
|
-
if (w.show === !1) continue;
|
|
2322
|
-
const b = o.dataStore.getYValues(w.group, w.index), k = w.group === c ? b[u] : null;
|
|
2323
|
-
S.push({
|
|
2324
|
-
label: w.label ?? `Series ${w.index}`,
|
|
2325
|
-
value: k,
|
|
2326
|
-
color: typeof w.stroke == "string" ? w.stroke : "#000",
|
|
2327
|
-
group: w.group,
|
|
2328
|
-
index: w.index
|
|
2329
|
-
});
|
|
2330
|
-
}
|
|
2331
|
-
const p = {
|
|
2332
|
-
x: d,
|
|
2333
|
-
xLabel: y,
|
|
2334
|
-
items: S,
|
|
2335
|
-
left: a.left + h.left,
|
|
2336
|
-
top: a.top + h.top
|
|
2337
|
-
}, g = s.x ?? 12, I = s.y ?? -12, L = a.left + h.left + g + Jn > h.left + h.width, P = a.top + h.top + I < h.top, T = L ? p.left - g : p.left + g, M = P ? p.top + Math.abs(I) : p.top + I;
|
|
2338
|
-
return n ? /* @__PURE__ */ E(
|
|
2339
|
-
"div",
|
|
2340
|
-
{
|
|
2341
|
-
className: e,
|
|
2342
|
-
style: {
|
|
2343
|
-
position: "absolute",
|
|
2344
|
-
left: T,
|
|
2345
|
-
top: M,
|
|
2346
|
-
transform: L ? "translateX(-100%)" : void 0,
|
|
2347
|
-
pointerEvents: "none",
|
|
2348
|
-
zIndex: 100
|
|
2349
|
-
},
|
|
2350
|
-
children: n(p)
|
|
2351
|
-
}
|
|
2352
|
-
) : /* @__PURE__ */ J(
|
|
2353
|
-
"div",
|
|
2354
|
-
{
|
|
2355
|
-
className: e,
|
|
2356
|
-
style: {
|
|
2357
|
-
position: "absolute",
|
|
2358
|
-
left: T,
|
|
2359
|
-
top: M,
|
|
2360
|
-
transform: L ? "translateX(-100%)" : void 0,
|
|
2361
|
-
pointerEvents: "none",
|
|
2362
|
-
zIndex: 100,
|
|
2363
|
-
background: "rgba(0,0,0,0.85)",
|
|
2364
|
-
color: "#fff",
|
|
2365
|
-
padding: "6px 10px",
|
|
2366
|
-
borderRadius: 4,
|
|
2367
|
-
fontSize: 12,
|
|
2368
|
-
fontFamily: "sans-serif",
|
|
2369
|
-
whiteSpace: "nowrap",
|
|
2370
|
-
lineHeight: 1.5
|
|
2371
|
-
},
|
|
2372
|
-
children: [
|
|
2373
|
-
/* @__PURE__ */ E("div", { style: { fontWeight: 600, marginBottom: 2 }, children: y }),
|
|
2374
|
-
S.map((w) => /* @__PURE__ */ J("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
2375
|
-
/* @__PURE__ */ E("span", { style: { width: 8, height: 8, borderRadius: "50%", backgroundColor: w.color, display: "inline-block" } }),
|
|
2376
|
-
/* @__PURE__ */ J("span", { children: [
|
|
2377
|
-
w.label,
|
|
2378
|
-
":"
|
|
2379
|
-
] }),
|
|
2380
|
-
/* @__PURE__ */ E("span", { style: { fontWeight: 600 }, children: w.value != null ? w.value.toPrecision(4) : "—" })
|
|
2381
|
-
] }, `${w.group}:${w.index}`))
|
|
2382
|
-
]
|
|
2383
|
-
}
|
|
2384
|
-
);
|
|
2385
|
-
}
|
|
2386
|
-
function us({
|
|
2387
|
-
width: t,
|
|
2388
|
-
height: e,
|
|
2389
|
-
data: n,
|
|
2390
|
-
onRangeChange: s,
|
|
2391
|
-
initialRange: o,
|
|
2392
|
-
className: i,
|
|
2393
|
-
colors: l,
|
|
2394
|
-
grips: r = !1
|
|
2395
|
-
}) {
|
|
2396
|
-
const a = X(null), [c, u] = vt(() => {
|
|
2397
|
-
if (o != null && n.length > 0) {
|
|
2398
|
-
const T = n[0];
|
|
2399
|
-
if (T != null && T.x.length > 1) {
|
|
2400
|
-
const M = T.x[0], b = T.x[T.x.length - 1] - M;
|
|
2401
|
-
if (b > 0)
|
|
2402
|
-
return [
|
|
2403
|
-
Math.max(0, (o[0] - M) / b),
|
|
2404
|
-
Math.min(1, (o[1] - M) / b)
|
|
2405
|
-
];
|
|
2406
|
-
}
|
|
2407
|
-
}
|
|
2408
|
-
return [0.25, 0.75];
|
|
2409
|
-
}), h = X(null);
|
|
2410
|
-
Y(() => {
|
|
2411
|
-
if (s == null || n.length === 0) return;
|
|
2412
|
-
const T = n[0];
|
|
2413
|
-
if (T == null || T.x.length < 2) return;
|
|
2414
|
-
const M = T.x[0], b = T.x[T.x.length - 1] - M, k = M + c[0] * b, D = M + c[1] * b, m = h.current, v = Math.max(1e-10, Math.abs(D - k) * 1e-12);
|
|
2415
|
-
m != null && Math.abs(m[0] - k) < v && Math.abs(m[1] - D) < v || (h.current = [k, D], s(k, D));
|
|
2416
|
-
}, [c, n, s]);
|
|
2417
|
-
const f = X(null), d = K((T) => {
|
|
2418
|
-
const M = a.current;
|
|
2419
|
-
if (M == null) return 0;
|
|
2420
|
-
const w = M.getBoundingClientRect();
|
|
2421
|
-
return Math.max(0, Math.min(1, (T - w.left) / w.width));
|
|
2422
|
-
}, []), y = K((T) => {
|
|
2423
|
-
const M = a.current;
|
|
2424
|
-
if (M == null) return;
|
|
2425
|
-
const w = d(T.clientX), b = M.getBoundingClientRect().width, k = b > 0 ? 8 / b : 0;
|
|
2426
|
-
let D;
|
|
2427
|
-
if (Math.abs(w - c[0]) < k)
|
|
2428
|
-
D = "left";
|
|
2429
|
-
else if (Math.abs(w - c[1]) < k)
|
|
2430
|
-
D = "right";
|
|
2431
|
-
else if (w >= c[0] && w <= c[1])
|
|
2432
|
-
D = "move";
|
|
2433
|
-
else {
|
|
2434
|
-
const m = c[1] - c[0], v = m / 2, x = Math.max(0, Math.min(1 - m, w - v));
|
|
2435
|
-
u([x, x + m]), D = "move";
|
|
2436
|
-
}
|
|
2437
|
-
f.current = {
|
|
2438
|
-
mode: D,
|
|
2439
|
-
startX: T.clientX,
|
|
2440
|
-
startFrac: [...c]
|
|
2441
|
-
}, M.setPointerCapture(T.pointerId), T.preventDefault();
|
|
2442
|
-
}, [c, d]), S = K((T) => {
|
|
2443
|
-
const M = f.current;
|
|
2444
|
-
if (M == null) return;
|
|
2445
|
-
const w = d(T.clientX), b = d(M.startX), k = w - b;
|
|
2446
|
-
if (M.mode === "move") {
|
|
2447
|
-
const D = M.startFrac[1] - M.startFrac[0];
|
|
2448
|
-
let m = M.startFrac[0] + k;
|
|
2449
|
-
m = Math.max(0, Math.min(1 - D, m)), u([m, m + D]);
|
|
2450
|
-
} else if (M.mode === "left") {
|
|
2451
|
-
const D = Math.max(0, Math.min(M.startFrac[1] - 0.01, M.startFrac[0] + k));
|
|
2452
|
-
u([D, M.startFrac[1]]);
|
|
2453
|
-
} else {
|
|
2454
|
-
const D = Math.min(1, Math.max(M.startFrac[0] + 0.01, M.startFrac[1] + k));
|
|
2455
|
-
u([M.startFrac[0], D]);
|
|
2456
|
-
}
|
|
2457
|
-
}, [d]), p = K((T) => {
|
|
2458
|
-
f.current = null;
|
|
2459
|
-
const M = a.current;
|
|
2460
|
-
M != null && M.releasePointerCapture(T.pointerId);
|
|
2461
|
-
}, []), g = `${c[0] * 100}%`, I = `${(c[1] - c[0]) * 100}%`, L = n[0], P = L != null ? L.series.length : 0;
|
|
2462
|
-
return /* @__PURE__ */ J("div", { className: i, style: { position: "relative", width: t, height: e }, children: [
|
|
2463
|
-
/* @__PURE__ */ J(Ut, { width: t, height: e, data: n, children: [
|
|
2464
|
-
/* @__PURE__ */ E(Lt, { id: "x" }),
|
|
2465
|
-
/* @__PURE__ */ E(Lt, { id: "y" }),
|
|
2466
|
-
/* @__PURE__ */ E(zt, { scale: "x", show: !1 }),
|
|
2467
|
-
/* @__PURE__ */ E(zt, { scale: "y", show: !1 }),
|
|
2468
|
-
Array.from({ length: P }, (T, M) => /* @__PURE__ */ E(
|
|
2469
|
-
Ce,
|
|
2470
|
-
{
|
|
2471
|
-
group: 0,
|
|
2472
|
-
index: M,
|
|
2473
|
-
yScale: "y",
|
|
2474
|
-
stroke: l != null && l[M] != null ? l[M] : `hsl(${M * 137}, 60%, 50%)`,
|
|
2475
|
-
width: 1
|
|
2476
|
-
},
|
|
2477
|
-
M
|
|
2478
|
-
))
|
|
2479
|
-
] }),
|
|
2480
|
-
/* @__PURE__ */ J(
|
|
2481
|
-
"div",
|
|
2482
|
-
{
|
|
2483
|
-
ref: a,
|
|
2484
|
-
onPointerDown: y,
|
|
2485
|
-
onPointerMove: S,
|
|
2486
|
-
onPointerUp: p,
|
|
2487
|
-
style: {
|
|
2488
|
-
position: "absolute",
|
|
2489
|
-
top: 0,
|
|
2490
|
-
left: 0,
|
|
2491
|
-
width: "100%",
|
|
2492
|
-
height: "100%",
|
|
2493
|
-
cursor: "default",
|
|
2494
|
-
touchAction: "none"
|
|
2495
|
-
},
|
|
2496
|
-
children: [
|
|
2497
|
-
/* @__PURE__ */ E(
|
|
2498
|
-
"div",
|
|
2499
|
-
{
|
|
2500
|
-
style: {
|
|
2501
|
-
position: "absolute",
|
|
2502
|
-
top: 0,
|
|
2503
|
-
left: 0,
|
|
2504
|
-
width: g,
|
|
2505
|
-
height: "100%",
|
|
2506
|
-
background: "rgba(0,0,0,0.3)",
|
|
2507
|
-
pointerEvents: "none"
|
|
2508
|
-
}
|
|
2509
|
-
}
|
|
2510
|
-
),
|
|
2511
|
-
/* @__PURE__ */ E(
|
|
2512
|
-
"div",
|
|
2513
|
-
{
|
|
2514
|
-
style: {
|
|
2515
|
-
position: "absolute",
|
|
2516
|
-
top: 0,
|
|
2517
|
-
left: `${c[1] * 100}%`,
|
|
2518
|
-
right: 0,
|
|
2519
|
-
height: "100%",
|
|
2520
|
-
background: "rgba(0,0,0,0.3)",
|
|
2521
|
-
pointerEvents: "none"
|
|
2522
|
-
}
|
|
2523
|
-
}
|
|
2524
|
-
),
|
|
2525
|
-
/* @__PURE__ */ E(
|
|
2526
|
-
"div",
|
|
2527
|
-
{
|
|
2528
|
-
style: {
|
|
2529
|
-
position: "absolute",
|
|
2530
|
-
top: 0,
|
|
2531
|
-
left: g,
|
|
2532
|
-
width: I,
|
|
2533
|
-
height: "100%",
|
|
2534
|
-
borderLeft: "2px solid rgba(0,100,255,0.8)",
|
|
2535
|
-
borderRight: "2px solid rgba(0,100,255,0.8)",
|
|
2536
|
-
boxSizing: "border-box",
|
|
2537
|
-
cursor: "grab",
|
|
2538
|
-
pointerEvents: "none"
|
|
2539
|
-
},
|
|
2540
|
-
children: r && /* @__PURE__ */ J(Ae, { children: [
|
|
2541
|
-
/* @__PURE__ */ E("div", { style: {
|
|
2542
|
-
position: "absolute",
|
|
2543
|
-
left: -5,
|
|
2544
|
-
top: "50%",
|
|
2545
|
-
transform: "translateY(-50%)",
|
|
2546
|
-
width: 8,
|
|
2547
|
-
height: 24,
|
|
2548
|
-
borderRadius: 3,
|
|
2549
|
-
background: "rgba(0,100,255,0.8)",
|
|
2550
|
-
cursor: "ew-resize",
|
|
2551
|
-
pointerEvents: "auto"
|
|
2552
|
-
} }),
|
|
2553
|
-
/* @__PURE__ */ E("div", { style: {
|
|
2554
|
-
position: "absolute",
|
|
2555
|
-
right: -5,
|
|
2556
|
-
top: "50%",
|
|
2557
|
-
transform: "translateY(-50%)",
|
|
2558
|
-
width: 8,
|
|
2559
|
-
height: 24,
|
|
2560
|
-
borderRadius: 3,
|
|
2561
|
-
background: "rgba(0,100,255,0.8)",
|
|
2562
|
-
cursor: "ew-resize",
|
|
2563
|
-
pointerEvents: "auto"
|
|
2564
|
-
} })
|
|
2565
|
-
] })
|
|
2566
|
-
}
|
|
2567
|
-
)
|
|
2568
|
-
]
|
|
2569
|
-
}
|
|
2570
|
-
)
|
|
2571
|
-
] });
|
|
2572
|
-
}
|
|
2573
|
-
function Pt(t) {
|
|
2574
|
-
const e = st(), n = X(t);
|
|
2575
|
-
n.current = t, Y(() => {
|
|
2576
|
-
const s = (o) => n.current(o);
|
|
2577
|
-
return e.drawHooks.add(s), () => {
|
|
2578
|
-
e.drawHooks.delete(s);
|
|
2579
|
-
};
|
|
2580
|
-
}, [e]);
|
|
2581
|
-
}
|
|
2582
|
-
function fs(t) {
|
|
2583
|
-
const e = st(), n = X(t);
|
|
2584
|
-
n.current = t, Y(() => {
|
|
2585
|
-
const s = (o, i) => n.current(o, i);
|
|
2586
|
-
return e.cursorDrawHooks.add(s), () => {
|
|
2587
|
-
e.cursorDrawHooks.delete(s);
|
|
2588
|
-
};
|
|
2589
|
-
}, [e]);
|
|
2590
|
-
}
|
|
2591
|
-
function hs({
|
|
2592
|
-
lanes: t,
|
|
2593
|
-
laneHeight: e = 24,
|
|
2594
|
-
gap: n = 2,
|
|
2595
|
-
scaleId: s = "x"
|
|
2596
|
-
}) {
|
|
2597
|
-
const o = st();
|
|
2598
|
-
return Pt(({ ctx: i, plotBox: l, pxRatio: r }) => {
|
|
2599
|
-
const a = o.scaleManager.getScale(s);
|
|
2600
|
-
if (a == null || a.min == null || a.max == null) return;
|
|
2601
|
-
i.save(), i.beginPath(), i.rect(
|
|
2602
|
-
l.left * r,
|
|
2603
|
-
l.top * r,
|
|
2604
|
-
l.width * r,
|
|
2605
|
-
l.height * r
|
|
2606
|
-
), i.clip();
|
|
2607
|
-
const c = (e + n) * r, u = e * r, h = l.top * r;
|
|
2608
|
-
for (let f = 0; f < t.length; f++) {
|
|
2609
|
-
const d = t[f];
|
|
2610
|
-
if (d == null) continue;
|
|
2611
|
-
const y = h + f * c;
|
|
2612
|
-
i.fillStyle = "#666", i.font = `${11 * r}px sans-serif`, i.textAlign = "right", i.textBaseline = "middle", i.fillText(d.label, (l.left - 6) * r, y + u / 2);
|
|
2613
|
-
for (const S of d.segments) {
|
|
2614
|
-
const p = V(S.start, a, l.width, l.left) * r, I = V(S.end, a, l.width, l.left) * r - p;
|
|
2615
|
-
I <= 0 || (i.fillStyle = S.color ?? "#4dabf7", i.fillRect(p, y, I, u), S.label != null && I > 20 * r && (i.fillStyle = "#fff", i.font = `${10 * r}px sans-serif`, i.textAlign = "center", i.textBaseline = "middle", i.fillText(S.label, p + I / 2, y + u / 2, I - 4 * r)));
|
|
2616
|
-
}
|
|
2617
|
-
}
|
|
2618
|
-
i.restore();
|
|
2619
|
-
}), null;
|
|
2620
|
-
}
|
|
2621
|
-
function ds({
|
|
2622
|
-
data: t,
|
|
2623
|
-
width: e = 150,
|
|
2624
|
-
height: n = 30,
|
|
2625
|
-
stroke: s = "#03a9f4",
|
|
2626
|
-
fill: o,
|
|
2627
|
-
lineWidth: i = 1,
|
|
2628
|
-
paths: l,
|
|
2629
|
-
fillTo: r,
|
|
2630
|
-
className: a
|
|
2631
|
-
}) {
|
|
2632
|
-
return /* @__PURE__ */ E("div", { style: { pointerEvents: "none" }, className: a, children: /* @__PURE__ */ J(Ut, { width: e, height: n, data: t, children: [
|
|
2633
|
-
/* @__PURE__ */ E(Lt, { id: "x" }),
|
|
2634
|
-
/* @__PURE__ */ E(Lt, { id: "y" }),
|
|
2635
|
-
/* @__PURE__ */ E(zt, { scale: "x", show: !1 }),
|
|
2636
|
-
/* @__PURE__ */ E(zt, { scale: "y", show: !1 }),
|
|
2637
|
-
/* @__PURE__ */ E(
|
|
2638
|
-
Ce,
|
|
2639
|
-
{
|
|
2640
|
-
group: 0,
|
|
2641
|
-
index: 0,
|
|
2642
|
-
yScale: "y",
|
|
2643
|
-
stroke: s,
|
|
2644
|
-
fill: o,
|
|
2645
|
-
width: i,
|
|
2646
|
-
paths: l,
|
|
2647
|
-
fillTo: r
|
|
2648
|
-
}
|
|
2649
|
-
)
|
|
2650
|
-
] }) });
|
|
2651
|
-
}
|
|
2652
|
-
function gs({
|
|
2653
|
-
minWidth: t = 100,
|
|
2654
|
-
minHeight: e = 100,
|
|
2655
|
-
aspectRatio: n,
|
|
2656
|
-
initialHeight: s = 300,
|
|
2657
|
-
...o
|
|
2658
|
-
}) {
|
|
2659
|
-
const i = X(null), [l, r] = vt(null), a = K(
|
|
2660
|
-
(c) => {
|
|
2661
|
-
const u = Math.max(c.width, t);
|
|
2662
|
-
let h;
|
|
2663
|
-
return n != null ? h = Math.max(u / n, e) : h = Math.max(c.height || s, e), { width: Math.round(u), height: Math.round(h) };
|
|
2664
|
-
},
|
|
2665
|
-
[t, e, n, s]
|
|
2666
|
-
);
|
|
2667
|
-
return Y(() => {
|
|
2668
|
-
const c = i.current;
|
|
2669
|
-
if (c == null) return;
|
|
2670
|
-
const u = c.getBoundingClientRect();
|
|
2671
|
-
if (r(a({ width: u.width, height: u.height })), typeof ResizeObserver > "u") return;
|
|
2672
|
-
const h = new ResizeObserver((f) => {
|
|
2673
|
-
const d = f[0];
|
|
2674
|
-
if (d == null) return;
|
|
2675
|
-
const { width: y, height: S } = d.contentRect;
|
|
2676
|
-
r(a({ width: y, height: S }));
|
|
2677
|
-
});
|
|
2678
|
-
return h.observe(c), () => h.disconnect();
|
|
2679
|
-
}, [a]), /* @__PURE__ */ E(
|
|
2680
|
-
"div",
|
|
2681
|
-
{
|
|
2682
|
-
ref: i,
|
|
2683
|
-
style: {
|
|
2684
|
-
width: "100%",
|
|
2685
|
-
height: n != null ? "auto" : "100%"
|
|
2686
|
-
},
|
|
2687
|
-
children: l != null && /* @__PURE__ */ E(Ut, { ...o, width: l.width, height: l.height })
|
|
2688
|
-
}
|
|
2689
|
-
);
|
|
2690
|
-
}
|
|
2691
|
-
function Qn(t, e, n, s = {}) {
|
|
2692
|
-
const { ctx: o, plotBox: i } = t, l = V(n, e, i.height, i.top);
|
|
2693
|
-
o.beginPath(), o.moveTo(i.left, l), o.lineTo(i.left + i.width, l), o.strokeStyle = s.stroke ?? "red", o.lineWidth = s.width ?? 1, s.dash && o.setLineDash(s.dash), o.stroke(), s.dash && o.setLineDash([]);
|
|
2694
|
-
}
|
|
2695
|
-
function ts(t, e, n, s = {}) {
|
|
2696
|
-
const { ctx: o, plotBox: i } = t, l = V(n, e, i.width, i.left);
|
|
2697
|
-
o.beginPath(), o.moveTo(l, i.top), o.lineTo(l, i.top + i.height), o.strokeStyle = s.stroke ?? "red", o.lineWidth = s.width ?? 1, s.dash && o.setLineDash(s.dash), o.stroke(), s.dash && o.setLineDash([]);
|
|
2698
|
-
}
|
|
2699
|
-
function ps(t, e, n, s, o, i, l = {}) {
|
|
2700
|
-
const { ctx: r, plotBox: a } = t, c = V(s, e, a.width, a.left), u = V(o, n, a.height, a.top);
|
|
2701
|
-
r.font = l.font ?? "12px sans-serif", r.fillStyle = l.fill ?? "#000", r.textBaseline = "bottom", r.fillText(i, c, u - 4);
|
|
2702
|
-
}
|
|
2703
|
-
function es(t, e, n, s, o = {}) {
|
|
2704
|
-
const { ctx: i, plotBox: l } = t, r = V(s, e, l.height, l.top), a = V(n, e, l.height, l.top);
|
|
2705
|
-
i.fillStyle = o.fill ?? "rgba(255,0,0,0.1)", i.fillRect(l.left, Math.min(r, a), l.width, Math.abs(a - r)), o.stroke && (i.strokeStyle = o.stroke, i.lineWidth = o.width ?? 1, o.dash && i.setLineDash(o.dash), i.strokeRect(l.left, Math.min(r, a), l.width, Math.abs(a - r)), o.dash && i.setLineDash([]));
|
|
2706
|
-
}
|
|
2707
|
-
function ms(t) {
|
|
2708
|
-
const e = X(t);
|
|
2709
|
-
return Dt(() => {
|
|
2710
|
-
e.current = t;
|
|
2711
|
-
}), Pt((n) => {
|
|
2712
|
-
const s = e.current, o = s.yScale ?? "y", i = n.getScale(o);
|
|
2713
|
-
if (i != null && (Qn(n, i, s.value, {
|
|
2714
|
-
stroke: s.stroke,
|
|
2715
|
-
width: s.width,
|
|
2716
|
-
dash: s.dash
|
|
2717
|
-
}), s.label != null)) {
|
|
2718
|
-
const l = n.valToY(s.value, o);
|
|
2719
|
-
if (l == null) return;
|
|
2720
|
-
const { ctx: r, plotBox: a } = n;
|
|
2721
|
-
r.font = s.labelFont ?? "11px sans-serif", r.fillStyle = s.stroke ?? "red", r.textAlign = "left", r.textBaseline = "bottom", r.fillText(s.label, a.left + 4, l - 4);
|
|
2722
|
-
}
|
|
2723
|
-
}), null;
|
|
2724
|
-
}
|
|
2725
|
-
function ws(t) {
|
|
2726
|
-
const e = X(t);
|
|
2727
|
-
return Dt(() => {
|
|
2728
|
-
e.current = t;
|
|
2729
|
-
}), Pt((n) => {
|
|
2730
|
-
const s = e.current, o = s.xScale ?? "x", i = n.getScale(o);
|
|
2731
|
-
if (i != null && (ts(n, i, s.value, {
|
|
2732
|
-
stroke: s.stroke,
|
|
2733
|
-
width: s.width,
|
|
2734
|
-
dash: s.dash
|
|
2735
|
-
}), s.label != null)) {
|
|
2736
|
-
const l = n.valToX(s.value, o);
|
|
2737
|
-
if (l == null) return;
|
|
2738
|
-
const { ctx: r, plotBox: a } = n;
|
|
2739
|
-
r.font = s.labelFont ?? "11px sans-serif", r.fillStyle = s.stroke ?? "red", r.textAlign = "center", r.textBaseline = "bottom", r.fillText(s.label, l, a.top - 4);
|
|
2740
|
-
}
|
|
2741
|
-
}), null;
|
|
2742
|
-
}
|
|
2743
|
-
function vs(t) {
|
|
2744
|
-
const e = X(t);
|
|
2745
|
-
return Dt(() => {
|
|
2746
|
-
e.current = t;
|
|
2747
|
-
}), Pt((n) => {
|
|
2748
|
-
const s = e.current, o = n.getScale(s.yScale ?? "y");
|
|
2749
|
-
o != null && es(n, o, s.yMin, s.yMax, {
|
|
2750
|
-
fill: s.fill,
|
|
2751
|
-
stroke: s.stroke,
|
|
2752
|
-
width: s.strokeWidth,
|
|
2753
|
-
dash: s.dash
|
|
2754
|
-
});
|
|
2755
|
-
}), null;
|
|
2756
|
-
}
|
|
2757
|
-
function xs(t) {
|
|
2758
|
-
const e = X(t);
|
|
2759
|
-
return Dt(() => {
|
|
2760
|
-
e.current = t;
|
|
2761
|
-
}), Pt((n) => {
|
|
2762
|
-
const s = e.current, o = n.valToX(s.x, s.xScale ?? "x"), i = n.valToY(s.y, s.yScale ?? "y");
|
|
2763
|
-
if (o == null || i == null) return;
|
|
2764
|
-
const { ctx: l } = n;
|
|
2765
|
-
l.font = s.font ?? "12px sans-serif", l.fillStyle = s.fill ?? "#000", l.textAlign = s.align ?? "left", l.textBaseline = s.baseline ?? "bottom", l.fillText(s.text, o, i - 4);
|
|
2766
|
-
}), null;
|
|
2767
|
-
}
|
|
2768
|
-
function Ms(t, e) {
|
|
2769
|
-
const { window: n, batchSize: s = 1 } = e, o = e.autoStart ?? !0, [i, l] = vt(t), [r, a] = vt(!1), [c, u] = vt(0), h = X(0), f = X(0), d = X(0), y = K(
|
|
2770
|
-
(g, ...I) => {
|
|
2771
|
-
l((L) => {
|
|
2772
|
-
const P = L[0];
|
|
2773
|
-
if (P == null) return L;
|
|
2774
|
-
const T = P.x, M = Math.max(0, T.length + g.length - n), w = M > 0 ? T.slice(M).concat(g) : T.concat(g), b = P.series.map((k, D) => {
|
|
2775
|
-
const m = k, v = I[D] ?? [];
|
|
2776
|
-
return M > 0 ? m.slice(M).concat(v) : m.concat(v);
|
|
2777
|
-
});
|
|
2778
|
-
return [{ x: w, series: b }];
|
|
2779
|
-
});
|
|
2780
|
-
},
|
|
2781
|
-
[n]
|
|
2782
|
-
), S = K(() => {
|
|
2783
|
-
a(!0);
|
|
2784
|
-
}, []), p = K(() => {
|
|
2785
|
-
a(!1);
|
|
2786
|
-
}, []);
|
|
2787
|
-
return Y(() => {
|
|
2788
|
-
if (!r) {
|
|
2789
|
-
h.current !== 0 && (cancelAnimationFrame(h.current), h.current = 0);
|
|
2790
|
-
return;
|
|
2791
|
-
}
|
|
2792
|
-
d.current = performance.now(), f.current = 0;
|
|
2793
|
-
const g = (I) => {
|
|
2794
|
-
f.current++;
|
|
2795
|
-
const L = I - d.current;
|
|
2796
|
-
L >= 1e3 && (u(Math.round(f.current * 1e3 / L)), f.current = 0, d.current = I), h.current = requestAnimationFrame(g);
|
|
2797
|
-
};
|
|
2798
|
-
return h.current = requestAnimationFrame(g), () => {
|
|
2799
|
-
h.current !== 0 && (cancelAnimationFrame(h.current), h.current = 0);
|
|
2800
|
-
};
|
|
2801
|
-
}, [r]), Y(() => {
|
|
2802
|
-
o && a(!0);
|
|
2803
|
-
}, [o]), { data: i, push: y, start: S, stop: p, running: r, fps: c };
|
|
2804
|
-
}
|
|
2805
|
-
function Ss(t) {
|
|
2806
|
-
return (e, n, s, o, i, l, r, a, c, u, h, f, d) => {
|
|
2807
|
-
const y = (d == null ? void 0 : d.align) ?? t ?? 1, S = (d == null ? void 0 : d.spanGaps) ?? !1;
|
|
2808
|
-
if ([c, u] = Ft(n, c, u), c === -1)
|
|
2809
|
-
return { stroke: new Path2D(), fill: null, clip: null, band: null, gaps: null };
|
|
2810
|
-
const p = (k) => f(V(k, s, i, r)), g = (k) => f(V(k, o, l, a)), I = s.ori === G.Horizontal ? _t : Rt, L = { stroke: new Path2D(), fill: null, clip: null, band: null, gaps: null }, P = L.stroke;
|
|
2811
|
-
let T = !1;
|
|
2812
|
-
const M = h === O.Forward ? c : u;
|
|
2813
|
-
let w = g(n[M]), b = p(e[M]);
|
|
2814
|
-
I(P, b, w);
|
|
2815
|
-
for (let k = M; k >= c && k <= u; k += h) {
|
|
2816
|
-
const D = n[k];
|
|
2817
|
-
if (D == null) {
|
|
2818
|
-
D === null && !S && (T = !0);
|
|
2819
|
-
continue;
|
|
2820
|
-
}
|
|
2821
|
-
const m = p(e[k]), v = g(D);
|
|
2822
|
-
if (y === 1)
|
|
2823
|
-
I(P, m, w);
|
|
2824
|
-
else if (y === -1)
|
|
2825
|
-
I(P, b, v);
|
|
2826
|
-
else {
|
|
2827
|
-
const x = f((b + m) / 2);
|
|
2828
|
-
I(P, x, w), I(P, x, v);
|
|
2829
|
-
}
|
|
2830
|
-
I(P, m, v), w = v, b = m;
|
|
2831
|
-
}
|
|
2832
|
-
{
|
|
2833
|
-
const k = L.fill = new Path2D(P), D = (d == null ? void 0 : d.fillTo) ?? o.min ?? 0, m = g(D);
|
|
2834
|
-
let v = r, x = r + i;
|
|
2835
|
-
h === O.Backward && ([x, v] = [v, x]), I(k, x, m), I(k, v, m);
|
|
2836
|
-
}
|
|
2837
|
-
if (T) {
|
|
2838
|
-
const k = $t(e, n, c, u, h, p);
|
|
2839
|
-
L.gaps = k, L.clip = Yt(k, s.ori, r, a, i, l);
|
|
2840
|
-
}
|
|
2841
|
-
return L;
|
|
2842
|
-
};
|
|
2843
|
-
}
|
|
2844
|
-
function bs() {
|
|
2845
|
-
return (t, e, n, s, o, i, l, r, a, c, u, h, f) => {
|
|
2846
|
-
const d = (f == null ? void 0 : f.barWidth) ?? 0.6, y = (f == null ? void 0 : f.barGap) ?? 0, S = (f == null ? void 0 : f.barRadius) ?? 0, p = (f == null ? void 0 : f.barGroupIdx) ?? 0, g = (f == null ? void 0 : f.barGroupCount) ?? 1, I = (x) => h(V(x, n, o, l)), L = (x) => h(V(x, s, i, r));
|
|
2847
|
-
let P = o;
|
|
2848
|
-
if (c > a) {
|
|
2849
|
-
let x = 1 / 0, C = -1;
|
|
2850
|
-
for (let z = a; z <= c; z++)
|
|
2851
|
-
if (e[z] != null) {
|
|
2852
|
-
if (C >= 0) {
|
|
2853
|
-
const A = t[z], F = t[C], _ = Math.abs(I(A) - I(F));
|
|
2854
|
-
_ < x && (x = _);
|
|
2855
|
-
}
|
|
2856
|
-
C = z;
|
|
2857
|
-
}
|
|
2858
|
-
x < 1 / 0 && (P = x);
|
|
2859
|
-
}
|
|
2860
|
-
const T = P * (1 - d), M = Math.max(0, T + y), w = Math.max(1, h(P - M)), b = g > 1 ? Math.max(1, h(w / Math.max(1, g))) : w, k = (f == null ? void 0 : f.fillTo) ?? s.min ?? 0, D = L(k), m = new Path2D(), v = n.ori === G.Horizontal;
|
|
2861
|
-
for (let x = u === O.Forward ? a : c; x >= a && x <= c; x += u) {
|
|
2862
|
-
const C = e[x];
|
|
2863
|
-
if (C == null) continue;
|
|
2864
|
-
const z = I(t[x]), A = L(C), F = g > 1 ? (p - (g - 1) / 2) * b : 0, _ = h(z - b / 2 + F), R = Math.min(A, D), $ = Math.max(A, D) - R;
|
|
2865
|
-
if ($ !== 0)
|
|
2866
|
-
if (S > 0) {
|
|
2867
|
-
const W = Math.min(S * b, $ / 2);
|
|
2868
|
-
ns(m, v, _, R, b, $, W, C < k);
|
|
2869
|
-
} else
|
|
2870
|
-
v ? m.rect(_, R, b, $) : m.rect(R, _, $, b);
|
|
2871
|
-
}
|
|
2872
|
-
return {
|
|
2873
|
-
stroke: m,
|
|
2874
|
-
fill: m,
|
|
2875
|
-
// bars are filled with the same path
|
|
2876
|
-
clip: null,
|
|
2877
|
-
band: null,
|
|
2878
|
-
gaps: null
|
|
2879
|
-
};
|
|
2880
|
-
};
|
|
2881
|
-
}
|
|
2882
|
-
function ns(t, e, n, s, o, i, l, r) {
|
|
2883
|
-
l = Math.min(l, o / 2, i / 2), e ? r ? (t.moveTo(n, s), t.lineTo(n + o, s), t.lineTo(n + o, s + i - l), t.arc(n + o - l, s + i - l, l, 0, Math.PI / 2), t.lineTo(n + l, s + i), t.arc(n + l, s + i - l, l, Math.PI / 2, Math.PI), t.closePath()) : (t.moveTo(n, s + i), t.lineTo(n, s + l), t.arc(n + l, s + l, l, Math.PI, Math.PI * 1.5), t.lineTo(n + o - l, s), t.arc(n + o - l, s + l, l, Math.PI * 1.5, 0), t.lineTo(n + o, s + i), t.closePath()) : r ? (t.moveTo(s, n), t.lineTo(s, n + o), t.lineTo(s + i - l, n + o), t.arc(s + i - l, n + o - l, l, Math.PI / 2, 0, !0), t.lineTo(s + i, n + l), t.arc(s + i - l, n + l, l, 0, -Math.PI / 2, !0), t.closePath()) : (t.moveTo(s + i, n), t.lineTo(s + l, n), t.arc(s + l, n + l, l, -Math.PI / 2, Math.PI, !0), t.lineTo(s, n + o - l), t.arc(s + l, n + o - l, l, Math.PI, Math.PI / 2, !0), t.lineTo(s + i, n + o), t.closePath());
|
|
2884
|
-
}
|
|
2885
|
-
function Te(t) {
|
|
2886
|
-
return (e, n, s, o, i, l, r, a, c, u, h, f, d) => {
|
|
2887
|
-
const y = (d == null ? void 0 : d.spanGaps) ?? !1;
|
|
2888
|
-
if ([c, u] = Ft(n, c, u), c === -1)
|
|
2889
|
-
return { stroke: new Path2D(), fill: null, clip: null, band: null, gaps: null };
|
|
2890
|
-
const S = (b) => f(V(b, s, i, r)), p = (b) => f(V(b, o, l, a)), g = s.ori === G.Horizontal ? _t : Rt, I = [], L = [];
|
|
2891
|
-
let P = !1;
|
|
2892
|
-
for (let b = h === O.Forward ? c : u; b >= c && b <= u; b += h) {
|
|
2893
|
-
const k = n[b];
|
|
2894
|
-
k != null ? (I.push(S(e[b])), L.push(p(k))) : k === null && !y && (P = !0);
|
|
2895
|
-
}
|
|
2896
|
-
const T = s.ori === G.Horizontal, M = t(I, L, T, f), w = {
|
|
2897
|
-
stroke: M ?? new Path2D(),
|
|
2898
|
-
fill: null,
|
|
2899
|
-
clip: null,
|
|
2900
|
-
band: null,
|
|
2901
|
-
gaps: null
|
|
2902
|
-
};
|
|
2903
|
-
if (M != null) {
|
|
2904
|
-
const b = w.fill = new Path2D(M), k = (d == null ? void 0 : d.fillTo) ?? o.min ?? 0, D = p(k);
|
|
2905
|
-
let m = r, v = r + i;
|
|
2906
|
-
h === O.Backward && ([v, m] = [m, v]), g(b, v, D), g(b, m, D);
|
|
2907
|
-
}
|
|
2908
|
-
if (P) {
|
|
2909
|
-
const b = $t(e, n, c, u, h, S);
|
|
2910
|
-
w.gaps = b, w.clip = Yt(b, s.ori, r, a, i, l);
|
|
2911
|
-
}
|
|
2912
|
-
return w;
|
|
2913
|
-
};
|
|
2914
|
-
}
|
|
2915
|
-
function ys() {
|
|
2916
|
-
return Te(ss);
|
|
2917
|
-
}
|
|
2918
|
-
const ss = (t, e, n, s) => {
|
|
2919
|
-
const o = t.length;
|
|
2920
|
-
if (o < 2) return null;
|
|
2921
|
-
const i = new Path2D(), l = t[0] ?? 0, r = e[0] ?? 0;
|
|
2922
|
-
if (n ? i.moveTo(l, r) : i.moveTo(r, l), o === 2) {
|
|
2923
|
-
const f = t[1] ?? 0, d = e[1] ?? 0;
|
|
2924
|
-
return n ? i.lineTo(f, d) : i.lineTo(d, f), i;
|
|
2925
|
-
}
|
|
2926
|
-
const a = new Array(o), c = new Array(o - 1), u = new Array(o - 1), h = new Array(o - 1);
|
|
2927
|
-
for (let f = 0; f < o - 1; f++)
|
|
2928
|
-
u[f] = (e[f + 1] ?? 0) - (e[f] ?? 0), h[f] = (t[f + 1] ?? 0) - (t[f] ?? 0), c[f] = h[f] !== 0 ? (u[f] ?? 0) / (h[f] ?? 1) : 0;
|
|
2929
|
-
a[0] = c[0] ?? 0;
|
|
2930
|
-
for (let f = 1; f < o - 1; f++) {
|
|
2931
|
-
const d = c[f] ?? 0, y = c[f - 1] ?? 0;
|
|
2932
|
-
if (d === 0 || y === 0 || y > 0 != d > 0)
|
|
2933
|
-
a[f] = 0;
|
|
2934
|
-
else {
|
|
2935
|
-
const S = h[f] ?? 1, p = h[f - 1] ?? 1;
|
|
2936
|
-
a[f] = 3 * (p + S) / ((2 * S + p) / y + (S + 2 * p) / d), isFinite(a[f] ?? 0) || (a[f] = 0);
|
|
2937
|
-
}
|
|
2938
|
-
}
|
|
2939
|
-
a[o - 1] = c[o - 2] ?? 0;
|
|
2940
|
-
for (let f = 0; f < o - 1; f++) {
|
|
2941
|
-
const d = h[f] ?? 1, y = t[f] ?? 0, S = e[f] ?? 0, p = t[f + 1] ?? 0, g = e[f + 1] ?? 0, I = a[f] ?? 0, L = a[f + 1] ?? 0, P = y + d / 3, T = S + I * d / 3, M = p - d / 3, w = g - L * d / 3;
|
|
2942
|
-
n ? i.bezierCurveTo(P, T, M, w, p, g) : i.bezierCurveTo(T, P, w, M, g, p);
|
|
2943
|
-
}
|
|
2944
|
-
return i;
|
|
2945
|
-
};
|
|
2946
|
-
function ks() {
|
|
2947
|
-
return Te(os);
|
|
2948
|
-
}
|
|
2949
|
-
const os = (t, e, n, s) => {
|
|
2950
|
-
const o = t.length;
|
|
2951
|
-
if (o < 2) return null;
|
|
2952
|
-
const i = new Path2D(), l = s(t[0] ?? 0), r = s(e[0] ?? 0);
|
|
2953
|
-
if (n ? i.moveTo(l, r) : i.moveTo(r, l), o === 2) {
|
|
2954
|
-
const a = s(t[1] ?? 0), c = s(e[1] ?? 0);
|
|
2955
|
-
return n ? i.lineTo(a, c) : i.lineTo(c, a), i;
|
|
2956
|
-
}
|
|
2957
|
-
for (let a = 0; a < o - 1; a++) {
|
|
2958
|
-
const c = a === 0 ? 0 : a - 1, u = t[c] ?? 0, h = e[c] ?? 0, f = t[a] ?? 0, d = e[a] ?? 0, y = t[a + 1] ?? 0, S = e[a + 1] ?? 0, p = a + 2 < o ? t[a + 2] ?? 0 : y, g = a + 2 < o ? e[a + 2] ?? 0 : S, I = Math.hypot(u - f, h - d), L = Math.hypot(f - y, d - S), P = Math.hypot(y - p, S - g), T = Math.sqrt(P), M = P, w = Math.sqrt(L), b = L, k = Math.sqrt(I), D = I, m = 2 * D + 3 * k * w + b, v = 2 * M + 3 * T * w + b, x = 3 * k * (k + w), C = 3 * T * (T + w);
|
|
2959
|
-
let z, A, F, _;
|
|
2960
|
-
if (x > 0) {
|
|
2961
|
-
const R = 1 / x;
|
|
2962
|
-
z = (-b * u + m * f + D * y) * R, A = (-b * h + m * d + D * S) * R;
|
|
2963
|
-
} else
|
|
2964
|
-
z = f, A = d;
|
|
2965
|
-
if (C > 0) {
|
|
2966
|
-
const R = 1 / C;
|
|
2967
|
-
F = (M * f + v * y - b * p) * R, _ = (M * d + v * S - b * g) * R;
|
|
2968
|
-
} else
|
|
2969
|
-
F = y, _ = S;
|
|
2970
|
-
n ? i.bezierCurveTo(z, A, F, _, y, S) : i.bezierCurveTo(A, z, _, F, S, y);
|
|
2971
|
-
}
|
|
2972
|
-
return i;
|
|
2973
|
-
};
|
|
2974
|
-
function Cs(t = 4) {
|
|
2975
|
-
return (e, n, s, o, i, l, r, a, c, u, h, f, d) => {
|
|
2976
|
-
const y = (L) => f(V(L, s, i, r)), S = (L) => f(V(L, o, l, a)), p = t / 2, g = new Path2D(), I = s.ori === G.Horizontal;
|
|
2977
|
-
for (let L = h === O.Forward ? c : u; L >= c && L <= u; L += h) {
|
|
2978
|
-
const P = n[L];
|
|
2979
|
-
if (P == null) continue;
|
|
2980
|
-
const T = y(e[L]), M = S(P);
|
|
2981
|
-
I ? (g.moveTo(T + p, M), g.arc(T, M, p, 0, Math.PI * 2)) : (g.moveTo(M + p, T), g.arc(M, T, p, 0, Math.PI * 2));
|
|
2982
|
-
}
|
|
2983
|
-
return {
|
|
2984
|
-
stroke: g,
|
|
2985
|
-
fill: g,
|
|
2986
|
-
clip: null,
|
|
2987
|
-
band: null,
|
|
2988
|
-
gaps: null
|
|
2989
|
-
};
|
|
2990
|
-
};
|
|
2991
|
-
}
|
|
2992
|
-
function Ts(t) {
|
|
2993
|
-
return ({ ctx: e, plotBox: n, pxRatio: s }) => {
|
|
2994
|
-
const {
|
|
2995
|
-
xValues: o,
|
|
2996
|
-
open: i,
|
|
2997
|
-
high: l,
|
|
2998
|
-
low: r,
|
|
2999
|
-
close: a,
|
|
3000
|
-
xScale: c,
|
|
3001
|
-
yScale: u,
|
|
3002
|
-
upColor: h = "#26a69a",
|
|
3003
|
-
downColor: f = "#ef5350",
|
|
3004
|
-
bodyWidth: d = 0.6,
|
|
3005
|
-
wickWidth: y = 1
|
|
3006
|
-
} = t;
|
|
3007
|
-
if (c.min == null || c.max == null || u.min == null || u.max == null) return;
|
|
3008
|
-
const S = o.length;
|
|
3009
|
-
if (S === 0) return;
|
|
3010
|
-
const g = Math.max(2, n.width / S * d) * s / 2;
|
|
3011
|
-
e.save();
|
|
3012
|
-
for (let I = 0; I < S; I++) {
|
|
3013
|
-
const L = o[I], P = i[I], T = l[I], M = r[I], w = a[I];
|
|
3014
|
-
if (L == null || P == null || T == null || M == null || w == null) continue;
|
|
3015
|
-
const b = V(L, c, n.width, n.left) * s, k = V(P, u, n.height, n.top) * s, D = V(T, u, n.height, n.top) * s, m = V(M, u, n.height, n.top) * s, v = V(w, u, n.height, n.top) * s, C = w >= P ? h : f;
|
|
3016
|
-
e.strokeStyle = C, e.lineWidth = y * s, e.beginPath(), e.moveTo(b, D), e.lineTo(b, m), e.stroke();
|
|
3017
|
-
const z = Math.min(k, v), A = Math.abs(v - k);
|
|
3018
|
-
e.fillStyle = C, e.fillRect(b - g, z, g * 2, Math.max(A, 1 * s));
|
|
3019
|
-
}
|
|
3020
|
-
e.restore();
|
|
3021
|
-
};
|
|
3022
|
-
}
|
|
3023
|
-
function Is(t, e, n = 0) {
|
|
3024
|
-
const s = e ?? t.series.map((c, u) => u), o = t.x.length, i = [], l = new Float64Array(o);
|
|
3025
|
-
for (let c = 0; c < s.length; c++) {
|
|
3026
|
-
const u = s[c];
|
|
3027
|
-
if (u == null) continue;
|
|
3028
|
-
const h = t.series[u];
|
|
3029
|
-
if (h == null) continue;
|
|
3030
|
-
const f = new Array(o);
|
|
3031
|
-
for (let d = 0; d < o; d++) {
|
|
3032
|
-
const y = h[d];
|
|
3033
|
-
y != null ? (l[d] = l[d] + y, f[d] = l[d]) : f[d] = null;
|
|
3034
|
-
}
|
|
3035
|
-
i.push(f);
|
|
3036
|
-
}
|
|
3037
|
-
const r = [];
|
|
3038
|
-
for (let c = 0; c < t.series.length; c++) {
|
|
3039
|
-
const u = s.indexOf(c), h = u >= 0 ? i[u] : void 0;
|
|
3040
|
-
h != null ? r.push(h) : r.push(t.series[c] ?? []);
|
|
3041
|
-
}
|
|
3042
|
-
const a = [];
|
|
3043
|
-
for (let c = s.length - 1; c > 0; c--) {
|
|
3044
|
-
const u = s[c], h = s[c - 1];
|
|
3045
|
-
u != null && h != null && a.push({
|
|
3046
|
-
group: n,
|
|
3047
|
-
series: [u, h]
|
|
3048
|
-
});
|
|
3049
|
-
}
|
|
3050
|
-
return {
|
|
3051
|
-
group: { x: t.x, series: r },
|
|
3052
|
-
bands: a
|
|
3053
|
-
};
|
|
3054
|
-
}
|
|
3055
|
-
function As(t) {
|
|
3056
|
-
const e = /* @__PURE__ */ new Set();
|
|
3057
|
-
for (const [i] of t)
|
|
3058
|
-
for (let l = 0; l < i.length; l++) {
|
|
3059
|
-
const r = i[l];
|
|
3060
|
-
r != null && e.add(r);
|
|
3061
|
-
}
|
|
3062
|
-
const n = Float64Array.from([...e].sort((i, l) => i - l)), s = /* @__PURE__ */ new Map();
|
|
3063
|
-
for (let i = 0; i < n.length; i++) {
|
|
3064
|
-
const l = n[i];
|
|
3065
|
-
l != null && s.set(l, i);
|
|
3066
|
-
}
|
|
3067
|
-
const o = [];
|
|
3068
|
-
for (const [i, l] of t) {
|
|
3069
|
-
const r = new Array(n.length).fill(null);
|
|
3070
|
-
for (let a = 0; a < i.length; a++) {
|
|
3071
|
-
const c = i[a];
|
|
3072
|
-
if (c == null) continue;
|
|
3073
|
-
const u = s.get(c);
|
|
3074
|
-
u != null && (r[u] = l[a] ?? null);
|
|
3075
|
-
}
|
|
3076
|
-
o.push(r);
|
|
3077
|
-
}
|
|
3078
|
-
return [{ x: n, series: o }];
|
|
3079
|
-
}
|
|
3080
|
-
function Ps(t) {
|
|
3081
|
-
const e = (t == null ? void 0 : t.decimals) ?? 1;
|
|
3082
|
-
return (n) => n.map((s) => {
|
|
3083
|
-
const o = Math.abs(s);
|
|
3084
|
-
return o >= 1e9 ? (s / 1e9).toFixed(e) + "B" : o >= 1e6 ? (s / 1e6).toFixed(e) + "M" : o >= 1e3 ? (s / 1e3).toFixed(e) + "K" : s.toFixed(o >= 1 ? 0 : e);
|
|
3085
|
-
});
|
|
3086
|
-
}
|
|
3087
|
-
function Ls(t, e = 0) {
|
|
3088
|
-
return (n) => n.map((s) => s.toFixed(e) + t);
|
|
3089
|
-
}
|
|
3090
|
-
function zs(t) {
|
|
3091
|
-
const e = (t == null ? void 0 : t.utc) ?? !1;
|
|
3092
|
-
return (n) => n.map((s) => e ? et(s, { hour: "2-digit", minute: "2-digit", hour12: !1 }, "UTC") : et(s, { hour: "2-digit", minute: "2-digit", hour12: !1 }));
|
|
3093
|
-
}
|
|
3094
|
-
function Ds(t) {
|
|
3095
|
-
const e = t != null && t.utc ? "UTC" : void 0, n = (t == null ? void 0 : t.format) ?? "short";
|
|
3096
|
-
return (s) => s.map((o) => et(o, { month: n }, e));
|
|
3097
|
-
}
|
|
3098
|
-
function Fs(t) {
|
|
3099
|
-
const { tz: e, ...n } = t ?? {};
|
|
3100
|
-
return (s) => s.map((o) => et(o, n, e));
|
|
3101
|
-
}
|
|
3102
|
-
function _s(t, e = 0) {
|
|
3103
|
-
return (n) => n.map((s) => {
|
|
3104
|
-
const o = Math.round(s) - e;
|
|
3105
|
-
return t[o] ?? String(s);
|
|
3106
|
-
});
|
|
3107
|
-
}
|
|
3108
|
-
function Ie(t) {
|
|
3109
|
-
const e = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(t);
|
|
3110
|
-
if (e)
|
|
3111
|
-
return [
|
|
3112
|
-
parseInt(e[1], 16),
|
|
3113
|
-
parseInt(e[2], 16),
|
|
3114
|
-
parseInt(e[3], 16)
|
|
3115
|
-
];
|
|
3116
|
-
const n = /^#([0-9a-f])([0-9a-f])([0-9a-f])/i.exec(t);
|
|
3117
|
-
if (n)
|
|
3118
|
-
return [
|
|
3119
|
-
parseInt(n[1] + n[1], 16),
|
|
3120
|
-
parseInt(n[2] + n[2], 16),
|
|
3121
|
-
parseInt(n[3] + n[3], 16)
|
|
3122
|
-
];
|
|
3123
|
-
const s = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i.exec(t);
|
|
3124
|
-
return s ? [Number(s[1]), Number(s[2]), Number(s[3])] : null;
|
|
3125
|
-
}
|
|
3126
|
-
function Rs(t, e = 0.8, n = 0) {
|
|
3127
|
-
const s = Ie(t);
|
|
3128
|
-
if (s == null)
|
|
3129
|
-
return { type: "linear", stops: [[0, t], [1, t]] };
|
|
3130
|
-
const [o, i, l] = s;
|
|
3131
|
-
return {
|
|
3132
|
-
type: "linear",
|
|
3133
|
-
stops: [
|
|
3134
|
-
[0, `rgba(${o},${i},${l},${e})`],
|
|
3135
|
-
[1, `rgba(${o},${i},${l},${n})`]
|
|
3136
|
-
]
|
|
3137
|
-
};
|
|
3138
|
-
}
|
|
3139
|
-
function Gs(t, e) {
|
|
3140
|
-
const n = Ie(t);
|
|
3141
|
-
if (n == null) return t;
|
|
3142
|
-
const [s, o, i] = n;
|
|
3143
|
-
return `rgba(${s},${o},${i},${e})`;
|
|
3144
|
-
}
|
|
3145
|
-
function Vs(t, e = 65, n = 50) {
|
|
3146
|
-
const s = [];
|
|
3147
|
-
for (let i = 0; i < t; i++) {
|
|
3148
|
-
const l = i * 137.508 % 360;
|
|
3149
|
-
s.push(`hsl(${l.toFixed(1)},${e}%,${n}%)`);
|
|
3150
|
-
}
|
|
3151
|
-
return s;
|
|
3152
|
-
}
|
|
3153
|
-
export {
|
|
3154
|
-
xs as AnnotationLabel,
|
|
3155
|
-
zt as Axis,
|
|
3156
|
-
rs as Band,
|
|
3157
|
-
Ut as Chart,
|
|
3158
|
-
O as Direction,
|
|
3159
|
-
N as Distribution,
|
|
3160
|
-
ms as HLine,
|
|
3161
|
-
as as Legend,
|
|
3162
|
-
G as Orientation,
|
|
3163
|
-
vs as Region,
|
|
3164
|
-
gs as ResponsiveChart,
|
|
3165
|
-
Lt as Scale,
|
|
3166
|
-
Ce as Series,
|
|
3167
|
-
U as Side,
|
|
3168
|
-
yt as SortOrder,
|
|
3169
|
-
ds as Sparkline,
|
|
3170
|
-
hs as Timeline,
|
|
3171
|
-
cs as Tooltip,
|
|
3172
|
-
ws as VLine,
|
|
3173
|
-
us as ZoomRanger,
|
|
3174
|
-
As as alignData,
|
|
3175
|
-
bs as bars,
|
|
3176
|
-
ks as catmullRom,
|
|
3177
|
-
Ts as drawCandlesticks,
|
|
3178
|
-
Qn as drawHLine,
|
|
3179
|
-
ps as drawLabel,
|
|
3180
|
-
es as drawRegion,
|
|
3181
|
-
ts as drawVLine,
|
|
3182
|
-
Rs as fadeGradient,
|
|
3183
|
-
Ps as fmtCompact,
|
|
3184
|
-
Fs as fmtDateStr,
|
|
3185
|
-
zs as fmtHourMin,
|
|
3186
|
-
_s as fmtLabels,
|
|
3187
|
-
Ds as fmtMonthName,
|
|
3188
|
-
Ls as fmtSuffix,
|
|
3189
|
-
Je as linear,
|
|
3190
|
-
ys as monotoneCubic,
|
|
3191
|
-
Vs as palette,
|
|
3192
|
-
Cs as points,
|
|
3193
|
-
it as posToVal,
|
|
3194
|
-
Mt as sideOrientation,
|
|
3195
|
-
Is as stackGroup,
|
|
3196
|
-
Ss as stepped,
|
|
3197
|
-
st as useChart,
|
|
3198
|
-
fs as useCursorDrawHook,
|
|
3199
|
-
Pt as useDrawHook,
|
|
3200
|
-
Ms as useStreamingData,
|
|
3201
|
-
V as valToPos,
|
|
3202
|
-
Gs as withAlpha
|
|
3203
|
-
};
|