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