@canplot/react 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CanPlot.d.ts.map +1 -1
- package/dist/canplot.cjs +4 -4
- package/dist/canplot.cjs.map +1 -1
- package/dist/canplot.mjs +539 -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,34 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
|
|
|
868
896
|
zIndex: 25,
|
|
869
897
|
...s
|
|
870
898
|
},
|
|
871
|
-
onClick: (
|
|
872
|
-
f(
|
|
899
|
+
onClick: (c) => {
|
|
900
|
+
f(c, (p, y, x) => {
|
|
873
901
|
T.sync_click.dispatchEvent(l, {
|
|
874
|
-
positions:
|
|
902
|
+
positions: p,
|
|
875
903
|
keys: x
|
|
876
904
|
});
|
|
877
905
|
});
|
|
878
906
|
},
|
|
879
|
-
onMouseLeave: (
|
|
880
|
-
f(
|
|
907
|
+
onMouseLeave: (c) => {
|
|
908
|
+
f(c, (p, y, x) => {
|
|
881
909
|
T.sync_move.dispatchEvent(l, {
|
|
882
910
|
positions: null,
|
|
883
911
|
keys: x
|
|
884
912
|
});
|
|
885
913
|
});
|
|
886
914
|
},
|
|
887
|
-
onMouseMove: (
|
|
888
|
-
f(
|
|
915
|
+
onMouseMove: (c) => {
|
|
916
|
+
f(c, (p, y, x) => {
|
|
889
917
|
T.sync_move.dispatchEvent(l, {
|
|
890
|
-
positions:
|
|
918
|
+
positions: p,
|
|
891
919
|
keys: x
|
|
892
920
|
});
|
|
893
921
|
});
|
|
894
922
|
},
|
|
895
|
-
onMouseDown: (
|
|
896
|
-
f(
|
|
923
|
+
onMouseDown: (c) => {
|
|
924
|
+
f(c, (p, { cssX: y, cssY: x }, v) => {
|
|
897
925
|
T.sync_mousedown.dispatchEvent(l, {
|
|
898
|
-
positions:
|
|
926
|
+
positions: p,
|
|
899
927
|
keys: v
|
|
900
928
|
}), u.current = null, d.current = {
|
|
901
929
|
xRangeCss: { start: y, end: y },
|
|
@@ -903,67 +931,67 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
|
|
|
903
931
|
};
|
|
904
932
|
});
|
|
905
933
|
},
|
|
906
|
-
onMouseUp: (
|
|
907
|
-
f(
|
|
934
|
+
onMouseUp: (c) => {
|
|
935
|
+
f(c, (p, y, x) => {
|
|
908
936
|
T.sync_mouseup.dispatchEvent(l, {
|
|
909
|
-
positions:
|
|
937
|
+
positions: p,
|
|
910
938
|
keys: x
|
|
911
939
|
});
|
|
912
940
|
const v = u.current;
|
|
913
941
|
u.current = null;
|
|
914
|
-
const
|
|
915
|
-
if (d.current = null,
|
|
916
|
-
const
|
|
942
|
+
const S = d.current;
|
|
943
|
+
if (d.current = null, S && v) {
|
|
944
|
+
const g = {
|
|
917
945
|
...v,
|
|
918
946
|
keys: x,
|
|
919
947
|
completed: !0
|
|
920
948
|
};
|
|
921
949
|
T.sync_spanselect.dispatchEvent(
|
|
922
950
|
l,
|
|
923
|
-
|
|
951
|
+
g
|
|
924
952
|
);
|
|
925
953
|
}
|
|
926
954
|
});
|
|
927
955
|
},
|
|
928
|
-
onDoubleClick: (
|
|
929
|
-
f(
|
|
956
|
+
onDoubleClick: (c) => {
|
|
957
|
+
f(c, (p, y, x) => {
|
|
930
958
|
T.sync_dblclick.dispatchEvent(l, {
|
|
931
|
-
positions:
|
|
959
|
+
positions: p,
|
|
932
960
|
keys: x
|
|
933
961
|
});
|
|
934
962
|
});
|
|
935
963
|
}
|
|
936
964
|
}
|
|
937
965
|
);
|
|
938
|
-
},
|
|
939
|
-
const [
|
|
966
|
+
}, Te = ({ data: t, renderTooltip: s, xScaleId: e }) => {
|
|
967
|
+
const [i, o] = V(null);
|
|
940
968
|
pt("move", (a) => {
|
|
941
969
|
o(a);
|
|
942
970
|
});
|
|
943
|
-
const n =
|
|
944
|
-
if (!
|
|
971
|
+
const n = Q(() => {
|
|
972
|
+
if (!i)
|
|
945
973
|
return null;
|
|
946
|
-
const { frame: a, pointer: l } =
|
|
974
|
+
const { frame: a, pointer: l } = i, d = l?.scaled[e];
|
|
947
975
|
if (d === void 0)
|
|
948
976
|
return null;
|
|
949
977
|
const u = [];
|
|
950
978
|
let r = d;
|
|
951
|
-
for (const
|
|
979
|
+
for (const m of t) {
|
|
952
980
|
let f = null, h = 1 / 0;
|
|
953
|
-
for (const [
|
|
954
|
-
if (!
|
|
981
|
+
for (const [p, y] of m.points.entries()) {
|
|
982
|
+
if (!at(a, y.x, e) || !at(a, y.y, m.yScaleId))
|
|
955
983
|
continue;
|
|
956
984
|
const x = Math.abs(y.x - d);
|
|
957
|
-
x < h && (h = x, f =
|
|
985
|
+
x < h && (h = x, f = p);
|
|
958
986
|
}
|
|
959
|
-
const
|
|
960
|
-
if (!
|
|
961
|
-
u.push({ seriesId:
|
|
987
|
+
const c = m.points[f ?? -1];
|
|
988
|
+
if (!c || dt(a, h, e, "css") > 30) {
|
|
989
|
+
u.push({ seriesId: m.seriesId, y: null });
|
|
962
990
|
continue;
|
|
963
991
|
}
|
|
964
|
-
r =
|
|
965
|
-
seriesId:
|
|
966
|
-
y:
|
|
992
|
+
r = c.x, u.push({
|
|
993
|
+
seriesId: m.seriesId,
|
|
994
|
+
y: c.y
|
|
967
995
|
});
|
|
968
996
|
}
|
|
969
997
|
return {
|
|
@@ -971,17 +999,17 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
|
|
|
971
999
|
x: r,
|
|
972
1000
|
points: u
|
|
973
1001
|
};
|
|
974
|
-
}, [t,
|
|
1002
|
+
}, [t, i, e]);
|
|
975
1003
|
return s(n);
|
|
976
|
-
},
|
|
977
|
-
const [o, n] =
|
|
1004
|
+
}, ke = ({ makeXStyle: t, makeXClassName: s, makeYStyle: e, makeYClassName: i }) => {
|
|
1005
|
+
const [o, n] = V(null);
|
|
978
1006
|
if (pt("move", (r) => {
|
|
979
1007
|
n(r);
|
|
980
1008
|
}), !o)
|
|
981
1009
|
return null;
|
|
982
1010
|
const { frame: a, pointer: l } = o, d = O(a, l?.cssX ?? 0, "css"), u = $(a, l?.cssY ?? 0, "css");
|
|
983
|
-
return /* @__PURE__ */
|
|
984
|
-
/* @__PURE__ */
|
|
1011
|
+
return /* @__PURE__ */ ut(Rt, { children: [
|
|
1012
|
+
/* @__PURE__ */ A(
|
|
985
1013
|
"div",
|
|
986
1014
|
{
|
|
987
1015
|
"data-show": !!l,
|
|
@@ -1001,10 +1029,10 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
|
|
|
1001
1029
|
}
|
|
1002
1030
|
}
|
|
1003
1031
|
),
|
|
1004
|
-
/* @__PURE__ */
|
|
1032
|
+
/* @__PURE__ */ A(
|
|
1005
1033
|
"div",
|
|
1006
1034
|
{
|
|
1007
|
-
className:
|
|
1035
|
+
className: i?.(o),
|
|
1008
1036
|
"data-show": !!l,
|
|
1009
1037
|
style: {
|
|
1010
1038
|
position: "absolute",
|
|
@@ -1021,12 +1049,12 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
|
|
|
1021
1049
|
}
|
|
1022
1050
|
)
|
|
1023
1051
|
] });
|
|
1024
|
-
},
|
|
1025
|
-
const [e,
|
|
1052
|
+
}, Ee = ({ makeClassName: t, makeStyle: s }) => {
|
|
1053
|
+
const [e, i] = V(null);
|
|
1026
1054
|
pt("spanselect", (n) => {
|
|
1027
|
-
|
|
1055
|
+
i(n.mode === "none" || n.completed ? null : n);
|
|
1028
1056
|
});
|
|
1029
|
-
const o =
|
|
1057
|
+
const o = Q(() => {
|
|
1030
1058
|
if (!e)
|
|
1031
1059
|
return null;
|
|
1032
1060
|
const n = O(
|
|
@@ -1045,10 +1073,10 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
|
|
|
1045
1073
|
e.frame,
|
|
1046
1074
|
e.y.toCSS,
|
|
1047
1075
|
"css"
|
|
1048
|
-
), u = Math.min(n, a), r = Math.min(l, d),
|
|
1049
|
-
return { leftPx: u, topPx: r, widthPx:
|
|
1076
|
+
), u = Math.min(n, a), r = Math.min(l, d), m = Math.abs(a - n), f = Math.abs(d - l);
|
|
1077
|
+
return { leftPx: u, topPx: r, widthPx: m, heightPx: f };
|
|
1050
1078
|
}, [e]);
|
|
1051
|
-
return /* @__PURE__ */
|
|
1079
|
+
return /* @__PURE__ */ A(
|
|
1052
1080
|
"div",
|
|
1053
1081
|
{
|
|
1054
1082
|
className: e ? t?.(e) : void 0,
|
|
@@ -1064,9 +1092,9 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
|
|
|
1064
1092
|
}
|
|
1065
1093
|
}
|
|
1066
1094
|
);
|
|
1067
|
-
},
|
|
1095
|
+
}, Me = ({ style: t, children: s, scaleId: e, ...i }) => {
|
|
1068
1096
|
const o = ft((n) => n.getScale(e)?.axis);
|
|
1069
|
-
return o ? /* @__PURE__ */
|
|
1097
|
+
return o ? /* @__PURE__ */ A(
|
|
1070
1098
|
"div",
|
|
1071
1099
|
{
|
|
1072
1100
|
style: {
|
|
@@ -1078,31 +1106,31 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
|
|
|
1078
1106
|
width: o.cssRect.width,
|
|
1079
1107
|
...t
|
|
1080
1108
|
},
|
|
1081
|
-
...
|
|
1109
|
+
...i,
|
|
1082
1110
|
children: s
|
|
1083
1111
|
}
|
|
1084
1112
|
) : null;
|
|
1085
|
-
},
|
|
1113
|
+
}, kt = 60, Ht = 30, Et = "UTC", Wt = "en-GB", Pe = ({
|
|
1086
1114
|
space: t,
|
|
1087
1115
|
formatter: s
|
|
1088
|
-
} = {}) => (e,
|
|
1089
|
-
const { min: o, max: n } = e, a = [], l = window.devicePixelRatio || 1, d = (t ?? (e.origin === "x" ?
|
|
1090
|
-
|
|
1116
|
+
} = {}) => (e, i) => {
|
|
1117
|
+
const { min: o, max: n } = e, a = [], l = window.devicePixelRatio || 1, d = (t ?? (e.origin === "x" ? kt : Ht)) * l, u = Dt(
|
|
1118
|
+
i,
|
|
1091
1119
|
d,
|
|
1092
1120
|
e.id,
|
|
1093
1121
|
"canvas"
|
|
1094
|
-
), r =
|
|
1095
|
-
let
|
|
1096
|
-
for (;
|
|
1097
|
-
a.push(
|
|
1098
|
-
return (s ??
|
|
1099
|
-
},
|
|
1122
|
+
), r = W.find((f) => f > u) ?? 1;
|
|
1123
|
+
let m = o % r < Number.EPSILON ? o : o + r - o % r;
|
|
1124
|
+
for (; m <= n; )
|
|
1125
|
+
a.push(m), m += r;
|
|
1126
|
+
return (s ?? qt)(a);
|
|
1127
|
+
}, qt = (t) => {
|
|
1100
1128
|
const s = Math.max(0, Math.ceil(-Math.log10(t[1] - t[0])));
|
|
1101
1129
|
return t.map((e) => ({ value: e, label: e.toFixed(s) }));
|
|
1102
|
-
},
|
|
1130
|
+
}, W = [];
|
|
1103
1131
|
for (let t = -12; t <= 12; t++)
|
|
1104
|
-
|
|
1105
|
-
const
|
|
1132
|
+
W.push(1 * 10 ** t), W.push(2 * 10 ** t), W.push(5 * 10 ** t);
|
|
1133
|
+
const Gt = 1, Mt = 1e3 * Gt, yt = 60 * Mt, tt = 60 * yt, st = 24 * tt, Zt = 30 * st, Jt = 365 * st, Qt = [
|
|
1106
1134
|
// second divisors
|
|
1107
1135
|
[1, "milliseconds"],
|
|
1108
1136
|
[2, "milliseconds"],
|
|
@@ -1154,67 +1182,67 @@ const Wt = 1, Ct = 1e3 * Wt, yt = 60 * Ct, q = 60 * yt, tt = 24 * q, Gt = 30 * t
|
|
|
1154
1182
|
[25, "years"],
|
|
1155
1183
|
[50, "years"],
|
|
1156
1184
|
[100, "years"]
|
|
1157
|
-
],
|
|
1185
|
+
], q = (t) => {
|
|
1158
1186
|
const [s, e] = t;
|
|
1159
1187
|
switch (e) {
|
|
1160
1188
|
case "milliseconds":
|
|
1161
1189
|
return s;
|
|
1162
1190
|
case "seconds":
|
|
1163
|
-
return s *
|
|
1191
|
+
return s * Mt;
|
|
1164
1192
|
case "minutes":
|
|
1165
1193
|
return s * yt;
|
|
1166
1194
|
case "hours":
|
|
1167
|
-
return s * q;
|
|
1168
|
-
case "days":
|
|
1169
1195
|
return s * tt;
|
|
1196
|
+
case "days":
|
|
1197
|
+
return s * st;
|
|
1170
1198
|
case "months":
|
|
1171
|
-
return s * Gt;
|
|
1172
|
-
case "years":
|
|
1173
1199
|
return s * Zt;
|
|
1200
|
+
case "years":
|
|
1201
|
+
return s * Jt;
|
|
1174
1202
|
}
|
|
1175
|
-
},
|
|
1203
|
+
}, te = (t, s) => {
|
|
1176
1204
|
const e = new Date(t);
|
|
1177
1205
|
return e.setUTCMilliseconds(e.getUTCMilliseconds() + s), e.getTime();
|
|
1178
|
-
},
|
|
1206
|
+
}, ee = (t, s) => {
|
|
1179
1207
|
const e = new Date(t);
|
|
1180
1208
|
return e.setUTCSeconds(e.getUTCSeconds() + s), e.getTime();
|
|
1181
|
-
},
|
|
1209
|
+
}, se = (t, s) => {
|
|
1182
1210
|
const e = new Date(t);
|
|
1183
1211
|
return e.setUTCMinutes(e.getUTCMinutes() + s), e.getTime();
|
|
1184
|
-
},
|
|
1212
|
+
}, ne = (t, s) => {
|
|
1185
1213
|
const e = new Date(t);
|
|
1186
1214
|
return e.setUTCHours(e.getUTCHours() + s), e.getTime();
|
|
1187
|
-
},
|
|
1215
|
+
}, oe = (t, s) => {
|
|
1188
1216
|
const e = new Date(t);
|
|
1189
1217
|
return e.setUTCDate(e.getUTCDate() + s), e.getTime();
|
|
1190
|
-
},
|
|
1218
|
+
}, gt = (t, s) => {
|
|
1191
1219
|
const e = new Date(t);
|
|
1192
1220
|
return e.setUTCMonth(e.getUTCMonth() + s), e.getTime();
|
|
1193
|
-
},
|
|
1194
|
-
const [e,
|
|
1195
|
-
switch (
|
|
1221
|
+
}, K = (t, s) => {
|
|
1222
|
+
const [e, i] = s;
|
|
1223
|
+
switch (i) {
|
|
1196
1224
|
case "milliseconds":
|
|
1197
|
-
return
|
|
1225
|
+
return te(t, e);
|
|
1198
1226
|
case "seconds":
|
|
1199
|
-
return
|
|
1227
|
+
return ee(t, e);
|
|
1200
1228
|
case "minutes":
|
|
1201
|
-
return
|
|
1229
|
+
return se(t, e);
|
|
1202
1230
|
case "hours":
|
|
1203
|
-
return
|
|
1231
|
+
return ne(t, e);
|
|
1204
1232
|
case "days":
|
|
1205
|
-
return
|
|
1233
|
+
return oe(t, e);
|
|
1206
1234
|
case "months":
|
|
1207
|
-
return
|
|
1235
|
+
return gt(t, e);
|
|
1208
1236
|
case "years":
|
|
1209
|
-
return
|
|
1237
|
+
return gt(t, e * 12);
|
|
1210
1238
|
}
|
|
1211
1239
|
};
|
|
1212
1240
|
function G(t, s) {
|
|
1213
|
-
const e = new Date(t),
|
|
1214
|
-
return (
|
|
1241
|
+
const e = new Date(t), i = new Date(e.toLocaleString("en-US", { timeZone: s })), o = new Date(e.toLocaleString("en-US", { timeZone: "UTC" }));
|
|
1242
|
+
return (i.getTime() - o.getTime()) / (3600 * 1e3);
|
|
1215
1243
|
}
|
|
1216
|
-
const
|
|
1217
|
-
const [
|
|
1244
|
+
const ie = (t, s, e = "UTC") => {
|
|
1245
|
+
const [i, o] = s;
|
|
1218
1246
|
let n = new Date(t);
|
|
1219
1247
|
const a = () => {
|
|
1220
1248
|
n.setUTCHours(-G(n, e), 0, 0, 0);
|
|
@@ -1222,25 +1250,25 @@ const ne = (t, s, e = "UTC") => {
|
|
|
1222
1250
|
switch (o) {
|
|
1223
1251
|
case "milliseconds":
|
|
1224
1252
|
n.setUTCMilliseconds(
|
|
1225
|
-
Math.ceil(n.getUTCMilliseconds() /
|
|
1253
|
+
Math.ceil(n.getUTCMilliseconds() / i) * i
|
|
1226
1254
|
);
|
|
1227
1255
|
break;
|
|
1228
1256
|
case "seconds":
|
|
1229
1257
|
n.setUTCSeconds(
|
|
1230
|
-
Math.ceil(n.getUTCSeconds() /
|
|
1258
|
+
Math.ceil(n.getUTCSeconds() / i) * i,
|
|
1231
1259
|
0
|
|
1232
1260
|
);
|
|
1233
1261
|
break;
|
|
1234
1262
|
case "minutes":
|
|
1235
1263
|
n.setUTCMinutes(
|
|
1236
|
-
Math.ceil(n.getTime() %
|
|
1264
|
+
Math.ceil(n.getTime() % tt / yt / i) * i,
|
|
1237
1265
|
0,
|
|
1238
1266
|
0
|
|
1239
1267
|
);
|
|
1240
1268
|
break;
|
|
1241
1269
|
case "hours":
|
|
1242
1270
|
n.setUTCHours(
|
|
1243
|
-
Math.ceil(n.getTime() %
|
|
1271
|
+
Math.ceil(n.getTime() % st / tt / i) * i,
|
|
1244
1272
|
0,
|
|
1245
1273
|
0,
|
|
1246
1274
|
0
|
|
@@ -1249,20 +1277,20 @@ const ne = (t, s, e = "UTC") => {
|
|
|
1249
1277
|
case "days":
|
|
1250
1278
|
case "months":
|
|
1251
1279
|
case "years":
|
|
1252
|
-
o === "months" ? n.setUTCDate(1) : o === "years" && n.setUTCMonth(0, 1), a(), n.getTime() < t && (n = new Date(
|
|
1280
|
+
o === "months" ? n.setUTCDate(1) : o === "years" && n.setUTCMonth(0, 1), a(), n.getTime() < t && (n = new Date(K(n, [1, o])));
|
|
1253
1281
|
break;
|
|
1254
1282
|
}
|
|
1255
1283
|
return n.getTime();
|
|
1256
|
-
},
|
|
1257
|
-
timeZone: t =
|
|
1258
|
-
space: s =
|
|
1284
|
+
}, Ae = ({
|
|
1285
|
+
timeZone: t = Et,
|
|
1286
|
+
space: s = kt,
|
|
1259
1287
|
formatter: e,
|
|
1260
|
-
locale:
|
|
1288
|
+
locale: i,
|
|
1261
1289
|
showTimezone: o
|
|
1262
1290
|
} = {}) => (n, a) => {
|
|
1263
|
-
const { min: l, max: d } = n, u = Math.floor(a.chartAreaCanvasPX.width / s) + 1,
|
|
1264
|
-
(v) =>
|
|
1265
|
-
) ?? [1, "milliseconds"],
|
|
1291
|
+
const { min: l, max: d } = n, u = Math.floor(a.chartAreaCanvasPX.width / s) + 1, m = (d - l) / u, [f, h] = Qt.find(
|
|
1292
|
+
(v) => q(v) >= m
|
|
1293
|
+
) ?? [1, "milliseconds"], c = ie(l, [f, h], t), p = G(c, t), y = [c];
|
|
1266
1294
|
let x;
|
|
1267
1295
|
for (; ; ) {
|
|
1268
1296
|
switch (h) {
|
|
@@ -1270,31 +1298,31 @@ const ne = (t, s, e = "UTC") => {
|
|
|
1270
1298
|
case "seconds":
|
|
1271
1299
|
case "minutes":
|
|
1272
1300
|
case "hours": {
|
|
1273
|
-
x =
|
|
1301
|
+
x = K(c, [y.length * f, h]);
|
|
1274
1302
|
break;
|
|
1275
1303
|
}
|
|
1276
1304
|
case "days": {
|
|
1277
|
-
const v =
|
|
1305
|
+
const v = K(c, [
|
|
1278
1306
|
y.length * f,
|
|
1279
1307
|
h
|
|
1280
1308
|
]);
|
|
1281
|
-
x =
|
|
1282
|
-
|
|
1309
|
+
x = K(v, [
|
|
1310
|
+
p - G(v, t),
|
|
1283
1311
|
"hours"
|
|
1284
1312
|
]);
|
|
1285
1313
|
break;
|
|
1286
1314
|
}
|
|
1287
1315
|
case "months":
|
|
1288
1316
|
case "years": {
|
|
1289
|
-
const v =
|
|
1290
|
-
|
|
1317
|
+
const v = K(
|
|
1318
|
+
K(K(c, [p, "hours"]), [
|
|
1291
1319
|
y.length * f,
|
|
1292
1320
|
h
|
|
1293
1321
|
]),
|
|
1294
|
-
[-
|
|
1322
|
+
[-p, "hours"]
|
|
1295
1323
|
);
|
|
1296
|
-
x =
|
|
1297
|
-
|
|
1324
|
+
x = K(v, [
|
|
1325
|
+
p - G(v, t),
|
|
1298
1326
|
"hours"
|
|
1299
1327
|
]);
|
|
1300
1328
|
break;
|
|
@@ -1304,17 +1332,17 @@ const ne = (t, s, e = "UTC") => {
|
|
|
1304
1332
|
break;
|
|
1305
1333
|
y.push(x);
|
|
1306
1334
|
}
|
|
1307
|
-
return (e ??
|
|
1308
|
-
locale:
|
|
1335
|
+
return (e ?? ce({
|
|
1336
|
+
locale: i,
|
|
1309
1337
|
showTimezone: o,
|
|
1310
1338
|
timeZone: t
|
|
1311
1339
|
}))(y);
|
|
1312
|
-
},
|
|
1313
|
-
timeZone: t =
|
|
1314
|
-
locale: s =
|
|
1340
|
+
}, I = (t, s, e) => t.find((i) => i.type === e)?.value !== s.find((i) => i.type === e)?.value, ce = ({
|
|
1341
|
+
timeZone: t = Et,
|
|
1342
|
+
locale: s = Wt,
|
|
1315
1343
|
showTimezone: e = !0
|
|
1316
1344
|
}) => {
|
|
1317
|
-
const
|
|
1345
|
+
const i = new Intl.DateTimeFormat(s, {
|
|
1318
1346
|
year: "numeric",
|
|
1319
1347
|
day: "numeric",
|
|
1320
1348
|
month: "short",
|
|
@@ -1327,26 +1355,26 @@ const ne = (t, s, e = "UTC") => {
|
|
|
1327
1355
|
timeZone: t
|
|
1328
1356
|
});
|
|
1329
1357
|
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
|
|
1358
|
+
const n = o[1] - o[0], a = n < q([1, "days"]), l = n < q([1, "minutes"]), d = n < q([1, "seconds"]);
|
|
1359
|
+
return o.map((u) => ({ value: u, label: i.formatToParts(new Date(u)) })).map((u, r, m) => {
|
|
1360
|
+
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 = [];
|
|
1361
|
+
if (a && (y || v || x || S || g)) {
|
|
1362
|
+
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;
|
|
1363
|
+
let U = "";
|
|
1336
1364
|
if (l) {
|
|
1337
|
-
const
|
|
1365
|
+
const P = u.label.find((F) => F.type === "second")?.value, B = u.label.find(
|
|
1338
1366
|
(F) => F.type === "fractionalSecond"
|
|
1339
1367
|
)?.value;
|
|
1340
|
-
|
|
1368
|
+
U = `:${P}` + (d ? `.${B}` : "");
|
|
1341
1369
|
}
|
|
1342
1370
|
C.push(
|
|
1343
|
-
`${w}:${b}${
|
|
1371
|
+
`${w}:${b}${U}` + (e && x ? ` ${k}` : "")
|
|
1344
1372
|
);
|
|
1345
1373
|
}
|
|
1346
|
-
return (
|
|
1374
|
+
return (c || p) && C.push(
|
|
1347
1375
|
[
|
|
1348
1376
|
u.label.find((w) => w.type === "month")?.value,
|
|
1349
|
-
|
|
1377
|
+
c && u.label.find((w) => w.type === "day")?.value
|
|
1350
1378
|
].filter(Boolean).join(" ")
|
|
1351
1379
|
), h && C.push(u.label.find((w) => w.type === "year")?.value), {
|
|
1352
1380
|
value: u.value,
|
|
@@ -1357,38 +1385,41 @@ const ne = (t, s, e = "UTC") => {
|
|
|
1357
1385
|
};
|
|
1358
1386
|
};
|
|
1359
1387
|
export {
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1388
|
+
Se as AreaPlot,
|
|
1389
|
+
Me as AxisOverlay,
|
|
1390
|
+
xe as BarPlot,
|
|
1391
|
+
me as CanPlot,
|
|
1392
|
+
Ce as ChartAreaInteractions,
|
|
1393
|
+
ke as Crosshair,
|
|
1394
|
+
pe as LinePlot,
|
|
1395
|
+
ye as ScatterPlot,
|
|
1396
|
+
Ee as SelectBox,
|
|
1397
|
+
ge as SparklinePlot,
|
|
1398
|
+
Te as TooltipsX,
|
|
1399
|
+
we as XTicks,
|
|
1400
|
+
be as YTicks,
|
|
1401
|
+
_ as applyStyles,
|
|
1402
|
+
j as clamp,
|
|
1403
|
+
fe as clampUnfit,
|
|
1375
1404
|
O as clampXPosToChartArea,
|
|
1376
1405
|
$ as clampYPosToChartArea,
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1406
|
+
qt as defaultNumericalTicksFormatter,
|
|
1407
|
+
de as findClosestIndex,
|
|
1408
|
+
R as getScale,
|
|
1409
|
+
et as isXScale,
|
|
1410
|
+
he as isYScale,
|
|
1411
|
+
Pe as makeLinearTicks,
|
|
1412
|
+
ce as makeTimeTickFormat,
|
|
1413
|
+
Ae as makeTimeTicks,
|
|
1414
|
+
X as posToVal,
|
|
1415
|
+
Dt as pxToValDistance,
|
|
1416
|
+
ue as sum,
|
|
1386
1417
|
z as useDrawEffect,
|
|
1387
1418
|
ft as useFrameState,
|
|
1388
1419
|
pt as useInteractionsEvent,
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1420
|
+
ve as useXPositioned,
|
|
1421
|
+
at as valFits,
|
|
1422
|
+
H as valToPos,
|
|
1392
1423
|
dt as valToPxDistance
|
|
1393
1424
|
};
|
|
1394
1425
|
//# sourceMappingURL=canplot.mjs.map
|