@canplot/react 0.1.23 → 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 +613 -608
- package/dist/canplot.mjs.map +1 -1
- package/dist/interactions/ChartAreaInteractions.d.ts +1 -0
- package/dist/interactions/ChartAreaInteractions.d.ts.map +1 -1
- package/dist/interactions/CrossHair.d.ts.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
|
-
}, [
|
|
186
|
-
const
|
|
187
|
-
return /* @__PURE__ */
|
|
185
|
+
}, [d, u]);
|
|
186
|
+
const h = window.devicePixelRatio || 1;
|
|
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
|
-
|
|
276
|
+
h -= l.axis.size * o, m = {
|
|
277
277
|
x: i.x,
|
|
278
|
-
y:
|
|
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,36 +333,36 @@ 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
|
-
|
|
345
|
-
for (const
|
|
346
|
-
const a = r(h
|
|
347
|
-
|
|
342
|
+
({ getCtx: i, clampXPosToChartArea: r, clampYPosToChartArea: c, valToPos: u }) => {
|
|
343
|
+
const d = i();
|
|
344
|
+
d.save(), d.beginPath(), _(d, o);
|
|
345
|
+
for (const h of e) {
|
|
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
|
|
356
|
-
|
|
354
|
+
({ getCtx: c, valToPos: u, valFits: d }) => {
|
|
355
|
+
const h = c();
|
|
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
368
|
), null), be = ({
|
|
@@ -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:
|
|
382
|
-
valToPos:
|
|
380
|
+
getCtx: u,
|
|
381
|
+
valToPxDistance: d,
|
|
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 =
|
|
393
|
-
r ?
|
|
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(
|
|
394
|
+
y,
|
|
394
395
|
b,
|
|
396
|
+
g,
|
|
395
397
|
S,
|
|
396
|
-
w,
|
|
397
|
-
y,
|
|
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
|
-
const
|
|
413
|
-
if (
|
|
414
|
-
|
|
415
|
-
for (const a of
|
|
416
|
-
|
|
417
|
-
|
|
412
|
+
const h = i();
|
|
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
|
+
h.lineTo(a.x, a.y);
|
|
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:
|
|
424
|
-
const
|
|
425
|
-
for (const
|
|
426
|
-
const
|
|
427
|
-
|
|
423
|
+
({ getCtx: r, clampXPosToChartArea: c, clampYPosToChartArea: u, valToPos: d }) => {
|
|
424
|
+
const h = [], a = r();
|
|
425
|
+
for (const x of e) {
|
|
426
|
+
const p = c(d(x.x, s)), v = u(d(x.y, o));
|
|
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,82 +450,82 @@ 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
|
|
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
|
|
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
|
},
|
|
527
527
|
[r, e, t, s]
|
|
528
|
-
), null),
|
|
528
|
+
), null), k = () => {
|
|
529
529
|
const n = [];
|
|
530
530
|
return {
|
|
531
531
|
addEventListener: (e, t) => (n.push({
|
|
@@ -541,16 +541,16 @@ const ye = Kt(({ configuration: n, children: e, style: t, className: s }, o) =>
|
|
|
541
541
|
}
|
|
542
542
|
};
|
|
543
543
|
}, E = {
|
|
544
|
-
dblclick:
|
|
545
|
-
click:
|
|
546
|
-
contextmenu:
|
|
547
|
-
move:
|
|
548
|
-
mousedown:
|
|
549
|
-
mouseup:
|
|
550
|
-
spanselect:
|
|
551
|
-
documentmouseup:
|
|
552
|
-
pressandwheel:
|
|
553
|
-
sync_move:
|
|
544
|
+
dblclick: k(),
|
|
545
|
+
click: k(),
|
|
546
|
+
contextmenu: k(),
|
|
547
|
+
move: k(),
|
|
548
|
+
mousedown: k(),
|
|
549
|
+
mouseup: k(),
|
|
550
|
+
spanselect: k(),
|
|
551
|
+
documentmouseup: k(),
|
|
552
|
+
pressandwheel: k(),
|
|
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(
|
|
@@ -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(
|
|
562
|
+
}, vt = Q.createContext(""), gt = (n, e) => {
|
|
563
|
+
const t = Q.useContext(vt);
|
|
564
564
|
return A(n, t, e);
|
|
565
|
-
},
|
|
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, h = {
|
|
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,78 +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:
|
|
631
|
-
style:
|
|
625
|
+
onSpanSelect: c,
|
|
626
|
+
onContextMenu: u,
|
|
627
|
+
className: d,
|
|
628
|
+
style: h,
|
|
632
629
|
sync: a,
|
|
633
|
-
|
|
630
|
+
innerChildren: f,
|
|
631
|
+
children: l
|
|
634
632
|
}) => {
|
|
635
|
-
const
|
|
636
|
-
return A("dblclick",
|
|
637
|
-
t?.(
|
|
638
|
-
}), A("click",
|
|
639
|
-
e?.(
|
|
640
|
-
}), A("move",
|
|
641
|
-
s?.(
|
|
642
|
-
}), A("mousedown",
|
|
643
|
-
o?.(
|
|
644
|
-
}), A("mouseup",
|
|
645
|
-
i?.(
|
|
646
|
-
}), A("documentmouseup",
|
|
647
|
-
r?.(
|
|
648
|
-
}), A("spanselect",
|
|
649
|
-
|
|
650
|
-
}), A("contextmenu",
|
|
651
|
-
|
|
652
|
-
}), /* @__PURE__ */
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
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,
|
|
653
|
+
{
|
|
654
|
+
id: n,
|
|
655
|
+
className: d,
|
|
656
|
+
style: h,
|
|
657
|
+
sync: a,
|
|
658
|
+
children: f
|
|
659
|
+
}
|
|
660
|
+
),
|
|
661
|
+
l
|
|
662
|
+
] });
|
|
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)
|
|
668
670
|
throw new Error(
|
|
669
671
|
"ChartAreaInteractions must be used within a CanPlot component"
|
|
670
672
|
);
|
|
671
|
-
return
|
|
673
|
+
return p.getBoundingClientRect();
|
|
672
674
|
}
|
|
673
|
-
},
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
675
|
+
}, m = (p, v) => {
|
|
676
|
+
const w = Gt(
|
|
677
|
+
p,
|
|
678
|
+
l(),
|
|
679
|
+
c.current,
|
|
680
|
+
s?.xViaScaleId,
|
|
681
|
+
s?.yViaScaleId
|
|
680
682
|
);
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
{ cssX:
|
|
683
|
+
w && v(
|
|
684
|
+
w.pointerSyncPosition,
|
|
685
|
+
{ cssX: w.cssX, cssY: w.cssY },
|
|
684
686
|
{
|
|
685
|
-
ctrlKey:
|
|
686
|
-
altKey:
|
|
687
|
-
shiftKey:
|
|
688
|
-
metaKey:
|
|
687
|
+
ctrlKey: p.ctrlKey,
|
|
688
|
+
altKey: p.altKey,
|
|
689
|
+
shiftKey: p.shiftKey,
|
|
690
|
+
metaKey: p.metaKey
|
|
689
691
|
}
|
|
690
692
|
);
|
|
691
|
-
},
|
|
692
|
-
return
|
|
693
|
-
const
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
...
|
|
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,
|
|
697
699
|
completed: !0
|
|
698
|
-
}), E.documentmouseup.dispatchEvent(
|
|
699
|
-
frame:
|
|
700
|
+
}), E.documentmouseup.dispatchEvent(u, {
|
|
701
|
+
frame: c.current,
|
|
700
702
|
keys: {
|
|
701
703
|
ctrlKey: y.ctrlKey,
|
|
702
704
|
altKey: y.altKey,
|
|
@@ -704,72 +706,72 @@ const ye = Kt(({ configuration: n, children: e, style: t, className: s }, o) =>
|
|
|
704
706
|
metaKey: y.metaKey
|
|
705
707
|
}
|
|
706
708
|
});
|
|
707
|
-
},
|
|
708
|
-
const
|
|
709
|
+
}, v = (y) => {
|
|
710
|
+
const g = {
|
|
709
711
|
ctrlKey: y.ctrlKey,
|
|
710
712
|
altKey: y.altKey,
|
|
711
713
|
shiftKey: y.shiftKey,
|
|
712
714
|
metaKey: y.metaKey
|
|
713
|
-
},
|
|
714
|
-
if (
|
|
715
|
-
([T, M]) =>
|
|
715
|
+
}, P = f.current;
|
|
716
|
+
if (P && Object.entries(g).some(
|
|
717
|
+
([T, M]) => P.keys[T] !== M
|
|
716
718
|
)) {
|
|
717
|
-
const T = { ...
|
|
718
|
-
|
|
719
|
+
const T = { ...P, keys: g };
|
|
720
|
+
f.current = T, E.sync_move.dispatchEvent(d, T);
|
|
719
721
|
}
|
|
720
|
-
const
|
|
721
|
-
if (
|
|
722
|
-
([T, M]) =>
|
|
722
|
+
const C = a.current;
|
|
723
|
+
if (C && Object.entries(g).some(
|
|
724
|
+
([T, M]) => C.keys[T] !== M
|
|
723
725
|
)) {
|
|
724
726
|
y.stopPropagation(), y.preventDefault();
|
|
725
|
-
const T = { ...
|
|
726
|
-
|
|
727
|
+
const T = { ...C, keys: g };
|
|
728
|
+
a.current = T, E.spanselect.dispatchEvent(u, T);
|
|
727
729
|
}
|
|
728
|
-
},
|
|
729
|
-
|
|
730
|
+
}, w = (y) => {
|
|
731
|
+
x.current(
|
|
730
732
|
y,
|
|
731
|
-
(
|
|
732
|
-
const M =
|
|
733
|
-
if (!M || !
|
|
734
|
-
const
|
|
735
|
-
|
|
736
|
-
xRangeCss: { start:
|
|
737
|
-
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 }
|
|
738
740
|
};
|
|
739
741
|
let $ = "below_threshold";
|
|
740
|
-
const
|
|
741
|
-
|
|
742
|
-
const
|
|
743
|
-
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,
|
|
744
746
|
from: L(
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
747
|
+
R,
|
|
748
|
+
B(c.current, O, "css"),
|
|
749
|
+
ct.id,
|
|
748
750
|
"css"
|
|
749
751
|
),
|
|
750
752
|
to: L(
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
753
|
+
R,
|
|
754
|
+
B(c.current, ot, "css"),
|
|
755
|
+
ct.id,
|
|
754
756
|
"css"
|
|
755
757
|
)
|
|
756
|
-
},
|
|
757
|
-
scaleId:
|
|
758
|
+
}, St = {
|
|
759
|
+
scaleId: at.id,
|
|
758
760
|
from: L(
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
761
|
+
R,
|
|
762
|
+
N(c.current, it, "css"),
|
|
763
|
+
at.id,
|
|
762
764
|
"css"
|
|
763
765
|
),
|
|
764
766
|
to: L(
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
767
|
+
R,
|
|
768
|
+
N(c.current, rt, "css"),
|
|
769
|
+
at.id,
|
|
768
770
|
"css"
|
|
769
771
|
)
|
|
770
|
-
}, W =
|
|
772
|
+
}, W = bt && Ct("x", bt, c.current), q = St && Ct("y", St, c.current), Lt = W?.scaled, Ut = q?.scaled, Tt = {
|
|
771
773
|
mode: $,
|
|
772
|
-
frame:
|
|
774
|
+
frame: c.current,
|
|
773
775
|
completed: !1,
|
|
774
776
|
x: {
|
|
775
777
|
css: W && {
|
|
@@ -783,265 +785,268 @@ const ye = Kt(({ configuration: n, children: e, style: t, className: s }, o) =>
|
|
|
783
785
|
from: q.fromCSS,
|
|
784
786
|
to: q.toCSS
|
|
785
787
|
},
|
|
786
|
-
scaled:
|
|
788
|
+
scaled: Ut ?? []
|
|
787
789
|
},
|
|
788
790
|
keys: T
|
|
789
791
|
};
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
792
|
+
a.current = Tt, E.spanselect.dispatchEvent(
|
|
793
|
+
u,
|
|
794
|
+
Tt
|
|
793
795
|
);
|
|
794
796
|
}
|
|
795
797
|
);
|
|
796
|
-
},
|
|
797
|
-
|
|
798
|
-
const T =
|
|
799
|
-
|
|
800
|
-
|
|
798
|
+
}, b = (y) => {
|
|
799
|
+
x.current(y, (g, P, C) => {
|
|
800
|
+
const T = F(
|
|
801
|
+
g,
|
|
802
|
+
c.current
|
|
801
803
|
);
|
|
802
804
|
if (!T) return;
|
|
803
|
-
if (Object.values(
|
|
805
|
+
if (Object.values(C).some((R) => R)) {
|
|
804
806
|
y.preventDefault();
|
|
805
|
-
const
|
|
806
|
-
E.pressandwheel.dispatchEvent(
|
|
807
|
+
const R = Math.abs(y.deltaY) > Math.abs(y.deltaX) ? y.deltaY : y.deltaX;
|
|
808
|
+
E.pressandwheel.dispatchEvent(u, {
|
|
807
809
|
pointer: T,
|
|
808
|
-
frame:
|
|
809
|
-
keys:
|
|
810
|
+
frame: c.current,
|
|
811
|
+
keys: C,
|
|
810
812
|
deltaX: y.deltaX,
|
|
811
813
|
deltaY: y.deltaY,
|
|
812
|
-
deltaAbs:
|
|
814
|
+
deltaAbs: R
|
|
813
815
|
});
|
|
814
816
|
}
|
|
815
817
|
});
|
|
816
818
|
};
|
|
817
|
-
document.addEventListener("mouseup",
|
|
818
|
-
const S =
|
|
819
|
-
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, {
|
|
820
822
|
passive: !1
|
|
821
823
|
}), () => {
|
|
822
|
-
document.removeEventListener("mouseup",
|
|
824
|
+
document.removeEventListener("mouseup", p), document.removeEventListener("keydown", v), document.removeEventListener("keyup", v), document.removeEventListener("mousemove", w), S?.removeEventListener("wheel", b);
|
|
823
825
|
};
|
|
824
|
-
}, [
|
|
825
|
-
const
|
|
826
|
-
|
|
827
|
-
|
|
826
|
+
}, [c, u, d, x]), A("sync_move", d, (p) => {
|
|
827
|
+
const v = p.positions ? F(
|
|
828
|
+
p.positions,
|
|
829
|
+
c.current
|
|
828
830
|
) : null;
|
|
829
|
-
|
|
830
|
-
frame:
|
|
831
|
-
pointer:
|
|
832
|
-
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"
|
|
833
836
|
});
|
|
834
|
-
}), /* @__PURE__ */
|
|
837
|
+
}), /* @__PURE__ */ D(
|
|
835
838
|
"div",
|
|
836
839
|
{
|
|
837
|
-
ref:
|
|
838
|
-
id:
|
|
839
|
-
className:
|
|
840
|
+
ref: i,
|
|
841
|
+
id: n,
|
|
842
|
+
className: e,
|
|
840
843
|
style: {
|
|
841
844
|
position: "absolute",
|
|
842
|
-
left:
|
|
843
|
-
top:
|
|
844
|
-
width:
|
|
845
|
-
height:
|
|
845
|
+
left: r.chartAreaCSS.x,
|
|
846
|
+
top: r.chartAreaCSS.y,
|
|
847
|
+
width: r.chartAreaCSS.width,
|
|
848
|
+
height: r.chartAreaCSS.height,
|
|
846
849
|
zIndex: 25,
|
|
847
|
-
...
|
|
850
|
+
...t
|
|
848
851
|
},
|
|
849
|
-
onDragStart: (
|
|
850
|
-
|
|
852
|
+
onDragStart: (p) => {
|
|
853
|
+
p.preventDefault();
|
|
851
854
|
},
|
|
852
|
-
onClick: (
|
|
853
|
-
|
|
854
|
-
const S =
|
|
855
|
-
|
|
856
|
-
|
|
855
|
+
onClick: (p) => {
|
|
856
|
+
m(p, (v, w, b) => {
|
|
857
|
+
const S = F(
|
|
858
|
+
v,
|
|
859
|
+
c.current
|
|
857
860
|
);
|
|
858
|
-
S && E.click.dispatchEvent(
|
|
861
|
+
S && E.click.dispatchEvent(u, {
|
|
859
862
|
pointer: S,
|
|
860
|
-
frame:
|
|
861
|
-
keys:
|
|
863
|
+
frame: c.current,
|
|
864
|
+
keys: b
|
|
862
865
|
});
|
|
863
866
|
});
|
|
864
867
|
},
|
|
865
|
-
onMouseLeave: (
|
|
866
|
-
|
|
867
|
-
E.sync_move.dispatchEvent(
|
|
868
|
+
onMouseLeave: (p) => {
|
|
869
|
+
m(p, (v, w, b) => {
|
|
870
|
+
E.sync_move.dispatchEvent(d, {
|
|
868
871
|
positions: null,
|
|
869
|
-
keys:
|
|
872
|
+
keys: b,
|
|
873
|
+
originInteractionsId: u
|
|
870
874
|
});
|
|
871
875
|
});
|
|
872
876
|
},
|
|
873
|
-
onMouseMove: (
|
|
874
|
-
|
|
875
|
-
E.sync_move.dispatchEvent(
|
|
876
|
-
positions:
|
|
877
|
-
keys:
|
|
877
|
+
onMouseMove: (p) => {
|
|
878
|
+
m(p, (v, w, b) => {
|
|
879
|
+
E.sync_move.dispatchEvent(d, {
|
|
880
|
+
positions: v,
|
|
881
|
+
keys: b,
|
|
882
|
+
originInteractionsId: u
|
|
878
883
|
});
|
|
879
884
|
});
|
|
880
885
|
},
|
|
881
|
-
onMouseDown: (
|
|
882
|
-
|
|
883
|
-
const y =
|
|
884
|
-
|
|
885
|
-
|
|
886
|
+
onMouseDown: (p) => {
|
|
887
|
+
m(p, (v, { cssX: w, cssY: b }, S) => {
|
|
888
|
+
const y = F(
|
|
889
|
+
v,
|
|
890
|
+
c.current
|
|
886
891
|
);
|
|
887
|
-
y && (E.mousedown.dispatchEvent(
|
|
892
|
+
y && (E.mousedown.dispatchEvent(u, {
|
|
888
893
|
pointer: y,
|
|
889
|
-
frame:
|
|
894
|
+
frame: c.current,
|
|
890
895
|
keys: S
|
|
891
|
-
}),
|
|
892
|
-
xRangeCss: { start:
|
|
893
|
-
yRangeCss: { start:
|
|
896
|
+
}), h.current = {
|
|
897
|
+
xRangeCss: { start: w, end: w },
|
|
898
|
+
yRangeCss: { start: b, end: b }
|
|
894
899
|
});
|
|
895
900
|
});
|
|
896
901
|
},
|
|
897
|
-
onMouseUp: (
|
|
898
|
-
|
|
899
|
-
const S =
|
|
900
|
-
|
|
901
|
-
|
|
902
|
+
onMouseUp: (p) => {
|
|
903
|
+
m(p, (v, w, b) => {
|
|
904
|
+
const S = F(
|
|
905
|
+
v,
|
|
906
|
+
c.current
|
|
902
907
|
);
|
|
903
908
|
if (!S) return;
|
|
904
|
-
E.mouseup.dispatchEvent(
|
|
905
|
-
frame:
|
|
909
|
+
E.mouseup.dispatchEvent(u, {
|
|
910
|
+
frame: c.current,
|
|
906
911
|
pointer: S,
|
|
907
|
-
keys:
|
|
912
|
+
keys: b
|
|
908
913
|
});
|
|
909
|
-
const y =
|
|
910
|
-
|
|
911
|
-
const
|
|
912
|
-
if (
|
|
913
|
-
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 = {
|
|
914
919
|
...y,
|
|
915
|
-
keys:
|
|
920
|
+
keys: b,
|
|
916
921
|
completed: !0
|
|
917
922
|
};
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
923
|
+
a.current = null, E.spanselect.dispatchEvent(
|
|
924
|
+
u,
|
|
925
|
+
P
|
|
921
926
|
);
|
|
922
927
|
}
|
|
923
928
|
});
|
|
924
929
|
},
|
|
925
|
-
onContextMenu: (
|
|
926
|
-
|
|
927
|
-
const S =
|
|
928
|
-
|
|
929
|
-
|
|
930
|
+
onContextMenu: (p) => {
|
|
931
|
+
p.preventDefault(), m(p, (v, w, b) => {
|
|
932
|
+
const S = F(
|
|
933
|
+
v,
|
|
934
|
+
c.current
|
|
930
935
|
);
|
|
931
|
-
S && E.contextmenu.dispatchEvent(
|
|
932
|
-
frame:
|
|
936
|
+
S && E.contextmenu.dispatchEvent(u, {
|
|
937
|
+
frame: c.current,
|
|
933
938
|
pointer: S,
|
|
934
|
-
keys:
|
|
939
|
+
keys: b
|
|
935
940
|
});
|
|
936
941
|
});
|
|
937
942
|
},
|
|
938
|
-
onDoubleClick: (
|
|
939
|
-
|
|
940
|
-
const S =
|
|
941
|
-
|
|
942
|
-
|
|
943
|
+
onDoubleClick: (p) => {
|
|
944
|
+
m(p, (v, w, b) => {
|
|
945
|
+
const S = F(
|
|
946
|
+
v,
|
|
947
|
+
c.current
|
|
943
948
|
);
|
|
944
|
-
S && E.dblclick.dispatchEvent(
|
|
945
|
-
frame:
|
|
949
|
+
S && E.dblclick.dispatchEvent(u, {
|
|
950
|
+
frame: c.current,
|
|
946
951
|
pointer: S,
|
|
947
|
-
keys:
|
|
952
|
+
keys: b
|
|
948
953
|
});
|
|
949
954
|
});
|
|
950
955
|
},
|
|
951
|
-
children:
|
|
956
|
+
children: o
|
|
952
957
|
}
|
|
953
958
|
);
|
|
954
|
-
},
|
|
959
|
+
}, Re = ({ data: n, renderTooltip: e, xScaleId: t }) => {
|
|
955
960
|
const [s, o] = V(null);
|
|
956
|
-
|
|
961
|
+
gt("move", (r) => {
|
|
957
962
|
o(r);
|
|
958
963
|
});
|
|
959
964
|
const i = et(() => {
|
|
960
965
|
if (!s)
|
|
961
966
|
return null;
|
|
962
|
-
const { frame: r, pointer:
|
|
963
|
-
if (
|
|
967
|
+
const { frame: r, pointer: c } = s, u = c?.scaled[t];
|
|
968
|
+
if (u === void 0)
|
|
964
969
|
return null;
|
|
965
|
-
const
|
|
966
|
-
let
|
|
970
|
+
const d = [];
|
|
971
|
+
let h = u;
|
|
967
972
|
for (const a of n) {
|
|
968
|
-
let
|
|
969
|
-
for (const [
|
|
970
|
-
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))
|
|
971
976
|
continue;
|
|
972
|
-
const v = Math.abs(
|
|
973
|
-
v <
|
|
977
|
+
const v = Math.abs(p.x - u);
|
|
978
|
+
v < l && (l = v, f = x);
|
|
974
979
|
}
|
|
975
|
-
const
|
|
976
|
-
if (!
|
|
977
|
-
|
|
980
|
+
const m = a.points[f ?? -1];
|
|
981
|
+
if (!m || pt(r, l, t, "css") > 30) {
|
|
982
|
+
d.push({ seriesId: a.seriesId, y: null });
|
|
978
983
|
continue;
|
|
979
984
|
}
|
|
980
|
-
|
|
985
|
+
h = m.x, d.push({
|
|
981
986
|
seriesId: a.seriesId,
|
|
982
|
-
y:
|
|
987
|
+
y: m.y
|
|
983
988
|
});
|
|
984
989
|
}
|
|
985
990
|
return {
|
|
986
991
|
frame: r,
|
|
987
|
-
x:
|
|
988
|
-
points:
|
|
992
|
+
x: h,
|
|
993
|
+
points: d
|
|
989
994
|
};
|
|
990
995
|
}, [n, s, t]);
|
|
991
996
|
return e(i);
|
|
992
997
|
}, ke = ({ makeXStyle: n, makeXClassName: e, makeYStyle: t, makeYClassName: s }) => {
|
|
993
998
|
const [o, i] = V(null);
|
|
994
|
-
if (
|
|
995
|
-
i(
|
|
999
|
+
if (gt("move", (f) => {
|
|
1000
|
+
i(f);
|
|
996
1001
|
}), !o)
|
|
997
1002
|
return null;
|
|
998
|
-
const { frame: r, pointer:
|
|
999
|
-
return /* @__PURE__ */
|
|
1000
|
-
/* @__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(
|
|
1001
1006
|
"div",
|
|
1002
1007
|
{
|
|
1003
|
-
"data-show": !!
|
|
1008
|
+
"data-show": !!c,
|
|
1004
1009
|
className: e?.(o),
|
|
1005
1010
|
style: {
|
|
1006
1011
|
position: "absolute",
|
|
1007
1012
|
left: 0,
|
|
1008
|
-
visibility:
|
|
1009
|
-
top:
|
|
1010
|
-
|
|
1013
|
+
visibility: u === null ? "hidden" : "visible",
|
|
1014
|
+
top: r.chartAreaCSS.y,
|
|
1015
|
+
height: r.chartAreaCSS.height,
|
|
1011
1016
|
borderColor: "red",
|
|
1012
1017
|
borderLeftWidth: "1px",
|
|
1013
1018
|
borderLeftStyle: "solid",
|
|
1014
1019
|
pointerEvents: "none",
|
|
1015
|
-
opacity:
|
|
1016
|
-
transform: `translateX(${
|
|
1020
|
+
opacity: c ? 1 : 0,
|
|
1021
|
+
transform: `translateX(${h}px)`,
|
|
1017
1022
|
...n?.(o)
|
|
1018
1023
|
}
|
|
1019
1024
|
}
|
|
1020
1025
|
),
|
|
1021
|
-
/* @__PURE__ */
|
|
1026
|
+
/* @__PURE__ */ D(
|
|
1022
1027
|
"div",
|
|
1023
1028
|
{
|
|
1024
1029
|
className: s?.(o),
|
|
1025
|
-
"data-show": !!
|
|
1030
|
+
"data-show": !!c,
|
|
1026
1031
|
style: {
|
|
1027
1032
|
position: "absolute",
|
|
1028
|
-
visibility:
|
|
1033
|
+
visibility: d === null ? "hidden" : "visible",
|
|
1029
1034
|
top: 0,
|
|
1030
1035
|
height: 0,
|
|
1031
1036
|
borderTop: "solid 1px red",
|
|
1032
|
-
left:
|
|
1033
|
-
|
|
1037
|
+
left: r.chartAreaCSS.x,
|
|
1038
|
+
width: r.chartAreaCSS.width,
|
|
1034
1039
|
pointerEvents: "none",
|
|
1035
|
-
opacity:
|
|
1040
|
+
opacity: c ? 1 : 0,
|
|
1036
1041
|
transform: `translateY(${a}px)`,
|
|
1037
1042
|
...t?.(o)
|
|
1038
1043
|
}
|
|
1039
1044
|
}
|
|
1040
1045
|
)
|
|
1041
1046
|
] });
|
|
1042
|
-
},
|
|
1047
|
+
}, Ae = ({ makeClassName: n, makeStyle: e }) => {
|
|
1043
1048
|
const [t, s] = V(null);
|
|
1044
|
-
|
|
1049
|
+
gt("spanselect", (i) => {
|
|
1045
1050
|
s(
|
|
1046
1051
|
i.mode === "below_threshold" || i.completed ? null : i
|
|
1047
1052
|
);
|
|
@@ -1049,10 +1054,10 @@ const ye = Kt(({ configuration: n, children: e, style: t, className: s }, o) =>
|
|
|
1049
1054
|
const o = et(() => {
|
|
1050
1055
|
if (!t || t.mode === "below_threshold")
|
|
1051
1056
|
return null;
|
|
1052
|
-
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,
|
|
1053
|
-
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 };
|
|
1054
1059
|
}, [t]);
|
|
1055
|
-
return /* @__PURE__ */
|
|
1060
|
+
return /* @__PURE__ */ D(
|
|
1056
1061
|
"div",
|
|
1057
1062
|
{
|
|
1058
1063
|
className: t ? n?.(t) : void 0,
|
|
@@ -1068,9 +1073,9 @@ const ye = Kt(({ configuration: n, children: e, style: t, className: s }, o) =>
|
|
|
1068
1073
|
}
|
|
1069
1074
|
}
|
|
1070
1075
|
);
|
|
1071
|
-
},
|
|
1072
|
-
const o =
|
|
1073
|
-
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(
|
|
1074
1079
|
"div",
|
|
1075
1080
|
{
|
|
1076
1081
|
style: {
|
|
@@ -1086,32 +1091,32 @@ const ye = Kt(({ configuration: n, children: e, style: t, className: s }, o) =>
|
|
|
1086
1091
|
children: e
|
|
1087
1092
|
}
|
|
1088
1093
|
) : null;
|
|
1089
|
-
},
|
|
1094
|
+
}, Dt = 60, Jt = 30, _t = "UTC", Qt = "en-GB", _e = ({
|
|
1090
1095
|
space: n,
|
|
1091
1096
|
formatter: e,
|
|
1092
1097
|
acceptableIncrements: t
|
|
1093
1098
|
} = {}) => (s, o) => {
|
|
1094
|
-
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(
|
|
1095
1100
|
o,
|
|
1096
|
-
|
|
1101
|
+
d,
|
|
1097
1102
|
s.id,
|
|
1098
1103
|
"canvas"
|
|
1099
|
-
), a = t ?? G,
|
|
1100
|
-
let
|
|
1101
|
-
if (Math.abs(
|
|
1102
|
-
const
|
|
1103
|
-
|
|
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;
|
|
1104
1109
|
}
|
|
1105
|
-
for (;
|
|
1106
|
-
|
|
1107
|
-
return (e ??
|
|
1108
|
-
},
|
|
1110
|
+
for (; l <= r && c.length < 1e3; )
|
|
1111
|
+
c.push(l), l += f;
|
|
1112
|
+
return (e ?? te)(c);
|
|
1113
|
+
}, te = (n) => {
|
|
1109
1114
|
const e = Math.max(0, Math.ceil(-Math.log10(n[1] - n[0])));
|
|
1110
1115
|
return n.map((t) => ({ value: t, label: t.toFixed(e) }));
|
|
1111
1116
|
}, G = [];
|
|
1112
1117
|
for (let n = -12; n <= 12; n++)
|
|
1113
1118
|
G.push(1 * 10 ** n), G.push(2 * 10 ** n), G.push(5 * 10 ** n);
|
|
1114
|
-
const
|
|
1119
|
+
const ee = 1, It = 1e3 * ee, wt = 60 * It, nt = 60 * wt, st = 24 * nt, ne = 30 * st, se = 365 * st, oe = [
|
|
1115
1120
|
// second divisors
|
|
1116
1121
|
[1, "milliseconds"],
|
|
1117
1122
|
[2, "milliseconds"],
|
|
@@ -1169,60 +1174,60 @@ const te = 1, _t = 1e3 * te, vt = 60 * _t, nt = 60 * vt, st = 24 * nt, ee = 30 *
|
|
|
1169
1174
|
case "milliseconds":
|
|
1170
1175
|
return e;
|
|
1171
1176
|
case "seconds":
|
|
1172
|
-
return e *
|
|
1177
|
+
return e * It;
|
|
1173
1178
|
case "minutes":
|
|
1174
|
-
return e *
|
|
1179
|
+
return e * wt;
|
|
1175
1180
|
case "hours":
|
|
1176
1181
|
return e * nt;
|
|
1177
1182
|
case "days":
|
|
1178
1183
|
return e * st;
|
|
1179
1184
|
case "months":
|
|
1180
|
-
return e * ee;
|
|
1181
|
-
case "years":
|
|
1182
1185
|
return e * ne;
|
|
1186
|
+
case "years":
|
|
1187
|
+
return e * se;
|
|
1183
1188
|
}
|
|
1184
|
-
},
|
|
1189
|
+
}, ie = (n, e) => {
|
|
1185
1190
|
const t = new Date(n);
|
|
1186
1191
|
return t.setUTCMilliseconds(t.getUTCMilliseconds() + e), t.getTime();
|
|
1187
|
-
},
|
|
1192
|
+
}, re = (n, e) => {
|
|
1188
1193
|
const t = new Date(n);
|
|
1189
1194
|
return t.setUTCSeconds(t.getUTCSeconds() + e), t.getTime();
|
|
1190
|
-
},
|
|
1195
|
+
}, ce = (n, e) => {
|
|
1191
1196
|
const t = new Date(n);
|
|
1192
1197
|
return t.setUTCMinutes(t.getUTCMinutes() + e), t.getTime();
|
|
1193
|
-
},
|
|
1198
|
+
}, ae = (n, e) => {
|
|
1194
1199
|
const t = new Date(n);
|
|
1195
1200
|
return t.setUTCHours(t.getUTCHours() + e), t.getTime();
|
|
1196
|
-
},
|
|
1201
|
+
}, le = (n, e) => {
|
|
1197
1202
|
const t = new Date(n);
|
|
1198
1203
|
return t.setUTCDate(t.getUTCDate() + e), t.getTime();
|
|
1199
|
-
},
|
|
1204
|
+
}, Mt = (n, e) => {
|
|
1200
1205
|
const t = new Date(n);
|
|
1201
1206
|
return t.setUTCMonth(t.getUTCMonth() + e), t.getTime();
|
|
1202
|
-
},
|
|
1207
|
+
}, K = (n, e) => {
|
|
1203
1208
|
const [t, s] = e;
|
|
1204
1209
|
switch (s) {
|
|
1205
1210
|
case "milliseconds":
|
|
1206
|
-
return oe(n, t);
|
|
1207
|
-
case "seconds":
|
|
1208
1211
|
return ie(n, t);
|
|
1209
|
-
case "
|
|
1212
|
+
case "seconds":
|
|
1210
1213
|
return re(n, t);
|
|
1211
|
-
case "
|
|
1214
|
+
case "minutes":
|
|
1212
1215
|
return ce(n, t);
|
|
1213
|
-
case "
|
|
1216
|
+
case "hours":
|
|
1214
1217
|
return ae(n, t);
|
|
1218
|
+
case "days":
|
|
1219
|
+
return le(n, t);
|
|
1215
1220
|
case "months":
|
|
1216
|
-
return
|
|
1221
|
+
return Mt(n, t);
|
|
1217
1222
|
case "years":
|
|
1218
|
-
return
|
|
1223
|
+
return Mt(n, t * 12);
|
|
1219
1224
|
}
|
|
1220
1225
|
};
|
|
1221
1226
|
function J(n, e) {
|
|
1222
1227
|
const t = new Date(n), s = new Date(t.toLocaleString("en-US", { timeZone: e })), o = new Date(t.toLocaleString("en-US", { timeZone: "UTC" }));
|
|
1223
1228
|
return (s.getTime() - o.getTime()) / (3600 * 1e3);
|
|
1224
1229
|
}
|
|
1225
|
-
const
|
|
1230
|
+
const ue = (n, e, t = "UTC") => {
|
|
1226
1231
|
const [s, o] = e;
|
|
1227
1232
|
let i = new Date(n);
|
|
1228
1233
|
const r = () => {
|
|
@@ -1242,7 +1247,7 @@ const le = (n, e, t = "UTC") => {
|
|
|
1242
1247
|
break;
|
|
1243
1248
|
case "minutes":
|
|
1244
1249
|
i.setUTCMinutes(
|
|
1245
|
-
Math.ceil(i.getTime() % nt /
|
|
1250
|
+
Math.ceil(i.getTime() % nt / wt / s) * s,
|
|
1246
1251
|
0,
|
|
1247
1252
|
0
|
|
1248
1253
|
);
|
|
@@ -1258,69 +1263,69 @@ const le = (n, e, t = "UTC") => {
|
|
|
1258
1263
|
case "days":
|
|
1259
1264
|
case "months":
|
|
1260
1265
|
case "years":
|
|
1261
|
-
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])));
|
|
1262
1267
|
break;
|
|
1263
1268
|
}
|
|
1264
1269
|
return i.getTime();
|
|
1265
|
-
},
|
|
1266
|
-
timeZone: n =
|
|
1267
|
-
space: e =
|
|
1270
|
+
}, Ie = ({
|
|
1271
|
+
timeZone: n = _t,
|
|
1272
|
+
space: e = Dt,
|
|
1268
1273
|
formatter: t,
|
|
1269
1274
|
locale: s,
|
|
1270
1275
|
showTimezone: o
|
|
1271
1276
|
} = {}) => (i, r) => {
|
|
1272
|
-
const { min:
|
|
1273
|
-
(
|
|
1274
|
-
) ?? [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];
|
|
1275
1280
|
let v;
|
|
1276
1281
|
for (; ; ) {
|
|
1277
|
-
switch (
|
|
1282
|
+
switch (l) {
|
|
1278
1283
|
case "milliseconds":
|
|
1279
1284
|
case "seconds":
|
|
1280
1285
|
case "minutes":
|
|
1281
1286
|
case "hours": {
|
|
1282
|
-
v =
|
|
1287
|
+
v = K(m, [p.length * f, l]);
|
|
1283
1288
|
break;
|
|
1284
1289
|
}
|
|
1285
1290
|
case "days": {
|
|
1286
|
-
const
|
|
1287
|
-
|
|
1288
|
-
|
|
1291
|
+
const w = K(m, [
|
|
1292
|
+
p.length * f,
|
|
1293
|
+
l
|
|
1289
1294
|
]);
|
|
1290
|
-
v =
|
|
1291
|
-
|
|
1295
|
+
v = K(w, [
|
|
1296
|
+
x - J(w, n),
|
|
1292
1297
|
"hours"
|
|
1293
1298
|
]);
|
|
1294
1299
|
break;
|
|
1295
1300
|
}
|
|
1296
1301
|
case "months":
|
|
1297
1302
|
case "years": {
|
|
1298
|
-
const
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1303
|
+
const w = K(
|
|
1304
|
+
K(K(m, [x, "hours"]), [
|
|
1305
|
+
p.length * f,
|
|
1306
|
+
l
|
|
1302
1307
|
]),
|
|
1303
|
-
[-
|
|
1308
|
+
[-x, "hours"]
|
|
1304
1309
|
);
|
|
1305
|
-
v =
|
|
1306
|
-
|
|
1310
|
+
v = K(w, [
|
|
1311
|
+
x - J(w, n),
|
|
1307
1312
|
"hours"
|
|
1308
1313
|
]);
|
|
1309
1314
|
break;
|
|
1310
1315
|
}
|
|
1311
1316
|
}
|
|
1312
|
-
if (v >
|
|
1317
|
+
if (v > u)
|
|
1313
1318
|
break;
|
|
1314
|
-
|
|
1319
|
+
p.push(v);
|
|
1315
1320
|
}
|
|
1316
|
-
return (t ??
|
|
1321
|
+
return (t ?? de({
|
|
1317
1322
|
locale: s,
|
|
1318
1323
|
showTimezone: o,
|
|
1319
1324
|
timeZone: n
|
|
1320
|
-
}))(
|
|
1321
|
-
},
|
|
1322
|
-
timeZone: n =
|
|
1323
|
-
locale: e =
|
|
1325
|
+
}))(p);
|
|
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,
|
|
1324
1329
|
showTimezone: t = !0
|
|
1325
1330
|
}) => {
|
|
1326
1331
|
const s = new Intl.DateTimeFormat(e, {
|
|
@@ -1336,70 +1341,70 @@ const le = (n, e, t = "UTC") => {
|
|
|
1336
1341
|
timeZone: n
|
|
1337
1342
|
});
|
|
1338
1343
|
return (o) => {
|
|
1339
|
-
const i = o[1] - o[0], r = i < Z([1, "days"]),
|
|
1340
|
-
return o.map((
|
|
1341
|
-
const
|
|
1342
|
-
if (r && (
|
|
1343
|
-
const
|
|
1344
|
-
let
|
|
1345
|
-
if (
|
|
1346
|
-
const
|
|
1347
|
-
(
|
|
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"
|
|
1348
1353
|
)?.value;
|
|
1349
|
-
|
|
1354
|
+
T = `:${M}` + (u ? `.${R}` : "");
|
|
1350
1355
|
}
|
|
1351
|
-
|
|
1352
|
-
`${
|
|
1356
|
+
y.push(
|
|
1357
|
+
`${g}:${P}${T}` + (t && v ? ` ${C}` : "")
|
|
1353
1358
|
);
|
|
1354
1359
|
}
|
|
1355
|
-
return (
|
|
1360
|
+
return (m || x) && y.push(
|
|
1356
1361
|
[
|
|
1357
|
-
|
|
1358
|
-
|
|
1362
|
+
d.label.find((g) => g.type === "month")?.value,
|
|
1363
|
+
m && d.label.find((g) => g.type === "day")?.value
|
|
1359
1364
|
].filter(Boolean).join(" ")
|
|
1360
|
-
),
|
|
1361
|
-
value:
|
|
1362
|
-
label:
|
|
1365
|
+
), l && y.push(d.label.find((g) => g.type === "year")?.value), {
|
|
1366
|
+
value: d.value,
|
|
1367
|
+
label: y.filter((g) => g).join(`
|
|
1363
1368
|
`)
|
|
1364
1369
|
};
|
|
1365
1370
|
});
|
|
1366
1371
|
};
|
|
1367
1372
|
};
|
|
1368
1373
|
export {
|
|
1369
|
-
|
|
1370
|
-
|
|
1374
|
+
Se as AreaPlot,
|
|
1375
|
+
De as AxisOverlay,
|
|
1371
1376
|
be as BarPlot,
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1377
|
+
ht as CANPLOT_LAYER,
|
|
1378
|
+
ve as CanPlot,
|
|
1379
|
+
Pe as ChartAreaInteractions,
|
|
1375
1380
|
ke as Crosshair,
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
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,
|
|
1384
1389
|
j as clamp,
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
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,
|
|
1394
1399
|
L as posToVal,
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
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,
|
|
1402
1407
|
H as valToPos,
|
|
1403
|
-
|
|
1408
|
+
pt as valToPxDistance
|
|
1404
1409
|
};
|
|
1405
1410
|
//# sourceMappingURL=canplot.mjs.map
|