@canplot/react 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/axes.d.ts +0 -15
- package/dist/axes.d.ts.map +1 -1
- package/dist/canplot.cjs +2 -4
- package/dist/canplot.cjs.map +1 -1
- package/dist/canplot.mjs +825 -856
- package/dist/canplot.mjs.map +1 -1
- package/dist/dataUtils.d.ts +7 -0
- package/dist/dataUtils.d.ts.map +1 -0
- package/dist/index.d.ts +16 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/plot/Positioned.d.ts +6 -0
- package/dist/plot/Positioned.d.ts.map +1 -0
- package/dist/plot/Ticks.d.ts +18 -0
- package/dist/plot/Ticks.d.ts.map +1 -0
- package/dist/tickUtils.d.ts +21 -0
- package/dist/tickUtils.d.ts.map +1 -0
- package/dist/types.d.ts +22 -33
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -2
package/dist/canplot.mjs
CHANGED
|
@@ -1,456 +1,146 @@
|
|
|
1
|
-
import { jsxs as at, jsx as
|
|
2
|
-
import
|
|
3
|
-
import { createStore as
|
|
4
|
-
const
|
|
5
|
-
const { min:
|
|
1
|
+
import { jsxs as at, jsx as L, Fragment as Et } from "react/jsx-runtime";
|
|
2
|
+
import Z, { createContext as Mt, useContext as lt, useRef as R, useLayoutEffect as G, version as Pt, forwardRef as At, useMemo as gt, useState as N, useId as _t, useEffect as Rt } from "react";
|
|
3
|
+
import { createStore as Ut, useStore as wt } from "zustand";
|
|
4
|
+
const J = (t, s, e) => Math.min(Math.max(t, s), e), Lt = (t, s, e, c) => {
|
|
5
|
+
const { min: n, max: o } = D(t, e), i = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, a = (Q(t, e) ? i.width : i.height) / (o - n);
|
|
6
6
|
return s / a;
|
|
7
|
-
},
|
|
8
|
-
const e = t.scales.find((
|
|
7
|
+
}, D = (t, s) => {
|
|
8
|
+
const e = t.scales.find((c) => c.id === s);
|
|
9
9
|
if (!e)
|
|
10
10
|
throw new Error(`Scale ${s} not found`);
|
|
11
11
|
return e;
|
|
12
|
-
},
|
|
12
|
+
}, Q = (t, s) => t.scales.find((e) => e.id === s)?.origin === "x", ae = (t, s) => t.scales.find((e) => e.id === s)?.origin === "y", O = (t, s) => {
|
|
13
13
|
const e = window.devicePixelRatio || 1;
|
|
14
14
|
t.lineCap = s?.lineCap ?? "butt", t.lineDashOffset = e * (s?.lineDashOffset ?? 0), t.lineJoin = s?.lineJoin ?? "miter", t.lineWidth = e * (s?.lineWidth ?? 1), t.miterLimit = e * (s?.miterLimit ?? 10), t.strokeStyle = s?.strokeStyle ?? "black", t.fillStyle = s?.fillStyle ?? t.strokeStyle, t.font = s?.font ?? `${10 * e}px sans-serif`, t.textAlign = s?.textAlign ?? "start", t.direction = s?.direction ?? "inherit", t.textBaseline = s?.textBaseline ?? "alphabetic", t.fontKerning = s?.fontKerning ?? "auto";
|
|
15
|
-
}, ut = (t, s, e,
|
|
16
|
-
const
|
|
15
|
+
}, ut = (t, s, e, c) => {
|
|
16
|
+
const n = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, { min: o, max: i } = D(t, e), a = (Q(t, e) ? n.width : n.height) / (i - o);
|
|
17
17
|
return s * a;
|
|
18
|
-
},
|
|
19
|
-
const { min:
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
) :
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
}, B = (t, s, e, c) => {
|
|
19
|
+
const { min: n } = D(t, e), o = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, i = ut(t, s - n, e, c);
|
|
20
|
+
return Q(t, e) ? J(
|
|
21
|
+
o.x + i,
|
|
22
|
+
o.x - 10 * o.width,
|
|
23
|
+
o.x + 11 * o.width
|
|
24
|
+
) : J(
|
|
25
|
+
o.y + o.height - i,
|
|
26
|
+
o.y - 10 * o.height,
|
|
27
|
+
o.y + 11 * o.height
|
|
28
28
|
);
|
|
29
|
-
},
|
|
30
|
-
const
|
|
31
|
-
return
|
|
32
|
-
},
|
|
33
|
-
const
|
|
34
|
-
return
|
|
35
|
-
},
|
|
36
|
-
const { min:
|
|
37
|
-
return s >=
|
|
38
|
-
},
|
|
39
|
-
const { min:
|
|
40
|
-
return
|
|
41
|
-
},
|
|
42
|
-
// second divisors
|
|
43
|
-
[1, "milliseconds"],
|
|
44
|
-
[2, "milliseconds"],
|
|
45
|
-
[5, "milliseconds"],
|
|
46
|
-
[10, "milliseconds"],
|
|
47
|
-
[20, "milliseconds"],
|
|
48
|
-
[50, "milliseconds"],
|
|
49
|
-
[100, "milliseconds"],
|
|
50
|
-
[200, "milliseconds"],
|
|
51
|
-
[500, "milliseconds"],
|
|
52
|
-
// minute divisors
|
|
53
|
-
[1, "seconds"],
|
|
54
|
-
[5, "seconds"],
|
|
55
|
-
[10, "seconds"],
|
|
56
|
-
[15, "seconds"],
|
|
57
|
-
[30, "seconds"],
|
|
58
|
-
// hour divisors
|
|
59
|
-
[1, "minutes"],
|
|
60
|
-
[5, "minutes"],
|
|
61
|
-
[10, "minutes"],
|
|
62
|
-
[15, "minutes"],
|
|
63
|
-
[30, "minutes"],
|
|
64
|
-
// day divisors
|
|
65
|
-
[1, "hours"],
|
|
66
|
-
[2, "hours"],
|
|
67
|
-
[3, "hours"],
|
|
68
|
-
[4, "hours"],
|
|
69
|
-
[6, "hours"],
|
|
70
|
-
[8, "hours"],
|
|
71
|
-
[12, "hours"],
|
|
72
|
-
// month divisors
|
|
73
|
-
[1, "days"],
|
|
74
|
-
[3, "days"],
|
|
75
|
-
[5, "days"],
|
|
76
|
-
[7, "days"],
|
|
77
|
-
[10, "days"],
|
|
78
|
-
[15, "days"],
|
|
79
|
-
// year divisors
|
|
80
|
-
[1, "months"],
|
|
81
|
-
[2, "months"],
|
|
82
|
-
[3, "months"],
|
|
83
|
-
[4, "months"],
|
|
84
|
-
[6, "months"],
|
|
85
|
-
// century divisors
|
|
86
|
-
[1, "years"],
|
|
87
|
-
[2, "years"],
|
|
88
|
-
[5, "years"],
|
|
89
|
-
[10, "years"],
|
|
90
|
-
[25, "years"],
|
|
91
|
-
[50, "years"],
|
|
92
|
-
[100, "years"]
|
|
93
|
-
], H = (t) => {
|
|
94
|
-
const [s, e] = t;
|
|
95
|
-
switch (e) {
|
|
96
|
-
case "milliseconds":
|
|
97
|
-
return s;
|
|
98
|
-
case "seconds":
|
|
99
|
-
return s * Mt;
|
|
100
|
-
case "minutes":
|
|
101
|
-
return s * dt;
|
|
102
|
-
case "hours":
|
|
103
|
-
return s * Q;
|
|
104
|
-
case "days":
|
|
105
|
-
return s * tt;
|
|
106
|
-
case "months":
|
|
107
|
-
return s * Ot;
|
|
108
|
-
case "years":
|
|
109
|
-
return s * $t;
|
|
110
|
-
}
|
|
111
|
-
}, Nt = (t, s) => {
|
|
112
|
-
const e = new Date(t);
|
|
113
|
-
return e.setUTCMilliseconds(e.getUTCMilliseconds() + s), e.getTime();
|
|
114
|
-
}, Vt = (t, s) => {
|
|
115
|
-
const e = new Date(t);
|
|
116
|
-
return e.setUTCSeconds(e.getUTCSeconds() + s), e.getTime();
|
|
117
|
-
}, jt = (t, s) => {
|
|
118
|
-
const e = new Date(t);
|
|
119
|
-
return e.setUTCMinutes(e.getUTCMinutes() + s), e.getTime();
|
|
120
|
-
}, Ht = (t, s) => {
|
|
121
|
-
const e = new Date(t);
|
|
122
|
-
return e.setUTCHours(e.getUTCHours() + s), e.getTime();
|
|
123
|
-
}, Zt = (t, s) => {
|
|
124
|
-
const e = new Date(t);
|
|
125
|
-
return e.setUTCDate(e.getUTCDate() + s), e.getTime();
|
|
126
|
-
}, xt = (t, s) => {
|
|
127
|
-
const e = new Date(t);
|
|
128
|
-
return e.setUTCMonth(e.getUTCMonth() + s), e.getTime();
|
|
129
|
-
}, z = (t, s) => {
|
|
130
|
-
const [e, o] = s;
|
|
131
|
-
switch (o) {
|
|
132
|
-
case "milliseconds":
|
|
133
|
-
return Nt(t, e);
|
|
134
|
-
case "seconds":
|
|
135
|
-
return Vt(t, e);
|
|
136
|
-
case "minutes":
|
|
137
|
-
return jt(t, e);
|
|
138
|
-
case "hours":
|
|
139
|
-
return Ht(t, e);
|
|
140
|
-
case "days":
|
|
141
|
-
return Zt(t, e);
|
|
142
|
-
case "months":
|
|
143
|
-
return xt(t, e);
|
|
144
|
-
case "years":
|
|
145
|
-
return xt(t, e * 12);
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
function Z(t, s) {
|
|
149
|
-
const e = new Date(t), o = new Date(e.toLocaleString("en-US", { timeZone: s })), i = new Date(e.toLocaleString("en-US", { timeZone: "UTC" }));
|
|
150
|
-
return (o.getTime() - i.getTime()) / (3600 * 1e3);
|
|
151
|
-
}
|
|
152
|
-
const Wt = (t, s, e = "UTC") => {
|
|
153
|
-
const [o, i] = s;
|
|
154
|
-
let n = new Date(t);
|
|
155
|
-
const r = () => {
|
|
156
|
-
n.setUTCHours(-Z(n, e), 0, 0, 0);
|
|
157
|
-
};
|
|
158
|
-
switch (i) {
|
|
159
|
-
case "milliseconds":
|
|
160
|
-
n.setUTCMilliseconds(
|
|
161
|
-
Math.ceil(n.getUTCMilliseconds() / o) * o
|
|
162
|
-
);
|
|
163
|
-
break;
|
|
164
|
-
case "seconds":
|
|
165
|
-
n.setUTCSeconds(
|
|
166
|
-
Math.ceil(n.getUTCSeconds() / o) * o,
|
|
167
|
-
0
|
|
168
|
-
);
|
|
169
|
-
break;
|
|
170
|
-
case "minutes":
|
|
171
|
-
n.setUTCMinutes(
|
|
172
|
-
Math.ceil(n.getTime() % Q / dt / o) * o,
|
|
173
|
-
0,
|
|
174
|
-
0
|
|
175
|
-
);
|
|
176
|
-
break;
|
|
177
|
-
case "hours":
|
|
178
|
-
n.setUTCHours(
|
|
179
|
-
Math.ceil(n.getTime() % tt / Q / o) * o,
|
|
180
|
-
0,
|
|
181
|
-
0,
|
|
182
|
-
0
|
|
183
|
-
);
|
|
184
|
-
break;
|
|
185
|
-
case "days":
|
|
186
|
-
case "months":
|
|
187
|
-
case "years":
|
|
188
|
-
i === "months" ? n.setUTCDate(1) : i === "years" && n.setUTCMonth(0, 1), r(), n.getTime() < t && (n = new Date(z(n, [1, i])));
|
|
189
|
-
break;
|
|
190
|
-
}
|
|
191
|
-
return n.getTime();
|
|
192
|
-
}, Gt = ({
|
|
193
|
-
timeZone: t = Et,
|
|
194
|
-
space: s = kt
|
|
195
|
-
}) => ({ frame: e, scaleId: o }) => {
|
|
196
|
-
const { min: i, max: n } = A(e, o), r = Math.floor(e.chartAreaCanvasPX.width / s) + 1, u = (n - i) / r, [l, d] = Bt.find(
|
|
197
|
-
(p) => H(p) >= u
|
|
198
|
-
) ?? [1, "milliseconds"], f = Wt(i, [l, d], t), m = Z(f, t), h = [f];
|
|
199
|
-
let c;
|
|
200
|
-
for (; ; ) {
|
|
201
|
-
switch (d) {
|
|
202
|
-
case "milliseconds":
|
|
203
|
-
case "seconds":
|
|
204
|
-
case "minutes":
|
|
205
|
-
case "hours": {
|
|
206
|
-
c = z(f, [h.length * l, d]);
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
case "days": {
|
|
210
|
-
const p = z(f, [
|
|
211
|
-
h.length * l,
|
|
212
|
-
d
|
|
213
|
-
]);
|
|
214
|
-
c = z(p, [
|
|
215
|
-
m - Z(p, t),
|
|
216
|
-
"hours"
|
|
217
|
-
]);
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
case "months":
|
|
221
|
-
case "years": {
|
|
222
|
-
const p = z(
|
|
223
|
-
z(z(f, [m, "hours"]), [
|
|
224
|
-
h.length * l,
|
|
225
|
-
d
|
|
226
|
-
]),
|
|
227
|
-
[-m, "hours"]
|
|
228
|
-
);
|
|
229
|
-
c = z(p, [
|
|
230
|
-
m - Z(p, t),
|
|
231
|
-
"hours"
|
|
232
|
-
]);
|
|
233
|
-
break;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
if (c > n)
|
|
237
|
-
break;
|
|
238
|
-
h.push(c);
|
|
239
|
-
}
|
|
240
|
-
return h;
|
|
241
|
-
}, I = (t, s, e) => t.find((o) => o.type === e)?.value !== s.find((o) => o.type === e)?.value, Jt = ({
|
|
242
|
-
timeZone: t = Et,
|
|
243
|
-
locale: s = zt,
|
|
244
|
-
showTimezone: e = !0
|
|
245
|
-
}) => {
|
|
246
|
-
const o = new Intl.DateTimeFormat(s, {
|
|
247
|
-
year: "numeric",
|
|
248
|
-
day: "numeric",
|
|
249
|
-
month: "short",
|
|
250
|
-
hour: "numeric",
|
|
251
|
-
hourCycle: "h23",
|
|
252
|
-
minute: "numeric",
|
|
253
|
-
second: "numeric",
|
|
254
|
-
fractionalSecondDigits: 3,
|
|
255
|
-
timeZoneName: "short",
|
|
256
|
-
timeZone: t
|
|
257
|
-
});
|
|
258
|
-
return ({ ticks: i }) => {
|
|
259
|
-
const n = i[1] - i[0], r = n < H([1, "days"]), a = n < H([1, "minutes"]), u = n < H([1, "seconds"]);
|
|
260
|
-
return i.map((l) => o.formatToParts(new Date(l))).map((l, d, f) => {
|
|
261
|
-
const m = f[d - 1], h = d === 0 || I(l, m, "year"), c = d === 0 || I(l, m, "day"), p = d === 0 || I(l, m, "month"), y = d === 0 || I(l, m, "hour"), x = d === 0 || I(l, m, "timeZoneName"), C = d === 0 || I(l, m, "minute"), S = d === 0 || I(l, m, "second"), g = d === 0 || I(l, m, "fractionalSecond"), k = [];
|
|
262
|
-
if (r && (y || C || x || S || g)) {
|
|
263
|
-
const v = l.find((P) => P.type === "hour")?.value, E = l.find((P) => P.type === "minute")?.value, M = l.find((P) => P.type === "timeZoneName")?.value;
|
|
264
|
-
let _ = "";
|
|
265
|
-
if (a) {
|
|
266
|
-
const P = l.find((F) => F.type === "second")?.value, B = l.find((F) => F.type === "fractionalSecond")?.value;
|
|
267
|
-
_ = `:${P}` + (u ? `.${B}` : "");
|
|
268
|
-
}
|
|
269
|
-
k.push(
|
|
270
|
-
`${v}:${E}${_}` + (e && x ? ` ${M}` : "")
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
return (c || p) && k.push(
|
|
274
|
-
[
|
|
275
|
-
l.find((v) => v.type === "month")?.value,
|
|
276
|
-
c && l.find((v) => v.type === "day")?.value
|
|
277
|
-
].filter(Boolean).join(" ")
|
|
278
|
-
), h && k.push(l.find((v) => v.type === "year")?.value), k.filter((v) => v).join(`
|
|
279
|
-
`);
|
|
280
|
-
});
|
|
281
|
-
};
|
|
282
|
-
}, W = [];
|
|
283
|
-
for (let t = -12; t <= 12; t++)
|
|
284
|
-
W.push(1 * 10 ** t), W.push(2 * 10 ** t), W.push(5 * 10 ** t);
|
|
285
|
-
const qt = (t) => {
|
|
29
|
+
}, z = (t, s, e) => {
|
|
30
|
+
const c = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
|
|
31
|
+
return J(s, c.x, c.x + c.width);
|
|
32
|
+
}, Y = (t, s, e) => {
|
|
33
|
+
const c = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
|
|
34
|
+
return J(s, c.y, c.y + c.height);
|
|
35
|
+
}, rt = (t, s, e) => {
|
|
36
|
+
const { min: c, max: n } = D(t, e);
|
|
37
|
+
return s >= c && s <= n;
|
|
38
|
+
}, U = (t, s, e, c) => {
|
|
39
|
+
const { min: n, max: o } = D(t, e), i = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, a = Q(t, e) ? (s - i.x) / i.width : (i.height - s + i.y) / i.height;
|
|
40
|
+
return n + a * (o - n);
|
|
41
|
+
}, Dt = (t) => {
|
|
286
42
|
const { ctx: s, scales: e } = t;
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
if (
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
const a = r.y + r.height;
|
|
303
|
-
s.beginPath(), s.moveTo(r.x, a), s.lineTo(r.x + r.width, a), s.stroke(), gt(t, o.id, a, i, n);
|
|
43
|
+
for (const c of e) {
|
|
44
|
+
if (!c.axis) continue;
|
|
45
|
+
s.save(), O(s, {
|
|
46
|
+
strokeStyle: "black",
|
|
47
|
+
fillStyle: "black",
|
|
48
|
+
lineWidth: 1,
|
|
49
|
+
...c.axis.style
|
|
50
|
+
});
|
|
51
|
+
const n = c.axis.canvasRect;
|
|
52
|
+
if (c.origin === "x") {
|
|
53
|
+
if (c.axis.position === "bottom")
|
|
54
|
+
s.beginPath(), s.moveTo(n.x, n.y), s.lineTo(n.x + n.width, n.y), s.stroke();
|
|
55
|
+
else if (c.axis.position === "top") {
|
|
56
|
+
const o = n.y + n.height;
|
|
57
|
+
s.beginPath(), s.moveTo(n.x, o), s.lineTo(n.x + n.width, o), s.stroke();
|
|
304
58
|
}
|
|
305
|
-
} else if (
|
|
306
|
-
const
|
|
307
|
-
s.beginPath(), s.moveTo(
|
|
308
|
-
} else
|
|
309
|
-
|
|
310
|
-
s.restore();
|
|
311
|
-
}, St = (t, s, e, o, i) => {
|
|
312
|
-
const { ctx: n } = t, r = t.scales.find((c) => c.id === s)?.axis;
|
|
313
|
-
if (!r) return;
|
|
314
|
-
const a = window.devicePixelRatio || 1, u = Tt, l = e, d = r.position === "left" ? e - u : e + u, f = bt * a, m = o({ frame: t, scaleId: s }) ?? [], h = i({
|
|
315
|
-
frame: t,
|
|
316
|
-
scaleId: s,
|
|
317
|
-
ticks: m
|
|
318
|
-
});
|
|
319
|
-
n.save(), n.fontKerning = "auto", X(n, {}), n.beginPath();
|
|
320
|
-
for (let c = 0; c < m.length; c++) {
|
|
321
|
-
const p = K(t, m[c], s, "canvas");
|
|
322
|
-
n.moveTo(l, p), n.lineTo(d, p);
|
|
59
|
+
} else if (c.axis.position === "left") {
|
|
60
|
+
const o = n.x + n.width;
|
|
61
|
+
s.beginPath(), s.moveTo(o, n.y), s.lineTo(o, n.y + n.height), s.stroke();
|
|
62
|
+
} else c.axis.position === "right" && (s.beginPath(), s.moveTo(n.x, n.y), s.lineTo(n.x, n.y + n.height), s.stroke());
|
|
63
|
+
s.restore();
|
|
323
64
|
}
|
|
324
|
-
|
|
325
|
-
textBaseline: "middle",
|
|
326
|
-
textAlign: r.position === "left" ? "right" : "left"
|
|
327
|
-
// ...axis.axisStyle,
|
|
328
|
-
// ...axis.tickLabelStyle,
|
|
329
|
-
});
|
|
330
|
-
for (let c = 0; c < m.length; c++) {
|
|
331
|
-
const p = K(t, m[c], s, "canvas"), y = h[c].split(`
|
|
332
|
-
`);
|
|
333
|
-
for (let x = 0; x < y.length; x++)
|
|
334
|
-
n.fillText(` ${y[x]} `, d, p + x * f);
|
|
335
|
-
}
|
|
336
|
-
n.restore();
|
|
337
|
-
}, gt = (t, s, e, o, i) => {
|
|
338
|
-
const { ctx: n } = t, r = t.scales.find((c) => c.id === s)?.axis;
|
|
339
|
-
if (!r) return;
|
|
340
|
-
const a = window.devicePixelRatio || 1, u = Tt, l = e, d = r.position === "top" ? e - u : e + u, f = bt * a, m = o({ frame: t, scaleId: s }) ?? [], h = i({ frame: t, scaleId: s, ticks: m });
|
|
341
|
-
n.save(), n.fontKerning = "auto", X(n, {}), n.beginPath();
|
|
342
|
-
for (let c = 0; c < m.length; c++) {
|
|
343
|
-
const p = K(t, m[c], s, "canvas");
|
|
344
|
-
n.moveTo(p, l), n.lineTo(p, d);
|
|
345
|
-
}
|
|
346
|
-
n.stroke(), n.restore(), n.save(), X(n, {
|
|
347
|
-
textBaseline: r.position === "top" ? "bottom" : "top",
|
|
348
|
-
textAlign: "center"
|
|
349
|
-
// ...axis.axisStyle,
|
|
350
|
-
// ...axis.tickLabelStyle,
|
|
351
|
-
});
|
|
352
|
-
for (let c = 0; c < m.length; c++) {
|
|
353
|
-
const p = K(t, m[c], s, "canvas"), y = h[c].split(`
|
|
354
|
-
`);
|
|
355
|
-
for (let x = 0; x < y.length; x++)
|
|
356
|
-
n.fillText(y[x], p, d + a * 2 + x * f);
|
|
357
|
-
}
|
|
358
|
-
n.restore();
|
|
359
|
-
}, Qt = ({
|
|
360
|
-
space: t
|
|
361
|
-
} = {}) => ({ frame: s, scaleId: e }) => {
|
|
362
|
-
const { min: o, max: i } = A(s, e), n = [], r = window.devicePixelRatio || 1, a = (t ?? (V(s, e) ? kt : It)) * r, u = Ft(
|
|
363
|
-
s,
|
|
364
|
-
a,
|
|
365
|
-
e,
|
|
366
|
-
"canvas"
|
|
367
|
-
), l = W.find((f) => f > u) ?? 1;
|
|
368
|
-
let d = o % l < Number.EPSILON ? o : o + l - o % l;
|
|
369
|
-
for (; d <= i; )
|
|
370
|
-
n.push(d), d += l;
|
|
371
|
-
return n;
|
|
372
|
-
}, te = ({ ticks: t }) => {
|
|
373
|
-
const s = Math.max(0, Math.ceil(-Math.log10(t[1] - t[0])));
|
|
374
|
-
return t.map((e) => e.toFixed(s));
|
|
375
|
-
}, ee = () => Kt((t, s) => {
|
|
65
|
+
}, It = () => Ut((t, s) => {
|
|
376
66
|
const e = () => {
|
|
377
|
-
const
|
|
378
|
-
if (!
|
|
379
|
-
return
|
|
67
|
+
const c = s()._frame;
|
|
68
|
+
if (!c) throw new Error("No frame set in frame store");
|
|
69
|
+
return c;
|
|
380
70
|
};
|
|
381
71
|
return {
|
|
382
72
|
_frame: null,
|
|
383
73
|
getFrame: e,
|
|
384
74
|
getCtx: () => e().ctx,
|
|
385
|
-
clampXPosToChartArea: (
|
|
386
|
-
clampYPosToChartArea: (
|
|
387
|
-
valToPos: (
|
|
388
|
-
valToPxDistance: (
|
|
75
|
+
clampXPosToChartArea: (c, n) => z(e(), c, n ?? "canvas"),
|
|
76
|
+
clampYPosToChartArea: (c, n) => Y(e(), c, n ?? "canvas"),
|
|
77
|
+
valToPos: (c, n, o) => B(e(), c, n, o ?? "canvas"),
|
|
78
|
+
valToPxDistance: (c, n, o) => ut(
|
|
389
79
|
e(),
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
80
|
+
c,
|
|
81
|
+
n,
|
|
82
|
+
o ?? "canvas"
|
|
393
83
|
),
|
|
394
|
-
valFits: (
|
|
395
|
-
getScale: (
|
|
84
|
+
valFits: (c, n) => rt(e(), c, n),
|
|
85
|
+
getScale: (c) => D(e(), c)
|
|
396
86
|
};
|
|
397
|
-
}),
|
|
398
|
-
const e = lt(
|
|
87
|
+
}), dt = Mt(null), V = (t, s) => {
|
|
88
|
+
const e = lt(dt);
|
|
399
89
|
if (!e)
|
|
400
90
|
throw new Error("useFrame must be used within a CanPlot component");
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
91
|
+
const c = R(t);
|
|
92
|
+
c.current = t, G(() => {
|
|
93
|
+
c.current(e.getState()), e.subscribe((n) => {
|
|
94
|
+
n._frame && c.current(n);
|
|
405
95
|
});
|
|
406
96
|
}, [e, ...s]);
|
|
407
|
-
},
|
|
408
|
-
const s = lt(
|
|
97
|
+
}, ht = (t) => {
|
|
98
|
+
const s = lt(dt);
|
|
409
99
|
if (!s)
|
|
410
100
|
throw new Error("useFrame must be used within a CanPlot component");
|
|
411
|
-
return
|
|
101
|
+
return wt(
|
|
412
102
|
s,
|
|
413
103
|
t ?? ((e) => e.getFrame())
|
|
414
104
|
);
|
|
415
105
|
};
|
|
416
|
-
function
|
|
106
|
+
function Xt(t) {
|
|
417
107
|
return (s) => {
|
|
418
|
-
for (const e of t)
|
|
108
|
+
for (const e of t) it(e, s);
|
|
419
109
|
};
|
|
420
110
|
}
|
|
421
|
-
function
|
|
111
|
+
function Kt(t) {
|
|
422
112
|
return (s) => {
|
|
423
113
|
const e = [];
|
|
424
|
-
for (const
|
|
425
|
-
const
|
|
426
|
-
e.push(
|
|
114
|
+
for (const c of t) {
|
|
115
|
+
const n = it(c, s), o = typeof n == "function";
|
|
116
|
+
e.push(o ? n : () => it(c, null));
|
|
427
117
|
}
|
|
428
118
|
return () => {
|
|
429
|
-
for (const
|
|
119
|
+
for (const c of e) c();
|
|
430
120
|
};
|
|
431
121
|
};
|
|
432
122
|
}
|
|
433
|
-
function
|
|
123
|
+
function it(t, s) {
|
|
434
124
|
if (typeof t == "function")
|
|
435
125
|
return t(s);
|
|
436
126
|
t && (t.current = s);
|
|
437
127
|
}
|
|
438
|
-
var
|
|
439
|
-
const
|
|
440
|
-
const
|
|
441
|
-
|
|
128
|
+
var Ft = parseInt(Pt.split(".")[0], 10) >= 19 ? Kt : Xt;
|
|
129
|
+
const le = At(({ configuration: t, children: s, style: e, className: c }, n) => {
|
|
130
|
+
const o = R(null), i = R(null), a = Yt(i), u = gt(It, []);
|
|
131
|
+
G(() => {
|
|
442
132
|
u.setState({
|
|
443
|
-
_frame:
|
|
133
|
+
_frame: Ot(t, a, o.current)
|
|
444
134
|
});
|
|
445
|
-
}, [t, a,
|
|
446
|
-
d._frame &&
|
|
135
|
+
}, [t, a, o, u]), G(() => u.subscribe((d) => {
|
|
136
|
+
d._frame && $t(d._frame);
|
|
447
137
|
}), [u]);
|
|
448
138
|
const l = window.devicePixelRatio || 1;
|
|
449
139
|
return /* @__PURE__ */ at(
|
|
450
140
|
"div",
|
|
451
141
|
{
|
|
452
|
-
ref:
|
|
453
|
-
className:
|
|
142
|
+
ref: Ft([n, i]),
|
|
143
|
+
className: c,
|
|
454
144
|
style: {
|
|
455
145
|
position: "relative",
|
|
456
146
|
overflow: "hidden",
|
|
@@ -458,10 +148,10 @@ const fe = Lt(({ configuration: t, children: s, style: e, className: o }, i) =>
|
|
|
458
148
|
},
|
|
459
149
|
"data-canplotroot": !0,
|
|
460
150
|
children: [
|
|
461
|
-
/* @__PURE__ */
|
|
151
|
+
/* @__PURE__ */ L(
|
|
462
152
|
"canvas",
|
|
463
153
|
{
|
|
464
|
-
ref:
|
|
154
|
+
ref: o,
|
|
465
155
|
width: a.width * l,
|
|
466
156
|
height: a.height * l,
|
|
467
157
|
style: {
|
|
@@ -472,74 +162,74 @@ const fe = Lt(({ configuration: t, children: s, style: e, className: o }, i) =>
|
|
|
472
162
|
}
|
|
473
163
|
}
|
|
474
164
|
),
|
|
475
|
-
/* @__PURE__ */
|
|
165
|
+
/* @__PURE__ */ L(zt, { frameStore: u, children: s })
|
|
476
166
|
]
|
|
477
167
|
}
|
|
478
168
|
);
|
|
479
|
-
}),
|
|
169
|
+
}), zt = ({ frameStore: t, children: s }) => wt(t, (c) => !!c._frame) ? /* @__PURE__ */ L(dt.Provider, { value: t, children: s }) : null, Yt = (t) => {
|
|
480
170
|
const [s, e] = N({
|
|
481
171
|
width: 0,
|
|
482
172
|
height: 0
|
|
483
|
-
}), [
|
|
484
|
-
for (const
|
|
485
|
-
const
|
|
173
|
+
}), [c] = N(() => new ResizeObserver((n) => {
|
|
174
|
+
for (const o of n) {
|
|
175
|
+
const i = Math.round(o.contentRect.width), a = Math.round(o.contentRect.height);
|
|
486
176
|
e(
|
|
487
|
-
(u) => u.width !==
|
|
177
|
+
(u) => u.width !== i || u.height !== a ? { ...u, width: i, height: a } : u
|
|
488
178
|
);
|
|
489
179
|
}
|
|
490
180
|
}));
|
|
491
|
-
return
|
|
181
|
+
return G(() => {
|
|
492
182
|
if (!t.current) return;
|
|
493
|
-
const
|
|
183
|
+
const n = t.current.clientWidth, o = t.current.clientHeight;
|
|
494
184
|
return e(
|
|
495
|
-
(
|
|
496
|
-
),
|
|
497
|
-
}, [
|
|
498
|
-
},
|
|
499
|
-
const
|
|
500
|
-
if (!
|
|
501
|
-
const
|
|
185
|
+
(i) => i.width !== n || i.height !== o ? { ...i, width: n, height: o } : i
|
|
186
|
+
), c.observe(t.current, { box: "border-box" }), () => c.disconnect();
|
|
187
|
+
}, [c, t]), s;
|
|
188
|
+
}, Ot = (t, s, e) => {
|
|
189
|
+
const c = e?.getContext("2d");
|
|
190
|
+
if (!c) return null;
|
|
191
|
+
const n = window.devicePixelRatio || 1;
|
|
502
192
|
if (s.width === 0 || s.height === 0)
|
|
503
193
|
return null;
|
|
504
|
-
const
|
|
194
|
+
const o = {
|
|
505
195
|
x: t.padding.left,
|
|
506
196
|
y: t.padding.top,
|
|
507
197
|
width: s.width - t.padding.left - t.padding.right,
|
|
508
198
|
height: s.height - t.padding.top - t.padding.bottom
|
|
509
199
|
};
|
|
510
200
|
for (const h of t.scales)
|
|
511
|
-
h.axis && (h.origin === "x" ? (h.axis.position === "bottom" || h.axis.position === "top") && (
|
|
201
|
+
h.axis && (h.origin === "x" ? (h.axis.position === "bottom" || h.axis.position === "top") && (o.height = Math.max(
|
|
512
202
|
0,
|
|
513
|
-
|
|
514
|
-
), h.axis.position === "top" && (
|
|
515
|
-
const
|
|
516
|
-
x:
|
|
517
|
-
y:
|
|
518
|
-
width:
|
|
519
|
-
height:
|
|
203
|
+
o.height - h.axis.size
|
|
204
|
+
), h.axis.position === "top" && (o.y += h.axis.size)) : (h.axis.position === "left" || h.axis.position === "right") && (o.width = Math.max(0, o.width - h.axis.size), h.axis.position === "left" && (o.x += h.axis.size)));
|
|
205
|
+
const i = {
|
|
206
|
+
x: o.x * n,
|
|
207
|
+
y: o.y * n,
|
|
208
|
+
width: o.width * n,
|
|
209
|
+
height: o.height * n
|
|
520
210
|
}, a = [];
|
|
521
|
-
let u = t.padding.left *
|
|
211
|
+
let u = t.padding.left * n, l = c.canvas.width - t.padding.right * n, d = c.canvas.height - t.padding.bottom * n, p = t.padding.top * n;
|
|
522
212
|
for (const h of t.scales) {
|
|
523
213
|
if (!h.axis) {
|
|
524
214
|
a.push({ ...h, axis: null });
|
|
525
215
|
continue;
|
|
526
216
|
}
|
|
527
|
-
let
|
|
217
|
+
let r;
|
|
528
218
|
if (h.origin === "x")
|
|
529
219
|
switch (h.axis.position) {
|
|
530
220
|
case "bottom":
|
|
531
|
-
d -= h.axis.size *
|
|
532
|
-
x:
|
|
533
|
-
y: d /
|
|
534
|
-
width:
|
|
221
|
+
d -= h.axis.size * n, r = {
|
|
222
|
+
x: o.x,
|
|
223
|
+
y: d / n,
|
|
224
|
+
width: o.width,
|
|
535
225
|
height: h.axis.size
|
|
536
226
|
};
|
|
537
227
|
break;
|
|
538
228
|
case "top":
|
|
539
|
-
|
|
540
|
-
x:
|
|
541
|
-
y:
|
|
542
|
-
width:
|
|
229
|
+
p += h.axis.size * n, r = {
|
|
230
|
+
x: o.x,
|
|
231
|
+
y: p / n - h.axis.size,
|
|
232
|
+
width: o.width,
|
|
543
233
|
height: h.axis.size
|
|
544
234
|
};
|
|
545
235
|
break;
|
|
@@ -550,231 +240,231 @@ const fe = Lt(({ configuration: t, children: s, style: e, className: o }, i) =>
|
|
|
550
240
|
else
|
|
551
241
|
switch (h.axis.position) {
|
|
552
242
|
case "left":
|
|
553
|
-
u += h.axis.size *
|
|
554
|
-
x: u /
|
|
555
|
-
y:
|
|
243
|
+
u += h.axis.size * n, r = {
|
|
244
|
+
x: u / n - h.axis.size,
|
|
245
|
+
y: o.y,
|
|
556
246
|
width: h.axis.size,
|
|
557
|
-
height:
|
|
247
|
+
height: o.height
|
|
558
248
|
};
|
|
559
249
|
break;
|
|
560
250
|
case "right":
|
|
561
|
-
l -= h.axis.size *
|
|
562
|
-
x: l /
|
|
563
|
-
y:
|
|
251
|
+
l -= h.axis.size * n, r = {
|
|
252
|
+
x: l / n,
|
|
253
|
+
y: o.y,
|
|
564
254
|
width: h.axis.size,
|
|
565
|
-
height:
|
|
255
|
+
height: o.height
|
|
566
256
|
};
|
|
567
257
|
break;
|
|
568
258
|
case "top":
|
|
569
259
|
case "bottom":
|
|
570
260
|
throw new Error("Invalid axis position for y origin");
|
|
571
261
|
}
|
|
572
|
-
const
|
|
573
|
-
x:
|
|
574
|
-
y:
|
|
575
|
-
width:
|
|
576
|
-
height:
|
|
262
|
+
const m = {
|
|
263
|
+
x: r.x * n,
|
|
264
|
+
y: r.y * n,
|
|
265
|
+
width: r.width * n,
|
|
266
|
+
height: r.height * n
|
|
577
267
|
};
|
|
578
268
|
a.push({
|
|
579
269
|
...h,
|
|
580
270
|
axis: {
|
|
581
271
|
...h.axis,
|
|
582
|
-
cssRect:
|
|
583
|
-
canvasRect:
|
|
272
|
+
cssRect: r,
|
|
273
|
+
canvasRect: m
|
|
584
274
|
}
|
|
585
275
|
});
|
|
586
276
|
}
|
|
587
277
|
return {
|
|
588
|
-
ctx:
|
|
589
|
-
dpr:
|
|
278
|
+
ctx: c,
|
|
279
|
+
dpr: n,
|
|
590
280
|
padding: t.padding,
|
|
591
281
|
scales: a,
|
|
592
|
-
chartAreaCSS:
|
|
593
|
-
chartAreaCanvasPX:
|
|
282
|
+
chartAreaCSS: o,
|
|
283
|
+
chartAreaCanvasPX: i
|
|
594
284
|
};
|
|
595
|
-
},
|
|
596
|
-
t.ctx.clearRect(0, 0, t.ctx.canvas.width, t.ctx.canvas.height),
|
|
597
|
-
},
|
|
598
|
-
({ getCtx:
|
|
599
|
-
const u =
|
|
600
|
-
u.save(), u.beginPath(),
|
|
285
|
+
}, $t = (t) => {
|
|
286
|
+
t.ctx.clearRect(0, 0, t.ctx.canvas.width, t.ctx.canvas.height), Dt(t);
|
|
287
|
+
}, ue = ({ data: t, xScaleId: s, yScaleId: e, style: c }) => (V(
|
|
288
|
+
({ getCtx: n, clampXPosToChartArea: o, clampYPosToChartArea: i, valToPos: a }) => {
|
|
289
|
+
const u = n();
|
|
290
|
+
u.save(), u.beginPath(), O(u, c);
|
|
601
291
|
for (const l of t) {
|
|
602
|
-
const d =
|
|
603
|
-
u.lineTo(d,
|
|
292
|
+
const d = o(a(l.x, s)), p = i(a(l.y, e));
|
|
293
|
+
u.lineTo(d, p);
|
|
604
294
|
}
|
|
605
295
|
u.stroke(), u.restore();
|
|
606
296
|
},
|
|
607
|
-
[t, s, e,
|
|
608
|
-
), null),
|
|
609
|
-
const u =
|
|
610
|
-
u.save(), u.beginPath(),
|
|
297
|
+
[t, s, e, c]
|
|
298
|
+
), null), de = ({ data: t, xScaleId: s, yScaleId: e, radius: c = 5, style: n }) => (V(({ getCtx: o, valToPos: i, valFits: a }) => {
|
|
299
|
+
const u = o();
|
|
300
|
+
u.save(), u.beginPath(), O(u, n);
|
|
611
301
|
for (const l of t) {
|
|
612
302
|
if (!a(l.x, s) || !a(l.y, e))
|
|
613
303
|
continue;
|
|
614
|
-
const d =
|
|
615
|
-
u.moveTo(d +
|
|
304
|
+
const d = i(l.x, s), p = i(l.y, e);
|
|
305
|
+
u.moveTo(d + c, p), u.arc(d, p, c, 0, Math.PI * 2);
|
|
616
306
|
}
|
|
617
307
|
u.stroke(), u.fill(), u.restore();
|
|
618
|
-
}, [t, s, e,
|
|
308
|
+
}, [t, s, e, c, n]), null), he = ({
|
|
619
309
|
data: t,
|
|
620
310
|
xScaleId: s,
|
|
621
311
|
yScaleId: e,
|
|
622
|
-
style:
|
|
623
|
-
barWidth:
|
|
624
|
-
xPositionOffset:
|
|
625
|
-
radius:
|
|
626
|
-
}) => (
|
|
312
|
+
style: c,
|
|
313
|
+
barWidth: n,
|
|
314
|
+
xPositionOffset: o,
|
|
315
|
+
radius: i
|
|
316
|
+
}) => (V(
|
|
627
317
|
({
|
|
628
318
|
getCtx: a,
|
|
629
319
|
valToPxDistance: u,
|
|
630
320
|
valToPos: l,
|
|
631
321
|
clampXPosToChartArea: d,
|
|
632
|
-
clampYPosToChartArea:
|
|
322
|
+
clampYPosToChartArea: p
|
|
633
323
|
}) => {
|
|
634
324
|
if (t.length === 0) return;
|
|
635
|
-
const
|
|
636
|
-
|
|
637
|
-
const h = u(
|
|
638
|
-
|
|
639
|
-
for (const
|
|
640
|
-
const y = l(
|
|
641
|
-
|
|
325
|
+
const f = a();
|
|
326
|
+
f.save(), O(f, c);
|
|
327
|
+
const h = u(n, s);
|
|
328
|
+
f.beginPath();
|
|
329
|
+
for (const r of t) {
|
|
330
|
+
const y = l(r.x, s) - h / 2 + o * h, x = p(l(0, e)), g = p(l(r.y, e)), S = x - g, w = d(y), k = d(y + h) - w;
|
|
331
|
+
i ? f.roundRect(
|
|
332
|
+
w,
|
|
642
333
|
g,
|
|
643
|
-
C,
|
|
644
334
|
k,
|
|
645
335
|
S,
|
|
646
|
-
|
|
647
|
-
) :
|
|
336
|
+
i
|
|
337
|
+
) : f.rect(w, g, k, S);
|
|
648
338
|
}
|
|
649
|
-
|
|
339
|
+
f.closePath(), f.fill(), c?.strokeStyle && f.stroke(), f.restore();
|
|
650
340
|
},
|
|
651
|
-
[t, s, e,
|
|
652
|
-
), null),
|
|
341
|
+
[t, s, e, c, n, o, i]
|
|
342
|
+
), null), me = ({ data: t, xScaleId: s, yScaleId: e, style: c }) => (V(({ getCtx: n, clampXPosToChartArea: o, clampYPosToChartArea: i, valToPos: a }) => {
|
|
653
343
|
const u = [];
|
|
654
344
|
for (const d of t) {
|
|
655
|
-
const
|
|
656
|
-
u.push({ x:
|
|
345
|
+
const p = o(a(d.x, s)), f = i(a(d.y[0], e)), h = i(a(d.y[1], e));
|
|
346
|
+
u.push({ x: p, y: f }), u.unshift({ x: p, y: h });
|
|
657
347
|
}
|
|
658
|
-
const l =
|
|
348
|
+
const l = n();
|
|
659
349
|
if (u.length > 0) {
|
|
660
|
-
l.save(), l.beginPath(),
|
|
350
|
+
l.save(), l.beginPath(), O(l, c), l.moveTo(u[0].x, u[0].y);
|
|
661
351
|
for (const d of u)
|
|
662
352
|
l.lineTo(d.x, d.y);
|
|
663
353
|
l.closePath(), l.fill(), l.restore();
|
|
664
354
|
}
|
|
665
|
-
}, [t, s, e,
|
|
666
|
-
({ getCtx:
|
|
667
|
-
const l = [], d =
|
|
668
|
-
for (const
|
|
669
|
-
const
|
|
670
|
-
l.push({ x:
|
|
355
|
+
}, [t, s, e, c]), null), fe = ({ data: t, stroked: s, xScaleId: e, yScaleId: c, style: n }) => (V(
|
|
356
|
+
({ getCtx: o, clampXPosToChartArea: i, clampYPosToChartArea: a, valToPos: u }) => {
|
|
357
|
+
const l = [], d = o();
|
|
358
|
+
for (const r of t) {
|
|
359
|
+
const m = i(u(r.x, e)), y = a(u(r.y, c));
|
|
360
|
+
l.push({ x: m, y });
|
|
671
361
|
}
|
|
672
|
-
const
|
|
673
|
-
if (!
|
|
362
|
+
const p = l.at(0), f = l.at(-1);
|
|
363
|
+
if (!p || !f)
|
|
674
364
|
return;
|
|
675
|
-
const h = a(u(0,
|
|
676
|
-
d.save(), d.beginPath(),
|
|
677
|
-
for (const
|
|
678
|
-
d.lineTo(
|
|
679
|
-
if (d.lineTo(
|
|
680
|
-
d.beginPath(), d.moveTo(
|
|
681
|
-
for (const
|
|
682
|
-
d.lineTo(
|
|
365
|
+
const h = a(u(0, c));
|
|
366
|
+
d.save(), d.beginPath(), O(d, n), d.moveTo(p.x, h);
|
|
367
|
+
for (const r of l)
|
|
368
|
+
d.lineTo(r.x, r.y);
|
|
369
|
+
if (d.lineTo(f.x, h), d.closePath(), d.fill(), s) {
|
|
370
|
+
d.beginPath(), d.moveTo(p.x, p.y);
|
|
371
|
+
for (const r of l)
|
|
372
|
+
d.lineTo(r.x, r.y);
|
|
683
373
|
d.stroke();
|
|
684
374
|
}
|
|
685
375
|
d.restore();
|
|
686
376
|
},
|
|
687
|
-
[t, s, e,
|
|
688
|
-
), null),
|
|
377
|
+
[t, s, e, c, n]
|
|
378
|
+
), null), pe = (t, s) => ht(
|
|
689
379
|
({
|
|
690
380
|
clampXPosToChartArea: e,
|
|
691
|
-
clampYPosToChartArea:
|
|
692
|
-
getScale:
|
|
693
|
-
valToPos:
|
|
694
|
-
valFits:
|
|
381
|
+
clampYPosToChartArea: c,
|
|
382
|
+
getScale: n,
|
|
383
|
+
valToPos: o,
|
|
384
|
+
valFits: i
|
|
695
385
|
}) => {
|
|
696
386
|
const a = {};
|
|
697
387
|
for (const u in t) {
|
|
698
388
|
const l = t[u];
|
|
699
389
|
switch (l.exceeding) {
|
|
700
390
|
case "discard": {
|
|
701
|
-
if (
|
|
702
|
-
const d =
|
|
391
|
+
if (i(l.value, l.scaleId)) {
|
|
392
|
+
const d = o(l.value, l.scaleId, s);
|
|
703
393
|
a[u] = d;
|
|
704
394
|
}
|
|
705
395
|
break;
|
|
706
396
|
}
|
|
707
397
|
case "clamp": {
|
|
708
|
-
const d =
|
|
709
|
-
a[u] =
|
|
398
|
+
const d = o(l.value, l.scaleId, s);
|
|
399
|
+
a[u] = n(l.scaleId)?.origin === "x" ? e(d, s) : c(d, s);
|
|
710
400
|
break;
|
|
711
401
|
}
|
|
712
402
|
}
|
|
713
403
|
}
|
|
714
404
|
return a;
|
|
715
405
|
}
|
|
716
|
-
),
|
|
406
|
+
), b = () => {
|
|
717
407
|
const t = [];
|
|
718
408
|
return {
|
|
719
409
|
addEventListener: (s, e) => (t.push({
|
|
720
410
|
syncKey: s,
|
|
721
411
|
callback: e
|
|
722
412
|
}), () => {
|
|
723
|
-
const
|
|
724
|
-
|
|
413
|
+
const c = t.findIndex((n) => n.callback === e);
|
|
414
|
+
c !== -1 && t.splice(c, 1);
|
|
725
415
|
}),
|
|
726
416
|
dispatchEvent: (s, e) => {
|
|
727
|
-
for (const
|
|
728
|
-
|
|
417
|
+
for (const c of t)
|
|
418
|
+
c.syncKey === s && c.callback(s, e);
|
|
729
419
|
}
|
|
730
420
|
};
|
|
731
|
-
},
|
|
732
|
-
dblclick:
|
|
733
|
-
click:
|
|
734
|
-
move:
|
|
735
|
-
mousedown:
|
|
736
|
-
mouseup:
|
|
737
|
-
spanselect:
|
|
738
|
-
documentmouseup:
|
|
739
|
-
pressandwheel:
|
|
740
|
-
sync_dblclick:
|
|
741
|
-
sync_click:
|
|
742
|
-
sync_move:
|
|
743
|
-
sync_mousedown:
|
|
744
|
-
sync_mouseup:
|
|
745
|
-
sync_spanselect:
|
|
746
|
-
sync_pressandwheel:
|
|
747
|
-
},
|
|
748
|
-
const
|
|
749
|
-
|
|
421
|
+
}, v = {
|
|
422
|
+
dblclick: b(),
|
|
423
|
+
click: b(),
|
|
424
|
+
move: b(),
|
|
425
|
+
mousedown: b(),
|
|
426
|
+
mouseup: b(),
|
|
427
|
+
spanselect: b(),
|
|
428
|
+
documentmouseup: b(),
|
|
429
|
+
pressandwheel: b(),
|
|
430
|
+
sync_dblclick: b(),
|
|
431
|
+
sync_click: b(),
|
|
432
|
+
sync_move: b(),
|
|
433
|
+
sync_mousedown: b(),
|
|
434
|
+
sync_mouseup: b(),
|
|
435
|
+
sync_spanselect: b(),
|
|
436
|
+
sync_pressandwheel: b()
|
|
437
|
+
}, T = (t, s, e) => {
|
|
438
|
+
const c = Z.useRef(e);
|
|
439
|
+
c.current = e, Z.useEffect(() => v[t].addEventListener(
|
|
750
440
|
s,
|
|
751
|
-
(
|
|
752
|
-
|
|
441
|
+
(o, i) => {
|
|
442
|
+
c.current(i, o);
|
|
753
443
|
}
|
|
754
|
-
), [s, t,
|
|
755
|
-
}, mt =
|
|
756
|
-
const e =
|
|
757
|
-
return
|
|
758
|
-
},
|
|
444
|
+
), [s, t, c]);
|
|
445
|
+
}, mt = Z.createContext(""), ft = (t, s) => {
|
|
446
|
+
const e = Z.useContext(mt);
|
|
447
|
+
return T(t, e, s);
|
|
448
|
+
}, Nt = (t, s, e, c, n) => {
|
|
759
449
|
if (!s) return;
|
|
760
|
-
const
|
|
761
|
-
if (!
|
|
450
|
+
const o = c ?? e.scales.find((p) => p.origin === "x")?.id, i = n ?? e.scales.find((p) => p.origin === "y")?.id;
|
|
451
|
+
if (!o || !i)
|
|
762
452
|
return;
|
|
763
453
|
const a = t.clientX - s.left, u = {
|
|
764
|
-
scaleId:
|
|
765
|
-
value:
|
|
454
|
+
scaleId: o,
|
|
455
|
+
value: U(e, a, o, "css")
|
|
766
456
|
}, l = t.clientY - s.top, d = {
|
|
767
|
-
scaleId:
|
|
768
|
-
value:
|
|
457
|
+
scaleId: i,
|
|
458
|
+
value: U(e, l, i, "css")
|
|
769
459
|
};
|
|
770
460
|
return { pointerSyncPosition: { x: u, y: d }, cssX: a, cssY: l };
|
|
771
|
-
},
|
|
772
|
-
const e = t.x ?
|
|
461
|
+
}, F = (t, s) => {
|
|
462
|
+
const e = t.x ? B(
|
|
773
463
|
s,
|
|
774
464
|
t.x.value,
|
|
775
465
|
t.x.scaleId,
|
|
776
466
|
"css"
|
|
777
|
-
) : 0,
|
|
467
|
+
) : 0, c = t.y ? B(
|
|
778
468
|
s,
|
|
779
469
|
t.y.value,
|
|
780
470
|
t.y.scaleId,
|
|
@@ -782,46 +472,46 @@ const fe = Lt(({ configuration: t, children: s, style: e, className: o }, i) =>
|
|
|
782
472
|
) : 0;
|
|
783
473
|
return {
|
|
784
474
|
cssX: e,
|
|
785
|
-
cssY:
|
|
475
|
+
cssY: c,
|
|
786
476
|
scaled: Object.fromEntries(
|
|
787
|
-
s.scales.map((
|
|
788
|
-
const
|
|
789
|
-
return [
|
|
477
|
+
s.scales.map((n) => {
|
|
478
|
+
const o = n.origin === "y" ? c : e;
|
|
479
|
+
return [n.id, U(s, o, n.id, "css")];
|
|
790
480
|
})
|
|
791
481
|
)
|
|
792
482
|
};
|
|
793
|
-
},
|
|
483
|
+
}, xt = (t, s, e) => {
|
|
794
484
|
if (!s) {
|
|
795
|
-
const
|
|
485
|
+
const i = t === "x" ? e.chartAreaCSS.x : e.chartAreaCSS.y, a = t === "x" ? e.chartAreaCSS.x + e.chartAreaCSS.width : e.chartAreaCSS.y + e.chartAreaCSS.height;
|
|
796
486
|
return {
|
|
797
|
-
fromCSS:
|
|
487
|
+
fromCSS: i,
|
|
798
488
|
toCSS: a,
|
|
799
489
|
scaled: e.scales.flatMap((u) => {
|
|
800
490
|
if (u.origin !== t)
|
|
801
491
|
return [];
|
|
802
|
-
const { min: l, max: d } =
|
|
492
|
+
const { min: l, max: d } = D(e, u.id);
|
|
803
493
|
return [{ scaleId: u.id, from: l, to: d }];
|
|
804
494
|
})
|
|
805
495
|
};
|
|
806
496
|
}
|
|
807
|
-
const
|
|
497
|
+
const c = B(
|
|
808
498
|
e,
|
|
809
499
|
s.from,
|
|
810
500
|
s.scaleId,
|
|
811
501
|
"css"
|
|
812
|
-
),
|
|
502
|
+
), n = B(
|
|
813
503
|
e,
|
|
814
504
|
s.to,
|
|
815
505
|
s.scaleId,
|
|
816
506
|
"css"
|
|
817
|
-
),
|
|
818
|
-
(
|
|
819
|
-
if (
|
|
507
|
+
), o = e.scales.flatMap(
|
|
508
|
+
(i) => {
|
|
509
|
+
if (i.origin !== t)
|
|
820
510
|
return [];
|
|
821
|
-
const a =
|
|
511
|
+
const a = U(e, c, i.id, "css"), u = U(e, n, i.id, "css");
|
|
822
512
|
return [
|
|
823
513
|
{
|
|
824
|
-
scaleId:
|
|
514
|
+
scaleId: i.id,
|
|
825
515
|
from: a,
|
|
826
516
|
to: u
|
|
827
517
|
}
|
|
@@ -829,89 +519,89 @@ const fe = Lt(({ configuration: t, children: s, style: e, className: o }, i) =>
|
|
|
829
519
|
}
|
|
830
520
|
);
|
|
831
521
|
return {
|
|
832
|
-
fromCSS:
|
|
833
|
-
toCSS:
|
|
834
|
-
scaled:
|
|
522
|
+
fromCSS: c,
|
|
523
|
+
toCSS: n,
|
|
524
|
+
scaled: o
|
|
835
525
|
};
|
|
836
|
-
},
|
|
526
|
+
}, ye = ({
|
|
837
527
|
id: t,
|
|
838
528
|
onClick: s,
|
|
839
529
|
onDblClick: e,
|
|
840
|
-
onMouseMove:
|
|
841
|
-
onMouseDown:
|
|
842
|
-
onMouseUp:
|
|
843
|
-
onDocumentMouseUp:
|
|
530
|
+
onMouseMove: c,
|
|
531
|
+
onMouseDown: n,
|
|
532
|
+
onMouseUp: o,
|
|
533
|
+
onDocumentMouseUp: i,
|
|
844
534
|
onSpanSelect: a,
|
|
845
535
|
className: u,
|
|
846
536
|
style: l,
|
|
847
537
|
sync: d,
|
|
848
|
-
children:
|
|
538
|
+
children: p
|
|
849
539
|
}) => {
|
|
850
|
-
const
|
|
851
|
-
return
|
|
852
|
-
e?.(
|
|
853
|
-
}),
|
|
854
|
-
s?.(
|
|
855
|
-
}),
|
|
856
|
-
|
|
857
|
-
}),
|
|
858
|
-
|
|
859
|
-
}),
|
|
860
|
-
|
|
861
|
-
}),
|
|
862
|
-
|
|
863
|
-
}),
|
|
864
|
-
a?.(
|
|
865
|
-
}), /* @__PURE__ */ at(mt, { value: h, children: [
|
|
866
|
-
/* @__PURE__ */
|
|
867
|
-
|
|
540
|
+
const f = _t(), h = t || f;
|
|
541
|
+
return T("dblclick", h, (r) => {
|
|
542
|
+
e?.(r);
|
|
543
|
+
}), T("click", h, (r) => {
|
|
544
|
+
s?.(r);
|
|
545
|
+
}), T("move", h, (r) => {
|
|
546
|
+
c?.(r);
|
|
547
|
+
}), T("mousedown", h, (r) => {
|
|
548
|
+
n?.(r);
|
|
549
|
+
}), T("mouseup", h, (r) => {
|
|
550
|
+
o?.(r);
|
|
551
|
+
}), T("documentmouseup", h, (r) => {
|
|
552
|
+
i?.(r);
|
|
553
|
+
}), T("spanselect", h, (r) => {
|
|
554
|
+
a?.(r);
|
|
555
|
+
}), /* @__PURE__ */ at(mt.Provider, { value: h, children: [
|
|
556
|
+
/* @__PURE__ */ L(
|
|
557
|
+
Bt,
|
|
868
558
|
{
|
|
869
559
|
className: u,
|
|
870
560
|
style: l,
|
|
871
561
|
sync: d
|
|
872
562
|
}
|
|
873
563
|
),
|
|
874
|
-
|
|
564
|
+
p
|
|
875
565
|
] });
|
|
876
|
-
},
|
|
877
|
-
const
|
|
878
|
-
|
|
879
|
-
const
|
|
880
|
-
const
|
|
881
|
-
if (
|
|
882
|
-
if (
|
|
566
|
+
}, Bt = ({ className: t, style: s, sync: e }) => {
|
|
567
|
+
const c = R(null), n = ht(), o = R(n);
|
|
568
|
+
o.current = n;
|
|
569
|
+
const i = lt(mt), a = e?.key || i, u = R(null), l = R(null), d = R(null), p = () => {
|
|
570
|
+
const r = c.current?.parentElement;
|
|
571
|
+
if (r) {
|
|
572
|
+
if (r.dataset.canplotroot === void 0)
|
|
883
573
|
throw new Error(
|
|
884
574
|
"ChartAreaInteractions must be used within a CanPlot component"
|
|
885
575
|
);
|
|
886
|
-
return
|
|
576
|
+
return r.getBoundingClientRect();
|
|
887
577
|
}
|
|
888
|
-
},
|
|
889
|
-
const y =
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
578
|
+
}, f = (r, m) => {
|
|
579
|
+
const y = Nt(
|
|
580
|
+
r,
|
|
581
|
+
p(),
|
|
582
|
+
o.current,
|
|
893
583
|
e?.xViaScaleId,
|
|
894
584
|
e?.yViaScaleId
|
|
895
585
|
);
|
|
896
|
-
y &&
|
|
586
|
+
y && m(
|
|
897
587
|
y.pointerSyncPosition,
|
|
898
588
|
{ cssX: y.cssX, cssY: y.cssY },
|
|
899
589
|
{
|
|
900
|
-
ctrlKey:
|
|
901
|
-
altKey:
|
|
902
|
-
shiftKey:
|
|
903
|
-
metaKey:
|
|
590
|
+
ctrlKey: r.ctrlKey,
|
|
591
|
+
altKey: r.altKey,
|
|
592
|
+
shiftKey: r.shiftKey,
|
|
593
|
+
metaKey: r.metaKey
|
|
904
594
|
}
|
|
905
595
|
);
|
|
906
|
-
}, h =
|
|
907
|
-
return h.current =
|
|
908
|
-
const
|
|
909
|
-
const
|
|
910
|
-
|
|
911
|
-
...
|
|
596
|
+
}, h = R(f);
|
|
597
|
+
return h.current = f, Rt(() => {
|
|
598
|
+
const r = (S) => {
|
|
599
|
+
const w = l.current;
|
|
600
|
+
w && v.sync_spanselect.dispatchEvent(a, {
|
|
601
|
+
...w,
|
|
912
602
|
completed: !0
|
|
913
|
-
}),
|
|
914
|
-
frame:
|
|
603
|
+
}), v.documentmouseup.dispatchEvent(a, {
|
|
604
|
+
frame: o.current,
|
|
915
605
|
keys: {
|
|
916
606
|
ctrlKey: S.ctrlKey,
|
|
917
607
|
altKey: S.altKey,
|
|
@@ -919,26 +609,26 @@ const fe = Lt(({ configuration: t, children: s, style: e, className: o }, i) =>
|
|
|
919
609
|
metaKey: S.metaKey
|
|
920
610
|
}
|
|
921
611
|
});
|
|
922
|
-
},
|
|
923
|
-
const
|
|
612
|
+
}, m = (S) => {
|
|
613
|
+
const w = {
|
|
924
614
|
ctrlKey: S.ctrlKey,
|
|
925
615
|
altKey: S.altKey,
|
|
926
616
|
shiftKey: S.shiftKey,
|
|
927
617
|
metaKey: S.metaKey
|
|
928
618
|
}, k = d.current;
|
|
929
|
-
if (k && Object.entries(
|
|
619
|
+
if (k && Object.entries(w).some(
|
|
930
620
|
([E, M]) => k.keys[E] !== M
|
|
931
621
|
)) {
|
|
932
|
-
const E = { ...k, keys:
|
|
933
|
-
d.current = E,
|
|
622
|
+
const E = { ...k, keys: w };
|
|
623
|
+
d.current = E, v.sync_move.dispatchEvent(a, E);
|
|
934
624
|
}
|
|
935
|
-
const
|
|
936
|
-
if (
|
|
937
|
-
([E, M]) =>
|
|
625
|
+
const C = l.current;
|
|
626
|
+
if (C && Object.entries(w).some(
|
|
627
|
+
([E, M]) => C.keys[E] !== M
|
|
938
628
|
)) {
|
|
939
629
|
S.stopPropagation(), S.preventDefault();
|
|
940
|
-
const E = { ...
|
|
941
|
-
l.current = E,
|
|
630
|
+
const E = { ...C, keys: w };
|
|
631
|
+
l.current = E, v.sync_spanselect.dispatchEvent(
|
|
942
632
|
a,
|
|
943
633
|
E
|
|
944
634
|
);
|
|
@@ -946,66 +636,66 @@ const fe = Lt(({ configuration: t, children: s, style: e, className: o }, i) =>
|
|
|
946
636
|
}, y = (S) => {
|
|
947
637
|
h.current(
|
|
948
638
|
S,
|
|
949
|
-
(
|
|
639
|
+
(w, { cssX: k, cssY: C }, E) => {
|
|
950
640
|
const M = u.current;
|
|
951
|
-
if (!M || !
|
|
952
|
-
const
|
|
641
|
+
if (!M || !w.x || !w.y) return;
|
|
642
|
+
const A = o.current, P = M.xRangeCss.start, $ = k, K = M.yRangeCss.start, et = C, st = D(A, w.x.scaleId), nt = D(A, w.y.scaleId);
|
|
953
643
|
u.current = {
|
|
954
|
-
xRangeCss: { start: P, end:
|
|
955
|
-
yRangeCss: { start:
|
|
644
|
+
xRangeCss: { start: P, end: $ },
|
|
645
|
+
yRangeCss: { start: K, end: et }
|
|
956
646
|
};
|
|
957
|
-
let
|
|
958
|
-
const ot = Math.abs(
|
|
959
|
-
ot < 10 &&
|
|
960
|
-
const
|
|
647
|
+
let _ = "none";
|
|
648
|
+
const ot = Math.abs(K - et), ct = Math.abs(P - $);
|
|
649
|
+
ot < 10 && ct < 10 ? _ = "none" : ot > 30 && ct > 30 ? _ = "box" : ot > ct ? _ = "y" : _ = "x";
|
|
650
|
+
const Tt = _ === "x" || _ === "box" ? {
|
|
961
651
|
scaleId: st.id,
|
|
962
|
-
from:
|
|
963
|
-
|
|
964
|
-
|
|
652
|
+
from: U(
|
|
653
|
+
A,
|
|
654
|
+
z(o.current, P, "css"),
|
|
965
655
|
st.id,
|
|
966
656
|
"css"
|
|
967
657
|
),
|
|
968
|
-
to:
|
|
969
|
-
|
|
970
|
-
|
|
658
|
+
to: U(
|
|
659
|
+
A,
|
|
660
|
+
z(o.current, $, "css"),
|
|
971
661
|
st.id,
|
|
972
662
|
"css"
|
|
973
663
|
)
|
|
974
|
-
} : void 0,
|
|
664
|
+
} : void 0, kt = _ === "y" || _ === "box" ? {
|
|
975
665
|
scaleId: nt.id,
|
|
976
|
-
from:
|
|
977
|
-
|
|
978
|
-
|
|
666
|
+
from: U(
|
|
667
|
+
A,
|
|
668
|
+
Y(o.current, K, "css"),
|
|
979
669
|
nt.id,
|
|
980
670
|
"css"
|
|
981
671
|
),
|
|
982
|
-
to:
|
|
983
|
-
|
|
984
|
-
|
|
672
|
+
to: U(
|
|
673
|
+
A,
|
|
674
|
+
Y(o.current, et, "css"),
|
|
985
675
|
nt.id,
|
|
986
676
|
"css"
|
|
987
677
|
)
|
|
988
678
|
} : void 0, yt = {
|
|
989
|
-
mode:
|
|
990
|
-
xRange:
|
|
991
|
-
yRange:
|
|
679
|
+
mode: _,
|
|
680
|
+
xRange: Tt,
|
|
681
|
+
yRange: kt,
|
|
992
682
|
completed: !1,
|
|
993
683
|
keys: E
|
|
994
684
|
};
|
|
995
|
-
l.current = yt,
|
|
685
|
+
l.current = yt, v.sync_spanselect.dispatchEvent(
|
|
996
686
|
a,
|
|
997
687
|
yt
|
|
998
688
|
);
|
|
999
689
|
}
|
|
1000
690
|
);
|
|
1001
691
|
}, x = (S) => {
|
|
1002
|
-
h.current(S, (
|
|
1003
|
-
if (Object.values(
|
|
692
|
+
h.current(S, (w, k, C) => {
|
|
693
|
+
if (Object.values(C).some((M) => M)) {
|
|
1004
694
|
S.preventDefault();
|
|
1005
695
|
const M = Math.abs(S.deltaY) > Math.abs(S.deltaX) ? S.deltaY : S.deltaX;
|
|
1006
|
-
|
|
1007
|
-
positions:
|
|
1008
|
-
keys:
|
|
696
|
+
v.sync_pressandwheel.dispatchEvent(a, {
|
|
697
|
+
positions: w,
|
|
698
|
+
keys: C,
|
|
1009
699
|
deltaX: S.deltaX,
|
|
1010
700
|
deltaY: S.deltaY,
|
|
1011
701
|
deltaAbs: M
|
|
@@ -1013,292 +703,292 @@ const fe = Lt(({ configuration: t, children: s, style: e, className: o }, i) =>
|
|
|
1013
703
|
}
|
|
1014
704
|
});
|
|
1015
705
|
};
|
|
1016
|
-
document.addEventListener("mouseup",
|
|
1017
|
-
const
|
|
1018
|
-
return
|
|
706
|
+
document.addEventListener("mouseup", r), document.addEventListener("keydown", m), document.addEventListener("keyup", m), document.addEventListener("mousemove", y);
|
|
707
|
+
const g = c.current;
|
|
708
|
+
return g?.addEventListener("wheel", x, {
|
|
1019
709
|
passive: !1
|
|
1020
710
|
}), () => {
|
|
1021
|
-
document.removeEventListener("mouseup",
|
|
711
|
+
document.removeEventListener("mouseup", r), document.removeEventListener("keydown", m), document.removeEventListener("keyup", m), document.removeEventListener("mousemove", y), g?.removeEventListener("wheel", x);
|
|
1022
712
|
};
|
|
1023
|
-
}, [
|
|
1024
|
-
const
|
|
1025
|
-
|
|
1026
|
-
|
|
713
|
+
}, [o, a, h]), T("sync_dblclick", a, (r) => {
|
|
714
|
+
const m = F(
|
|
715
|
+
r.positions,
|
|
716
|
+
o.current
|
|
1027
717
|
);
|
|
1028
|
-
|
|
1029
|
-
frame:
|
|
1030
|
-
pointer:
|
|
1031
|
-
keys:
|
|
718
|
+
m && v.dblclick.dispatchEvent(i, {
|
|
719
|
+
frame: o.current,
|
|
720
|
+
pointer: m,
|
|
721
|
+
keys: r.keys
|
|
1032
722
|
});
|
|
1033
|
-
}),
|
|
1034
|
-
const
|
|
1035
|
-
|
|
1036
|
-
|
|
723
|
+
}), T("sync_click", a, (r) => {
|
|
724
|
+
const m = F(
|
|
725
|
+
r.positions,
|
|
726
|
+
o.current
|
|
1037
727
|
);
|
|
1038
|
-
|
|
1039
|
-
frame:
|
|
1040
|
-
pointer:
|
|
1041
|
-
keys:
|
|
728
|
+
m && v.click.dispatchEvent(i, {
|
|
729
|
+
frame: o.current,
|
|
730
|
+
pointer: m,
|
|
731
|
+
keys: r.keys
|
|
1042
732
|
});
|
|
1043
|
-
}),
|
|
1044
|
-
const
|
|
1045
|
-
|
|
1046
|
-
|
|
733
|
+
}), T("sync_move", a, (r) => {
|
|
734
|
+
const m = r.positions ? F(
|
|
735
|
+
r.positions,
|
|
736
|
+
o.current
|
|
1047
737
|
) : null;
|
|
1048
|
-
d.current =
|
|
1049
|
-
frame:
|
|
1050
|
-
pointer:
|
|
1051
|
-
keys:
|
|
738
|
+
d.current = r, v.move.dispatchEvent(i, {
|
|
739
|
+
frame: o.current,
|
|
740
|
+
pointer: m ?? null,
|
|
741
|
+
keys: r.keys
|
|
1052
742
|
});
|
|
1053
|
-
}),
|
|
1054
|
-
const
|
|
1055
|
-
|
|
1056
|
-
|
|
743
|
+
}), T("sync_mousedown", a, (r) => {
|
|
744
|
+
const m = F(
|
|
745
|
+
r.positions,
|
|
746
|
+
o.current
|
|
1057
747
|
);
|
|
1058
|
-
|
|
1059
|
-
frame:
|
|
1060
|
-
pointer:
|
|
1061
|
-
keys:
|
|
748
|
+
m && v.mousedown.dispatchEvent(i, {
|
|
749
|
+
frame: o.current,
|
|
750
|
+
pointer: m,
|
|
751
|
+
keys: r.keys
|
|
1062
752
|
});
|
|
1063
|
-
}),
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1066
|
-
|
|
753
|
+
}), T("sync_mouseup", a, (r) => {
|
|
754
|
+
const m = F(
|
|
755
|
+
r.positions,
|
|
756
|
+
o.current
|
|
1067
757
|
);
|
|
1068
|
-
|
|
1069
|
-
frame:
|
|
1070
|
-
pointer:
|
|
1071
|
-
keys:
|
|
758
|
+
m && v.mouseup.dispatchEvent(i, {
|
|
759
|
+
frame: o.current,
|
|
760
|
+
pointer: m,
|
|
761
|
+
keys: r.keys
|
|
1072
762
|
});
|
|
1073
|
-
}),
|
|
763
|
+
}), T(
|
|
1074
764
|
"sync_pressandwheel",
|
|
1075
765
|
a,
|
|
1076
|
-
(
|
|
1077
|
-
const
|
|
1078
|
-
|
|
1079
|
-
|
|
766
|
+
(r) => {
|
|
767
|
+
const m = F(
|
|
768
|
+
r.positions,
|
|
769
|
+
o.current
|
|
1080
770
|
);
|
|
1081
|
-
|
|
1082
|
-
frame:
|
|
1083
|
-
pointer:
|
|
1084
|
-
keys:
|
|
1085
|
-
deltaX:
|
|
1086
|
-
deltaY:
|
|
1087
|
-
deltaAbs:
|
|
771
|
+
m && v.pressandwheel.dispatchEvent(i, {
|
|
772
|
+
frame: o.current,
|
|
773
|
+
pointer: m,
|
|
774
|
+
keys: r.keys,
|
|
775
|
+
deltaX: r.deltaX,
|
|
776
|
+
deltaY: r.deltaY,
|
|
777
|
+
deltaAbs: r.deltaAbs
|
|
1088
778
|
});
|
|
1089
779
|
}
|
|
1090
|
-
),
|
|
1091
|
-
const
|
|
780
|
+
), T("sync_spanselect", a, (r) => {
|
|
781
|
+
const m = xt(
|
|
1092
782
|
"x",
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
), y =
|
|
783
|
+
r.xRange,
|
|
784
|
+
o.current
|
|
785
|
+
), y = xt(
|
|
1096
786
|
"y",
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
), x =
|
|
1100
|
-
|
|
1101
|
-
mode:
|
|
1102
|
-
frame:
|
|
787
|
+
r.yRange,
|
|
788
|
+
o.current
|
|
789
|
+
), x = m.scaled, g = y.scaled;
|
|
790
|
+
r.completed && (u.current = null), v.spanselect.dispatchEvent(i, {
|
|
791
|
+
mode: r.mode,
|
|
792
|
+
frame: o.current,
|
|
1103
793
|
xRanges: x,
|
|
1104
|
-
yRanges:
|
|
1105
|
-
completed:
|
|
1106
|
-
x: { fromCSS:
|
|
794
|
+
yRanges: g,
|
|
795
|
+
completed: r.completed,
|
|
796
|
+
x: { fromCSS: m.fromCSS, toCSS: m.toCSS },
|
|
1107
797
|
y: { fromCSS: y.fromCSS, toCSS: y.toCSS },
|
|
1108
|
-
keys:
|
|
798
|
+
keys: r.keys
|
|
1109
799
|
});
|
|
1110
|
-
}), /* @__PURE__ */
|
|
800
|
+
}), /* @__PURE__ */ L(
|
|
1111
801
|
"div",
|
|
1112
802
|
{
|
|
1113
|
-
ref:
|
|
803
|
+
ref: c,
|
|
1114
804
|
id: "interactions",
|
|
1115
805
|
className: t,
|
|
1116
806
|
style: {
|
|
1117
807
|
position: "absolute",
|
|
1118
|
-
left:
|
|
1119
|
-
top:
|
|
1120
|
-
width:
|
|
1121
|
-
height:
|
|
808
|
+
left: n.chartAreaCSS.x,
|
|
809
|
+
top: n.chartAreaCSS.y,
|
|
810
|
+
width: n.chartAreaCSS.width,
|
|
811
|
+
height: n.chartAreaCSS.height,
|
|
1122
812
|
zIndex: 25,
|
|
1123
813
|
...s
|
|
1124
814
|
},
|
|
1125
|
-
onClick: (
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
positions:
|
|
815
|
+
onClick: (r) => {
|
|
816
|
+
f(r, (m, y, x) => {
|
|
817
|
+
v.sync_click.dispatchEvent(a, {
|
|
818
|
+
positions: m,
|
|
1129
819
|
keys: x
|
|
1130
820
|
});
|
|
1131
821
|
});
|
|
1132
822
|
},
|
|
1133
|
-
onMouseLeave: (
|
|
1134
|
-
|
|
1135
|
-
|
|
823
|
+
onMouseLeave: (r) => {
|
|
824
|
+
f(r, (m, y, x) => {
|
|
825
|
+
v.sync_move.dispatchEvent(a, {
|
|
1136
826
|
positions: null,
|
|
1137
827
|
keys: x
|
|
1138
828
|
});
|
|
1139
829
|
});
|
|
1140
830
|
},
|
|
1141
|
-
onMouseMove: (
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
positions:
|
|
831
|
+
onMouseMove: (r) => {
|
|
832
|
+
f(r, (m, y, x) => {
|
|
833
|
+
v.sync_move.dispatchEvent(a, {
|
|
834
|
+
positions: m,
|
|
1145
835
|
keys: x
|
|
1146
836
|
});
|
|
1147
837
|
});
|
|
1148
838
|
},
|
|
1149
|
-
onMouseDown: (
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
positions:
|
|
1153
|
-
keys:
|
|
839
|
+
onMouseDown: (r) => {
|
|
840
|
+
f(r, (m, { cssX: y, cssY: x }, g) => {
|
|
841
|
+
v.sync_mousedown.dispatchEvent(a, {
|
|
842
|
+
positions: m,
|
|
843
|
+
keys: g
|
|
1154
844
|
}), l.current = null, u.current = {
|
|
1155
845
|
xRangeCss: { start: y, end: y },
|
|
1156
846
|
yRangeCss: { start: x, end: x }
|
|
1157
847
|
};
|
|
1158
848
|
});
|
|
1159
849
|
},
|
|
1160
|
-
onMouseUp: (
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
positions:
|
|
850
|
+
onMouseUp: (r) => {
|
|
851
|
+
f(r, (m, y, x) => {
|
|
852
|
+
v.sync_mouseup.dispatchEvent(a, {
|
|
853
|
+
positions: m,
|
|
1164
854
|
keys: x
|
|
1165
855
|
});
|
|
1166
|
-
const
|
|
856
|
+
const g = l.current;
|
|
1167
857
|
l.current = null;
|
|
1168
858
|
const S = u.current;
|
|
1169
|
-
if (u.current = null, S &&
|
|
1170
|
-
const
|
|
1171
|
-
...
|
|
859
|
+
if (u.current = null, S && g) {
|
|
860
|
+
const w = {
|
|
861
|
+
...g,
|
|
1172
862
|
keys: x,
|
|
1173
863
|
completed: !0
|
|
1174
864
|
};
|
|
1175
|
-
|
|
865
|
+
v.sync_spanselect.dispatchEvent(
|
|
1176
866
|
a,
|
|
1177
|
-
|
|
867
|
+
w
|
|
1178
868
|
);
|
|
1179
869
|
}
|
|
1180
870
|
});
|
|
1181
871
|
},
|
|
1182
|
-
onDoubleClick: (
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
positions:
|
|
872
|
+
onDoubleClick: (r) => {
|
|
873
|
+
f(r, (m, y, x) => {
|
|
874
|
+
v.sync_dblclick.dispatchEvent(a, {
|
|
875
|
+
positions: m,
|
|
1186
876
|
keys: x
|
|
1187
877
|
});
|
|
1188
878
|
});
|
|
1189
879
|
}
|
|
1190
880
|
}
|
|
1191
881
|
);
|
|
1192
|
-
},
|
|
1193
|
-
const [
|
|
1194
|
-
ft("move", (
|
|
1195
|
-
i
|
|
882
|
+
}, xe = ({ data: t, renderTooltip: s, xScaleId: e }) => {
|
|
883
|
+
const [c, n] = N(null);
|
|
884
|
+
ft("move", (i) => {
|
|
885
|
+
n(i);
|
|
1196
886
|
});
|
|
1197
|
-
const
|
|
1198
|
-
if (!
|
|
887
|
+
const o = gt(() => {
|
|
888
|
+
if (!c)
|
|
1199
889
|
return null;
|
|
1200
|
-
const { frame:
|
|
890
|
+
const { frame: i, pointer: a } = c, u = a?.scaled[e];
|
|
1201
891
|
if (u === void 0)
|
|
1202
892
|
return null;
|
|
1203
893
|
const l = [];
|
|
1204
894
|
let d = u;
|
|
1205
|
-
for (const
|
|
1206
|
-
let
|
|
1207
|
-
for (const [
|
|
1208
|
-
if (!
|
|
895
|
+
for (const p of t) {
|
|
896
|
+
let f = null, h = 1 / 0;
|
|
897
|
+
for (const [m, y] of p.points.entries()) {
|
|
898
|
+
if (!rt(i, y.x, e) || !rt(i, y.y, p.yScaleId))
|
|
1209
899
|
continue;
|
|
1210
900
|
const x = Math.abs(y.x - u);
|
|
1211
|
-
x < h && (h = x,
|
|
901
|
+
x < h && (h = x, f = m);
|
|
1212
902
|
}
|
|
1213
|
-
const
|
|
1214
|
-
if (!
|
|
1215
|
-
l.push({ seriesId:
|
|
903
|
+
const r = p.points[f ?? -1];
|
|
904
|
+
if (!r || ut(i, h, e, "css") > 30) {
|
|
905
|
+
l.push({ seriesId: p.seriesId, y: null });
|
|
1216
906
|
continue;
|
|
1217
907
|
}
|
|
1218
|
-
d =
|
|
1219
|
-
seriesId:
|
|
1220
|
-
y:
|
|
908
|
+
d = r.x, l.push({
|
|
909
|
+
seriesId: p.seriesId,
|
|
910
|
+
y: r.y
|
|
1221
911
|
});
|
|
1222
912
|
}
|
|
1223
913
|
return {
|
|
1224
|
-
frame:
|
|
914
|
+
frame: i,
|
|
1225
915
|
x: d,
|
|
1226
916
|
points: l
|
|
1227
917
|
};
|
|
1228
|
-
}, [t,
|
|
1229
|
-
return s(
|
|
1230
|
-
},
|
|
1231
|
-
const [
|
|
918
|
+
}, [t, c, e]);
|
|
919
|
+
return s(o);
|
|
920
|
+
}, Se = ({ makeXStyle: t, makeXClassName: s, makeYStyle: e, makeYClassName: c }) => {
|
|
921
|
+
const [n, o] = N(null);
|
|
1232
922
|
if (ft("move", (d) => {
|
|
1233
|
-
|
|
1234
|
-
}), !
|
|
923
|
+
o(d);
|
|
924
|
+
}), !n)
|
|
1235
925
|
return null;
|
|
1236
|
-
const { frame:
|
|
1237
|
-
return /* @__PURE__ */ at(
|
|
1238
|
-
/* @__PURE__ */
|
|
926
|
+
const { frame: i, pointer: a } = n, u = z(i, a?.cssX ?? 0, "css"), l = Y(i, a?.cssY ?? 0, "css");
|
|
927
|
+
return /* @__PURE__ */ at(Et, { children: [
|
|
928
|
+
/* @__PURE__ */ L(
|
|
1239
929
|
"div",
|
|
1240
930
|
{
|
|
1241
931
|
"data-show": !!a,
|
|
1242
|
-
className: s?.(
|
|
932
|
+
className: s?.(n),
|
|
1243
933
|
style: {
|
|
1244
934
|
position: "absolute",
|
|
1245
935
|
left: 0,
|
|
1246
|
-
top:
|
|
1247
|
-
height:
|
|
936
|
+
top: i.chartAreaCSS.y,
|
|
937
|
+
height: i.chartAreaCSS.height,
|
|
1248
938
|
borderColor: "red",
|
|
1249
939
|
borderLeftWidth: "1px",
|
|
1250
940
|
borderLeftStyle: "solid",
|
|
1251
941
|
pointerEvents: "none",
|
|
1252
942
|
opacity: a ? 1 : 0,
|
|
1253
943
|
transform: `translateX(${u}px)`,
|
|
1254
|
-
...t?.(
|
|
944
|
+
...t?.(n)
|
|
1255
945
|
}
|
|
1256
946
|
}
|
|
1257
947
|
),
|
|
1258
|
-
/* @__PURE__ */
|
|
948
|
+
/* @__PURE__ */ L(
|
|
1259
949
|
"div",
|
|
1260
950
|
{
|
|
1261
|
-
className:
|
|
951
|
+
className: c?.(n),
|
|
1262
952
|
"data-show": !!a,
|
|
1263
953
|
style: {
|
|
1264
954
|
position: "absolute",
|
|
1265
955
|
top: 0,
|
|
1266
956
|
height: 0,
|
|
1267
957
|
borderTop: "solid 1px red",
|
|
1268
|
-
left:
|
|
1269
|
-
width:
|
|
958
|
+
left: i.chartAreaCSS.x,
|
|
959
|
+
width: i.chartAreaCSS.width,
|
|
1270
960
|
pointerEvents: "none",
|
|
1271
961
|
opacity: a ? 1 : 0,
|
|
1272
962
|
transform: `translateY(${l}px)`,
|
|
1273
|
-
...e?.(
|
|
963
|
+
...e?.(n)
|
|
1274
964
|
}
|
|
1275
965
|
}
|
|
1276
966
|
)
|
|
1277
967
|
] });
|
|
1278
|
-
},
|
|
1279
|
-
const [e,
|
|
1280
|
-
if (ft("spanselect", (
|
|
1281
|
-
|
|
968
|
+
}, ge = ({ makeClassName: t, makeStyle: s }) => {
|
|
969
|
+
const [e, c] = N(null);
|
|
970
|
+
if (ft("spanselect", (f) => {
|
|
971
|
+
c(f.mode === "none" || f.completed ? null : f);
|
|
1282
972
|
}), !e)
|
|
1283
973
|
return null;
|
|
1284
|
-
const
|
|
974
|
+
const n = z(
|
|
1285
975
|
e.frame,
|
|
1286
976
|
e.x.fromCSS,
|
|
1287
977
|
"css"
|
|
1288
|
-
),
|
|
978
|
+
), o = z(
|
|
1289
979
|
e.frame,
|
|
1290
980
|
e.x.toCSS,
|
|
1291
981
|
"css"
|
|
1292
|
-
),
|
|
982
|
+
), i = Y(
|
|
1293
983
|
e.frame,
|
|
1294
984
|
e.y.fromCSS,
|
|
1295
985
|
"css"
|
|
1296
|
-
), a =
|
|
986
|
+
), a = Y(
|
|
1297
987
|
e.frame,
|
|
1298
988
|
e.y.toCSS,
|
|
1299
989
|
"css"
|
|
1300
|
-
), u = Math.min(
|
|
1301
|
-
return /* @__PURE__ */
|
|
990
|
+
), u = Math.min(n, o), l = Math.min(i, a), d = Math.abs(o - n), p = Math.abs(a - i);
|
|
991
|
+
return /* @__PURE__ */ L(
|
|
1302
992
|
"div",
|
|
1303
993
|
{
|
|
1304
994
|
className: t?.(e),
|
|
@@ -1308,54 +998,333 @@ const fe = Lt(({ configuration: t, children: s, style: e, className: o }, i) =>
|
|
|
1308
998
|
left: `${u}px`,
|
|
1309
999
|
top: `${l}px`,
|
|
1310
1000
|
width: `${d}px`,
|
|
1311
|
-
height: `${
|
|
1001
|
+
height: `${p}px`,
|
|
1312
1002
|
pointerEvents: "none",
|
|
1313
1003
|
...s?.(e)
|
|
1314
1004
|
}
|
|
1315
1005
|
}
|
|
1316
1006
|
);
|
|
1317
|
-
},
|
|
1318
|
-
const
|
|
1319
|
-
return
|
|
1007
|
+
}, we = ({ style: t, children: s, scaleId: e, ...c }) => {
|
|
1008
|
+
const n = ht((o) => o.getScale(e)?.axis);
|
|
1009
|
+
return n ? /* @__PURE__ */ L(
|
|
1320
1010
|
"div",
|
|
1321
1011
|
{
|
|
1322
1012
|
style: {
|
|
1323
1013
|
position: "absolute",
|
|
1324
1014
|
backgroundColor: "#0000ff11",
|
|
1325
|
-
left:
|
|
1326
|
-
top:
|
|
1327
|
-
height:
|
|
1328
|
-
width:
|
|
1015
|
+
left: n.cssRect.x,
|
|
1016
|
+
top: n.cssRect.y,
|
|
1017
|
+
height: n.cssRect.height,
|
|
1018
|
+
width: n.cssRect.width,
|
|
1329
1019
|
...t
|
|
1330
1020
|
},
|
|
1331
|
-
...
|
|
1021
|
+
...c,
|
|
1332
1022
|
children: s
|
|
1333
1023
|
}
|
|
1334
1024
|
) : null;
|
|
1025
|
+
}, vt = 60, Vt = 30, Ct = "UTC", Ht = "en-GB", ve = ({
|
|
1026
|
+
space: t,
|
|
1027
|
+
formatter: s
|
|
1028
|
+
} = {}) => (e, c) => {
|
|
1029
|
+
const { min: n, max: o } = e, i = [], a = window.devicePixelRatio || 1, u = (t ?? (e.origin === "x" ? vt : Vt)) * a, l = Lt(
|
|
1030
|
+
c,
|
|
1031
|
+
u,
|
|
1032
|
+
e.id,
|
|
1033
|
+
"canvas"
|
|
1034
|
+
), d = H.find((f) => f > l) ?? 1;
|
|
1035
|
+
let p = n % d < Number.EPSILON ? n : n + d - n % d;
|
|
1036
|
+
for (; p <= o; )
|
|
1037
|
+
i.push(p), p += d;
|
|
1038
|
+
return (s ?? jt)(i);
|
|
1039
|
+
}, jt = (t) => {
|
|
1040
|
+
const s = Math.max(0, Math.ceil(-Math.log10(t[1] - t[0])));
|
|
1041
|
+
return t.map((e) => ({ value: e, label: e.toFixed(s) }));
|
|
1042
|
+
}, H = [];
|
|
1043
|
+
for (let t = -12; t <= 12; t++)
|
|
1044
|
+
H.push(1 * 10 ** t), H.push(2 * 10 ** t), H.push(5 * 10 ** t);
|
|
1045
|
+
const Wt = 1, bt = 1e3 * Wt, pt = 60 * bt, q = 60 * pt, tt = 24 * q, Zt = 30 * tt, Gt = 365 * tt, Jt = [
|
|
1046
|
+
// second divisors
|
|
1047
|
+
[1, "milliseconds"],
|
|
1048
|
+
[2, "milliseconds"],
|
|
1049
|
+
[5, "milliseconds"],
|
|
1050
|
+
[10, "milliseconds"],
|
|
1051
|
+
[20, "milliseconds"],
|
|
1052
|
+
[50, "milliseconds"],
|
|
1053
|
+
[100, "milliseconds"],
|
|
1054
|
+
[200, "milliseconds"],
|
|
1055
|
+
[500, "milliseconds"],
|
|
1056
|
+
// minute divisors
|
|
1057
|
+
[1, "seconds"],
|
|
1058
|
+
[5, "seconds"],
|
|
1059
|
+
[10, "seconds"],
|
|
1060
|
+
[15, "seconds"],
|
|
1061
|
+
[30, "seconds"],
|
|
1062
|
+
// hour divisors
|
|
1063
|
+
[1, "minutes"],
|
|
1064
|
+
[5, "minutes"],
|
|
1065
|
+
[10, "minutes"],
|
|
1066
|
+
[15, "minutes"],
|
|
1067
|
+
[30, "minutes"],
|
|
1068
|
+
// day divisors
|
|
1069
|
+
[1, "hours"],
|
|
1070
|
+
[2, "hours"],
|
|
1071
|
+
[3, "hours"],
|
|
1072
|
+
[4, "hours"],
|
|
1073
|
+
[6, "hours"],
|
|
1074
|
+
[8, "hours"],
|
|
1075
|
+
[12, "hours"],
|
|
1076
|
+
// month divisors
|
|
1077
|
+
[1, "days"],
|
|
1078
|
+
[3, "days"],
|
|
1079
|
+
[5, "days"],
|
|
1080
|
+
[7, "days"],
|
|
1081
|
+
[10, "days"],
|
|
1082
|
+
[15, "days"],
|
|
1083
|
+
// year divisors
|
|
1084
|
+
[1, "months"],
|
|
1085
|
+
[2, "months"],
|
|
1086
|
+
[3, "months"],
|
|
1087
|
+
[4, "months"],
|
|
1088
|
+
[6, "months"],
|
|
1089
|
+
// century divisors
|
|
1090
|
+
[1, "years"],
|
|
1091
|
+
[2, "years"],
|
|
1092
|
+
[5, "years"],
|
|
1093
|
+
[10, "years"],
|
|
1094
|
+
[25, "years"],
|
|
1095
|
+
[50, "years"],
|
|
1096
|
+
[100, "years"]
|
|
1097
|
+
], j = (t) => {
|
|
1098
|
+
const [s, e] = t;
|
|
1099
|
+
switch (e) {
|
|
1100
|
+
case "milliseconds":
|
|
1101
|
+
return s;
|
|
1102
|
+
case "seconds":
|
|
1103
|
+
return s * bt;
|
|
1104
|
+
case "minutes":
|
|
1105
|
+
return s * pt;
|
|
1106
|
+
case "hours":
|
|
1107
|
+
return s * q;
|
|
1108
|
+
case "days":
|
|
1109
|
+
return s * tt;
|
|
1110
|
+
case "months":
|
|
1111
|
+
return s * Zt;
|
|
1112
|
+
case "years":
|
|
1113
|
+
return s * Gt;
|
|
1114
|
+
}
|
|
1115
|
+
}, qt = (t, s) => {
|
|
1116
|
+
const e = new Date(t);
|
|
1117
|
+
return e.setUTCMilliseconds(e.getUTCMilliseconds() + s), e.getTime();
|
|
1118
|
+
}, Qt = (t, s) => {
|
|
1119
|
+
const e = new Date(t);
|
|
1120
|
+
return e.setUTCSeconds(e.getUTCSeconds() + s), e.getTime();
|
|
1121
|
+
}, te = (t, s) => {
|
|
1122
|
+
const e = new Date(t);
|
|
1123
|
+
return e.setUTCMinutes(e.getUTCMinutes() + s), e.getTime();
|
|
1124
|
+
}, ee = (t, s) => {
|
|
1125
|
+
const e = new Date(t);
|
|
1126
|
+
return e.setUTCHours(e.getUTCHours() + s), e.getTime();
|
|
1127
|
+
}, se = (t, s) => {
|
|
1128
|
+
const e = new Date(t);
|
|
1129
|
+
return e.setUTCDate(e.getUTCDate() + s), e.getTime();
|
|
1130
|
+
}, St = (t, s) => {
|
|
1131
|
+
const e = new Date(t);
|
|
1132
|
+
return e.setUTCMonth(e.getUTCMonth() + s), e.getTime();
|
|
1133
|
+
}, X = (t, s) => {
|
|
1134
|
+
const [e, c] = s;
|
|
1135
|
+
switch (c) {
|
|
1136
|
+
case "milliseconds":
|
|
1137
|
+
return qt(t, e);
|
|
1138
|
+
case "seconds":
|
|
1139
|
+
return Qt(t, e);
|
|
1140
|
+
case "minutes":
|
|
1141
|
+
return te(t, e);
|
|
1142
|
+
case "hours":
|
|
1143
|
+
return ee(t, e);
|
|
1144
|
+
case "days":
|
|
1145
|
+
return se(t, e);
|
|
1146
|
+
case "months":
|
|
1147
|
+
return St(t, e);
|
|
1148
|
+
case "years":
|
|
1149
|
+
return St(t, e * 12);
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
function W(t, s) {
|
|
1153
|
+
const e = new Date(t), c = new Date(e.toLocaleString("en-US", { timeZone: s })), n = new Date(e.toLocaleString("en-US", { timeZone: "UTC" }));
|
|
1154
|
+
return (c.getTime() - n.getTime()) / (3600 * 1e3);
|
|
1155
|
+
}
|
|
1156
|
+
const ne = (t, s, e = "UTC") => {
|
|
1157
|
+
const [c, n] = s;
|
|
1158
|
+
let o = new Date(t);
|
|
1159
|
+
const i = () => {
|
|
1160
|
+
o.setUTCHours(-W(o, e), 0, 0, 0);
|
|
1161
|
+
};
|
|
1162
|
+
switch (n) {
|
|
1163
|
+
case "milliseconds":
|
|
1164
|
+
o.setUTCMilliseconds(
|
|
1165
|
+
Math.ceil(o.getUTCMilliseconds() / c) * c
|
|
1166
|
+
);
|
|
1167
|
+
break;
|
|
1168
|
+
case "seconds":
|
|
1169
|
+
o.setUTCSeconds(
|
|
1170
|
+
Math.ceil(o.getUTCSeconds() / c) * c,
|
|
1171
|
+
0
|
|
1172
|
+
);
|
|
1173
|
+
break;
|
|
1174
|
+
case "minutes":
|
|
1175
|
+
o.setUTCMinutes(
|
|
1176
|
+
Math.ceil(o.getTime() % q / pt / c) * c,
|
|
1177
|
+
0,
|
|
1178
|
+
0
|
|
1179
|
+
);
|
|
1180
|
+
break;
|
|
1181
|
+
case "hours":
|
|
1182
|
+
o.setUTCHours(
|
|
1183
|
+
Math.ceil(o.getTime() % tt / q / c) * c,
|
|
1184
|
+
0,
|
|
1185
|
+
0,
|
|
1186
|
+
0
|
|
1187
|
+
);
|
|
1188
|
+
break;
|
|
1189
|
+
case "days":
|
|
1190
|
+
case "months":
|
|
1191
|
+
case "years":
|
|
1192
|
+
n === "months" ? o.setUTCDate(1) : n === "years" && o.setUTCMonth(0, 1), i(), o.getTime() < t && (o = new Date(X(o, [1, n])));
|
|
1193
|
+
break;
|
|
1194
|
+
}
|
|
1195
|
+
return o.getTime();
|
|
1196
|
+
}, Ce = ({
|
|
1197
|
+
timeZone: t = Ct,
|
|
1198
|
+
space: s = vt,
|
|
1199
|
+
formatter: e,
|
|
1200
|
+
locale: c,
|
|
1201
|
+
showTimezone: n
|
|
1202
|
+
} = {}) => (o, i) => {
|
|
1203
|
+
const { min: a, max: u } = o, l = Math.floor(i.chartAreaCanvasPX.width / s) + 1, p = (u - a) / l, [f, h] = Jt.find(
|
|
1204
|
+
(g) => j(g) >= p
|
|
1205
|
+
) ?? [1, "milliseconds"], r = ne(a, [f, h], t), m = W(r, t), y = [r];
|
|
1206
|
+
let x;
|
|
1207
|
+
for (; ; ) {
|
|
1208
|
+
switch (h) {
|
|
1209
|
+
case "milliseconds":
|
|
1210
|
+
case "seconds":
|
|
1211
|
+
case "minutes":
|
|
1212
|
+
case "hours": {
|
|
1213
|
+
x = X(r, [y.length * f, h]);
|
|
1214
|
+
break;
|
|
1215
|
+
}
|
|
1216
|
+
case "days": {
|
|
1217
|
+
const g = X(r, [
|
|
1218
|
+
y.length * f,
|
|
1219
|
+
h
|
|
1220
|
+
]);
|
|
1221
|
+
x = X(g, [
|
|
1222
|
+
m - W(g, t),
|
|
1223
|
+
"hours"
|
|
1224
|
+
]);
|
|
1225
|
+
break;
|
|
1226
|
+
}
|
|
1227
|
+
case "months":
|
|
1228
|
+
case "years": {
|
|
1229
|
+
const g = X(
|
|
1230
|
+
X(X(r, [m, "hours"]), [
|
|
1231
|
+
y.length * f,
|
|
1232
|
+
h
|
|
1233
|
+
]),
|
|
1234
|
+
[-m, "hours"]
|
|
1235
|
+
);
|
|
1236
|
+
x = X(g, [
|
|
1237
|
+
m - W(g, t),
|
|
1238
|
+
"hours"
|
|
1239
|
+
]);
|
|
1240
|
+
break;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
if (x > u)
|
|
1244
|
+
break;
|
|
1245
|
+
y.push(x);
|
|
1246
|
+
}
|
|
1247
|
+
return (e ?? oe({
|
|
1248
|
+
locale: c,
|
|
1249
|
+
showTimezone: n,
|
|
1250
|
+
timeZone: t
|
|
1251
|
+
}))(y);
|
|
1252
|
+
}, I = (t, s, e) => t.find((c) => c.type === e)?.value !== s.find((c) => c.type === e)?.value, oe = ({
|
|
1253
|
+
timeZone: t = Ct,
|
|
1254
|
+
locale: s = Ht,
|
|
1255
|
+
showTimezone: e = !0
|
|
1256
|
+
}) => {
|
|
1257
|
+
const c = new Intl.DateTimeFormat(s, {
|
|
1258
|
+
year: "numeric",
|
|
1259
|
+
day: "numeric",
|
|
1260
|
+
month: "short",
|
|
1261
|
+
hour: "numeric",
|
|
1262
|
+
hourCycle: "h23",
|
|
1263
|
+
minute: "numeric",
|
|
1264
|
+
second: "numeric",
|
|
1265
|
+
fractionalSecondDigits: 3,
|
|
1266
|
+
timeZoneName: "short",
|
|
1267
|
+
timeZone: t
|
|
1268
|
+
});
|
|
1269
|
+
return (n) => {
|
|
1270
|
+
const o = n[1] - n[0], i = o < j([1, "days"]), a = o < j([1, "minutes"]), u = o < j([1, "seconds"]);
|
|
1271
|
+
return n.map((l) => ({ value: l, label: c.formatToParts(new Date(l)) })).map((l, d, p) => {
|
|
1272
|
+
const f = p[d - 1], h = d === 0 || I(l.label, f.label, "year"), r = d === 0 || I(l.label, f.label, "day"), m = d === 0 || I(l.label, f.label, "month"), y = d === 0 || I(l.label, f.label, "hour"), x = d === 0 || I(l.label, f.label, "timeZoneName"), g = d === 0 || I(l.label, f.label, "minute"), S = d === 0 || I(l.label, f.label, "second"), w = d === 0 || I(l.label, f.label, "fractionalSecond"), k = [];
|
|
1273
|
+
if (i && (y || g || x || S || w)) {
|
|
1274
|
+
const C = l.label.find((P) => P.type === "hour")?.value, E = l.label.find((P) => P.type === "minute")?.value, M = l.label.find((P) => P.type === "timeZoneName")?.value;
|
|
1275
|
+
let A = "";
|
|
1276
|
+
if (a) {
|
|
1277
|
+
const P = l.label.find((K) => K.type === "second")?.value, $ = l.label.find(
|
|
1278
|
+
(K) => K.type === "fractionalSecond"
|
|
1279
|
+
)?.value;
|
|
1280
|
+
A = `:${P}` + (u ? `.${$}` : "");
|
|
1281
|
+
}
|
|
1282
|
+
k.push(
|
|
1283
|
+
`${C}:${E}${A}` + (e && x ? ` ${M}` : "")
|
|
1284
|
+
);
|
|
1285
|
+
}
|
|
1286
|
+
return (r || m) && k.push(
|
|
1287
|
+
[
|
|
1288
|
+
l.label.find((C) => C.type === "month")?.value,
|
|
1289
|
+
r && l.label.find((C) => C.type === "day")?.value
|
|
1290
|
+
].filter(Boolean).join(" ")
|
|
1291
|
+
), h && k.push(l.label.find((C) => C.type === "year")?.value), {
|
|
1292
|
+
value: l.value,
|
|
1293
|
+
label: k.filter((C) => C).join(`
|
|
1294
|
+
`)
|
|
1295
|
+
};
|
|
1296
|
+
});
|
|
1297
|
+
};
|
|
1335
1298
|
};
|
|
1336
1299
|
export {
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1300
|
+
me as AreaPlot,
|
|
1301
|
+
we as AxisOverlay,
|
|
1302
|
+
he as BarPlot,
|
|
1303
|
+
le as CanPlot,
|
|
1304
|
+
ye as ChartAreaInteractions,
|
|
1305
|
+
Se as Crosshair,
|
|
1306
|
+
ue as LinePlot,
|
|
1307
|
+
de as ScatterPlot,
|
|
1308
|
+
ge as SelectBox,
|
|
1309
|
+
fe as SparklinePlot,
|
|
1310
|
+
xe as TooltipsX,
|
|
1311
|
+
O as applyStyles,
|
|
1312
|
+
z as clampXPosToChartArea,
|
|
1313
|
+
Y as clampYPosToChartArea,
|
|
1314
|
+
jt as defaultNumericalTicksFormatter,
|
|
1315
|
+
D as getScale,
|
|
1316
|
+
Q as isXScale,
|
|
1317
|
+
ae as isYScale,
|
|
1318
|
+
ve as makeLinearTicks,
|
|
1319
|
+
oe as makeTimeTickFormat,
|
|
1320
|
+
Ce as makeTimeTicks,
|
|
1321
|
+
U as posToVal,
|
|
1322
|
+
Lt as pxToValDistance,
|
|
1323
|
+
V as useDrawEffect,
|
|
1324
|
+
ht as useFrameState,
|
|
1325
|
+
pe as usePositioned,
|
|
1326
|
+
rt as valFits,
|
|
1327
|
+
B as valToPos,
|
|
1359
1328
|
ut as valToPxDistance
|
|
1360
1329
|
};
|
|
1361
1330
|
//# sourceMappingURL=canplot.mjs.map
|