@canplot/react 0.5.6 → 0.5.8
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/canplot.cjs +4 -4
- package/dist/canplot.cjs.map +1 -1
- package/dist/canplot.mjs +487 -480
- package/dist/canplot.mjs.map +1 -1
- package/dist/plot/BarPlot.d.ts +1 -0
- package/dist/plot/BarPlot.d.ts.map +1 -1
- package/dist/plot/LinePlot.d.ts +1 -0
- package/dist/plot/LinePlot.d.ts.map +1 -1
- package/dist/plot/ScatterPlot.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/canplot.mjs
CHANGED
|
@@ -2,8 +2,8 @@ var Be = Object.defineProperty;
|
|
|
2
2
|
var ze = (e, t, n) => t in e ? Be(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var O = (e, t, n) => ze(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { jsxs as pe, jsx as R, Fragment as Ne } from "react/jsx-runtime";
|
|
5
|
-
import D, { version as $e, createContext as ye, forwardRef as je, useRef as
|
|
6
|
-
const
|
|
5
|
+
import D, { version as $e, createContext as ye, forwardRef as je, useRef as k, useState as B, useMemo as Z, useLayoutEffect as $, useCallback as Ve, useContext as q, useEffect as ke, useId as He } from "react";
|
|
6
|
+
const ie = (e, t, n) => Math.min(Math.max(e, t), n), kt = (e) => e.reduce((t, n) => t + (n ?? 0), 0), Rt = (e, t) => {
|
|
7
7
|
let n = 0;
|
|
8
8
|
for (let s = 0; s < e.length; s++)
|
|
9
9
|
Math.abs(e[s] - t) < Math.abs(e[n] - t) && (n = s);
|
|
@@ -12,46 +12,46 @@ const re = (e, t, n) => Math.min(Math.max(e, t), n), At = (e) => e.reduce((t, n)
|
|
|
12
12
|
const o = X(e, n);
|
|
13
13
|
if (!o)
|
|
14
14
|
return null;
|
|
15
|
-
const
|
|
16
|
-
return t /
|
|
15
|
+
const i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, r = (o.origin === "x" ? i.width : i.height) / (o.max - o.min);
|
|
16
|
+
return t / r;
|
|
17
17
|
}, X = (e, t) => e.scales.find((n) => n.id === t) ?? null, U = (e, t) => {
|
|
18
18
|
const n = window.devicePixelRatio || 1;
|
|
19
19
|
e.lineCap = t?.lineCap ?? "butt", e.lineDashOffset = n * (t?.lineDashOffset ?? 0), e.lineJoin = t?.lineJoin ?? "miter", e.lineWidth = n * (t?.lineWidth ?? 1), e.miterLimit = n * (t?.miterLimit ?? 10), e.strokeStyle = t?.strokeStyle ?? "black", e.fillStyle = t?.fillStyle ?? e.strokeStyle, e.font = t?.font ?? `${10 * n}px sans-serif`, e.textAlign = t?.textAlign ?? "start", e.direction = t?.direction ?? "inherit", e.textBaseline = t?.textBaseline ?? "alphabetic", e.fontKerning = t?.fontKerning ?? "auto";
|
|
20
20
|
}, ge = (e, t, n, s) => {
|
|
21
|
-
const o = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS,
|
|
22
|
-
if (!
|
|
21
|
+
const o = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, i = X(e, n);
|
|
22
|
+
if (!i)
|
|
23
23
|
return null;
|
|
24
|
-
const
|
|
25
|
-
return t *
|
|
24
|
+
const r = (i.origin === "x" ? o.width : o.height) / (i.max - i.min);
|
|
25
|
+
return t * r;
|
|
26
26
|
}, G = (e, t, n, s) => {
|
|
27
27
|
const o = X(e, n);
|
|
28
28
|
if (!o)
|
|
29
29
|
return null;
|
|
30
|
-
const
|
|
30
|
+
const i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, r = ge(
|
|
31
31
|
e,
|
|
32
32
|
t - o.min,
|
|
33
33
|
n,
|
|
34
34
|
s
|
|
35
35
|
);
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
) :
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
return r === null ? null : o.origin === "x" ? ie(
|
|
37
|
+
i.x + r,
|
|
38
|
+
i.x - 10 * i.width,
|
|
39
|
+
i.x + 11 * i.width
|
|
40
|
+
) : ie(
|
|
41
|
+
i.y + i.height - r,
|
|
42
|
+
i.y - 10 * i.height,
|
|
43
|
+
i.y + 11 * i.height
|
|
44
44
|
);
|
|
45
45
|
}, V = (e, t, n) => {
|
|
46
46
|
if (t === null)
|
|
47
47
|
return null;
|
|
48
48
|
const s = n === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS;
|
|
49
|
-
return
|
|
49
|
+
return ie(t, s.x, s.x + s.width);
|
|
50
50
|
}, H = (e, t, n) => {
|
|
51
51
|
if (t === null)
|
|
52
52
|
return null;
|
|
53
53
|
const s = n === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS;
|
|
54
|
-
return
|
|
54
|
+
return ie(t, s.y, s.y + s.height);
|
|
55
55
|
}, fe = (e, t, n) => {
|
|
56
56
|
if (t === null)
|
|
57
57
|
return !1;
|
|
@@ -61,8 +61,8 @@ const re = (e, t, n) => Math.min(Math.max(e, t), n), At = (e) => e.reduce((t, n)
|
|
|
61
61
|
const o = X(e, n);
|
|
62
62
|
if (!o)
|
|
63
63
|
return null;
|
|
64
|
-
const
|
|
65
|
-
return o.min +
|
|
64
|
+
const i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, r = o.origin === "x" ? (t - i.x) / i.width : (i.height - t + i.y) / i.height;
|
|
65
|
+
return o.min + r * (o.max - o.min);
|
|
66
66
|
}, F = (e, t) => {
|
|
67
67
|
if (e === t) return !0;
|
|
68
68
|
if (e == null || t == null || typeof e != typeof t || typeof e != "object" || Array.isArray(e) !== Array.isArray(t)) return !1;
|
|
@@ -92,12 +92,12 @@ const re = (e, t, n) => Math.min(Math.max(e, t), n), At = (e) => e.reduce((t, n)
|
|
|
92
92
|
if (s.axis.position === "bottom")
|
|
93
93
|
t.beginPath(), t.moveTo(o.x, o.y), t.lineTo(o.x + o.width, o.y), t.stroke();
|
|
94
94
|
else if (s.axis.position === "top") {
|
|
95
|
-
const
|
|
96
|
-
t.beginPath(), t.moveTo(o.x,
|
|
95
|
+
const i = o.y + o.height;
|
|
96
|
+
t.beginPath(), t.moveTo(o.x, i), t.lineTo(o.x + o.width, i), t.stroke();
|
|
97
97
|
}
|
|
98
98
|
} else if (s.axis.position === "left") {
|
|
99
|
-
const
|
|
100
|
-
t.beginPath(), t.moveTo(
|
|
99
|
+
const i = o.x + o.width;
|
|
100
|
+
t.beginPath(), t.moveTo(i, o.y), t.lineTo(i, o.y + o.height), t.stroke();
|
|
101
101
|
} else s.axis.position === "right" && (t.beginPath(), t.moveTo(o.x, o.y), t.lineTo(o.x, o.y + o.height), t.stroke());
|
|
102
102
|
t.restore();
|
|
103
103
|
}
|
|
@@ -111,8 +111,8 @@ function Ze(e) {
|
|
|
111
111
|
return (t) => {
|
|
112
112
|
const n = [];
|
|
113
113
|
for (const s of e) {
|
|
114
|
-
const o = me(s, t),
|
|
115
|
-
n.push(
|
|
114
|
+
const o = me(s, t), i = typeof o == "function";
|
|
115
|
+
n.push(i ? o : () => me(s, null));
|
|
116
116
|
}
|
|
117
117
|
return () => {
|
|
118
118
|
for (const s of n) s();
|
|
@@ -133,9 +133,9 @@ const Re = ye({
|
|
|
133
133
|
}
|
|
134
134
|
}), Qe = () => {
|
|
135
135
|
const e = [];
|
|
136
|
-
return { listeners: e, subscribe: (s, o) => (e.push([o, s]), e.sort((
|
|
137
|
-
const
|
|
138
|
-
|
|
136
|
+
return { listeners: e, subscribe: (s, o) => (e.push([o, s]), e.sort((i, r) => i[0] - r[0]), () => {
|
|
137
|
+
const i = e.findIndex(([, r]) => r === s);
|
|
138
|
+
i !== -1 && e.splice(i, 1);
|
|
139
139
|
}), notifyListeners: () => {
|
|
140
140
|
for (const [, s] of e)
|
|
141
141
|
s();
|
|
@@ -170,18 +170,18 @@ class Le {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
173
|
-
const
|
|
174
|
-
() => nt(e, c,
|
|
175
|
-
[e, c,
|
|
173
|
+
const i = k(null), r = k(null), c = tt(r), [u, l] = B(null), p = Z(
|
|
174
|
+
() => nt(e, c, u),
|
|
175
|
+
[e, c, u]
|
|
176
176
|
);
|
|
177
177
|
$(() => {
|
|
178
|
-
|
|
179
|
-
}, [
|
|
180
|
-
const
|
|
178
|
+
l(i.current?.getContext("2d") || null);
|
|
179
|
+
}, [i]);
|
|
180
|
+
const d = window.devicePixelRatio || 1;
|
|
181
181
|
return /* @__PURE__ */ pe(
|
|
182
182
|
"div",
|
|
183
183
|
{
|
|
184
|
-
ref: Je([o,
|
|
184
|
+
ref: Je([o, r]),
|
|
185
185
|
style: {
|
|
186
186
|
position: "relative",
|
|
187
187
|
overflow: "hidden",
|
|
@@ -193,9 +193,9 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
193
193
|
/* @__PURE__ */ R(
|
|
194
194
|
"canvas",
|
|
195
195
|
{
|
|
196
|
-
ref:
|
|
197
|
-
width: c.width *
|
|
198
|
-
height: c.height *
|
|
196
|
+
ref: i,
|
|
197
|
+
width: c.width * d,
|
|
198
|
+
height: c.height * d,
|
|
199
199
|
style: {
|
|
200
200
|
inset: 0,
|
|
201
201
|
position: "absolute",
|
|
@@ -204,7 +204,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
),
|
|
207
|
-
|
|
207
|
+
p && /* @__PURE__ */ R(et, { frame: p, children: t })
|
|
208
208
|
]
|
|
209
209
|
}
|
|
210
210
|
);
|
|
@@ -216,10 +216,10 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
216
216
|
$(() => {
|
|
217
217
|
e?.ctx.clearRect(0, 0, e.ctx.canvas.width, e.ctx.canvas.height);
|
|
218
218
|
}, [e, s]);
|
|
219
|
-
const
|
|
220
|
-
|
|
219
|
+
const i = k(null);
|
|
220
|
+
i.current = e, $(() => {
|
|
221
221
|
n.subscribe(() => {
|
|
222
|
-
|
|
222
|
+
i.current && qe(i.current);
|
|
223
223
|
}, Ie.BOTTOM);
|
|
224
224
|
}, [n]), $(() => {
|
|
225
225
|
let c = null;
|
|
@@ -229,27 +229,27 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
229
229
|
c && cancelAnimationFrame(c);
|
|
230
230
|
};
|
|
231
231
|
}, [s, e, n]);
|
|
232
|
-
const
|
|
232
|
+
const r = Ve(() => {
|
|
233
233
|
o((c) => c + 1);
|
|
234
234
|
}, [o]);
|
|
235
|
-
return /* @__PURE__ */ R(Re.Provider, { value: n, children: /* @__PURE__ */ R(De.Provider, { value:
|
|
235
|
+
return /* @__PURE__ */ R(Re.Provider, { value: n, children: /* @__PURE__ */ R(De.Provider, { value: r, children: /* @__PURE__ */ R(ve.Provider, { value: e, children: t }) }) });
|
|
236
236
|
}, tt = (e) => {
|
|
237
237
|
const [t, n] = B({
|
|
238
238
|
width: 0,
|
|
239
239
|
height: 0
|
|
240
240
|
}), [s] = B(() => new ResizeObserver((o) => {
|
|
241
|
-
for (const
|
|
242
|
-
const
|
|
241
|
+
for (const i of o) {
|
|
242
|
+
const r = Math.round(i.contentRect.width), c = Math.round(i.contentRect.height);
|
|
243
243
|
n(
|
|
244
|
-
(
|
|
244
|
+
(u) => u.width !== r || u.height !== c ? { ...u, width: r, height: c } : u
|
|
245
245
|
);
|
|
246
246
|
}
|
|
247
247
|
}));
|
|
248
248
|
return $(() => {
|
|
249
249
|
if (!e.current) return;
|
|
250
|
-
const o = e.current.clientWidth,
|
|
250
|
+
const o = e.current.clientWidth, i = e.current.clientHeight;
|
|
251
251
|
return n(
|
|
252
|
-
(
|
|
252
|
+
(r) => r.width !== o || r.height !== i ? { ...r, width: o, height: i } : r
|
|
253
253
|
), s.observe(e.current, { box: "border-box" }), () => s.disconnect();
|
|
254
254
|
}, [s, e]), t;
|
|
255
255
|
}, nt = (e, t, n) => {
|
|
@@ -269,33 +269,33 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
269
269
|
0,
|
|
270
270
|
o.height - a.axis.size
|
|
271
271
|
), a.axis.position === "top" && (o.y += a.axis.size)) : (a.axis.position === "left" || a.axis.position === "right") && (o.width = Math.max(0, o.width - a.axis.size), a.axis.position === "left" && (o.x += a.axis.size)));
|
|
272
|
-
const
|
|
272
|
+
const i = {
|
|
273
273
|
x: o.x * s,
|
|
274
274
|
y: o.y * s,
|
|
275
275
|
width: o.width * s,
|
|
276
276
|
height: o.height * s
|
|
277
|
-
},
|
|
278
|
-
let c = e.padding.left * s,
|
|
277
|
+
}, r = [];
|
|
278
|
+
let c = e.padding.left * s, u = t.width * s - e.padding.right * s, l = t.height * s - e.padding.bottom * s, p = e.padding.top * s;
|
|
279
279
|
for (const a of e.scales) {
|
|
280
280
|
if (!a.axis) {
|
|
281
|
-
|
|
281
|
+
r.push({ ...a, axis: null });
|
|
282
282
|
continue;
|
|
283
283
|
}
|
|
284
|
-
let
|
|
284
|
+
let g;
|
|
285
285
|
if (a.origin === "x")
|
|
286
286
|
switch (a.axis.position) {
|
|
287
287
|
case "bottom":
|
|
288
|
-
|
|
288
|
+
l -= a.axis.size * s, g = {
|
|
289
289
|
x: o.x,
|
|
290
|
-
y:
|
|
290
|
+
y: l / s,
|
|
291
291
|
width: o.width,
|
|
292
292
|
height: a.axis.size
|
|
293
293
|
};
|
|
294
294
|
break;
|
|
295
295
|
case "top":
|
|
296
|
-
|
|
296
|
+
p += a.axis.size * s, g = {
|
|
297
297
|
x: o.x,
|
|
298
|
-
y:
|
|
298
|
+
y: p / s - a.axis.size,
|
|
299
299
|
width: o.width,
|
|
300
300
|
height: a.axis.size
|
|
301
301
|
};
|
|
@@ -307,7 +307,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
307
307
|
else
|
|
308
308
|
switch (a.axis.position) {
|
|
309
309
|
case "left":
|
|
310
|
-
c += a.axis.size * s,
|
|
310
|
+
c += a.axis.size * s, g = {
|
|
311
311
|
x: c / s - a.axis.size,
|
|
312
312
|
y: o.y,
|
|
313
313
|
width: a.axis.size,
|
|
@@ -315,8 +315,8 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
315
315
|
};
|
|
316
316
|
break;
|
|
317
317
|
case "right":
|
|
318
|
-
|
|
319
|
-
x:
|
|
318
|
+
u -= a.axis.size * s, g = {
|
|
319
|
+
x: u / s,
|
|
320
320
|
y: o.y,
|
|
321
321
|
width: a.axis.size,
|
|
322
322
|
height: o.height
|
|
@@ -326,18 +326,18 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
326
326
|
case "bottom":
|
|
327
327
|
throw new Error("Invalid axis position for y origin");
|
|
328
328
|
}
|
|
329
|
-
const
|
|
330
|
-
x:
|
|
331
|
-
y:
|
|
332
|
-
width:
|
|
333
|
-
height:
|
|
329
|
+
const f = {
|
|
330
|
+
x: g.x * s,
|
|
331
|
+
y: g.y * s,
|
|
332
|
+
width: g.width * s,
|
|
333
|
+
height: g.height * s
|
|
334
334
|
};
|
|
335
|
-
|
|
335
|
+
r.push({
|
|
336
336
|
...a,
|
|
337
337
|
axis: {
|
|
338
338
|
...a.axis,
|
|
339
|
-
cssRect:
|
|
340
|
-
canvasRect:
|
|
339
|
+
cssRect: g,
|
|
340
|
+
canvasRect: f
|
|
341
341
|
}
|
|
342
342
|
});
|
|
343
343
|
}
|
|
@@ -345,32 +345,32 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
345
345
|
ctx: n,
|
|
346
346
|
dpr: s,
|
|
347
347
|
padding: e.padding,
|
|
348
|
-
scales:
|
|
348
|
+
scales: r,
|
|
349
349
|
chartAreaCSS: o,
|
|
350
|
-
chartAreaCanvasPX:
|
|
350
|
+
chartAreaCanvasPX: i
|
|
351
351
|
};
|
|
352
352
|
}, j = (e, t, n) => {
|
|
353
|
-
const s = q(ve), o = q(De),
|
|
353
|
+
const s = q(ve), o = q(De), i = q(Re);
|
|
354
354
|
if (!s || !o)
|
|
355
355
|
throw new Error("useFrame must be used within a CanPlot component");
|
|
356
|
-
const [
|
|
357
|
-
|
|
358
|
-
const c =
|
|
359
|
-
c.current =
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
const
|
|
356
|
+
const [r] = B(() => new Le());
|
|
357
|
+
r._updateFrame(s);
|
|
358
|
+
const c = k(r);
|
|
359
|
+
c.current = r;
|
|
360
|
+
const u = k(t);
|
|
361
|
+
u.current = t, $(() => {
|
|
362
|
+
const l = i.subscribe(
|
|
363
363
|
() => {
|
|
364
|
-
|
|
364
|
+
u.current(r);
|
|
365
365
|
},
|
|
366
366
|
typeof e == "number" ? e : Ie[e]
|
|
367
367
|
);
|
|
368
368
|
return () => {
|
|
369
|
-
|
|
369
|
+
l();
|
|
370
370
|
};
|
|
371
|
-
}, [
|
|
371
|
+
}, [i, e, r]), $(() => {
|
|
372
372
|
o();
|
|
373
|
-
}, [o, ...n]),
|
|
373
|
+
}, [o, ...n]), ke(() => () => {
|
|
374
374
|
o();
|
|
375
375
|
}, [o]);
|
|
376
376
|
}, Ue = () => {
|
|
@@ -381,189 +381,196 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
381
381
|
const t = new Le();
|
|
382
382
|
return t._updateFrame(e), t;
|
|
383
383
|
}, [e]);
|
|
384
|
-
}, st = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o }) => (j(
|
|
384
|
+
}, st = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o, globalAlpha: i }) => (j(
|
|
385
385
|
e,
|
|
386
|
-
({ ctx: r, clampXPosToChartArea:
|
|
387
|
-
r.save(), r.beginPath(), U(r, o);
|
|
388
|
-
for (const
|
|
389
|
-
const
|
|
390
|
-
|
|
386
|
+
({ ctx: r, clampXPosToChartArea: c, clampYPosToChartArea: u, valToPos: l }) => {
|
|
387
|
+
r.save(), r.beginPath(), U(r, o), i !== void 0 && (r.globalAlpha = i);
|
|
388
|
+
for (const p of t) {
|
|
389
|
+
const d = c(l(p.x, n, "canvas")), a = u(l(p.y, s, "canvas"));
|
|
390
|
+
d === null || a === null || r.lineTo(d, a);
|
|
391
391
|
}
|
|
392
392
|
r.stroke(), r.restore();
|
|
393
393
|
},
|
|
394
|
-
[t, n, s, o]
|
|
394
|
+
[t, n, s, o, i]
|
|
395
395
|
), null), It = D.memo(st, F), ot = ({
|
|
396
396
|
layer: e = "MIDDLE",
|
|
397
397
|
data: t,
|
|
398
398
|
xScaleId: n,
|
|
399
399
|
yScaleId: s,
|
|
400
400
|
xStrategy: o = "clip",
|
|
401
|
-
yStrategy:
|
|
402
|
-
radius:
|
|
401
|
+
yStrategy: i = "clip",
|
|
402
|
+
radius: r = 5,
|
|
403
403
|
style: c,
|
|
404
|
-
globalAlpha:
|
|
404
|
+
globalAlpha: u
|
|
405
405
|
}) => (j(
|
|
406
406
|
e,
|
|
407
407
|
({
|
|
408
|
-
ctx:
|
|
409
|
-
valToPos:
|
|
410
|
-
valFits:
|
|
408
|
+
ctx: l,
|
|
409
|
+
valToPos: p,
|
|
410
|
+
valFits: d,
|
|
411
411
|
clampXPosToChartArea: a,
|
|
412
|
-
clampYPosToChartArea:
|
|
412
|
+
clampYPosToChartArea: g
|
|
413
413
|
}) => {
|
|
414
|
-
|
|
415
|
-
const
|
|
416
|
-
U(u, c), l !== void 0 && (u.globalAlpha = l);
|
|
414
|
+
l.save(), U(l, c), u !== void 0 && (l.globalAlpha = u);
|
|
415
|
+
const f = [];
|
|
417
416
|
for (const y of t) {
|
|
418
|
-
let h,
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
417
|
+
let h = null, m = null;
|
|
418
|
+
const w = p(y.x, n);
|
|
419
|
+
if (w === null) continue;
|
|
420
|
+
if (o === "clip") {
|
|
421
|
+
if (!d(y.x, n)) continue;
|
|
422
|
+
h = w;
|
|
423
|
+
} else
|
|
424
|
+
h = a(w, "canvas");
|
|
425
|
+
const x = p(y.y, s);
|
|
426
|
+
if (x !== null) {
|
|
427
|
+
if (i === "clip") {
|
|
428
|
+
if (!d(y.y, s)) continue;
|
|
429
|
+
m = x;
|
|
430
|
+
} else
|
|
431
|
+
m = g(x, "canvas");
|
|
432
|
+
h === null || m === null || f.push({ x: h, y: m });
|
|
431
433
|
}
|
|
432
|
-
switch (r) {
|
|
433
|
-
case "clip":
|
|
434
|
-
if (!m(y.y, s))
|
|
435
|
-
continue;
|
|
436
|
-
g = f(y.y, s);
|
|
437
|
-
break;
|
|
438
|
-
case "clamp":
|
|
439
|
-
g = p(f(y.y, s), "canvas");
|
|
440
|
-
break;
|
|
441
|
-
}
|
|
442
|
-
h === null || g === null || (d.moveTo(h + i, g), d.arc(h, g, i, 0, Math.PI * 2));
|
|
443
434
|
}
|
|
444
|
-
|
|
435
|
+
if (c?.fillStyle)
|
|
436
|
+
for (const y of f)
|
|
437
|
+
l.beginPath(), l.arc(y.x, y.y, r, 0, Math.PI * 2), l.fill();
|
|
438
|
+
if (c?.strokeStyle) {
|
|
439
|
+
l.beginPath();
|
|
440
|
+
for (const y of f)
|
|
441
|
+
l.moveTo(y.x + r, y.y), l.arc(y.x, y.y, r, 0, Math.PI * 2);
|
|
442
|
+
l.stroke();
|
|
443
|
+
}
|
|
444
|
+
l.restore();
|
|
445
445
|
},
|
|
446
|
-
[t, n, s,
|
|
447
|
-
), null), Lt = D.memo(ot, F),
|
|
446
|
+
[t, n, s, r, c, u]
|
|
447
|
+
), null), Lt = D.memo(ot, F), it = ({
|
|
448
448
|
data: e,
|
|
449
449
|
xScaleId: t,
|
|
450
450
|
yScaleId: n,
|
|
451
451
|
style: s,
|
|
452
452
|
barWidth: o,
|
|
453
|
-
xPositionOffset:
|
|
454
|
-
|
|
455
|
-
|
|
453
|
+
xPositionOffset: i,
|
|
454
|
+
globalAlpha: r,
|
|
455
|
+
radius: c,
|
|
456
|
+
layer: u = "MIDDLE"
|
|
456
457
|
}) => (j(
|
|
457
|
-
|
|
458
|
+
u,
|
|
458
459
|
({
|
|
459
460
|
ctx: l,
|
|
460
|
-
valToPxDistance:
|
|
461
|
-
valToPos:
|
|
462
|
-
clampXPosToChartArea:
|
|
463
|
-
clampYPosToChartArea:
|
|
461
|
+
valToPxDistance: p,
|
|
462
|
+
valToPos: d,
|
|
463
|
+
clampXPosToChartArea: a,
|
|
464
|
+
clampYPosToChartArea: g
|
|
464
465
|
}) => {
|
|
465
466
|
if (e.length === 0) return;
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
);
|
|
477
|
-
if (g === null)
|
|
467
|
+
const f = g(
|
|
468
|
+
d(0, n, "canvas"),
|
|
469
|
+
"canvas"
|
|
470
|
+
);
|
|
471
|
+
if (f === null)
|
|
472
|
+
return;
|
|
473
|
+
const y = p(o, t, "canvas") ?? 0, h = [];
|
|
474
|
+
for (const m of e) {
|
|
475
|
+
const w = d(m.x, t, "canvas");
|
|
476
|
+
if (w === null)
|
|
478
477
|
continue;
|
|
479
|
-
const w =
|
|
480
|
-
|
|
478
|
+
const x = w - y / 2 + i * y, T = g(
|
|
479
|
+
d(m.y, n, "canvas"),
|
|
481
480
|
"canvas"
|
|
482
481
|
);
|
|
483
|
-
if (
|
|
482
|
+
if (T === null)
|
|
484
483
|
continue;
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
b,
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
484
|
+
const v = f - T, b = a(x, "canvas"), S = a(x + y, "canvas") - b;
|
|
485
|
+
h.push({
|
|
486
|
+
x: b,
|
|
487
|
+
y: T,
|
|
488
|
+
width: S,
|
|
489
|
+
height: v
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
if (l.save(), U(l, s), r !== void 0 && (l.globalAlpha = r), s?.fillStyle)
|
|
493
|
+
for (const m of h)
|
|
494
|
+
l.beginPath(), c ? l.roundRect(m.x, m.y, m.width, m.height, c) : l.rect(m.x, m.y, m.width, m.height), l.fill();
|
|
495
|
+
if (s?.strokeStyle) {
|
|
496
|
+
l.beginPath();
|
|
497
|
+
for (const m of h)
|
|
498
|
+
c ? l.roundRect(m.x, m.y, m.width, m.height, c) : l.rect(m.x, m.y, m.width, m.height);
|
|
499
|
+
l.stroke();
|
|
493
500
|
}
|
|
494
|
-
l.
|
|
501
|
+
l.restore();
|
|
495
502
|
},
|
|
496
|
-
[e, t, n, s, o,
|
|
497
|
-
), null), Ut = D.memo(
|
|
503
|
+
[e, t, n, s, o, i, c]
|
|
504
|
+
), null), Ut = D.memo(it, F), rt = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o }) => (j(
|
|
498
505
|
e,
|
|
499
|
-
({ ctx:
|
|
500
|
-
const
|
|
501
|
-
for (const
|
|
502
|
-
const a =
|
|
506
|
+
({ ctx: i, clampXPosToChartArea: r, clampYPosToChartArea: c, valToPos: u }) => {
|
|
507
|
+
const l = [];
|
|
508
|
+
for (const d of t) {
|
|
509
|
+
const a = r(u(d.x, n));
|
|
503
510
|
if (a === null)
|
|
504
511
|
continue;
|
|
505
|
-
const
|
|
506
|
-
if (
|
|
512
|
+
const g = c(u(d.y[0], s));
|
|
513
|
+
if (g === null)
|
|
507
514
|
continue;
|
|
508
|
-
const
|
|
509
|
-
|
|
515
|
+
const f = c(u(d.y[1], s));
|
|
516
|
+
f !== null && (l.push({ x: a, y: g }), l.unshift({ x: a, y: f }));
|
|
510
517
|
}
|
|
511
|
-
const
|
|
512
|
-
if (
|
|
513
|
-
|
|
514
|
-
for (const
|
|
515
|
-
|
|
516
|
-
|
|
518
|
+
const p = l[0];
|
|
519
|
+
if (p) {
|
|
520
|
+
i.save(), i.beginPath(), U(i, o), i.moveTo(p.x, p.y);
|
|
521
|
+
for (const d of l)
|
|
522
|
+
i.lineTo(d.x, d.y);
|
|
523
|
+
i.closePath(), i.fill(), i.restore();
|
|
517
524
|
}
|
|
518
525
|
},
|
|
519
526
|
[t, n, s, o]
|
|
520
|
-
), null), _t = D.memo(
|
|
527
|
+
), null), _t = D.memo(rt, F), ct = ({ layer: e = "MIDDLE", data: t, stroked: n, xScaleId: s, yScaleId: o, style: i }) => (j(
|
|
521
528
|
e,
|
|
522
|
-
({ ctx:
|
|
523
|
-
const
|
|
524
|
-
for (const
|
|
525
|
-
const y = c(
|
|
526
|
-
y === null || h === null ||
|
|
529
|
+
({ ctx: r, clampXPosToChartArea: c, clampYPosToChartArea: u, valToPos: l }) => {
|
|
530
|
+
const p = [];
|
|
531
|
+
for (const f of t) {
|
|
532
|
+
const y = c(l(f.x, s)), h = u(l(f.y, o));
|
|
533
|
+
y === null || h === null || p.push({ x: y, y: h });
|
|
527
534
|
}
|
|
528
|
-
const
|
|
529
|
-
if (!
|
|
535
|
+
const d = p.at(0), a = p.at(-1);
|
|
536
|
+
if (!d || !a)
|
|
530
537
|
return;
|
|
531
|
-
const
|
|
532
|
-
if (
|
|
533
|
-
|
|
534
|
-
for (const
|
|
535
|
-
|
|
536
|
-
if (
|
|
537
|
-
|
|
538
|
-
for (const
|
|
539
|
-
|
|
540
|
-
|
|
538
|
+
const g = u(l(0, o));
|
|
539
|
+
if (g !== null) {
|
|
540
|
+
r.save(), r.beginPath(), U(r, i), r.moveTo(d.x, g);
|
|
541
|
+
for (const f of p)
|
|
542
|
+
r.lineTo(f.x, f.y);
|
|
543
|
+
if (r.lineTo(a.x, g), r.closePath(), r.fill(), n) {
|
|
544
|
+
r.beginPath(), r.moveTo(d.x, d.y);
|
|
545
|
+
for (const f of p)
|
|
546
|
+
r.lineTo(f.x, f.y);
|
|
547
|
+
r.stroke();
|
|
541
548
|
}
|
|
542
|
-
|
|
549
|
+
r.restore();
|
|
543
550
|
}
|
|
544
551
|
},
|
|
545
|
-
[t, n, s, o,
|
|
552
|
+
[t, n, s, o, i]
|
|
546
553
|
), null), Xt = D.memo(ct, F), at = ({
|
|
547
554
|
layer: e = "BOTTOM",
|
|
548
555
|
scaleId: t,
|
|
549
556
|
tickStyle: n,
|
|
550
557
|
labelStyle: s,
|
|
551
558
|
labelGap: o,
|
|
552
|
-
tickSize:
|
|
553
|
-
ticks:
|
|
559
|
+
tickSize: i,
|
|
560
|
+
ticks: r
|
|
554
561
|
}) => (j(
|
|
555
562
|
e,
|
|
556
|
-
({ ctx: c, valToPos:
|
|
557
|
-
const
|
|
558
|
-
if (!
|
|
559
|
-
const a =
|
|
563
|
+
({ ctx: c, valToPos: u, getScale: l, frame: p }) => {
|
|
564
|
+
const d = l(t);
|
|
565
|
+
if (!d || !d.axis || d.origin !== "x") return;
|
|
566
|
+
const a = d.axis, g = a.position === "top" ? a.canvasRect.y + a.canvasRect.height : a.canvasRect.y, f = window.devicePixelRatio || 1, y = g, h = (i ?? 6) * f, m = a.position === "top" ? g - h : g + h, w = (o ?? 12) * f;
|
|
560
567
|
c.save(), c.fontKerning = "auto", U(c, {
|
|
561
568
|
...n
|
|
562
569
|
}), c.beginPath();
|
|
563
|
-
const x = Array.isArray(
|
|
564
|
-
for (const { value:
|
|
565
|
-
const v =
|
|
566
|
-
v !== null && (c.moveTo(v, y), c.lineTo(v,
|
|
570
|
+
const x = Array.isArray(r) ? r : r({ ...d, axis: a }, p);
|
|
571
|
+
for (const { value: T } of x) {
|
|
572
|
+
const v = u(T, t, "canvas");
|
|
573
|
+
v !== null && (c.moveTo(v, y), c.lineTo(v, m));
|
|
567
574
|
}
|
|
568
575
|
c.stroke(), c.restore(), c.save(), U(c, {
|
|
569
576
|
textBaseline: a.position === "top" ? "bottom" : "top",
|
|
@@ -573,36 +580,36 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
573
580
|
// alter font size for DPR
|
|
574
581
|
font: _e(s?.font ?? n?.font)
|
|
575
582
|
});
|
|
576
|
-
for (const { value:
|
|
577
|
-
const
|
|
578
|
-
if (
|
|
583
|
+
for (const { value: T, label: v } of x) {
|
|
584
|
+
const b = u(T, t, "canvas");
|
|
585
|
+
if (b === null)
|
|
579
586
|
continue;
|
|
580
|
-
const
|
|
587
|
+
const S = v.split(`
|
|
581
588
|
`);
|
|
582
|
-
for (let E = 0; E <
|
|
583
|
-
c.fillText(
|
|
589
|
+
for (let E = 0; E < S.length; E++)
|
|
590
|
+
c.fillText(S[E], b, m + f * 2 + E * w);
|
|
584
591
|
}
|
|
585
592
|
c.restore();
|
|
586
593
|
},
|
|
587
|
-
[
|
|
594
|
+
[r, t, n, s]
|
|
588
595
|
), null), Ft = D.memo(at, F), lt = ({
|
|
589
596
|
layer: e = "BOTTOM",
|
|
590
597
|
scaleId: t,
|
|
591
598
|
tickStyle: n,
|
|
592
599
|
labelStyle: s,
|
|
593
600
|
labelGap: o,
|
|
594
|
-
tickSize:
|
|
595
|
-
ticks:
|
|
601
|
+
tickSize: i,
|
|
602
|
+
ticks: r
|
|
596
603
|
}) => (j(
|
|
597
604
|
e,
|
|
598
|
-
({ ctx: c, valToPos:
|
|
599
|
-
const
|
|
600
|
-
if (!
|
|
601
|
-
const a =
|
|
605
|
+
({ ctx: c, valToPos: u, getScale: l, frame: p }) => {
|
|
606
|
+
const d = l(t);
|
|
607
|
+
if (!d || !d.axis || d.origin !== "y") return;
|
|
608
|
+
const a = d.axis, g = a.position === "left" ? a.canvasRect.x + a.canvasRect.width : a.canvasRect.x, f = g, y = i ?? 6, h = a.position === "left" ? g - y : g + y, m = o ?? 12, w = Array.isArray(r) ? r : r({ ...d, axis: a }, p);
|
|
602
609
|
c.save(), c.fontKerning = "auto", U(c, { ...n }), c.beginPath();
|
|
603
610
|
for (const { value: x } of w) {
|
|
604
|
-
const
|
|
605
|
-
|
|
611
|
+
const T = u(x, t, "canvas");
|
|
612
|
+
T !== null && (c.moveTo(f, T), c.lineTo(h, T));
|
|
606
613
|
}
|
|
607
614
|
c.stroke(), c.restore(), c.save(), U(c, {
|
|
608
615
|
textBaseline: "middle",
|
|
@@ -612,18 +619,18 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
612
619
|
// alter font size for DPR
|
|
613
620
|
font: _e(s?.font ?? n?.font)
|
|
614
621
|
});
|
|
615
|
-
for (const { value: x, label:
|
|
616
|
-
const v =
|
|
622
|
+
for (const { value: x, label: T } of w) {
|
|
623
|
+
const v = u(x, t, "canvas");
|
|
617
624
|
if (v === null)
|
|
618
625
|
continue;
|
|
619
|
-
const
|
|
626
|
+
const b = T.split(`
|
|
620
627
|
`);
|
|
621
|
-
for (let
|
|
622
|
-
c.fillText(` ${
|
|
628
|
+
for (let S = 0; S < b.length; S++)
|
|
629
|
+
c.fillText(` ${b[S]} `, h, v + S * m);
|
|
623
630
|
}
|
|
624
631
|
c.restore();
|
|
625
632
|
},
|
|
626
|
-
[
|
|
633
|
+
[r, t, n, s]
|
|
627
634
|
), null), Ot = D.memo(lt, F), _e = (e) => {
|
|
628
635
|
if (e)
|
|
629
636
|
try {
|
|
@@ -661,8 +668,8 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
661
668
|
const s = D.useRef(n);
|
|
662
669
|
s.current = n, D.useEffect(() => M[e].addEventListener(
|
|
663
670
|
t,
|
|
664
|
-
(
|
|
665
|
-
s.current(
|
|
671
|
+
(i, r) => {
|
|
672
|
+
s.current(r, i);
|
|
666
673
|
}
|
|
667
674
|
), [t, e, s]);
|
|
668
675
|
}, we = D.createContext(""), xe = (e, t) => {
|
|
@@ -670,23 +677,23 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
670
677
|
return L(e, n, t);
|
|
671
678
|
}, ut = (e, t, n, s, o) => {
|
|
672
679
|
if (!t) return;
|
|
673
|
-
const
|
|
674
|
-
scaleId: r,
|
|
675
|
-
value: _(n, c, r, "css")
|
|
676
|
-
} : null, u = e.clientY - t.top, f = i ? {
|
|
680
|
+
const i = s ?? n.scales.find((d) => d.origin === "x")?.id, r = o ?? n.scales.find((d) => d.origin === "y")?.id, c = e.clientX - t.left, u = i ? {
|
|
677
681
|
scaleId: i,
|
|
678
|
-
value: _(n,
|
|
682
|
+
value: _(n, c, i, "css")
|
|
683
|
+
} : null, l = e.clientY - t.top, p = r ? {
|
|
684
|
+
scaleId: r,
|
|
685
|
+
value: _(n, l, r, "css")
|
|
679
686
|
} : null;
|
|
680
|
-
return { pointerSyncPosition: { x:
|
|
687
|
+
return { pointerSyncPosition: { x: u, y: p }, cssX: c, cssY: l };
|
|
681
688
|
}, N = (e, t) => {
|
|
682
|
-
const { x: n, y: s } = e, o = n && t.scales.some((
|
|
689
|
+
const { x: n, y: s } = e, o = n && t.scales.some((r) => r.id === n.scaleId) ? G(t, n.value, n.scaleId, "css") : null, i = s && t.scales.some((r) => r.id === s.scaleId) ? G(t, s.value, s.scaleId, "css") : null;
|
|
683
690
|
return {
|
|
684
691
|
cssX: o,
|
|
685
|
-
cssY:
|
|
692
|
+
cssY: i,
|
|
686
693
|
scaled: Object.fromEntries(
|
|
687
|
-
t.scales.flatMap((
|
|
688
|
-
const c =
|
|
689
|
-
return c === null ? [] : [[
|
|
694
|
+
t.scales.flatMap((r) => {
|
|
695
|
+
const c = r.origin === "y" ? i : o;
|
|
696
|
+
return c === null ? [] : [[r.id, _(t, c, r.id, "css")]];
|
|
690
697
|
})
|
|
691
698
|
)
|
|
692
699
|
};
|
|
@@ -704,16 +711,16 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
704
711
|
);
|
|
705
712
|
if (s === null || o === null)
|
|
706
713
|
return null;
|
|
707
|
-
const
|
|
708
|
-
(
|
|
709
|
-
if (
|
|
714
|
+
const i = n.scales.flatMap(
|
|
715
|
+
(r) => {
|
|
716
|
+
if (r.origin !== e)
|
|
710
717
|
return [];
|
|
711
|
-
const c = _(n, s,
|
|
712
|
-
return c === null ||
|
|
718
|
+
const c = _(n, s, r.id, "css"), u = _(n, o, r.id, "css");
|
|
719
|
+
return c === null || u === null ? [] : [
|
|
713
720
|
{
|
|
714
|
-
scaleId:
|
|
721
|
+
scaleId: r.id,
|
|
715
722
|
from: c,
|
|
716
|
-
to:
|
|
723
|
+
to: u
|
|
717
724
|
}
|
|
718
725
|
];
|
|
719
726
|
}
|
|
@@ -721,7 +728,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
721
728
|
return {
|
|
722
729
|
fromCSS: s,
|
|
723
730
|
toCSS: o,
|
|
724
|
-
scaled:
|
|
731
|
+
scaled: i
|
|
725
732
|
};
|
|
726
733
|
}, Kt = ({
|
|
727
734
|
id: e,
|
|
@@ -729,51 +736,51 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
729
736
|
onDblClick: n,
|
|
730
737
|
onMouseMove: s,
|
|
731
738
|
onMouseDown: o,
|
|
732
|
-
onMouseUp:
|
|
733
|
-
onDocumentMouseUp:
|
|
739
|
+
onMouseUp: i,
|
|
740
|
+
onDocumentMouseUp: r,
|
|
734
741
|
onSpanSelect: c,
|
|
735
|
-
onContextMenu:
|
|
736
|
-
className:
|
|
737
|
-
style:
|
|
738
|
-
sync:
|
|
742
|
+
onContextMenu: u,
|
|
743
|
+
className: l,
|
|
744
|
+
style: p,
|
|
745
|
+
sync: d,
|
|
739
746
|
innerChildren: a,
|
|
740
|
-
children:
|
|
747
|
+
children: g
|
|
741
748
|
}) => {
|
|
742
|
-
const
|
|
743
|
-
return L("dblclick",
|
|
749
|
+
const f = He();
|
|
750
|
+
return L("dblclick", f, (y) => {
|
|
744
751
|
n?.(y);
|
|
745
|
-
}), L("click",
|
|
752
|
+
}), L("click", f, (y) => {
|
|
746
753
|
t?.(y);
|
|
747
|
-
}), L("move",
|
|
754
|
+
}), L("move", f, (y) => {
|
|
748
755
|
s?.(y);
|
|
749
|
-
}), L("mousedown",
|
|
756
|
+
}), L("mousedown", f, (y) => {
|
|
750
757
|
o?.(y);
|
|
751
|
-
}), L("mouseup",
|
|
752
|
-
r?.(y);
|
|
753
|
-
}), L("documentmouseup", d, (y) => {
|
|
758
|
+
}), L("mouseup", f, (y) => {
|
|
754
759
|
i?.(y);
|
|
755
|
-
}), L("
|
|
760
|
+
}), L("documentmouseup", f, (y) => {
|
|
761
|
+
r?.(y);
|
|
762
|
+
}), L("spanselect", f, (y) => {
|
|
756
763
|
c?.(y);
|
|
757
|
-
}), L("contextmenu",
|
|
758
|
-
|
|
759
|
-
}), /* @__PURE__ */ pe(we.Provider, { value:
|
|
764
|
+
}), L("contextmenu", f, (y) => {
|
|
765
|
+
u?.(y);
|
|
766
|
+
}), /* @__PURE__ */ pe(we.Provider, { value: f, children: [
|
|
760
767
|
/* @__PURE__ */ R(
|
|
761
768
|
ht,
|
|
762
769
|
{
|
|
763
770
|
id: e,
|
|
764
|
-
className:
|
|
765
|
-
style:
|
|
766
|
-
sync:
|
|
771
|
+
className: l,
|
|
772
|
+
style: p,
|
|
773
|
+
sync: d,
|
|
767
774
|
children: a
|
|
768
775
|
}
|
|
769
776
|
),
|
|
770
|
-
|
|
777
|
+
g
|
|
771
778
|
] });
|
|
772
779
|
}, ht = ({ id: e, className: t, style: n, sync: s, children: o }) => {
|
|
773
|
-
const
|
|
774
|
-
c.current =
|
|
775
|
-
const
|
|
776
|
-
const h =
|
|
780
|
+
const i = k(null), r = Ue().frame, c = k(r);
|
|
781
|
+
c.current = r;
|
|
782
|
+
const u = q(we), l = s?.key || u, p = k(null), d = k(null), a = k(null), g = () => {
|
|
783
|
+
const h = i.current?.parentElement;
|
|
777
784
|
if (h) {
|
|
778
785
|
if (h.dataset.canplotroot === void 0)
|
|
779
786
|
throw new Error(
|
|
@@ -781,15 +788,15 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
781
788
|
);
|
|
782
789
|
return h.getBoundingClientRect();
|
|
783
790
|
}
|
|
784
|
-
},
|
|
791
|
+
}, f = (h, m) => {
|
|
785
792
|
const w = ut(
|
|
786
793
|
h,
|
|
787
|
-
|
|
794
|
+
g(),
|
|
788
795
|
c.current,
|
|
789
796
|
s?.xViaScaleId,
|
|
790
797
|
s?.yViaScaleId
|
|
791
798
|
);
|
|
792
|
-
w &&
|
|
799
|
+
w && m(
|
|
793
800
|
w.pointerSyncPosition,
|
|
794
801
|
{ cssX: w.cssX, cssY: w.cssY },
|
|
795
802
|
{
|
|
@@ -799,14 +806,14 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
799
806
|
metaKey: h.metaKey
|
|
800
807
|
}
|
|
801
808
|
);
|
|
802
|
-
}, y =
|
|
803
|
-
return y.current =
|
|
809
|
+
}, y = k(f);
|
|
810
|
+
return y.current = f, ke(() => {
|
|
804
811
|
const h = (v) => {
|
|
805
|
-
const
|
|
806
|
-
|
|
807
|
-
...
|
|
812
|
+
const b = d.current;
|
|
813
|
+
b && M.spanselect.dispatchEvent(u, {
|
|
814
|
+
...b,
|
|
808
815
|
completed: !0
|
|
809
|
-
}), M.documentmouseup.dispatchEvent(
|
|
816
|
+
}), M.documentmouseup.dispatchEvent(u, {
|
|
810
817
|
frame: c.current,
|
|
811
818
|
keys: {
|
|
812
819
|
ctrlKey: v.ctrlKey,
|
|
@@ -815,38 +822,38 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
815
822
|
metaKey: v.metaKey
|
|
816
823
|
}
|
|
817
824
|
});
|
|
818
|
-
},
|
|
819
|
-
const
|
|
825
|
+
}, m = (v) => {
|
|
826
|
+
const b = {
|
|
820
827
|
ctrlKey: v.ctrlKey,
|
|
821
828
|
altKey: v.altKey,
|
|
822
829
|
shiftKey: v.shiftKey,
|
|
823
830
|
metaKey: v.metaKey
|
|
824
|
-
},
|
|
825
|
-
if (
|
|
826
|
-
([
|
|
831
|
+
}, S = a.current;
|
|
832
|
+
if (S && Object.entries(b).some(
|
|
833
|
+
([C, P]) => S.keys[C] !== P
|
|
827
834
|
)) {
|
|
828
|
-
const
|
|
829
|
-
a.current =
|
|
835
|
+
const C = { ...S, keys: b };
|
|
836
|
+
a.current = C, M.sync_move.dispatchEvent(l, C);
|
|
830
837
|
}
|
|
831
|
-
const E =
|
|
832
|
-
if (E && Object.entries(
|
|
833
|
-
([
|
|
838
|
+
const E = d.current;
|
|
839
|
+
if (E && Object.entries(b).some(
|
|
840
|
+
([C, P]) => E.keys[C] !== P
|
|
834
841
|
)) {
|
|
835
842
|
v.stopPropagation(), v.preventDefault();
|
|
836
|
-
const
|
|
837
|
-
|
|
843
|
+
const C = { ...E, keys: b };
|
|
844
|
+
d.current = C, M.spanselect.dispatchEvent(u, C);
|
|
838
845
|
}
|
|
839
846
|
}, w = (v) => {
|
|
840
847
|
y.current(
|
|
841
848
|
v,
|
|
842
|
-
(
|
|
843
|
-
const P =
|
|
844
|
-
if (!P || !
|
|
845
|
-
const
|
|
849
|
+
(b, { cssX: S, cssY: E }, C) => {
|
|
850
|
+
const P = p.current;
|
|
851
|
+
if (!P || !b.x || !b.y) return;
|
|
852
|
+
const A = c.current, z = P.xRangeCss.start, ae = S, le = P.yRangeCss.start, ue = E, J = X(A, b.x.scaleId);
|
|
846
853
|
if (!J) return;
|
|
847
|
-
const Q = X(
|
|
854
|
+
const Q = X(A, b.y.scaleId);
|
|
848
855
|
if (!Q) return;
|
|
849
|
-
|
|
856
|
+
p.current = {
|
|
850
857
|
xRangeCss: { start: z, end: ae },
|
|
851
858
|
yRangeCss: { start: le, end: ue }
|
|
852
859
|
};
|
|
@@ -854,28 +861,28 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
854
861
|
const he = Math.abs(le - ue), de = Math.abs(z - ae);
|
|
855
862
|
he < 10 && de < 10 ? W = "below_threshold" : he > 30 && de > 30 ? W = "box" : he > de ? W = "y" : W = "x";
|
|
856
863
|
const Te = _(
|
|
857
|
-
|
|
864
|
+
A,
|
|
858
865
|
V(c.current, z, "css"),
|
|
859
866
|
J.id,
|
|
860
867
|
"css"
|
|
861
868
|
);
|
|
862
869
|
if (Te === null) return;
|
|
863
|
-
const
|
|
864
|
-
|
|
870
|
+
const Se = _(
|
|
871
|
+
A,
|
|
865
872
|
V(c.current, ae, "css"),
|
|
866
873
|
J.id,
|
|
867
874
|
"css"
|
|
868
875
|
);
|
|
869
|
-
if (
|
|
870
|
-
const
|
|
871
|
-
|
|
876
|
+
if (Se === null) return;
|
|
877
|
+
const Ce = _(
|
|
878
|
+
A,
|
|
872
879
|
H(c.current, le, "css"),
|
|
873
880
|
Q.id,
|
|
874
881
|
"css"
|
|
875
882
|
);
|
|
876
|
-
if (
|
|
883
|
+
if (Ce === null) return;
|
|
877
884
|
const Pe = _(
|
|
878
|
-
|
|
885
|
+
A,
|
|
879
886
|
H(c.current, ue, "css"),
|
|
880
887
|
Q.id,
|
|
881
888
|
"css"
|
|
@@ -883,11 +890,11 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
883
890
|
if (Pe === null) return;
|
|
884
891
|
const ee = Ee(
|
|
885
892
|
"x",
|
|
886
|
-
{ scaleId: J.id, from: Te, to:
|
|
893
|
+
{ scaleId: J.id, from: Te, to: Se },
|
|
887
894
|
c.current
|
|
888
895
|
), te = Ee(
|
|
889
896
|
"y",
|
|
890
|
-
{ scaleId: Q.id, from:
|
|
897
|
+
{ scaleId: Q.id, from: Ce, to: Pe },
|
|
891
898
|
c.current
|
|
892
899
|
), Ke = ee?.scaled, Ye = te?.scaled, Me = {
|
|
893
900
|
mode: W,
|
|
@@ -907,65 +914,65 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
907
914
|
} : void 0,
|
|
908
915
|
scaled: Ye ?? []
|
|
909
916
|
},
|
|
910
|
-
keys:
|
|
917
|
+
keys: C
|
|
911
918
|
};
|
|
912
|
-
|
|
913
|
-
|
|
919
|
+
d.current = Me, M.spanselect.dispatchEvent(
|
|
920
|
+
u,
|
|
914
921
|
Me
|
|
915
922
|
);
|
|
916
923
|
}
|
|
917
924
|
);
|
|
918
925
|
}, x = (v) => {
|
|
919
|
-
y.current(v, (
|
|
920
|
-
const
|
|
921
|
-
|
|
926
|
+
y.current(v, (b, S, E) => {
|
|
927
|
+
const C = N(
|
|
928
|
+
b,
|
|
922
929
|
c.current
|
|
923
930
|
);
|
|
924
|
-
if (!
|
|
925
|
-
if (Object.values(E).some((
|
|
931
|
+
if (!C) return;
|
|
932
|
+
if (Object.values(E).some((A) => A)) {
|
|
926
933
|
v.preventDefault();
|
|
927
|
-
const
|
|
928
|
-
M.pressandwheel.dispatchEvent(
|
|
929
|
-
pointer:
|
|
934
|
+
const A = Math.abs(v.deltaY) > Math.abs(v.deltaX) ? v.deltaY : v.deltaX;
|
|
935
|
+
M.pressandwheel.dispatchEvent(u, {
|
|
936
|
+
pointer: C,
|
|
930
937
|
frame: c.current,
|
|
931
938
|
keys: E,
|
|
932
939
|
deltaX: v.deltaX,
|
|
933
940
|
deltaY: v.deltaY,
|
|
934
|
-
deltaAbs:
|
|
941
|
+
deltaAbs: A
|
|
935
942
|
});
|
|
936
943
|
}
|
|
937
944
|
});
|
|
938
945
|
};
|
|
939
|
-
document.addEventListener("mouseup", h), document.addEventListener("keydown",
|
|
940
|
-
const
|
|
941
|
-
return
|
|
946
|
+
document.addEventListener("mouseup", h), document.addEventListener("keydown", m), document.addEventListener("keyup", m), document.addEventListener("mousemove", w);
|
|
947
|
+
const T = i.current;
|
|
948
|
+
return T?.addEventListener("wheel", x, {
|
|
942
949
|
passive: !1
|
|
943
950
|
}), () => {
|
|
944
|
-
document.removeEventListener("mouseup", h), document.removeEventListener("keydown",
|
|
951
|
+
document.removeEventListener("mouseup", h), document.removeEventListener("keydown", m), document.removeEventListener("keyup", m), document.removeEventListener("mousemove", w), T?.removeEventListener("wheel", x);
|
|
945
952
|
};
|
|
946
|
-
}, [c,
|
|
947
|
-
const
|
|
953
|
+
}, [c, u, l, y]), L("sync_move", l, (h) => {
|
|
954
|
+
const m = h.positions ? N(
|
|
948
955
|
h.positions,
|
|
949
956
|
c.current
|
|
950
957
|
) : null;
|
|
951
|
-
a.current = h, M.move.dispatchEvent(
|
|
958
|
+
a.current = h, M.move.dispatchEvent(u, {
|
|
952
959
|
frame: c.current,
|
|
953
|
-
pointer:
|
|
960
|
+
pointer: m ?? null,
|
|
954
961
|
keys: h.keys,
|
|
955
|
-
source: h.originInteractionsId ===
|
|
962
|
+
source: h.originInteractionsId === u ? "own" : "sync"
|
|
956
963
|
});
|
|
957
964
|
}), /* @__PURE__ */ R(
|
|
958
965
|
"div",
|
|
959
966
|
{
|
|
960
|
-
ref:
|
|
967
|
+
ref: i,
|
|
961
968
|
id: e,
|
|
962
969
|
className: t,
|
|
963
970
|
style: {
|
|
964
971
|
position: "absolute",
|
|
965
|
-
left:
|
|
966
|
-
top:
|
|
967
|
-
width:
|
|
968
|
-
height:
|
|
972
|
+
left: r.chartAreaCSS.x,
|
|
973
|
+
top: r.chartAreaCSS.y,
|
|
974
|
+
width: r.chartAreaCSS.width,
|
|
975
|
+
height: r.chartAreaCSS.height,
|
|
969
976
|
zIndex: 25,
|
|
970
977
|
...n
|
|
971
978
|
},
|
|
@@ -973,102 +980,102 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
973
980
|
h.preventDefault();
|
|
974
981
|
},
|
|
975
982
|
onClick: (h) => {
|
|
976
|
-
|
|
977
|
-
const
|
|
978
|
-
|
|
983
|
+
f(h, (m, w, x) => {
|
|
984
|
+
const T = N(
|
|
985
|
+
m,
|
|
979
986
|
c.current
|
|
980
987
|
);
|
|
981
|
-
|
|
982
|
-
pointer:
|
|
988
|
+
T && M.click.dispatchEvent(u, {
|
|
989
|
+
pointer: T,
|
|
983
990
|
frame: c.current,
|
|
984
991
|
keys: x
|
|
985
992
|
});
|
|
986
993
|
});
|
|
987
994
|
},
|
|
988
995
|
onMouseLeave: (h) => {
|
|
989
|
-
|
|
990
|
-
M.sync_move.dispatchEvent(
|
|
996
|
+
f(h, (m, w, x) => {
|
|
997
|
+
M.sync_move.dispatchEvent(l, {
|
|
991
998
|
positions: null,
|
|
992
999
|
keys: x,
|
|
993
|
-
originInteractionsId:
|
|
1000
|
+
originInteractionsId: u
|
|
994
1001
|
});
|
|
995
1002
|
});
|
|
996
1003
|
},
|
|
997
1004
|
onMouseMove: (h) => {
|
|
998
|
-
|
|
999
|
-
M.sync_move.dispatchEvent(
|
|
1000
|
-
positions:
|
|
1005
|
+
f(h, (m, w, x) => {
|
|
1006
|
+
M.sync_move.dispatchEvent(l, {
|
|
1007
|
+
positions: m,
|
|
1001
1008
|
keys: x,
|
|
1002
|
-
originInteractionsId:
|
|
1009
|
+
originInteractionsId: u
|
|
1003
1010
|
});
|
|
1004
1011
|
});
|
|
1005
1012
|
},
|
|
1006
1013
|
onMouseDown: (h) => {
|
|
1007
|
-
|
|
1014
|
+
f(h, (m, { cssX: w, cssY: x }, T) => {
|
|
1008
1015
|
const v = N(
|
|
1009
|
-
|
|
1016
|
+
m,
|
|
1010
1017
|
c.current
|
|
1011
1018
|
);
|
|
1012
|
-
v && (M.mousedown.dispatchEvent(
|
|
1019
|
+
v && (M.mousedown.dispatchEvent(u, {
|
|
1013
1020
|
pointer: v,
|
|
1014
1021
|
frame: c.current,
|
|
1015
|
-
keys:
|
|
1016
|
-
}),
|
|
1022
|
+
keys: T
|
|
1023
|
+
}), p.current = {
|
|
1017
1024
|
xRangeCss: { start: w, end: w },
|
|
1018
1025
|
yRangeCss: { start: x, end: x }
|
|
1019
1026
|
});
|
|
1020
1027
|
});
|
|
1021
1028
|
},
|
|
1022
1029
|
onMouseUp: (h) => {
|
|
1023
|
-
|
|
1024
|
-
const
|
|
1025
|
-
|
|
1030
|
+
f(h, (m, w, x) => {
|
|
1031
|
+
const T = N(
|
|
1032
|
+
m,
|
|
1026
1033
|
c.current
|
|
1027
1034
|
);
|
|
1028
|
-
if (!
|
|
1029
|
-
M.mouseup.dispatchEvent(
|
|
1035
|
+
if (!T) return;
|
|
1036
|
+
M.mouseup.dispatchEvent(u, {
|
|
1030
1037
|
frame: c.current,
|
|
1031
|
-
pointer:
|
|
1038
|
+
pointer: T,
|
|
1032
1039
|
keys: x
|
|
1033
1040
|
});
|
|
1034
|
-
const v =
|
|
1035
|
-
|
|
1036
|
-
const
|
|
1037
|
-
if (
|
|
1038
|
-
const
|
|
1041
|
+
const v = d.current;
|
|
1042
|
+
d.current = null;
|
|
1043
|
+
const b = p.current;
|
|
1044
|
+
if (p.current = null, b && v) {
|
|
1045
|
+
const S = {
|
|
1039
1046
|
...v,
|
|
1040
1047
|
keys: x,
|
|
1041
1048
|
completed: !0
|
|
1042
1049
|
};
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1050
|
+
d.current = null, M.spanselect.dispatchEvent(
|
|
1051
|
+
u,
|
|
1052
|
+
S
|
|
1046
1053
|
);
|
|
1047
1054
|
}
|
|
1048
1055
|
});
|
|
1049
1056
|
},
|
|
1050
1057
|
onContextMenu: (h) => {
|
|
1051
|
-
h.preventDefault(),
|
|
1052
|
-
const
|
|
1053
|
-
|
|
1058
|
+
h.preventDefault(), f(h, (m, w, x) => {
|
|
1059
|
+
const T = N(
|
|
1060
|
+
m,
|
|
1054
1061
|
c.current
|
|
1055
1062
|
);
|
|
1056
|
-
|
|
1063
|
+
T && M.contextmenu.dispatchEvent(u, {
|
|
1057
1064
|
frame: c.current,
|
|
1058
|
-
pointer:
|
|
1065
|
+
pointer: T,
|
|
1059
1066
|
keys: x
|
|
1060
1067
|
});
|
|
1061
1068
|
});
|
|
1062
1069
|
},
|
|
1063
1070
|
onDoubleClick: (h) => {
|
|
1064
|
-
|
|
1065
|
-
const
|
|
1066
|
-
|
|
1071
|
+
f(h, (m, w, x) => {
|
|
1072
|
+
const T = N(
|
|
1073
|
+
m,
|
|
1067
1074
|
c.current
|
|
1068
1075
|
);
|
|
1069
|
-
|
|
1076
|
+
T && M.dblclick.dispatchEvent(u, {
|
|
1070
1077
|
frame: c.current,
|
|
1071
|
-
pointer:
|
|
1078
|
+
pointer: T,
|
|
1072
1079
|
keys: x
|
|
1073
1080
|
});
|
|
1074
1081
|
});
|
|
@@ -1078,49 +1085,49 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1078
1085
|
);
|
|
1079
1086
|
}, Yt = ({ data: e, renderTooltip: t, xScaleId: n }) => {
|
|
1080
1087
|
const [s, o] = B(null);
|
|
1081
|
-
xe("move", (
|
|
1082
|
-
o(
|
|
1088
|
+
xe("move", (r) => {
|
|
1089
|
+
o(r);
|
|
1083
1090
|
});
|
|
1084
|
-
const
|
|
1091
|
+
const i = Z(() => {
|
|
1085
1092
|
if (!s)
|
|
1086
1093
|
return null;
|
|
1087
|
-
const { frame:
|
|
1088
|
-
if (
|
|
1094
|
+
const { frame: r, pointer: c } = s, u = c?.scaled[n];
|
|
1095
|
+
if (u === void 0 || !X(r, n))
|
|
1089
1096
|
return null;
|
|
1090
|
-
const
|
|
1091
|
-
let
|
|
1097
|
+
const p = [];
|
|
1098
|
+
let d = u;
|
|
1092
1099
|
for (const a of e) {
|
|
1093
|
-
let
|
|
1094
|
-
for (const [
|
|
1095
|
-
if (!fe(
|
|
1100
|
+
let g = null, f = 1 / 0;
|
|
1101
|
+
for (const [m, w] of a.points.entries()) {
|
|
1102
|
+
if (!fe(r, w.x, n) || !fe(r, w.y, a.yScaleId))
|
|
1096
1103
|
continue;
|
|
1097
|
-
const x = Math.abs(w.x -
|
|
1098
|
-
x <
|
|
1104
|
+
const x = Math.abs(w.x - u);
|
|
1105
|
+
x < f && (f = x, g = m);
|
|
1099
1106
|
}
|
|
1100
|
-
const y = a.points[
|
|
1107
|
+
const y = a.points[g ?? -1], h = ge(r, f, n, "css");
|
|
1101
1108
|
if (!y || h === null || h > 30) {
|
|
1102
|
-
|
|
1109
|
+
p.push({ seriesId: a.seriesId, y: null });
|
|
1103
1110
|
continue;
|
|
1104
1111
|
}
|
|
1105
|
-
|
|
1112
|
+
d = y.x, p.push({
|
|
1106
1113
|
seriesId: a.seriesId,
|
|
1107
1114
|
y: y.y
|
|
1108
1115
|
});
|
|
1109
1116
|
}
|
|
1110
1117
|
return {
|
|
1111
|
-
frame:
|
|
1112
|
-
x:
|
|
1113
|
-
points:
|
|
1118
|
+
frame: r,
|
|
1119
|
+
x: d,
|
|
1120
|
+
points: p
|
|
1114
1121
|
};
|
|
1115
1122
|
}, [e, s, n]);
|
|
1116
|
-
return t(
|
|
1123
|
+
return t(i);
|
|
1117
1124
|
}, Bt = ({ makeXStyle: e, makeXClassName: t, makeYStyle: n, makeYClassName: s }) => {
|
|
1118
|
-
const [o,
|
|
1125
|
+
const [o, i] = B(null);
|
|
1119
1126
|
if (xe("move", (a) => {
|
|
1120
|
-
|
|
1127
|
+
i(a);
|
|
1121
1128
|
}), !o)
|
|
1122
1129
|
return null;
|
|
1123
|
-
const { frame:
|
|
1130
|
+
const { frame: r, pointer: c } = o, u = c?.cssX ?? null, l = c?.cssY ?? null, p = u ? V(r, u, "css") : 0, d = l ? H(r, l, "css") : 0;
|
|
1124
1131
|
return /* @__PURE__ */ pe(Ne, { children: [
|
|
1125
1132
|
/* @__PURE__ */ R(
|
|
1126
1133
|
"div",
|
|
@@ -1130,15 +1137,15 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1130
1137
|
style: {
|
|
1131
1138
|
position: "absolute",
|
|
1132
1139
|
left: 0,
|
|
1133
|
-
visibility:
|
|
1134
|
-
top:
|
|
1135
|
-
height:
|
|
1140
|
+
visibility: u === null ? "hidden" : "visible",
|
|
1141
|
+
top: r.chartAreaCSS.y,
|
|
1142
|
+
height: r.chartAreaCSS.height,
|
|
1136
1143
|
borderColor: "red",
|
|
1137
1144
|
borderLeftWidth: "1px",
|
|
1138
1145
|
borderLeftStyle: "solid",
|
|
1139
1146
|
pointerEvents: "none",
|
|
1140
1147
|
opacity: c ? 1 : 0,
|
|
1141
|
-
transform: `translateX(${
|
|
1148
|
+
transform: `translateX(${p}px)`,
|
|
1142
1149
|
...e?.(o)
|
|
1143
1150
|
}
|
|
1144
1151
|
}
|
|
@@ -1150,15 +1157,15 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1150
1157
|
"data-show": !!c,
|
|
1151
1158
|
style: {
|
|
1152
1159
|
position: "absolute",
|
|
1153
|
-
visibility:
|
|
1160
|
+
visibility: l === null ? "hidden" : "visible",
|
|
1154
1161
|
top: 0,
|
|
1155
1162
|
height: 0,
|
|
1156
1163
|
borderTop: "solid 1px red",
|
|
1157
|
-
left:
|
|
1158
|
-
width:
|
|
1164
|
+
left: r.chartAreaCSS.x,
|
|
1165
|
+
width: r.chartAreaCSS.width,
|
|
1159
1166
|
pointerEvents: "none",
|
|
1160
1167
|
opacity: c ? 1 : 0,
|
|
1161
|
-
transform: `translateY(${
|
|
1168
|
+
transform: `translateY(${d}px)`,
|
|
1162
1169
|
...n?.(o)
|
|
1163
1170
|
}
|
|
1164
1171
|
}
|
|
@@ -1166,16 +1173,16 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1166
1173
|
] });
|
|
1167
1174
|
}, zt = ({ makeClassName: e, makeStyle: t }) => {
|
|
1168
1175
|
const [n, s] = B(null);
|
|
1169
|
-
xe("spanselect", (
|
|
1176
|
+
xe("spanselect", (i) => {
|
|
1170
1177
|
s(
|
|
1171
|
-
|
|
1178
|
+
i.mode === "below_threshold" || i.completed ? null : i
|
|
1172
1179
|
);
|
|
1173
1180
|
});
|
|
1174
1181
|
const o = Z(() => {
|
|
1175
1182
|
if (!n || n.mode === "below_threshold")
|
|
1176
1183
|
return null;
|
|
1177
|
-
const
|
|
1178
|
-
return { leftPx:
|
|
1184
|
+
const i = n.mode === "y" ? -1 / 0 : n.x.css?.from ?? -1 / 0, r = n.mode === "y" ? 1 / 0 : n.x.css?.to ?? 1 / 0, c = n.mode === "x" ? -1 / 0 : n.y.css?.from ?? -1 / 0, u = n.mode === "x" ? 1 / 0 : n.y.css?.to ?? 1 / 0, l = V(n.frame, i, "css"), p = V(n.frame, r, "css"), d = H(n.frame, c, "css"), a = H(n.frame, u, "css"), g = Math.min(l, p), f = Math.min(d, a), y = Math.abs(p - l), h = Math.abs(a - d);
|
|
1185
|
+
return { leftPx: g, topPx: f, widthPx: y, heightPx: h };
|
|
1179
1186
|
}, [n]);
|
|
1180
1187
|
return /* @__PURE__ */ R(
|
|
1181
1188
|
"div",
|
|
@@ -1216,22 +1223,22 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1216
1223
|
formatter: t,
|
|
1217
1224
|
acceptableIncrements: n
|
|
1218
1225
|
} = {}) => (s, o) => {
|
|
1219
|
-
const { min:
|
|
1226
|
+
const { min: i, max: r } = s, c = [], u = window.devicePixelRatio || 1, l = (e ?? (s.origin === "x" ? Xe : dt)) * u, p = We(
|
|
1220
1227
|
o,
|
|
1221
|
-
|
|
1228
|
+
l,
|
|
1222
1229
|
s.id,
|
|
1223
1230
|
"canvas"
|
|
1224
1231
|
);
|
|
1225
|
-
if (
|
|
1232
|
+
if (p === null)
|
|
1226
1233
|
return [];
|
|
1227
|
-
const
|
|
1228
|
-
let
|
|
1229
|
-
if (Math.abs(
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1234
|
+
const d = n ?? ne, a = d.find((f) => f > p) ?? d.at(-1) ?? 1;
|
|
1235
|
+
let g = i;
|
|
1236
|
+
if (Math.abs(g % a) > Number.EPSILON) {
|
|
1237
|
+
const f = (a - g % a) % a;
|
|
1238
|
+
g += f;
|
|
1232
1239
|
}
|
|
1233
|
-
for (;
|
|
1234
|
-
c.push(
|
|
1240
|
+
for (; g <= r && c.length < 1e3; )
|
|
1241
|
+
c.push(g), g += a;
|
|
1235
1242
|
return (t ?? mt)(c);
|
|
1236
1243
|
}, mt = (e) => {
|
|
1237
1244
|
const t = Math.max(0, Math.ceil(-Math.log10(e[1] - e[0])));
|
|
@@ -1239,7 +1246,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1239
1246
|
}, ne = [];
|
|
1240
1247
|
for (let e = -12; e <= 12; e++)
|
|
1241
1248
|
ne.push(1 * 10 ** e), ne.push(2 * 10 ** e), ne.push(5 * 10 ** e);
|
|
1242
|
-
const pt = 1, Oe = 1e3 * pt, be = 60 * Oe,
|
|
1249
|
+
const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, re = 60 * be, ce = 24 * re, yt = 30 * ce, gt = 365 * ce, vt = [
|
|
1243
1250
|
// second divisors
|
|
1244
1251
|
[1, "milliseconds"],
|
|
1245
1252
|
[2, "milliseconds"],
|
|
@@ -1301,7 +1308,7 @@ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, ie = 60 * be, ce = 24 * ie, yt = 30 *
|
|
|
1301
1308
|
case "minutes":
|
|
1302
1309
|
return t * be;
|
|
1303
1310
|
case "hours":
|
|
1304
|
-
return t *
|
|
1311
|
+
return t * re;
|
|
1305
1312
|
case "days":
|
|
1306
1313
|
return t * ce;
|
|
1307
1314
|
case "months":
|
|
@@ -1321,10 +1328,10 @@ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, ie = 60 * be, ce = 24 * ie, yt = 30 *
|
|
|
1321
1328
|
}, Tt = (e, t) => {
|
|
1322
1329
|
const n = new Date(e);
|
|
1323
1330
|
return n.setUTCHours(n.getUTCHours() + t), n.getTime();
|
|
1324
|
-
},
|
|
1331
|
+
}, St = (e, t) => {
|
|
1325
1332
|
const n = new Date(e);
|
|
1326
1333
|
return n.setUTCDate(n.getUTCDate() + t), n.getTime();
|
|
1327
|
-
},
|
|
1334
|
+
}, Ae = (e, t) => {
|
|
1328
1335
|
const n = new Date(e);
|
|
1329
1336
|
return n.setUTCMonth(n.getUTCMonth() + t), n.getTime();
|
|
1330
1337
|
}, Y = (e, t) => {
|
|
@@ -1339,45 +1346,45 @@ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, ie = 60 * be, ce = 24 * ie, yt = 30 *
|
|
|
1339
1346
|
case "hours":
|
|
1340
1347
|
return Tt(e, n);
|
|
1341
1348
|
case "days":
|
|
1342
|
-
return
|
|
1349
|
+
return St(e, n);
|
|
1343
1350
|
case "months":
|
|
1344
|
-
return
|
|
1351
|
+
return Ae(e, n);
|
|
1345
1352
|
case "years":
|
|
1346
|
-
return
|
|
1353
|
+
return Ae(e, n * 12);
|
|
1347
1354
|
}
|
|
1348
1355
|
};
|
|
1349
1356
|
function oe(e, t) {
|
|
1350
1357
|
const n = new Date(e), s = new Date(n.toLocaleString("en-US", { timeZone: t })), o = new Date(n.toLocaleString("en-US", { timeZone: "UTC" }));
|
|
1351
1358
|
return (s.getTime() - o.getTime()) / (3600 * 1e3);
|
|
1352
1359
|
}
|
|
1353
|
-
const
|
|
1360
|
+
const Ct = (e, t, n = "UTC") => {
|
|
1354
1361
|
const [s, o] = t;
|
|
1355
|
-
let
|
|
1356
|
-
const
|
|
1357
|
-
|
|
1362
|
+
let i = new Date(e);
|
|
1363
|
+
const r = () => {
|
|
1364
|
+
i.setUTCHours(-oe(i, n), 0, 0, 0);
|
|
1358
1365
|
};
|
|
1359
1366
|
switch (o) {
|
|
1360
1367
|
case "milliseconds":
|
|
1361
|
-
|
|
1362
|
-
Math.ceil(
|
|
1368
|
+
i.setUTCMilliseconds(
|
|
1369
|
+
Math.ceil(i.getUTCMilliseconds() / s) * s
|
|
1363
1370
|
);
|
|
1364
1371
|
break;
|
|
1365
1372
|
case "seconds":
|
|
1366
|
-
|
|
1367
|
-
Math.ceil(
|
|
1373
|
+
i.setUTCSeconds(
|
|
1374
|
+
Math.ceil(i.getUTCSeconds() / s) * s,
|
|
1368
1375
|
0
|
|
1369
1376
|
);
|
|
1370
1377
|
break;
|
|
1371
1378
|
case "minutes":
|
|
1372
|
-
|
|
1373
|
-
Math.ceil(
|
|
1379
|
+
i.setUTCMinutes(
|
|
1380
|
+
Math.ceil(i.getTime() % re / be / s) * s,
|
|
1374
1381
|
0,
|
|
1375
1382
|
0
|
|
1376
1383
|
);
|
|
1377
1384
|
break;
|
|
1378
1385
|
case "hours":
|
|
1379
|
-
|
|
1380
|
-
Math.ceil(
|
|
1386
|
+
i.setUTCHours(
|
|
1387
|
+
Math.ceil(i.getTime() % ce / re / s) * s,
|
|
1381
1388
|
0,
|
|
1382
1389
|
0,
|
|
1383
1390
|
0
|
|
@@ -1386,42 +1393,42 @@ const St = (e, t, n = "UTC") => {
|
|
|
1386
1393
|
case "days":
|
|
1387
1394
|
case "months":
|
|
1388
1395
|
case "years":
|
|
1389
|
-
o === "months" ?
|
|
1396
|
+
o === "months" ? i.setUTCDate(1) : o === "years" && i.setUTCMonth(0, 1), r(), i.getTime() < e && (i = new Date(Y(i, [1, o])));
|
|
1390
1397
|
break;
|
|
1391
1398
|
}
|
|
1392
|
-
return
|
|
1399
|
+
return i.getTime();
|
|
1393
1400
|
}, jt = ({
|
|
1394
1401
|
timeZone: e = Fe,
|
|
1395
1402
|
space: t = Xe,
|
|
1396
1403
|
formatter: n,
|
|
1397
1404
|
locale: s,
|
|
1398
1405
|
showTimezone: o
|
|
1399
|
-
} = {}) => (
|
|
1400
|
-
const { min: c, max:
|
|
1401
|
-
if (!Number.isFinite(c) || !Number.isFinite(
|
|
1406
|
+
} = {}) => (i, r) => {
|
|
1407
|
+
const { min: c, max: u } = i;
|
|
1408
|
+
if (!Number.isFinite(c) || !Number.isFinite(u))
|
|
1402
1409
|
return [];
|
|
1403
|
-
const
|
|
1404
|
-
(w) => se(w) >=
|
|
1410
|
+
const l = Math.floor(r.chartAreaCanvasPX.width / t) + 1, d = (u - c) / l, [a, g] = vt.find(
|
|
1411
|
+
(w) => se(w) >= d
|
|
1405
1412
|
) ?? [1, "milliseconds"];
|
|
1406
|
-
if (!a || !
|
|
1413
|
+
if (!a || !g)
|
|
1407
1414
|
return [];
|
|
1408
|
-
const
|
|
1409
|
-
let
|
|
1415
|
+
const f = Ct(c, [a, g], e), y = oe(f, e), h = [f];
|
|
1416
|
+
let m;
|
|
1410
1417
|
for (; !(h.length > 1e3); ) {
|
|
1411
|
-
switch (
|
|
1418
|
+
switch (g) {
|
|
1412
1419
|
case "milliseconds":
|
|
1413
1420
|
case "seconds":
|
|
1414
1421
|
case "minutes":
|
|
1415
1422
|
case "hours": {
|
|
1416
|
-
|
|
1423
|
+
m = Y(f, [h.length * a, g]);
|
|
1417
1424
|
break;
|
|
1418
1425
|
}
|
|
1419
1426
|
case "days": {
|
|
1420
|
-
const w = Y(
|
|
1427
|
+
const w = Y(f, [
|
|
1421
1428
|
h.length * a,
|
|
1422
|
-
|
|
1429
|
+
g
|
|
1423
1430
|
]);
|
|
1424
|
-
|
|
1431
|
+
m = Y(w, [
|
|
1425
1432
|
y - oe(w, e),
|
|
1426
1433
|
"hours"
|
|
1427
1434
|
]);
|
|
@@ -1430,22 +1437,22 @@ const St = (e, t, n = "UTC") => {
|
|
|
1430
1437
|
case "months":
|
|
1431
1438
|
case "years": {
|
|
1432
1439
|
const w = Y(
|
|
1433
|
-
Y(Y(
|
|
1440
|
+
Y(Y(f, [y, "hours"]), [
|
|
1434
1441
|
h.length * a,
|
|
1435
|
-
|
|
1442
|
+
g
|
|
1436
1443
|
]),
|
|
1437
1444
|
[-y, "hours"]
|
|
1438
1445
|
);
|
|
1439
|
-
|
|
1446
|
+
m = Y(w, [
|
|
1440
1447
|
y - oe(w, e),
|
|
1441
1448
|
"hours"
|
|
1442
1449
|
]);
|
|
1443
1450
|
break;
|
|
1444
1451
|
}
|
|
1445
1452
|
}
|
|
1446
|
-
if (
|
|
1453
|
+
if (m > u)
|
|
1447
1454
|
break;
|
|
1448
|
-
h.push(
|
|
1455
|
+
h.push(m);
|
|
1449
1456
|
}
|
|
1450
1457
|
return (n ?? Pt({
|
|
1451
1458
|
locale: s,
|
|
@@ -1470,30 +1477,30 @@ const St = (e, t, n = "UTC") => {
|
|
|
1470
1477
|
timeZone: e
|
|
1471
1478
|
});
|
|
1472
1479
|
return (o) => {
|
|
1473
|
-
const
|
|
1474
|
-
return o.map((
|
|
1475
|
-
const a =
|
|
1476
|
-
if (
|
|
1477
|
-
const
|
|
1478
|
-
let
|
|
1480
|
+
const i = o[1] - o[0], r = i < se([1, "days"]), c = i < se([1, "minutes"]), u = i < se([1, "seconds"]);
|
|
1481
|
+
return o.map((l) => ({ value: l, label: s.formatToParts(new Date(l)) })).map((l, p, d) => {
|
|
1482
|
+
const a = d[p - 1], g = p === 0 || K(l.label, a.label, "year"), f = p === 0 || K(l.label, a.label, "day"), y = p === 0 || K(l.label, a.label, "month"), h = p === 0 || K(l.label, a.label, "hour"), m = p === 0 || K(l.label, a.label, "timeZoneName"), w = p === 0 || K(l.label, a.label, "minute"), x = p === 0 || K(l.label, a.label, "second"), T = p === 0 || K(l.label, a.label, "fractionalSecond"), v = [];
|
|
1483
|
+
if (r && (h || w || m || x || T)) {
|
|
1484
|
+
const b = l.label.find((P) => P.type === "hour")?.value, S = l.label.find((P) => P.type === "minute")?.value, E = l.label.find((P) => P.type === "timeZoneName")?.value;
|
|
1485
|
+
let C = "";
|
|
1479
1486
|
if (c) {
|
|
1480
|
-
const P =
|
|
1487
|
+
const P = l.label.find((z) => z.type === "second")?.value, A = l.label.find(
|
|
1481
1488
|
(z) => z.type === "fractionalSecond"
|
|
1482
1489
|
)?.value;
|
|
1483
|
-
|
|
1490
|
+
C = `:${P}` + (u ? `.${A}` : "");
|
|
1484
1491
|
}
|
|
1485
1492
|
v.push(
|
|
1486
|
-
`${
|
|
1493
|
+
`${b}:${S}${C}` + (n && m ? ` ${E}` : "")
|
|
1487
1494
|
);
|
|
1488
1495
|
}
|
|
1489
|
-
return (
|
|
1496
|
+
return (f || y) && v.push(
|
|
1490
1497
|
[
|
|
1491
|
-
|
|
1492
|
-
|
|
1498
|
+
l.label.find((b) => b.type === "month")?.value,
|
|
1499
|
+
f && l.label.find((b) => b.type === "day")?.value
|
|
1493
1500
|
].filter(Boolean).join(" ")
|
|
1494
|
-
),
|
|
1495
|
-
value:
|
|
1496
|
-
label: v.filter((
|
|
1501
|
+
), g && v.push(l.label.find((b) => b.type === "year")?.value), {
|
|
1502
|
+
value: l.value,
|
|
1503
|
+
label: v.filter((b) => b).join(`
|
|
1497
1504
|
`)
|
|
1498
1505
|
};
|
|
1499
1506
|
});
|
|
@@ -1516,7 +1523,7 @@ export {
|
|
|
1516
1523
|
Ft as XTicks,
|
|
1517
1524
|
Ot as YTicks,
|
|
1518
1525
|
U as applyStyles,
|
|
1519
|
-
|
|
1526
|
+
ie as clamp,
|
|
1520
1527
|
V as clampXPosToChartArea,
|
|
1521
1528
|
H as clampYPosToChartArea,
|
|
1522
1529
|
F as deepEqual,
|
|
@@ -1528,7 +1535,7 @@ export {
|
|
|
1528
1535
|
jt as makeTimeTicks,
|
|
1529
1536
|
_ as posToVal,
|
|
1530
1537
|
We as pxToValDistance,
|
|
1531
|
-
|
|
1538
|
+
kt as sum,
|
|
1532
1539
|
j as useDrawEffect,
|
|
1533
1540
|
Ue as useFrameState,
|
|
1534
1541
|
xe as useInteractionsEvent,
|