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