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