@canplot/react 0.1.8 → 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 +519 -493
- 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,
|
|
800
805
|
n.current
|
|
801
806
|
);
|
|
802
|
-
|
|
807
|
+
h && b.dblclick.dispatchEvent(l, {
|
|
803
808
|
frame: n.current,
|
|
804
|
-
pointer:
|
|
805
|
-
keys:
|
|
809
|
+
pointer: h,
|
|
810
|
+
keys: i.keys
|
|
806
811
|
});
|
|
807
|
-
}), M("sync_click",
|
|
808
|
-
const
|
|
809
|
-
|
|
812
|
+
}), M("sync_click", r, (i) => {
|
|
813
|
+
const h = z(
|
|
814
|
+
i.positions,
|
|
810
815
|
n.current
|
|
811
816
|
);
|
|
812
|
-
|
|
817
|
+
h && b.click.dispatchEvent(l, {
|
|
813
818
|
frame: n.current,
|
|
814
|
-
pointer:
|
|
815
|
-
keys:
|
|
819
|
+
pointer: h,
|
|
820
|
+
keys: i.keys
|
|
816
821
|
});
|
|
817
|
-
}), M("
|
|
818
|
-
const
|
|
819
|
-
|
|
822
|
+
}), M("sync_contextmenu", r, (i) => {
|
|
823
|
+
const h = z(
|
|
824
|
+
i.positions,
|
|
825
|
+
n.current
|
|
826
|
+
);
|
|
827
|
+
h && b.contextmenu.dispatchEvent(l, {
|
|
828
|
+
frame: n.current,
|
|
829
|
+
pointer: h,
|
|
830
|
+
keys: i.keys
|
|
831
|
+
});
|
|
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,34 +911,37 @@ const me = Ut(({ configuration: t, children: s, style: e, className: i }, o) =>
|
|
|
896
911
|
zIndex: 25,
|
|
897
912
|
...s
|
|
898
913
|
},
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
914
|
+
onDragStart: (i) => {
|
|
915
|
+
i.preventDefault();
|
|
916
|
+
},
|
|
917
|
+
onClick: (i) => {
|
|
918
|
+
f(i, (h, y, x) => {
|
|
919
|
+
b.sync_click.dispatchEvent(r, {
|
|
920
|
+
positions: h,
|
|
903
921
|
keys: x
|
|
904
922
|
});
|
|
905
923
|
});
|
|
906
924
|
},
|
|
907
|
-
onMouseLeave: (
|
|
908
|
-
f(
|
|
909
|
-
|
|
925
|
+
onMouseLeave: (i) => {
|
|
926
|
+
f(i, (h, y, x) => {
|
|
927
|
+
b.sync_move.dispatchEvent(r, {
|
|
910
928
|
positions: null,
|
|
911
929
|
keys: x
|
|
912
930
|
});
|
|
913
931
|
});
|
|
914
932
|
},
|
|
915
|
-
onMouseMove: (
|
|
916
|
-
f(
|
|
917
|
-
|
|
918
|
-
positions:
|
|
933
|
+
onMouseMove: (i) => {
|
|
934
|
+
f(i, (h, y, x) => {
|
|
935
|
+
b.sync_move.dispatchEvent(r, {
|
|
936
|
+
positions: h,
|
|
919
937
|
keys: x
|
|
920
938
|
});
|
|
921
939
|
});
|
|
922
940
|
},
|
|
923
|
-
onMouseDown: (
|
|
924
|
-
f(
|
|
925
|
-
|
|
926
|
-
positions:
|
|
941
|
+
onMouseDown: (i) => {
|
|
942
|
+
f(i, (h, { cssX: y, cssY: x }, v) => {
|
|
943
|
+
b.sync_mousedown.dispatchEvent(r, {
|
|
944
|
+
positions: h,
|
|
927
945
|
keys: v
|
|
928
946
|
}), u.current = null, d.current = {
|
|
929
947
|
xRangeCss: { start: y, end: y },
|
|
@@ -931,10 +949,10 @@ const me = Ut(({ configuration: t, children: s, style: e, className: i }, o) =>
|
|
|
931
949
|
};
|
|
932
950
|
});
|
|
933
951
|
},
|
|
934
|
-
onMouseUp: (
|
|
935
|
-
f(
|
|
936
|
-
|
|
937
|
-
positions:
|
|
952
|
+
onMouseUp: (i) => {
|
|
953
|
+
f(i, (h, y, x) => {
|
|
954
|
+
b.sync_mouseup.dispatchEvent(r, {
|
|
955
|
+
positions: h,
|
|
938
956
|
keys: x
|
|
939
957
|
});
|
|
940
958
|
const v = u.current;
|
|
@@ -946,17 +964,25 @@ const me = Ut(({ configuration: t, children: s, style: e, className: i }, o) =>
|
|
|
946
964
|
keys: x,
|
|
947
965
|
completed: !0
|
|
948
966
|
};
|
|
949
|
-
|
|
950
|
-
|
|
967
|
+
b.sync_spanselect.dispatchEvent(
|
|
968
|
+
r,
|
|
951
969
|
g
|
|
952
970
|
);
|
|
953
971
|
}
|
|
954
972
|
});
|
|
955
973
|
},
|
|
956
|
-
|
|
957
|
-
f(
|
|
958
|
-
|
|
959
|
-
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,
|
|
960
986
|
keys: x
|
|
961
987
|
});
|
|
962
988
|
});
|
|
@@ -964,66 +990,66 @@ const me = Ut(({ configuration: t, children: s, style: e, className: i }, o) =>
|
|
|
964
990
|
}
|
|
965
991
|
);
|
|
966
992
|
}, Te = ({ data: t, renderTooltip: s, xScaleId: e }) => {
|
|
967
|
-
const [
|
|
968
|
-
pt("move", (
|
|
969
|
-
o(
|
|
993
|
+
const [c, o] = V(null);
|
|
994
|
+
pt("move", (l) => {
|
|
995
|
+
o(l);
|
|
970
996
|
});
|
|
971
997
|
const n = Q(() => {
|
|
972
|
-
if (!
|
|
998
|
+
if (!c)
|
|
973
999
|
return null;
|
|
974
|
-
const { frame:
|
|
1000
|
+
const { frame: l, pointer: r } = c, d = r?.scaled[e];
|
|
975
1001
|
if (d === void 0)
|
|
976
1002
|
return null;
|
|
977
1003
|
const u = [];
|
|
978
|
-
let
|
|
979
|
-
for (const
|
|
980
|
-
let f = null,
|
|
981
|
-
for (const [
|
|
982
|
-
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))
|
|
983
1009
|
continue;
|
|
984
1010
|
const x = Math.abs(y.x - d);
|
|
985
|
-
x <
|
|
1011
|
+
x < m && (m = x, f = h);
|
|
986
1012
|
}
|
|
987
|
-
const
|
|
988
|
-
if (!
|
|
989
|
-
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 });
|
|
990
1016
|
continue;
|
|
991
1017
|
}
|
|
992
|
-
|
|
993
|
-
seriesId:
|
|
994
|
-
y:
|
|
1018
|
+
a = i.x, u.push({
|
|
1019
|
+
seriesId: p.seriesId,
|
|
1020
|
+
y: i.y
|
|
995
1021
|
});
|
|
996
1022
|
}
|
|
997
1023
|
return {
|
|
998
|
-
frame:
|
|
999
|
-
x:
|
|
1024
|
+
frame: l,
|
|
1025
|
+
x: a,
|
|
1000
1026
|
points: u
|
|
1001
1027
|
};
|
|
1002
|
-
}, [t,
|
|
1028
|
+
}, [t, c, e]);
|
|
1003
1029
|
return s(n);
|
|
1004
|
-
}, ke = ({ makeXStyle: t, makeXClassName: s, makeYStyle: e, makeYClassName:
|
|
1030
|
+
}, ke = ({ makeXStyle: t, makeXClassName: s, makeYStyle: e, makeYClassName: c }) => {
|
|
1005
1031
|
const [o, n] = V(null);
|
|
1006
|
-
if (pt("move", (
|
|
1007
|
-
n(
|
|
1032
|
+
if (pt("move", (a) => {
|
|
1033
|
+
n(a);
|
|
1008
1034
|
}), !o)
|
|
1009
1035
|
return null;
|
|
1010
|
-
const { frame:
|
|
1011
|
-
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: [
|
|
1012
1038
|
/* @__PURE__ */ A(
|
|
1013
1039
|
"div",
|
|
1014
1040
|
{
|
|
1015
|
-
"data-show": !!
|
|
1041
|
+
"data-show": !!r,
|
|
1016
1042
|
className: s?.(o),
|
|
1017
1043
|
style: {
|
|
1018
1044
|
position: "absolute",
|
|
1019
1045
|
left: 0,
|
|
1020
|
-
top:
|
|
1021
|
-
height:
|
|
1046
|
+
top: l.chartAreaCSS.y,
|
|
1047
|
+
height: l.chartAreaCSS.height,
|
|
1022
1048
|
borderColor: "red",
|
|
1023
1049
|
borderLeftWidth: "1px",
|
|
1024
1050
|
borderLeftStyle: "solid",
|
|
1025
1051
|
pointerEvents: "none",
|
|
1026
|
-
opacity:
|
|
1052
|
+
opacity: r ? 1 : 0,
|
|
1027
1053
|
transform: `translateX(${d}px)`,
|
|
1028
1054
|
...t?.(o)
|
|
1029
1055
|
}
|
|
@@ -1032,17 +1058,17 @@ const me = Ut(({ configuration: t, children: s, style: e, className: i }, o) =>
|
|
|
1032
1058
|
/* @__PURE__ */ A(
|
|
1033
1059
|
"div",
|
|
1034
1060
|
{
|
|
1035
|
-
className:
|
|
1036
|
-
"data-show": !!
|
|
1061
|
+
className: c?.(o),
|
|
1062
|
+
"data-show": !!r,
|
|
1037
1063
|
style: {
|
|
1038
1064
|
position: "absolute",
|
|
1039
1065
|
top: 0,
|
|
1040
1066
|
height: 0,
|
|
1041
1067
|
borderTop: "solid 1px red",
|
|
1042
|
-
left:
|
|
1043
|
-
width:
|
|
1068
|
+
left: l.chartAreaCSS.x,
|
|
1069
|
+
width: l.chartAreaCSS.width,
|
|
1044
1070
|
pointerEvents: "none",
|
|
1045
|
-
opacity:
|
|
1071
|
+
opacity: r ? 1 : 0,
|
|
1046
1072
|
transform: `translateY(${u}px)`,
|
|
1047
1073
|
...e?.(o)
|
|
1048
1074
|
}
|
|
@@ -1050,9 +1076,9 @@ const me = Ut(({ configuration: t, children: s, style: e, className: i }, o) =>
|
|
|
1050
1076
|
)
|
|
1051
1077
|
] });
|
|
1052
1078
|
}, Ee = ({ makeClassName: t, makeStyle: s }) => {
|
|
1053
|
-
const [e,
|
|
1079
|
+
const [e, c] = V(null);
|
|
1054
1080
|
pt("spanselect", (n) => {
|
|
1055
|
-
|
|
1081
|
+
c(n.mode === "none" || n.completed ? null : n);
|
|
1056
1082
|
});
|
|
1057
1083
|
const o = Q(() => {
|
|
1058
1084
|
if (!e)
|
|
@@ -1061,11 +1087,11 @@ const me = Ut(({ configuration: t, children: s, style: e, className: i }, o) =>
|
|
|
1061
1087
|
e.frame,
|
|
1062
1088
|
e.x.fromCSS,
|
|
1063
1089
|
"css"
|
|
1064
|
-
),
|
|
1090
|
+
), l = O(
|
|
1065
1091
|
e.frame,
|
|
1066
1092
|
e.x.toCSS,
|
|
1067
1093
|
"css"
|
|
1068
|
-
),
|
|
1094
|
+
), r = $(
|
|
1069
1095
|
e.frame,
|
|
1070
1096
|
e.y.fromCSS,
|
|
1071
1097
|
"css"
|
|
@@ -1073,8 +1099,8 @@ const me = Ut(({ configuration: t, children: s, style: e, className: i }, o) =>
|
|
|
1073
1099
|
e.frame,
|
|
1074
1100
|
e.y.toCSS,
|
|
1075
1101
|
"css"
|
|
1076
|
-
), u = Math.min(n,
|
|
1077
|
-
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 };
|
|
1078
1104
|
}, [e]);
|
|
1079
1105
|
return /* @__PURE__ */ A(
|
|
1080
1106
|
"div",
|
|
@@ -1092,7 +1118,7 @@ const me = Ut(({ configuration: t, children: s, style: e, className: i }, o) =>
|
|
|
1092
1118
|
}
|
|
1093
1119
|
}
|
|
1094
1120
|
);
|
|
1095
|
-
}, Me = ({ style: t, children: s, scaleId: e, ...
|
|
1121
|
+
}, Me = ({ style: t, children: s, scaleId: e, ...c }) => {
|
|
1096
1122
|
const o = ft((n) => n.getScale(e)?.axis);
|
|
1097
1123
|
return o ? /* @__PURE__ */ A(
|
|
1098
1124
|
"div",
|
|
@@ -1106,24 +1132,24 @@ const me = Ut(({ configuration: t, children: s, style: e, className: i }, o) =>
|
|
|
1106
1132
|
width: o.cssRect.width,
|
|
1107
1133
|
...t
|
|
1108
1134
|
},
|
|
1109
|
-
...
|
|
1135
|
+
...c,
|
|
1110
1136
|
children: s
|
|
1111
1137
|
}
|
|
1112
1138
|
) : null;
|
|
1113
1139
|
}, kt = 60, Ht = 30, Et = "UTC", Wt = "en-GB", Pe = ({
|
|
1114
1140
|
space: t,
|
|
1115
1141
|
formatter: s
|
|
1116
|
-
} = {}) => (e,
|
|
1117
|
-
const { min: o, max: n } = e,
|
|
1118
|
-
|
|
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,
|
|
1119
1145
|
d,
|
|
1120
1146
|
e.id,
|
|
1121
1147
|
"canvas"
|
|
1122
|
-
),
|
|
1123
|
-
let
|
|
1124
|
-
for (;
|
|
1125
|
-
|
|
1126
|
-
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);
|
|
1127
1153
|
}, qt = (t) => {
|
|
1128
1154
|
const s = Math.max(0, Math.ceil(-Math.log10(t[1] - t[0])));
|
|
1129
1155
|
return t.map((e) => ({ value: e, label: e.toFixed(s) }));
|
|
@@ -1219,8 +1245,8 @@ const Gt = 1, Mt = 1e3 * Gt, yt = 60 * Mt, tt = 60 * yt, st = 24 * tt, Zt = 30 *
|
|
|
1219
1245
|
const e = new Date(t);
|
|
1220
1246
|
return e.setUTCMonth(e.getUTCMonth() + s), e.getTime();
|
|
1221
1247
|
}, K = (t, s) => {
|
|
1222
|
-
const [e,
|
|
1223
|
-
switch (
|
|
1248
|
+
const [e, c] = s;
|
|
1249
|
+
switch (c) {
|
|
1224
1250
|
case "milliseconds":
|
|
1225
1251
|
return te(t, e);
|
|
1226
1252
|
case "seconds":
|
|
@@ -1238,37 +1264,37 @@ const Gt = 1, Mt = 1e3 * Gt, yt = 60 * Mt, tt = 60 * yt, st = 24 * tt, Zt = 30 *
|
|
|
1238
1264
|
}
|
|
1239
1265
|
};
|
|
1240
1266
|
function G(t, s) {
|
|
1241
|
-
const e = new Date(t),
|
|
1242
|
-
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);
|
|
1243
1269
|
}
|
|
1244
|
-
const
|
|
1245
|
-
const [
|
|
1270
|
+
const ce = (t, s, e = "UTC") => {
|
|
1271
|
+
const [c, o] = s;
|
|
1246
1272
|
let n = new Date(t);
|
|
1247
|
-
const
|
|
1273
|
+
const l = () => {
|
|
1248
1274
|
n.setUTCHours(-G(n, e), 0, 0, 0);
|
|
1249
1275
|
};
|
|
1250
1276
|
switch (o) {
|
|
1251
1277
|
case "milliseconds":
|
|
1252
1278
|
n.setUTCMilliseconds(
|
|
1253
|
-
Math.ceil(n.getUTCMilliseconds() /
|
|
1279
|
+
Math.ceil(n.getUTCMilliseconds() / c) * c
|
|
1254
1280
|
);
|
|
1255
1281
|
break;
|
|
1256
1282
|
case "seconds":
|
|
1257
1283
|
n.setUTCSeconds(
|
|
1258
|
-
Math.ceil(n.getUTCSeconds() /
|
|
1284
|
+
Math.ceil(n.getUTCSeconds() / c) * c,
|
|
1259
1285
|
0
|
|
1260
1286
|
);
|
|
1261
1287
|
break;
|
|
1262
1288
|
case "minutes":
|
|
1263
1289
|
n.setUTCMinutes(
|
|
1264
|
-
Math.ceil(n.getTime() % tt / yt /
|
|
1290
|
+
Math.ceil(n.getTime() % tt / yt / c) * c,
|
|
1265
1291
|
0,
|
|
1266
1292
|
0
|
|
1267
1293
|
);
|
|
1268
1294
|
break;
|
|
1269
1295
|
case "hours":
|
|
1270
1296
|
n.setUTCHours(
|
|
1271
|
-
Math.ceil(n.getTime() % st / tt /
|
|
1297
|
+
Math.ceil(n.getTime() % st / tt / c) * c,
|
|
1272
1298
|
0,
|
|
1273
1299
|
0,
|
|
1274
1300
|
0
|
|
@@ -1277,7 +1303,7 @@ const ie = (t, s, e = "UTC") => {
|
|
|
1277
1303
|
case "days":
|
|
1278
1304
|
case "months":
|
|
1279
1305
|
case "years":
|
|
1280
|
-
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])));
|
|
1281
1307
|
break;
|
|
1282
1308
|
}
|
|
1283
1309
|
return n.getTime();
|
|
@@ -1285,29 +1311,29 @@ const ie = (t, s, e = "UTC") => {
|
|
|
1285
1311
|
timeZone: t = Et,
|
|
1286
1312
|
space: s = kt,
|
|
1287
1313
|
formatter: e,
|
|
1288
|
-
locale:
|
|
1314
|
+
locale: c,
|
|
1289
1315
|
showTimezone: o
|
|
1290
|
-
} = {}) => (n,
|
|
1291
|
-
const { min:
|
|
1292
|
-
(v) => q(v) >=
|
|
1293
|
-
) ?? [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];
|
|
1294
1320
|
let x;
|
|
1295
1321
|
for (; ; ) {
|
|
1296
|
-
switch (
|
|
1322
|
+
switch (m) {
|
|
1297
1323
|
case "milliseconds":
|
|
1298
1324
|
case "seconds":
|
|
1299
1325
|
case "minutes":
|
|
1300
1326
|
case "hours": {
|
|
1301
|
-
x = K(
|
|
1327
|
+
x = K(i, [y.length * f, m]);
|
|
1302
1328
|
break;
|
|
1303
1329
|
}
|
|
1304
1330
|
case "days": {
|
|
1305
|
-
const v = K(
|
|
1331
|
+
const v = K(i, [
|
|
1306
1332
|
y.length * f,
|
|
1307
|
-
|
|
1333
|
+
m
|
|
1308
1334
|
]);
|
|
1309
1335
|
x = K(v, [
|
|
1310
|
-
|
|
1336
|
+
h - G(v, t),
|
|
1311
1337
|
"hours"
|
|
1312
1338
|
]);
|
|
1313
1339
|
break;
|
|
@@ -1315,14 +1341,14 @@ const ie = (t, s, e = "UTC") => {
|
|
|
1315
1341
|
case "months":
|
|
1316
1342
|
case "years": {
|
|
1317
1343
|
const v = K(
|
|
1318
|
-
K(K(
|
|
1344
|
+
K(K(i, [h, "hours"]), [
|
|
1319
1345
|
y.length * f,
|
|
1320
|
-
|
|
1346
|
+
m
|
|
1321
1347
|
]),
|
|
1322
|
-
[-
|
|
1348
|
+
[-h, "hours"]
|
|
1323
1349
|
);
|
|
1324
1350
|
x = K(v, [
|
|
1325
|
-
|
|
1351
|
+
h - G(v, t),
|
|
1326
1352
|
"hours"
|
|
1327
1353
|
]);
|
|
1328
1354
|
break;
|
|
@@ -1332,17 +1358,17 @@ const ie = (t, s, e = "UTC") => {
|
|
|
1332
1358
|
break;
|
|
1333
1359
|
y.push(x);
|
|
1334
1360
|
}
|
|
1335
|
-
return (e ??
|
|
1336
|
-
locale:
|
|
1361
|
+
return (e ?? ie({
|
|
1362
|
+
locale: c,
|
|
1337
1363
|
showTimezone: o,
|
|
1338
1364
|
timeZone: t
|
|
1339
1365
|
}))(y);
|
|
1340
|
-
}, 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 = ({
|
|
1341
1367
|
timeZone: t = Et,
|
|
1342
1368
|
locale: s = Wt,
|
|
1343
1369
|
showTimezone: e = !0
|
|
1344
1370
|
}) => {
|
|
1345
|
-
const
|
|
1371
|
+
const c = new Intl.DateTimeFormat(s, {
|
|
1346
1372
|
year: "numeric",
|
|
1347
1373
|
day: "numeric",
|
|
1348
1374
|
month: "short",
|
|
@@ -1355,30 +1381,30 @@ const ie = (t, s, e = "UTC") => {
|
|
|
1355
1381
|
timeZone: t
|
|
1356
1382
|
});
|
|
1357
1383
|
return (o) => {
|
|
1358
|
-
const n = o[1] - o[0],
|
|
1359
|
-
return o.map((u) => ({ value: u, label:
|
|
1360
|
-
const f =
|
|
1361
|
-
if (
|
|
1362
|
-
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;
|
|
1363
1389
|
let U = "";
|
|
1364
|
-
if (
|
|
1390
|
+
if (r) {
|
|
1365
1391
|
const P = u.label.find((F) => F.type === "second")?.value, B = u.label.find(
|
|
1366
1392
|
(F) => F.type === "fractionalSecond"
|
|
1367
1393
|
)?.value;
|
|
1368
1394
|
U = `:${P}` + (d ? `.${B}` : "");
|
|
1369
1395
|
}
|
|
1370
|
-
|
|
1371
|
-
`${w}:${
|
|
1396
|
+
T.push(
|
|
1397
|
+
`${w}:${C}${U}` + (e && x ? ` ${k}` : "")
|
|
1372
1398
|
);
|
|
1373
1399
|
}
|
|
1374
|
-
return (
|
|
1400
|
+
return (i || h) && T.push(
|
|
1375
1401
|
[
|
|
1376
1402
|
u.label.find((w) => w.type === "month")?.value,
|
|
1377
|
-
|
|
1403
|
+
i && u.label.find((w) => w.type === "day")?.value
|
|
1378
1404
|
].filter(Boolean).join(" ")
|
|
1379
|
-
),
|
|
1405
|
+
), m && T.push(u.label.find((w) => w.type === "year")?.value), {
|
|
1380
1406
|
value: u.value,
|
|
1381
|
-
label:
|
|
1407
|
+
label: T.filter((w) => w).join(`
|
|
1382
1408
|
`)
|
|
1383
1409
|
};
|
|
1384
1410
|
});
|
|
@@ -1398,23 +1424,23 @@ export {
|
|
|
1398
1424
|
Te as TooltipsX,
|
|
1399
1425
|
we as XTicks,
|
|
1400
1426
|
be as YTicks,
|
|
1401
|
-
|
|
1427
|
+
R as applyStyles,
|
|
1402
1428
|
j as clamp,
|
|
1403
1429
|
fe as clampUnfit,
|
|
1404
1430
|
O as clampXPosToChartArea,
|
|
1405
1431
|
$ as clampYPosToChartArea,
|
|
1406
1432
|
qt as defaultNumericalTicksFormatter,
|
|
1407
1433
|
de as findClosestIndex,
|
|
1408
|
-
|
|
1434
|
+
_ as getScale,
|
|
1409
1435
|
et as isXScale,
|
|
1410
1436
|
he as isYScale,
|
|
1411
1437
|
Pe as makeLinearTicks,
|
|
1412
|
-
|
|
1438
|
+
ie as makeTimeTickFormat,
|
|
1413
1439
|
Ae as makeTimeTicks,
|
|
1414
1440
|
X as posToVal,
|
|
1415
1441
|
Dt as pxToValDistance,
|
|
1416
1442
|
ue as sum,
|
|
1417
|
-
|
|
1443
|
+
Y as useDrawEffect,
|
|
1418
1444
|
ft as useFrameState,
|
|
1419
1445
|
pt as useInteractionsEvent,
|
|
1420
1446
|
ve as useXPositioned,
|