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