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