@canplot/react 0.5.11 → 0.5.13
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 +450 -447
- package/dist/canplot.mjs.map +1 -1
- package/dist/plot/LinePlot.d.ts +2 -0
- package/dist/plot/LinePlot.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/canplot.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
var Be = Object.defineProperty;
|
|
2
2
|
var ze = (e, t, n) => t in e ? Be(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var K = (e, t, n) => ze(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import { jsxs as pe, jsx as
|
|
5
|
-
import
|
|
6
|
-
const re = (e, t, n) => Math.min(Math.max(e, t), n),
|
|
4
|
+
import { jsxs as pe, jsx as A, Fragment as Ne } from "react/jsx-runtime";
|
|
5
|
+
import R, { version as $e, createContext as ye, forwardRef as je, useRef as k, useState as B, useMemo as Q, useLayoutEffect as $, useCallback as He, useContext as G, useEffect as ke, useId as Ve } from "react";
|
|
6
|
+
const re = (e, t, n) => Math.min(Math.max(e, t), n), kt = (e) => e.reduce((t, n) => t + (n ?? 0), 0), At = (e, t) => {
|
|
7
7
|
let n = 0;
|
|
8
8
|
for (let s = 0; s < e.length; s++)
|
|
9
9
|
Math.abs(e[s] - t) < Math.abs(e[n] - t) && (n = s);
|
|
10
10
|
return n;
|
|
11
|
-
},
|
|
11
|
+
}, qe = (e, t, n, s) => {
|
|
12
12
|
const o = F(e, n);
|
|
13
13
|
if (!o)
|
|
14
14
|
return null;
|
|
15
|
-
const i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS,
|
|
16
|
-
return t /
|
|
15
|
+
const i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, c = (o.origin === "x" ? i.width : i.height) / (o.max - o.min);
|
|
16
|
+
return t / c;
|
|
17
17
|
}, F = (e, t) => e.scales.find((n) => n.id === t) ?? null, _ = (e, t) => {
|
|
18
18
|
const n = window.devicePixelRatio || 1;
|
|
19
19
|
e.lineCap = t?.lineCap ?? "butt", e.lineDashOffset = n * (t?.lineDashOffset ?? 0), e.lineJoin = t?.lineJoin ?? "miter", e.lineWidth = n * (t?.lineWidth ?? 1), e.miterLimit = n * (t?.miterLimit ?? 10), e.strokeStyle = t?.strokeStyle ?? "black", e.fillStyle = t?.fillStyle ?? e.strokeStyle, e.font = t?.font ?? `${10 * n}px sans-serif`, e.textAlign = t?.textAlign ?? "start", e.direction = t?.direction ?? "inherit", e.textBaseline = t?.textBaseline ?? "alphabetic", e.fontKerning = t?.fontKerning ?? "auto";
|
|
@@ -21,24 +21,24 @@ const re = (e, t, n) => Math.min(Math.max(e, t), n), At = (e) => e.reduce((t, n)
|
|
|
21
21
|
const o = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, i = F(e, n);
|
|
22
22
|
if (!i)
|
|
23
23
|
return null;
|
|
24
|
-
const
|
|
25
|
-
return t *
|
|
24
|
+
const c = (i.origin === "x" ? o.width : o.height) / (i.max - i.min);
|
|
25
|
+
return t * c;
|
|
26
26
|
}, Z = (e, t, n, s) => {
|
|
27
27
|
const o = F(e, n);
|
|
28
28
|
if (!o)
|
|
29
29
|
return null;
|
|
30
|
-
const i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS,
|
|
30
|
+
const i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, c = ge(
|
|
31
31
|
e,
|
|
32
32
|
t - o.min,
|
|
33
33
|
n,
|
|
34
34
|
s
|
|
35
35
|
);
|
|
36
|
-
return
|
|
37
|
-
i.x +
|
|
36
|
+
return c === null ? null : o.origin === "x" ? re(
|
|
37
|
+
i.x + c,
|
|
38
38
|
i.x - 10 * i.width,
|
|
39
39
|
i.x + 11 * i.width
|
|
40
40
|
) : re(
|
|
41
|
-
i.y + i.height -
|
|
41
|
+
i.y + i.height - c,
|
|
42
42
|
i.y - 10 * i.height,
|
|
43
43
|
i.y + 11 * i.height
|
|
44
44
|
);
|
|
@@ -47,7 +47,7 @@ const re = (e, t, n) => Math.min(Math.max(e, t), n), At = (e) => e.reduce((t, n)
|
|
|
47
47
|
return null;
|
|
48
48
|
const s = n === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS;
|
|
49
49
|
return re(t, s.x, s.x + s.width);
|
|
50
|
-
},
|
|
50
|
+
}, q = (e, t, n) => {
|
|
51
51
|
if (t === null)
|
|
52
52
|
return null;
|
|
53
53
|
const s = n === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS;
|
|
@@ -61,8 +61,8 @@ const re = (e, t, n) => Math.min(Math.max(e, t), n), At = (e) => e.reduce((t, n)
|
|
|
61
61
|
const o = F(e, n);
|
|
62
62
|
if (!o)
|
|
63
63
|
return null;
|
|
64
|
-
const i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS,
|
|
65
|
-
return o.min +
|
|
64
|
+
const i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, c = o.origin === "x" ? (t - i.x) / i.width : (i.height - t + i.y) / i.height;
|
|
65
|
+
return o.min + c * (o.max - o.min);
|
|
66
66
|
}, O = (e, t) => {
|
|
67
67
|
if (e === t) return !0;
|
|
68
68
|
if (e == null || t == null || typeof e != typeof t || typeof e != "object" || Array.isArray(e) !== Array.isArray(t)) return !1;
|
|
@@ -77,7 +77,7 @@ const re = (e, t, n) => Math.min(Math.max(e, t), n), At = (e) => e.reduce((t, n)
|
|
|
77
77
|
for (const o of n)
|
|
78
78
|
if (!Object.prototype.hasOwnProperty.call(t, o) || !O(e[o], t[o])) return !1;
|
|
79
79
|
return !0;
|
|
80
|
-
},
|
|
80
|
+
}, We = (e) => {
|
|
81
81
|
const { ctx: t, scales: n } = e;
|
|
82
82
|
for (const s of n) {
|
|
83
83
|
if (!s.axis) continue;
|
|
@@ -125,7 +125,7 @@ function me(e, t) {
|
|
|
125
125
|
e && (e.current = t);
|
|
126
126
|
}
|
|
127
127
|
var Ze = parseInt($e.split(".")[0], 10) >= 19 ? Je : Ge;
|
|
128
|
-
const
|
|
128
|
+
const Ae = ye({
|
|
129
129
|
listeners: [],
|
|
130
130
|
subscribe: () => () => {
|
|
131
131
|
},
|
|
@@ -133,14 +133,14 @@ const Re = ye({
|
|
|
133
133
|
}
|
|
134
134
|
}), Qe = () => {
|
|
135
135
|
const e = [];
|
|
136
|
-
return { listeners: e, subscribe: (s, o) => (e.push([o, s]), e.sort((i,
|
|
137
|
-
const i = e.findIndex(([,
|
|
136
|
+
return { listeners: e, subscribe: (s, o) => (e.push([o, s]), e.sort((i, c) => i[0] - c[0]), () => {
|
|
137
|
+
const i = e.findIndex(([, c]) => c === s);
|
|
138
138
|
i !== -1 && e.splice(i, 1);
|
|
139
139
|
}), notifyListeners: () => {
|
|
140
140
|
for (const [, s] of e)
|
|
141
141
|
s();
|
|
142
142
|
} };
|
|
143
|
-
}, ve = ye(null),
|
|
143
|
+
}, ve = ye(null), Re = ye(() => {
|
|
144
144
|
}), Ie = {
|
|
145
145
|
TOP: 400,
|
|
146
146
|
MIDDLE: 300,
|
|
@@ -151,7 +151,7 @@ class Le {
|
|
|
151
151
|
constructor() {
|
|
152
152
|
K(this, "_frame", null);
|
|
153
153
|
K(this, "clampXPosToChartArea", (t, n = "canvas") => V(this.frame, t, n));
|
|
154
|
-
K(this, "clampYPosToChartArea", (t, n = "canvas") =>
|
|
154
|
+
K(this, "clampYPosToChartArea", (t, n = "canvas") => q(this.frame, t, n));
|
|
155
155
|
K(this, "valToPos", (t, n, s = "canvas") => Z(this.frame, t, n, s));
|
|
156
156
|
K(this, "valToPxDistance", (t, n, s = "canvas") => ge(this.frame, t, n, s));
|
|
157
157
|
K(this, "valFits", (t, n) => de(this.frame, t, n));
|
|
@@ -169,19 +169,19 @@ class Le {
|
|
|
169
169
|
return this.frame.ctx;
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
const
|
|
173
|
-
const i =
|
|
174
|
-
() => nt(e,
|
|
175
|
-
[e,
|
|
172
|
+
const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
173
|
+
const i = k(null), c = k(null), r = tt(c), [u, l] = B(null), y = Q(
|
|
174
|
+
() => nt(e, r, u),
|
|
175
|
+
[e, r, u]
|
|
176
176
|
);
|
|
177
177
|
$(() => {
|
|
178
178
|
l(i.current?.getContext("2d") || null);
|
|
179
179
|
}, [i]);
|
|
180
|
-
const
|
|
180
|
+
const d = window.devicePixelRatio || 1;
|
|
181
181
|
return /* @__PURE__ */ pe(
|
|
182
182
|
"div",
|
|
183
183
|
{
|
|
184
|
-
ref: Ze([o,
|
|
184
|
+
ref: Ze([o, c]),
|
|
185
185
|
style: {
|
|
186
186
|
position: "relative",
|
|
187
187
|
overflow: "hidden",
|
|
@@ -190,21 +190,21 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
190
190
|
"data-canplotroot": !0,
|
|
191
191
|
...s,
|
|
192
192
|
children: [
|
|
193
|
-
/* @__PURE__ */
|
|
193
|
+
/* @__PURE__ */ A(
|
|
194
194
|
"canvas",
|
|
195
195
|
{
|
|
196
196
|
ref: i,
|
|
197
|
-
width:
|
|
198
|
-
height:
|
|
197
|
+
width: r.width * d,
|
|
198
|
+
height: r.height * d,
|
|
199
199
|
style: {
|
|
200
200
|
inset: 0,
|
|
201
201
|
position: "absolute",
|
|
202
|
-
width: `${
|
|
203
|
-
height: `${
|
|
202
|
+
width: `${r.width}px`,
|
|
203
|
+
height: `${r.height}px`
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
),
|
|
207
|
-
|
|
207
|
+
y && /* @__PURE__ */ A(et, { frame: y, children: t })
|
|
208
208
|
]
|
|
209
209
|
}
|
|
210
210
|
);
|
|
@@ -216,32 +216,32 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
216
216
|
$(() => {
|
|
217
217
|
e?.ctx.clearRect(0, 0, e.ctx.canvas.width, e.ctx.canvas.height);
|
|
218
218
|
}, [e, s]);
|
|
219
|
-
const i =
|
|
219
|
+
const i = k(null);
|
|
220
220
|
i.current = e, $(() => {
|
|
221
221
|
n.subscribe(() => {
|
|
222
|
-
i.current &&
|
|
222
|
+
i.current && We(i.current);
|
|
223
223
|
}, Ie.BOTTOM);
|
|
224
224
|
}, [n]), $(() => {
|
|
225
|
-
let
|
|
226
|
-
return
|
|
227
|
-
|
|
225
|
+
let r = null;
|
|
226
|
+
return r = window.requestAnimationFrame(() => {
|
|
227
|
+
r = null, n.notifyListeners();
|
|
228
228
|
}), () => {
|
|
229
|
-
|
|
229
|
+
r && cancelAnimationFrame(r);
|
|
230
230
|
};
|
|
231
231
|
}, [s, e, n]);
|
|
232
|
-
const
|
|
233
|
-
o((
|
|
232
|
+
const c = He(() => {
|
|
233
|
+
o((r) => r + 1);
|
|
234
234
|
}, [o]);
|
|
235
|
-
return /* @__PURE__ */
|
|
235
|
+
return /* @__PURE__ */ A(Ae.Provider, { value: n, children: /* @__PURE__ */ A(Re.Provider, { value: c, children: /* @__PURE__ */ A(ve.Provider, { value: e, children: t }) }) });
|
|
236
236
|
}, tt = (e) => {
|
|
237
237
|
const [t, n] = B({
|
|
238
238
|
width: 0,
|
|
239
239
|
height: 0
|
|
240
240
|
}), [s] = B(() => new ResizeObserver((o) => {
|
|
241
241
|
for (const i of o) {
|
|
242
|
-
const
|
|
242
|
+
const c = Math.round(i.contentRect.width), r = Math.round(i.contentRect.height);
|
|
243
243
|
n(
|
|
244
|
-
(u) => u.width !==
|
|
244
|
+
(u) => u.width !== c || u.height !== r ? { ...u, width: c, height: r } : u
|
|
245
245
|
);
|
|
246
246
|
}
|
|
247
247
|
}));
|
|
@@ -249,7 +249,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
249
249
|
if (!e.current) return;
|
|
250
250
|
const o = e.current.clientWidth, i = e.current.clientHeight;
|
|
251
251
|
return n(
|
|
252
|
-
(
|
|
252
|
+
(c) => c.width !== o || c.height !== i ? { ...c, width: o, height: i } : c
|
|
253
253
|
), s.observe(e.current, { box: "border-box" }), () => s.disconnect();
|
|
254
254
|
}, [s, e]), t;
|
|
255
255
|
}, nt = (e, t, n) => {
|
|
@@ -274,11 +274,11 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
274
274
|
y: o.y * s,
|
|
275
275
|
width: o.width * s,
|
|
276
276
|
height: o.height * s
|
|
277
|
-
},
|
|
278
|
-
let
|
|
277
|
+
}, c = [];
|
|
278
|
+
let r = e.padding.left * s, u = t.width * s - e.padding.right * s, l = t.height * s - e.padding.bottom * s, y = e.padding.top * s;
|
|
279
279
|
for (const a of e.scales) {
|
|
280
280
|
if (!a.axis) {
|
|
281
|
-
|
|
281
|
+
c.push({ ...a, axis: null });
|
|
282
282
|
continue;
|
|
283
283
|
}
|
|
284
284
|
let g;
|
|
@@ -293,9 +293,9 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
293
293
|
};
|
|
294
294
|
break;
|
|
295
295
|
case "top":
|
|
296
|
-
|
|
296
|
+
y += a.axis.size * s, g = {
|
|
297
297
|
x: o.x,
|
|
298
|
-
y:
|
|
298
|
+
y: y / s - a.axis.size,
|
|
299
299
|
width: o.width,
|
|
300
300
|
height: a.axis.size
|
|
301
301
|
};
|
|
@@ -307,8 +307,8 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
307
307
|
else
|
|
308
308
|
switch (a.axis.position) {
|
|
309
309
|
case "left":
|
|
310
|
-
|
|
311
|
-
x:
|
|
310
|
+
r += a.axis.size * s, g = {
|
|
311
|
+
x: r / s - a.axis.size,
|
|
312
312
|
y: o.y,
|
|
313
313
|
width: a.axis.size,
|
|
314
314
|
height: o.height
|
|
@@ -326,18 +326,18 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
326
326
|
case "bottom":
|
|
327
327
|
throw new Error("Invalid axis position for y origin");
|
|
328
328
|
}
|
|
329
|
-
const
|
|
329
|
+
const h = {
|
|
330
330
|
x: g.x * s,
|
|
331
331
|
y: g.y * s,
|
|
332
332
|
width: g.width * s,
|
|
333
333
|
height: g.height * s
|
|
334
334
|
};
|
|
335
|
-
|
|
335
|
+
c.push({
|
|
336
336
|
...a,
|
|
337
337
|
axis: {
|
|
338
338
|
...a.axis,
|
|
339
339
|
cssRect: g,
|
|
340
|
-
canvasRect:
|
|
340
|
+
canvasRect: h
|
|
341
341
|
}
|
|
342
342
|
});
|
|
343
343
|
}
|
|
@@ -345,32 +345,32 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
345
345
|
ctx: n,
|
|
346
346
|
dpr: s,
|
|
347
347
|
padding: e.padding,
|
|
348
|
-
scales:
|
|
348
|
+
scales: c,
|
|
349
349
|
chartAreaCSS: o,
|
|
350
350
|
chartAreaCanvasPX: i
|
|
351
351
|
};
|
|
352
352
|
}, j = (e, t, n) => {
|
|
353
|
-
const s = G(ve), o = G(
|
|
353
|
+
const s = G(ve), o = G(Re), i = G(Ae);
|
|
354
354
|
if (!s || !o)
|
|
355
355
|
throw new Error("useFrame must be used within a CanPlot component");
|
|
356
|
-
const [
|
|
357
|
-
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
const u =
|
|
356
|
+
const [c] = B(() => new Le());
|
|
357
|
+
c._updateFrame(s);
|
|
358
|
+
const r = k(c);
|
|
359
|
+
r.current = c;
|
|
360
|
+
const u = k(t);
|
|
361
361
|
u.current = t, $(() => {
|
|
362
362
|
const l = i.subscribe(
|
|
363
363
|
() => {
|
|
364
|
-
u.current(
|
|
364
|
+
u.current(c);
|
|
365
365
|
},
|
|
366
366
|
typeof e == "number" ? e : Ie[e]
|
|
367
367
|
);
|
|
368
368
|
return () => {
|
|
369
369
|
l();
|
|
370
370
|
};
|
|
371
|
-
}, [i, e,
|
|
371
|
+
}, [i, e, c]), $(() => {
|
|
372
372
|
o();
|
|
373
|
-
}, [o, ...n]),
|
|
373
|
+
}, [o, ...n]), ke(() => () => {
|
|
374
374
|
o();
|
|
375
375
|
}, [o]);
|
|
376
376
|
}, Ue = () => {
|
|
@@ -381,198 +381,201 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
381
381
|
const t = new Le();
|
|
382
382
|
return t._updateFrame(e), t;
|
|
383
383
|
}, [e]);
|
|
384
|
-
}, st = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o, globalAlpha: i }) => (j(
|
|
384
|
+
}, st = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o, globalAlpha: i, xGapWidth: c }) => (j(
|
|
385
385
|
e,
|
|
386
|
-
({ ctx: r, clampXPosToChartArea:
|
|
387
|
-
r.save(), r.beginPath(), _(r, o)
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
386
|
+
({ ctx: r, clampXPosToChartArea: u, clampYPosToChartArea: l, valToPos: y }) => {
|
|
387
|
+
r.save(), r.beginPath(), _(r, o);
|
|
388
|
+
const d = r.getLineDash();
|
|
389
|
+
o?.lineDash && r.setLineDash(o.lineDash), i !== void 0 && (r.globalAlpha = i);
|
|
390
|
+
let a = null;
|
|
391
|
+
for (const g of t) {
|
|
392
|
+
const h = u(y(g.x, n, "canvas")), p = l(y(g.y, s, "canvas"));
|
|
393
|
+
h === null || p === null || (a !== null && c !== void 0 && h - a > c ? r.moveTo(h, p) : r.lineTo(h, p), a = h);
|
|
391
394
|
}
|
|
392
|
-
r.stroke(), r.restore();
|
|
395
|
+
r.stroke(), d && r.setLineDash(d), r.restore();
|
|
393
396
|
},
|
|
394
|
-
[t, n, s, o, i]
|
|
395
|
-
), null), It =
|
|
397
|
+
[t, n, s, o, i, c]
|
|
398
|
+
), null), It = R.memo(st, O), ot = ({
|
|
396
399
|
layer: e = "MIDDLE",
|
|
397
400
|
data: t,
|
|
398
401
|
xScaleId: n,
|
|
399
402
|
yScaleId: s,
|
|
400
403
|
xStrategy: o = "clip",
|
|
401
404
|
yStrategy: i = "clip",
|
|
402
|
-
radius:
|
|
403
|
-
style:
|
|
405
|
+
radius: c = 5,
|
|
406
|
+
style: r,
|
|
404
407
|
globalAlpha: u
|
|
405
408
|
}) => (j(
|
|
406
409
|
e,
|
|
407
410
|
({
|
|
408
411
|
ctx: l,
|
|
409
|
-
valToPos:
|
|
410
|
-
valFits:
|
|
412
|
+
valToPos: y,
|
|
413
|
+
valFits: d,
|
|
411
414
|
clampXPosToChartArea: a,
|
|
412
415
|
clampYPosToChartArea: g
|
|
413
416
|
}) => {
|
|
414
|
-
l.save(), _(l,
|
|
415
|
-
const
|
|
416
|
-
for (const
|
|
417
|
-
let
|
|
418
|
-
const v = p
|
|
417
|
+
l.save(), _(l, r), u !== void 0 && (l.globalAlpha = u);
|
|
418
|
+
const h = [];
|
|
419
|
+
for (const p of t) {
|
|
420
|
+
let f = null, m = null;
|
|
421
|
+
const v = y(p.x, n);
|
|
419
422
|
if (v === null) continue;
|
|
420
423
|
if (o === "clip") {
|
|
421
|
-
if (!
|
|
422
|
-
|
|
424
|
+
if (!d(p.x, n)) continue;
|
|
425
|
+
f = v;
|
|
423
426
|
} else
|
|
424
|
-
|
|
425
|
-
const
|
|
426
|
-
if (
|
|
427
|
+
f = a(v, "canvas");
|
|
428
|
+
const b = y(p.y, s);
|
|
429
|
+
if (b !== null) {
|
|
427
430
|
if (i === "clip") {
|
|
428
|
-
if (!
|
|
429
|
-
m =
|
|
431
|
+
if (!d(p.y, s)) continue;
|
|
432
|
+
m = b;
|
|
430
433
|
} else
|
|
431
|
-
m = g(
|
|
432
|
-
|
|
434
|
+
m = g(b, "canvas");
|
|
435
|
+
f === null || m === null || h.push({ x: f, y: m });
|
|
433
436
|
}
|
|
434
437
|
}
|
|
435
|
-
if (
|
|
436
|
-
for (const
|
|
437
|
-
l.beginPath(), l.arc(
|
|
438
|
-
if (
|
|
438
|
+
if (r?.fillStyle)
|
|
439
|
+
for (const p of h)
|
|
440
|
+
l.beginPath(), l.arc(p.x, p.y, c, 0, Math.PI * 2), l.fill();
|
|
441
|
+
if (r?.strokeStyle) {
|
|
439
442
|
l.beginPath();
|
|
440
|
-
for (const
|
|
441
|
-
l.moveTo(
|
|
443
|
+
for (const p of h)
|
|
444
|
+
l.moveTo(p.x + c, p.y), l.arc(p.x, p.y, c, 0, Math.PI * 2);
|
|
442
445
|
l.stroke();
|
|
443
446
|
}
|
|
444
447
|
l.restore();
|
|
445
448
|
},
|
|
446
|
-
[t, n, s,
|
|
447
|
-
), null), Lt =
|
|
449
|
+
[t, n, s, c, r, u]
|
|
450
|
+
), null), Lt = R.memo(ot, O), it = ({
|
|
448
451
|
data: e,
|
|
449
452
|
xScaleId: t,
|
|
450
453
|
yScaleId: n,
|
|
451
454
|
style: s,
|
|
452
455
|
barWidth: o,
|
|
453
456
|
xPositionOffset: i,
|
|
454
|
-
globalAlpha:
|
|
455
|
-
radius:
|
|
457
|
+
globalAlpha: c,
|
|
458
|
+
radius: r,
|
|
456
459
|
layer: u = "MIDDLE"
|
|
457
460
|
}) => (j(
|
|
458
461
|
u,
|
|
459
462
|
({
|
|
460
463
|
ctx: l,
|
|
461
|
-
valToPxDistance:
|
|
462
|
-
valToPos:
|
|
464
|
+
valToPxDistance: y,
|
|
465
|
+
valToPos: d,
|
|
463
466
|
clampXPosToChartArea: a,
|
|
464
467
|
clampYPosToChartArea: g
|
|
465
468
|
}) => {
|
|
466
469
|
if (e.length === 0) return;
|
|
467
|
-
const
|
|
468
|
-
|
|
470
|
+
const h = g(
|
|
471
|
+
d(0, n, "canvas"),
|
|
469
472
|
"canvas"
|
|
470
473
|
);
|
|
471
|
-
if (
|
|
474
|
+
if (h === null)
|
|
472
475
|
return;
|
|
473
|
-
const
|
|
476
|
+
const p = y(o, t, "canvas") ?? 0, f = [];
|
|
474
477
|
for (const m of e) {
|
|
475
|
-
const v =
|
|
478
|
+
const v = d(m.x, t, "canvas");
|
|
476
479
|
if (v === null)
|
|
477
480
|
continue;
|
|
478
|
-
const
|
|
479
|
-
|
|
481
|
+
const b = v - p / 2 + i * p, T = g(
|
|
482
|
+
d(m.y, n, "canvas"),
|
|
480
483
|
"canvas"
|
|
481
484
|
);
|
|
482
485
|
if (T === null)
|
|
483
486
|
continue;
|
|
484
|
-
const w =
|
|
485
|
-
|
|
486
|
-
x
|
|
487
|
+
const w = h - T, x = a(b, "canvas"), S = a(b + p, "canvas") - x;
|
|
488
|
+
f.push({
|
|
489
|
+
x,
|
|
487
490
|
y: T,
|
|
488
491
|
width: S,
|
|
489
492
|
height: w
|
|
490
493
|
});
|
|
491
494
|
}
|
|
492
|
-
if (l.save(), _(l, s),
|
|
493
|
-
for (const m of
|
|
494
|
-
l.beginPath(),
|
|
495
|
+
if (l.save(), _(l, s), c !== void 0 && (l.globalAlpha = c), s?.fillStyle)
|
|
496
|
+
for (const m of f)
|
|
497
|
+
l.beginPath(), r ? l.roundRect(m.x, m.y, m.width, m.height, r) : l.rect(m.x, m.y, m.width, m.height), l.fill();
|
|
495
498
|
if (s?.strokeStyle) {
|
|
496
499
|
l.beginPath();
|
|
497
|
-
for (const m of
|
|
498
|
-
|
|
500
|
+
for (const m of f)
|
|
501
|
+
r ? l.roundRect(m.x, m.y, m.width, m.height, r) : l.rect(m.x, m.y, m.width, m.height);
|
|
499
502
|
l.stroke();
|
|
500
503
|
}
|
|
501
504
|
l.restore();
|
|
502
505
|
},
|
|
503
|
-
[e, t, n, s, o, i,
|
|
504
|
-
), null), Ut =
|
|
506
|
+
[e, t, n, s, o, i, r, c]
|
|
507
|
+
), null), Ut = R.memo(it, O), rt = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o }) => (j(
|
|
505
508
|
e,
|
|
506
|
-
({ ctx: i, clampXPosToChartArea:
|
|
509
|
+
({ ctx: i, clampXPosToChartArea: c, clampYPosToChartArea: r, valToPos: u }) => {
|
|
507
510
|
const l = [];
|
|
508
|
-
for (const
|
|
509
|
-
const a =
|
|
511
|
+
for (const d of t) {
|
|
512
|
+
const a = c(u(d.x, n));
|
|
510
513
|
if (a === null)
|
|
511
514
|
continue;
|
|
512
|
-
const g =
|
|
515
|
+
const g = r(u(d.y[0], s));
|
|
513
516
|
if (g === null)
|
|
514
517
|
continue;
|
|
515
|
-
const
|
|
516
|
-
|
|
518
|
+
const h = r(u(d.y[1], s));
|
|
519
|
+
h !== null && (l.push({ x: a, y: g }), l.unshift({ x: a, y: h }));
|
|
517
520
|
}
|
|
518
|
-
const
|
|
519
|
-
if (
|
|
520
|
-
i.save(), i.beginPath(), _(i, o), i.moveTo(
|
|
521
|
-
for (const
|
|
522
|
-
i.lineTo(
|
|
521
|
+
const y = l[0];
|
|
522
|
+
if (y) {
|
|
523
|
+
i.save(), i.beginPath(), _(i, o), i.moveTo(y.x, y.y);
|
|
524
|
+
for (const d of l)
|
|
525
|
+
i.lineTo(d.x, d.y);
|
|
523
526
|
i.closePath(), i.fill(), i.restore();
|
|
524
527
|
}
|
|
525
528
|
},
|
|
526
529
|
[t, n, s, o]
|
|
527
|
-
), null), _t =
|
|
530
|
+
), null), _t = R.memo(rt, O), ct = ({ layer: e = "MIDDLE", data: t, stroked: n, xScaleId: s, yScaleId: o, style: i }) => (j(
|
|
528
531
|
e,
|
|
529
|
-
({ ctx:
|
|
530
|
-
const
|
|
531
|
-
for (const
|
|
532
|
-
const
|
|
533
|
-
|
|
532
|
+
({ ctx: c, clampXPosToChartArea: r, clampYPosToChartArea: u, valToPos: l }) => {
|
|
533
|
+
const y = [];
|
|
534
|
+
for (const h of t) {
|
|
535
|
+
const p = r(l(h.x, s)), f = u(l(h.y, o));
|
|
536
|
+
p === null || f === null || y.push({ x: p, y: f });
|
|
534
537
|
}
|
|
535
|
-
const
|
|
536
|
-
if (!
|
|
538
|
+
const d = y.at(0), a = y.at(-1);
|
|
539
|
+
if (!d || !a)
|
|
537
540
|
return;
|
|
538
541
|
const g = u(l(0, o));
|
|
539
542
|
if (g !== null) {
|
|
540
|
-
|
|
541
|
-
for (const
|
|
542
|
-
|
|
543
|
-
if (
|
|
544
|
-
|
|
545
|
-
for (const
|
|
546
|
-
|
|
547
|
-
|
|
543
|
+
c.save(), c.beginPath(), _(c, i), c.moveTo(d.x, g);
|
|
544
|
+
for (const h of y)
|
|
545
|
+
c.lineTo(h.x, h.y);
|
|
546
|
+
if (c.lineTo(a.x, g), c.closePath(), c.fill(), n) {
|
|
547
|
+
c.beginPath(), c.moveTo(d.x, d.y);
|
|
548
|
+
for (const h of y)
|
|
549
|
+
c.lineTo(h.x, h.y);
|
|
550
|
+
c.stroke();
|
|
548
551
|
}
|
|
549
|
-
|
|
552
|
+
c.restore();
|
|
550
553
|
}
|
|
551
554
|
},
|
|
552
555
|
[t, n, s, o, i]
|
|
553
|
-
), null), Xt =
|
|
556
|
+
), null), Xt = R.memo(ct, O), at = ({
|
|
554
557
|
layer: e = "BOTTOM",
|
|
555
558
|
scaleId: t,
|
|
556
559
|
tickStyle: n,
|
|
557
560
|
labelStyle: s,
|
|
558
561
|
labelGap: o,
|
|
559
562
|
tickSize: i,
|
|
560
|
-
ticks:
|
|
563
|
+
ticks: c
|
|
561
564
|
}) => (j(
|
|
562
565
|
e,
|
|
563
|
-
({ ctx:
|
|
564
|
-
const
|
|
565
|
-
if (!
|
|
566
|
-
const a =
|
|
567
|
-
|
|
566
|
+
({ ctx: r, valToPos: u, getScale: l, frame: y }) => {
|
|
567
|
+
const d = l(t);
|
|
568
|
+
if (!d || !d.axis || d.origin !== "x") return;
|
|
569
|
+
const a = d.axis, g = a.position === "top" ? a.canvasRect.y + a.canvasRect.height : a.canvasRect.y, h = window.devicePixelRatio || 1, p = g, f = (i ?? 6) * h, m = a.position === "top" ? g - f : g + f, v = (o ?? 12) * h;
|
|
570
|
+
r.save(), r.fontKerning = "auto", _(r, {
|
|
568
571
|
...n
|
|
569
|
-
}),
|
|
570
|
-
const
|
|
571
|
-
for (const { value: T } of
|
|
572
|
+
}), r.beginPath();
|
|
573
|
+
const b = Array.isArray(c) ? c : c({ ...d, axis: a }, y);
|
|
574
|
+
for (const { value: T } of b) {
|
|
572
575
|
const w = u(T, t, "canvas");
|
|
573
|
-
w !== null && (
|
|
576
|
+
w !== null && (r.moveTo(w, p), r.lineTo(w, m));
|
|
574
577
|
}
|
|
575
|
-
|
|
578
|
+
r.stroke(), r.restore(), r.save(), _(r, {
|
|
576
579
|
textBaseline: a.position === "top" ? "bottom" : "top",
|
|
577
580
|
textAlign: "center",
|
|
578
581
|
...n,
|
|
@@ -580,38 +583,38 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
580
583
|
// alter font size for DPR
|
|
581
584
|
font: _e(s?.font ?? n?.font)
|
|
582
585
|
});
|
|
583
|
-
for (const { value: T, label: w } of
|
|
584
|
-
const
|
|
585
|
-
if (
|
|
586
|
+
for (const { value: T, label: w } of b) {
|
|
587
|
+
const x = u(T, t, "canvas");
|
|
588
|
+
if (x === null)
|
|
586
589
|
continue;
|
|
587
590
|
const S = w.split(`
|
|
588
591
|
`);
|
|
589
592
|
for (let E = 0; E < S.length; E++)
|
|
590
|
-
|
|
593
|
+
r.fillText(S[E], x, m + h * 2 + E * v);
|
|
591
594
|
}
|
|
592
|
-
|
|
595
|
+
r.restore();
|
|
593
596
|
},
|
|
594
|
-
[
|
|
595
|
-
), null), Ft =
|
|
597
|
+
[c, t, n, s]
|
|
598
|
+
), null), Ft = R.memo(at, O), lt = ({
|
|
596
599
|
layer: e = "BOTTOM",
|
|
597
600
|
scaleId: t,
|
|
598
601
|
tickStyle: n,
|
|
599
602
|
labelStyle: s,
|
|
600
603
|
labelGap: o,
|
|
601
604
|
tickSize: i,
|
|
602
|
-
ticks:
|
|
605
|
+
ticks: c
|
|
603
606
|
}) => (j(
|
|
604
607
|
e,
|
|
605
|
-
({ ctx:
|
|
606
|
-
const
|
|
607
|
-
if (!
|
|
608
|
-
const a =
|
|
609
|
-
|
|
610
|
-
for (const { value:
|
|
611
|
-
const T = u(
|
|
612
|
-
T !== null && (
|
|
608
|
+
({ ctx: r, valToPos: u, getScale: l, frame: y }) => {
|
|
609
|
+
const d = l(t);
|
|
610
|
+
if (!d || !d.axis || d.origin !== "y") return;
|
|
611
|
+
const a = d.axis, g = a.position === "left" ? a.canvasRect.x + a.canvasRect.width : a.canvasRect.x, h = g, p = i ?? 6, f = a.position === "left" ? g - p : g + p, m = o ?? 12, v = Array.isArray(c) ? c : c({ ...d, axis: a }, y);
|
|
612
|
+
r.save(), r.fontKerning = "auto", _(r, { ...n }), r.beginPath();
|
|
613
|
+
for (const { value: b } of v) {
|
|
614
|
+
const T = u(b, t, "canvas");
|
|
615
|
+
T !== null && (r.moveTo(h, T), r.lineTo(f, T));
|
|
613
616
|
}
|
|
614
|
-
|
|
617
|
+
r.stroke(), r.restore(), r.save(), _(r, {
|
|
615
618
|
textBaseline: "middle",
|
|
616
619
|
textAlign: a.position === "left" ? "right" : "left",
|
|
617
620
|
...n,
|
|
@@ -619,19 +622,19 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
619
622
|
// alter font size for DPR
|
|
620
623
|
font: _e(s?.font ?? n?.font)
|
|
621
624
|
});
|
|
622
|
-
for (const { value:
|
|
623
|
-
const w = u(
|
|
625
|
+
for (const { value: b, label: T } of v) {
|
|
626
|
+
const w = u(b, t, "canvas");
|
|
624
627
|
if (w === null)
|
|
625
628
|
continue;
|
|
626
|
-
const
|
|
629
|
+
const x = T.split(`
|
|
627
630
|
`);
|
|
628
|
-
for (let S = 0; S <
|
|
629
|
-
|
|
631
|
+
for (let S = 0; S < x.length; S++)
|
|
632
|
+
r.fillText(` ${x[S]} `, f, w + S * m);
|
|
630
633
|
}
|
|
631
|
-
|
|
634
|
+
r.restore();
|
|
632
635
|
},
|
|
633
|
-
[
|
|
634
|
-
), null), Ot =
|
|
636
|
+
[c, t, n, s]
|
|
637
|
+
), null), Ot = R.memo(lt, O), _e = (e) => {
|
|
635
638
|
if (e)
|
|
636
639
|
try {
|
|
637
640
|
return e.replace(/(\d+)px/, (t, n) => `${parseInt(n) * window.devicePixelRatio || 1}px`);
|
|
@@ -665,35 +668,35 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
665
668
|
pressandwheel: I(),
|
|
666
669
|
sync_move: I()
|
|
667
670
|
}, L = (e, t, n) => {
|
|
668
|
-
const s =
|
|
669
|
-
s.current = n,
|
|
671
|
+
const s = R.useRef(n);
|
|
672
|
+
s.current = n, R.useEffect(() => M[e].addEventListener(
|
|
670
673
|
t,
|
|
671
|
-
(i,
|
|
672
|
-
s.current(
|
|
674
|
+
(i, c) => {
|
|
675
|
+
s.current(c, i);
|
|
673
676
|
}
|
|
674
677
|
), [t, e, s]);
|
|
675
|
-
}, we =
|
|
676
|
-
const n =
|
|
678
|
+
}, we = R.createContext(""), be = (e, t) => {
|
|
679
|
+
const n = R.useContext(we);
|
|
677
680
|
return L(e, n, t);
|
|
678
681
|
}, ut = (e, t, n, s, o) => {
|
|
679
682
|
if (!t) return;
|
|
680
|
-
const i = s ?? n.scales.find((
|
|
683
|
+
const i = s ?? n.scales.find((d) => d.origin === "x")?.id, c = o ?? n.scales.find((d) => d.origin === "y")?.id, r = e.clientX - t.left, u = i ? {
|
|
681
684
|
scaleId: i,
|
|
682
|
-
value: X(n,
|
|
683
|
-
} : null, l = e.clientY - t.top,
|
|
684
|
-
scaleId:
|
|
685
|
-
value: X(n, l,
|
|
685
|
+
value: X(n, r, i, "css")
|
|
686
|
+
} : null, l = e.clientY - t.top, y = c ? {
|
|
687
|
+
scaleId: c,
|
|
688
|
+
value: X(n, l, c, "css")
|
|
686
689
|
} : null;
|
|
687
|
-
return { pointerSyncPosition: { x: u, y
|
|
690
|
+
return { pointerSyncPosition: { x: u, y }, cssX: r, cssY: l };
|
|
688
691
|
}, N = (e, t) => {
|
|
689
|
-
const { x: n, y: s } = e, o = n && t.scales.some((
|
|
692
|
+
const { x: n, y: s } = e, o = n && t.scales.some((c) => c.id === n.scaleId) ? Z(t, n.value, n.scaleId, "css") : null, i = s && t.scales.some((c) => c.id === s.scaleId) ? Z(t, s.value, s.scaleId, "css") : null;
|
|
690
693
|
return {
|
|
691
694
|
cssX: o,
|
|
692
695
|
cssY: i,
|
|
693
696
|
scaled: Object.fromEntries(
|
|
694
|
-
t.scales.flatMap((
|
|
695
|
-
const
|
|
696
|
-
return
|
|
697
|
+
t.scales.flatMap((c) => {
|
|
698
|
+
const r = c.origin === "y" ? i : o;
|
|
699
|
+
return r === null ? [] : [[c.id, X(t, r, c.id, "css")]];
|
|
697
700
|
})
|
|
698
701
|
)
|
|
699
702
|
};
|
|
@@ -712,14 +715,14 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
712
715
|
if (s === null || o === null)
|
|
713
716
|
return null;
|
|
714
717
|
const i = n.scales.flatMap(
|
|
715
|
-
(
|
|
716
|
-
if (
|
|
718
|
+
(c) => {
|
|
719
|
+
if (c.origin !== e)
|
|
717
720
|
return [];
|
|
718
|
-
const
|
|
719
|
-
return
|
|
721
|
+
const r = X(n, s, c.id, "css"), u = X(n, o, c.id, "css");
|
|
722
|
+
return r === null || u === null ? [] : [
|
|
720
723
|
{
|
|
721
|
-
scaleId:
|
|
722
|
-
from:
|
|
724
|
+
scaleId: c.id,
|
|
725
|
+
from: r,
|
|
723
726
|
to: u
|
|
724
727
|
}
|
|
725
728
|
];
|
|
@@ -737,62 +740,62 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
737
740
|
onMouseMove: s,
|
|
738
741
|
onMouseDown: o,
|
|
739
742
|
onMouseUp: i,
|
|
740
|
-
onDocumentMouseUp:
|
|
741
|
-
onSpanSelect:
|
|
743
|
+
onDocumentMouseUp: c,
|
|
744
|
+
onSpanSelect: r,
|
|
742
745
|
onContextMenu: u,
|
|
743
746
|
className: l,
|
|
744
|
-
style:
|
|
745
|
-
sync:
|
|
747
|
+
style: y,
|
|
748
|
+
sync: d,
|
|
746
749
|
innerChildren: a,
|
|
747
750
|
children: g
|
|
748
751
|
}) => {
|
|
749
|
-
const
|
|
750
|
-
return L("dblclick",
|
|
751
|
-
n?.(
|
|
752
|
-
}), L("click",
|
|
753
|
-
t?.(
|
|
754
|
-
}), L("move",
|
|
755
|
-
s?.(
|
|
756
|
-
}), L("mousedown",
|
|
757
|
-
o?.(
|
|
758
|
-
}), L("mouseup",
|
|
759
|
-
i?.(
|
|
760
|
-
}), L("documentmouseup",
|
|
761
|
-
|
|
762
|
-
}), L("spanselect",
|
|
763
|
-
|
|
764
|
-
}), L("contextmenu",
|
|
765
|
-
u?.(
|
|
766
|
-
}), /* @__PURE__ */ pe(we.Provider, { value:
|
|
767
|
-
/* @__PURE__ */
|
|
752
|
+
const h = Ve();
|
|
753
|
+
return L("dblclick", h, (p) => {
|
|
754
|
+
n?.(p);
|
|
755
|
+
}), L("click", h, (p) => {
|
|
756
|
+
t?.(p);
|
|
757
|
+
}), L("move", h, (p) => {
|
|
758
|
+
s?.(p);
|
|
759
|
+
}), L("mousedown", h, (p) => {
|
|
760
|
+
o?.(p);
|
|
761
|
+
}), L("mouseup", h, (p) => {
|
|
762
|
+
i?.(p);
|
|
763
|
+
}), L("documentmouseup", h, (p) => {
|
|
764
|
+
c?.(p);
|
|
765
|
+
}), L("spanselect", h, (p) => {
|
|
766
|
+
r?.(p);
|
|
767
|
+
}), L("contextmenu", h, (p) => {
|
|
768
|
+
u?.(p);
|
|
769
|
+
}), /* @__PURE__ */ pe(we.Provider, { value: h, children: [
|
|
770
|
+
/* @__PURE__ */ A(
|
|
768
771
|
ht,
|
|
769
772
|
{
|
|
770
773
|
id: e,
|
|
771
774
|
className: l,
|
|
772
|
-
style:
|
|
773
|
-
sync:
|
|
775
|
+
style: y,
|
|
776
|
+
sync: d,
|
|
774
777
|
children: a
|
|
775
778
|
}
|
|
776
779
|
),
|
|
777
780
|
g
|
|
778
781
|
] });
|
|
779
782
|
}, ht = ({ id: e, className: t, style: n, sync: s, children: o }) => {
|
|
780
|
-
const i =
|
|
781
|
-
|
|
782
|
-
const u = G(we), l = s?.key || u,
|
|
783
|
-
const
|
|
784
|
-
if (
|
|
785
|
-
if (
|
|
783
|
+
const i = k(null), c = Ue().frame, r = k(c);
|
|
784
|
+
r.current = c;
|
|
785
|
+
const u = G(we), l = s?.key || u, y = k(null), d = k(null), a = k(null), g = () => {
|
|
786
|
+
const f = i.current?.parentElement;
|
|
787
|
+
if (f) {
|
|
788
|
+
if (f.dataset.canplotroot === void 0)
|
|
786
789
|
throw new Error(
|
|
787
790
|
"ChartAreaInteractions must be used within a CanPlot component"
|
|
788
791
|
);
|
|
789
|
-
return
|
|
792
|
+
return f.getBoundingClientRect();
|
|
790
793
|
}
|
|
791
|
-
},
|
|
794
|
+
}, h = (f, m) => {
|
|
792
795
|
const v = ut(
|
|
793
|
-
|
|
796
|
+
f,
|
|
794
797
|
g(),
|
|
795
|
-
|
|
798
|
+
r.current,
|
|
796
799
|
s?.xViaScaleId,
|
|
797
800
|
s?.yViaScaleId
|
|
798
801
|
);
|
|
@@ -800,21 +803,21 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
800
803
|
v.pointerSyncPosition,
|
|
801
804
|
{ cssX: v.cssX, cssY: v.cssY },
|
|
802
805
|
{
|
|
803
|
-
ctrlKey:
|
|
804
|
-
altKey:
|
|
805
|
-
shiftKey:
|
|
806
|
-
metaKey:
|
|
806
|
+
ctrlKey: f.ctrlKey,
|
|
807
|
+
altKey: f.altKey,
|
|
808
|
+
shiftKey: f.shiftKey,
|
|
809
|
+
metaKey: f.metaKey
|
|
807
810
|
}
|
|
808
811
|
);
|
|
809
|
-
},
|
|
810
|
-
return
|
|
811
|
-
const
|
|
812
|
-
const
|
|
813
|
-
|
|
814
|
-
...
|
|
812
|
+
}, p = k(h);
|
|
813
|
+
return p.current = h, ke(() => {
|
|
814
|
+
const f = (w) => {
|
|
815
|
+
const x = d.current;
|
|
816
|
+
x && M.spanselect.dispatchEvent(u, {
|
|
817
|
+
...x,
|
|
815
818
|
completed: !0
|
|
816
819
|
}), M.documentmouseup.dispatchEvent(u, {
|
|
817
|
-
frame:
|
|
820
|
+
frame: r.current,
|
|
818
821
|
keys: {
|
|
819
822
|
ctrlKey: w.ctrlKey,
|
|
820
823
|
altKey: w.altKey,
|
|
@@ -823,67 +826,67 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
823
826
|
}
|
|
824
827
|
});
|
|
825
828
|
}, m = (w) => {
|
|
826
|
-
const
|
|
829
|
+
const x = {
|
|
827
830
|
ctrlKey: w.ctrlKey,
|
|
828
831
|
altKey: w.altKey,
|
|
829
832
|
shiftKey: w.shiftKey,
|
|
830
833
|
metaKey: w.metaKey
|
|
831
834
|
}, S = a.current;
|
|
832
|
-
if (S && Object.entries(
|
|
835
|
+
if (S && Object.entries(x).some(
|
|
833
836
|
([C, P]) => S.keys[C] !== P
|
|
834
837
|
)) {
|
|
835
|
-
const C = { ...S, keys:
|
|
838
|
+
const C = { ...S, keys: x };
|
|
836
839
|
a.current = C, M.sync_move.dispatchEvent(l, C);
|
|
837
840
|
}
|
|
838
|
-
const E =
|
|
839
|
-
if (E && Object.entries(
|
|
841
|
+
const E = d.current;
|
|
842
|
+
if (E && Object.entries(x).some(
|
|
840
843
|
([C, P]) => E.keys[C] !== P
|
|
841
844
|
)) {
|
|
842
845
|
w.stopPropagation(), w.preventDefault();
|
|
843
|
-
const C = { ...E, keys:
|
|
844
|
-
|
|
846
|
+
const C = { ...E, keys: x };
|
|
847
|
+
d.current = C, M.spanselect.dispatchEvent(u, C);
|
|
845
848
|
}
|
|
846
849
|
}, v = (w) => {
|
|
847
|
-
|
|
850
|
+
p.current(
|
|
848
851
|
w,
|
|
849
|
-
(
|
|
850
|
-
const P =
|
|
851
|
-
if (!P || !
|
|
852
|
-
const
|
|
852
|
+
(x, { cssX: S, cssY: E }, C) => {
|
|
853
|
+
const P = y.current;
|
|
854
|
+
if (!P || !x.x || !x.y) return;
|
|
855
|
+
const D = r.current, z = P.xRangeCss.start, ae = S, le = P.yRangeCss.start, ue = E, ee = F(D, x.x.scaleId);
|
|
853
856
|
if (!ee) return;
|
|
854
|
-
const te = F(
|
|
857
|
+
const te = F(D, x.y.scaleId);
|
|
855
858
|
if (!te) return;
|
|
856
|
-
|
|
859
|
+
y.current = {
|
|
857
860
|
xRangeCss: { start: z, end: ae },
|
|
858
861
|
yRangeCss: { start: le, end: ue }
|
|
859
862
|
};
|
|
860
|
-
let
|
|
863
|
+
let W = "below_threshold";
|
|
861
864
|
const he = Math.abs(le - ue), fe = Math.abs(z - ae);
|
|
862
|
-
he < 10 && fe < 10 ?
|
|
865
|
+
he < 10 && fe < 10 ? W = "below_threshold" : he > 30 && fe > 30 ? W = "box" : he > fe ? W = "y" : W = "x";
|
|
863
866
|
const Te = X(
|
|
864
|
-
|
|
865
|
-
V(
|
|
867
|
+
D,
|
|
868
|
+
V(r.current, z, "css"),
|
|
866
869
|
ee.id,
|
|
867
870
|
"css"
|
|
868
871
|
);
|
|
869
872
|
if (Te === null) return;
|
|
870
873
|
const Se = X(
|
|
871
|
-
|
|
872
|
-
V(
|
|
874
|
+
D,
|
|
875
|
+
V(r.current, ae, "css"),
|
|
873
876
|
ee.id,
|
|
874
877
|
"css"
|
|
875
878
|
);
|
|
876
879
|
if (Se === null) return;
|
|
877
880
|
const Ce = X(
|
|
878
|
-
|
|
879
|
-
|
|
881
|
+
D,
|
|
882
|
+
q(r.current, le, "css"),
|
|
880
883
|
te.id,
|
|
881
884
|
"css"
|
|
882
885
|
);
|
|
883
886
|
if (Ce === null) return;
|
|
884
887
|
const Pe = X(
|
|
885
|
-
|
|
886
|
-
|
|
888
|
+
D,
|
|
889
|
+
q(r.current, ue, "css"),
|
|
887
890
|
te.id,
|
|
888
891
|
"css"
|
|
889
892
|
);
|
|
@@ -891,14 +894,14 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
891
894
|
const ne = Ee(
|
|
892
895
|
"x",
|
|
893
896
|
{ scaleId: ee.id, from: Te, to: Se },
|
|
894
|
-
|
|
897
|
+
r.current
|
|
895
898
|
), se = Ee(
|
|
896
899
|
"y",
|
|
897
900
|
{ scaleId: te.id, from: Ce, to: Pe },
|
|
898
|
-
|
|
901
|
+
r.current
|
|
899
902
|
), Ke = ne?.scaled, Ye = se?.scaled, Me = {
|
|
900
|
-
mode:
|
|
901
|
-
frame:
|
|
903
|
+
mode: W,
|
|
904
|
+
frame: r.current,
|
|
902
905
|
completed: !1,
|
|
903
906
|
x: {
|
|
904
907
|
css: ne ? {
|
|
@@ -916,52 +919,52 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
916
919
|
},
|
|
917
920
|
keys: C
|
|
918
921
|
};
|
|
919
|
-
|
|
922
|
+
d.current = Me, M.spanselect.dispatchEvent(
|
|
920
923
|
u,
|
|
921
924
|
Me
|
|
922
925
|
);
|
|
923
926
|
}
|
|
924
927
|
);
|
|
925
|
-
},
|
|
926
|
-
|
|
928
|
+
}, b = (w) => {
|
|
929
|
+
p.current(w, (x, S, E) => {
|
|
927
930
|
const C = N(
|
|
928
|
-
|
|
929
|
-
|
|
931
|
+
x,
|
|
932
|
+
r.current
|
|
930
933
|
);
|
|
931
934
|
if (!C) return;
|
|
932
|
-
if (Object.values(E).some((
|
|
935
|
+
if (Object.values(E).some((D) => D)) {
|
|
933
936
|
w.preventDefault();
|
|
934
|
-
const
|
|
937
|
+
const D = Math.abs(w.deltaY) > Math.abs(w.deltaX) ? w.deltaY : w.deltaX;
|
|
935
938
|
M.pressandwheel.dispatchEvent(u, {
|
|
936
939
|
pointer: C,
|
|
937
|
-
frame:
|
|
940
|
+
frame: r.current,
|
|
938
941
|
keys: E,
|
|
939
942
|
deltaX: w.deltaX,
|
|
940
943
|
deltaY: w.deltaY,
|
|
941
|
-
deltaAbs:
|
|
944
|
+
deltaAbs: D
|
|
942
945
|
});
|
|
943
946
|
}
|
|
944
947
|
});
|
|
945
948
|
};
|
|
946
|
-
document.addEventListener("mouseup",
|
|
949
|
+
document.addEventListener("mouseup", f), document.addEventListener("keydown", m), document.addEventListener("keyup", m), document.addEventListener("mousemove", v);
|
|
947
950
|
const T = i.current;
|
|
948
|
-
return T?.addEventListener("wheel",
|
|
951
|
+
return T?.addEventListener("wheel", b, {
|
|
949
952
|
passive: !1
|
|
950
953
|
}), () => {
|
|
951
|
-
document.removeEventListener("mouseup",
|
|
954
|
+
document.removeEventListener("mouseup", f), document.removeEventListener("keydown", m), document.removeEventListener("keyup", m), document.removeEventListener("mousemove", v), T?.removeEventListener("wheel", b);
|
|
952
955
|
};
|
|
953
|
-
}, [
|
|
954
|
-
const m =
|
|
955
|
-
|
|
956
|
-
|
|
956
|
+
}, [r, u, l, p]), L("sync_move", l, (f) => {
|
|
957
|
+
const m = f.positions ? N(
|
|
958
|
+
f.positions,
|
|
959
|
+
r.current
|
|
957
960
|
) : null;
|
|
958
|
-
a.current =
|
|
959
|
-
frame:
|
|
961
|
+
a.current = f, M.move.dispatchEvent(u, {
|
|
962
|
+
frame: r.current,
|
|
960
963
|
pointer: m ?? null,
|
|
961
|
-
keys:
|
|
962
|
-
source:
|
|
964
|
+
keys: f.keys,
|
|
965
|
+
source: f.originInteractionsId === u ? "own" : "sync"
|
|
963
966
|
});
|
|
964
|
-
}), /* @__PURE__ */
|
|
967
|
+
}), /* @__PURE__ */ A(
|
|
965
968
|
"div",
|
|
966
969
|
{
|
|
967
970
|
ref: i,
|
|
@@ -969,114 +972,114 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
969
972
|
className: t,
|
|
970
973
|
style: {
|
|
971
974
|
position: "absolute",
|
|
972
|
-
left:
|
|
973
|
-
top:
|
|
974
|
-
width:
|
|
975
|
-
height:
|
|
975
|
+
left: c.chartAreaCSS.x,
|
|
976
|
+
top: c.chartAreaCSS.y,
|
|
977
|
+
width: c.chartAreaCSS.width,
|
|
978
|
+
height: c.chartAreaCSS.height,
|
|
976
979
|
zIndex: 25,
|
|
977
980
|
...n
|
|
978
981
|
},
|
|
979
|
-
onDragStart: (
|
|
980
|
-
|
|
982
|
+
onDragStart: (f) => {
|
|
983
|
+
f.preventDefault();
|
|
981
984
|
},
|
|
982
|
-
onClick: (
|
|
983
|
-
|
|
985
|
+
onClick: (f) => {
|
|
986
|
+
h(f, (m, v, b) => {
|
|
984
987
|
const T = N(
|
|
985
988
|
m,
|
|
986
|
-
|
|
989
|
+
r.current
|
|
987
990
|
);
|
|
988
991
|
T && M.click.dispatchEvent(u, {
|
|
989
992
|
pointer: T,
|
|
990
|
-
frame:
|
|
991
|
-
keys:
|
|
993
|
+
frame: r.current,
|
|
994
|
+
keys: b
|
|
992
995
|
});
|
|
993
996
|
});
|
|
994
997
|
},
|
|
995
|
-
onMouseLeave: (
|
|
996
|
-
|
|
998
|
+
onMouseLeave: (f) => {
|
|
999
|
+
h(f, (m, v, b) => {
|
|
997
1000
|
M.sync_move.dispatchEvent(l, {
|
|
998
1001
|
positions: null,
|
|
999
|
-
keys:
|
|
1002
|
+
keys: b,
|
|
1000
1003
|
originInteractionsId: u
|
|
1001
1004
|
});
|
|
1002
1005
|
});
|
|
1003
1006
|
},
|
|
1004
|
-
onMouseMove: (
|
|
1005
|
-
|
|
1007
|
+
onMouseMove: (f) => {
|
|
1008
|
+
h(f, (m, v, b) => {
|
|
1006
1009
|
M.sync_move.dispatchEvent(l, {
|
|
1007
1010
|
positions: m,
|
|
1008
|
-
keys:
|
|
1011
|
+
keys: b,
|
|
1009
1012
|
originInteractionsId: u
|
|
1010
1013
|
});
|
|
1011
1014
|
});
|
|
1012
1015
|
},
|
|
1013
|
-
onMouseDown: (
|
|
1014
|
-
|
|
1016
|
+
onMouseDown: (f) => {
|
|
1017
|
+
h(f, (m, { cssX: v, cssY: b }, T) => {
|
|
1015
1018
|
const w = N(
|
|
1016
1019
|
m,
|
|
1017
|
-
|
|
1020
|
+
r.current
|
|
1018
1021
|
);
|
|
1019
1022
|
w && (M.mousedown.dispatchEvent(u, {
|
|
1020
1023
|
pointer: w,
|
|
1021
|
-
frame:
|
|
1024
|
+
frame: r.current,
|
|
1022
1025
|
keys: T
|
|
1023
|
-
}),
|
|
1026
|
+
}), y.current = {
|
|
1024
1027
|
xRangeCss: { start: v, end: v },
|
|
1025
|
-
yRangeCss: { start:
|
|
1028
|
+
yRangeCss: { start: b, end: b }
|
|
1026
1029
|
});
|
|
1027
1030
|
});
|
|
1028
1031
|
},
|
|
1029
|
-
onMouseUp: (
|
|
1030
|
-
|
|
1032
|
+
onMouseUp: (f) => {
|
|
1033
|
+
h(f, (m, v, b) => {
|
|
1031
1034
|
const T = N(
|
|
1032
1035
|
m,
|
|
1033
|
-
|
|
1036
|
+
r.current
|
|
1034
1037
|
);
|
|
1035
1038
|
if (!T) return;
|
|
1036
1039
|
M.mouseup.dispatchEvent(u, {
|
|
1037
|
-
frame:
|
|
1040
|
+
frame: r.current,
|
|
1038
1041
|
pointer: T,
|
|
1039
|
-
keys:
|
|
1042
|
+
keys: b
|
|
1040
1043
|
});
|
|
1041
|
-
const w =
|
|
1042
|
-
|
|
1043
|
-
const
|
|
1044
|
-
if (
|
|
1044
|
+
const w = d.current;
|
|
1045
|
+
d.current = null;
|
|
1046
|
+
const x = y.current;
|
|
1047
|
+
if (y.current = null, x && w) {
|
|
1045
1048
|
const S = {
|
|
1046
1049
|
...w,
|
|
1047
|
-
keys:
|
|
1050
|
+
keys: b,
|
|
1048
1051
|
completed: !0
|
|
1049
1052
|
};
|
|
1050
|
-
|
|
1053
|
+
d.current = null, M.spanselect.dispatchEvent(
|
|
1051
1054
|
u,
|
|
1052
1055
|
S
|
|
1053
1056
|
);
|
|
1054
1057
|
}
|
|
1055
1058
|
});
|
|
1056
1059
|
},
|
|
1057
|
-
onContextMenu: (
|
|
1058
|
-
|
|
1060
|
+
onContextMenu: (f) => {
|
|
1061
|
+
f.preventDefault(), h(f, (m, v, b) => {
|
|
1059
1062
|
const T = N(
|
|
1060
1063
|
m,
|
|
1061
|
-
|
|
1064
|
+
r.current
|
|
1062
1065
|
);
|
|
1063
1066
|
T && M.contextmenu.dispatchEvent(u, {
|
|
1064
|
-
frame:
|
|
1067
|
+
frame: r.current,
|
|
1065
1068
|
pointer: T,
|
|
1066
|
-
keys:
|
|
1069
|
+
keys: b
|
|
1067
1070
|
});
|
|
1068
1071
|
});
|
|
1069
1072
|
},
|
|
1070
|
-
onDoubleClick: (
|
|
1071
|
-
|
|
1073
|
+
onDoubleClick: (f) => {
|
|
1074
|
+
h(f, (m, v, b) => {
|
|
1072
1075
|
const T = N(
|
|
1073
1076
|
m,
|
|
1074
|
-
|
|
1077
|
+
r.current
|
|
1075
1078
|
);
|
|
1076
1079
|
T && M.dblclick.dispatchEvent(u, {
|
|
1077
|
-
frame:
|
|
1080
|
+
frame: r.current,
|
|
1078
1081
|
pointer: T,
|
|
1079
|
-
keys:
|
|
1082
|
+
keys: b
|
|
1080
1083
|
});
|
|
1081
1084
|
});
|
|
1082
1085
|
},
|
|
@@ -1085,87 +1088,87 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1085
1088
|
);
|
|
1086
1089
|
}, Yt = ({ data: e, renderTooltip: t, xScaleId: n }) => {
|
|
1087
1090
|
const [s, o] = B(null);
|
|
1088
|
-
|
|
1089
|
-
o(
|
|
1091
|
+
be("move", (c) => {
|
|
1092
|
+
o(c);
|
|
1090
1093
|
});
|
|
1091
1094
|
const i = Q(() => {
|
|
1092
1095
|
if (!s)
|
|
1093
1096
|
return null;
|
|
1094
|
-
const { frame:
|
|
1095
|
-
if (u === void 0 || !F(
|
|
1097
|
+
const { frame: c, pointer: r } = s, u = r?.scaled[n];
|
|
1098
|
+
if (u === void 0 || !F(c, n))
|
|
1096
1099
|
return null;
|
|
1097
|
-
const
|
|
1098
|
-
let
|
|
1100
|
+
const y = [];
|
|
1101
|
+
let d = u;
|
|
1099
1102
|
for (const a of e) {
|
|
1100
|
-
let g = null,
|
|
1103
|
+
let g = null, h = 1 / 0;
|
|
1101
1104
|
for (const [m, v] of a.points.entries()) {
|
|
1102
|
-
if (!de(
|
|
1105
|
+
if (!de(c, v.x, n) || !de(c, v.y, a.yScaleId))
|
|
1103
1106
|
continue;
|
|
1104
|
-
const
|
|
1105
|
-
|
|
1107
|
+
const b = Math.abs(v.x - u);
|
|
1108
|
+
b < h && (h = b, g = m);
|
|
1106
1109
|
}
|
|
1107
|
-
const
|
|
1108
|
-
if (!
|
|
1109
|
-
|
|
1110
|
+
const p = a.points[g ?? -1], f = ge(c, h, n, "css");
|
|
1111
|
+
if (!p || f === null || f > 30) {
|
|
1112
|
+
y.push({ seriesId: a.seriesId, y: null });
|
|
1110
1113
|
continue;
|
|
1111
1114
|
}
|
|
1112
|
-
|
|
1115
|
+
d = p.x, y.push({
|
|
1113
1116
|
seriesId: a.seriesId,
|
|
1114
|
-
y:
|
|
1117
|
+
y: p.y
|
|
1115
1118
|
});
|
|
1116
1119
|
}
|
|
1117
1120
|
return {
|
|
1118
|
-
frame:
|
|
1119
|
-
x:
|
|
1120
|
-
points:
|
|
1121
|
+
frame: c,
|
|
1122
|
+
x: d,
|
|
1123
|
+
points: y
|
|
1121
1124
|
};
|
|
1122
1125
|
}, [e, s, n]);
|
|
1123
1126
|
return t(i);
|
|
1124
1127
|
}, Bt = ({ makeXStyle: e, makeXClassName: t, makeYStyle: n, makeYClassName: s }) => {
|
|
1125
1128
|
const [o, i] = B(null);
|
|
1126
|
-
if (
|
|
1129
|
+
if (be("move", (a) => {
|
|
1127
1130
|
i(a);
|
|
1128
1131
|
}), !o)
|
|
1129
1132
|
return null;
|
|
1130
|
-
const { frame:
|
|
1133
|
+
const { frame: c, pointer: r } = o, u = r?.cssX ?? null, l = r?.cssY ?? null, y = u ? V(c, u, "css") : 0, d = l ? q(c, l, "css") : 0;
|
|
1131
1134
|
return /* @__PURE__ */ pe(Ne, { children: [
|
|
1132
|
-
/* @__PURE__ */
|
|
1135
|
+
/* @__PURE__ */ A(
|
|
1133
1136
|
"div",
|
|
1134
1137
|
{
|
|
1135
|
-
"data-show": !!
|
|
1138
|
+
"data-show": !!r,
|
|
1136
1139
|
className: t?.(o),
|
|
1137
1140
|
style: {
|
|
1138
1141
|
position: "absolute",
|
|
1139
1142
|
left: 0,
|
|
1140
1143
|
visibility: u === null ? "hidden" : "visible",
|
|
1141
|
-
top:
|
|
1142
|
-
height:
|
|
1144
|
+
top: c.chartAreaCSS.y,
|
|
1145
|
+
height: c.chartAreaCSS.height,
|
|
1143
1146
|
borderColor: "red",
|
|
1144
1147
|
borderLeftWidth: "1px",
|
|
1145
1148
|
borderLeftStyle: "solid",
|
|
1146
1149
|
pointerEvents: "none",
|
|
1147
|
-
opacity:
|
|
1148
|
-
transform: `translateX(${
|
|
1150
|
+
opacity: r ? 1 : 0,
|
|
1151
|
+
transform: `translateX(${y}px)`,
|
|
1149
1152
|
...e?.(o)
|
|
1150
1153
|
}
|
|
1151
1154
|
}
|
|
1152
1155
|
),
|
|
1153
|
-
/* @__PURE__ */
|
|
1156
|
+
/* @__PURE__ */ A(
|
|
1154
1157
|
"div",
|
|
1155
1158
|
{
|
|
1156
1159
|
className: s?.(o),
|
|
1157
|
-
"data-show": !!
|
|
1160
|
+
"data-show": !!r,
|
|
1158
1161
|
style: {
|
|
1159
1162
|
position: "absolute",
|
|
1160
1163
|
visibility: l === null ? "hidden" : "visible",
|
|
1161
1164
|
top: 0,
|
|
1162
1165
|
height: 0,
|
|
1163
1166
|
borderTop: "solid 1px red",
|
|
1164
|
-
left:
|
|
1165
|
-
width:
|
|
1167
|
+
left: c.chartAreaCSS.x,
|
|
1168
|
+
width: c.chartAreaCSS.width,
|
|
1166
1169
|
pointerEvents: "none",
|
|
1167
|
-
opacity:
|
|
1168
|
-
transform: `translateY(${
|
|
1170
|
+
opacity: r ? 1 : 0,
|
|
1171
|
+
transform: `translateY(${d}px)`,
|
|
1169
1172
|
...n?.(o)
|
|
1170
1173
|
}
|
|
1171
1174
|
}
|
|
@@ -1173,7 +1176,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1173
1176
|
] });
|
|
1174
1177
|
}, zt = ({ makeClassName: e, makeStyle: t }) => {
|
|
1175
1178
|
const [n, s] = B(null);
|
|
1176
|
-
|
|
1179
|
+
be("spanselect", (i) => {
|
|
1177
1180
|
s(
|
|
1178
1181
|
i.mode === "below_threshold" || i.completed ? null : i
|
|
1179
1182
|
);
|
|
@@ -1181,10 +1184,10 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1181
1184
|
const o = Q(() => {
|
|
1182
1185
|
if (!n || n.mode === "below_threshold")
|
|
1183
1186
|
return null;
|
|
1184
|
-
const i = n.mode === "y" ? -1 / 0 : n.x.css?.from ?? -1 / 0,
|
|
1185
|
-
return { leftPx: g, topPx:
|
|
1187
|
+
const i = n.mode === "y" ? -1 / 0 : n.x.css?.from ?? -1 / 0, c = n.mode === "y" ? 1 / 0 : n.x.css?.to ?? 1 / 0, r = n.mode === "x" ? -1 / 0 : n.y.css?.from ?? -1 / 0, u = n.mode === "x" ? 1 / 0 : n.y.css?.to ?? 1 / 0, l = V(n.frame, i, "css"), y = V(n.frame, c, "css"), d = q(n.frame, r, "css"), a = q(n.frame, u, "css"), g = Math.min(l, y), h = Math.min(d, a), p = Math.abs(y - l), f = Math.abs(a - d);
|
|
1188
|
+
return { leftPx: g, topPx: h, widthPx: p, heightPx: f };
|
|
1186
1189
|
}, [n]);
|
|
1187
|
-
return /* @__PURE__ */
|
|
1190
|
+
return /* @__PURE__ */ A(
|
|
1188
1191
|
"div",
|
|
1189
1192
|
{
|
|
1190
1193
|
className: n ? e?.(n) : void 0,
|
|
@@ -1202,7 +1205,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1202
1205
|
);
|
|
1203
1206
|
}, Nt = ({ style: e, children: t, scaleId: n, ...s }) => {
|
|
1204
1207
|
const o = Ue().getScale(n)?.axis;
|
|
1205
|
-
return o ? /* @__PURE__ */
|
|
1208
|
+
return o ? /* @__PURE__ */ A(
|
|
1206
1209
|
"div",
|
|
1207
1210
|
{
|
|
1208
1211
|
style: {
|
|
@@ -1223,30 +1226,30 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1223
1226
|
formatter: t,
|
|
1224
1227
|
acceptableIncrements: n
|
|
1225
1228
|
} = {}) => (s, o) => {
|
|
1226
|
-
const { min: i, max:
|
|
1229
|
+
const { min: i, max: c } = s, r = [], u = window.devicePixelRatio || 1, l = (e ?? (s.origin === "x" ? Xe : ft)) * u, y = qe(
|
|
1227
1230
|
o,
|
|
1228
1231
|
l,
|
|
1229
1232
|
s.id,
|
|
1230
1233
|
"canvas"
|
|
1231
1234
|
);
|
|
1232
|
-
if (
|
|
1235
|
+
if (y === null)
|
|
1233
1236
|
return [];
|
|
1234
|
-
const
|
|
1237
|
+
const d = n ?? oe, a = d.find((h) => h > y) ?? d.at(-1) ?? 1;
|
|
1235
1238
|
let g = i;
|
|
1236
1239
|
if (Math.abs(g % a) > Number.EPSILON) {
|
|
1237
|
-
const
|
|
1238
|
-
g +=
|
|
1240
|
+
const h = (a - g % a) % a;
|
|
1241
|
+
g += h;
|
|
1239
1242
|
}
|
|
1240
|
-
for (; g <=
|
|
1241
|
-
|
|
1242
|
-
return (t ?? mt)(
|
|
1243
|
+
for (; g <= c && r.length < 1e3; )
|
|
1244
|
+
r.push(g), g += a;
|
|
1245
|
+
return (t ?? mt)(r);
|
|
1243
1246
|
}, mt = (e) => {
|
|
1244
1247
|
const t = Math.max(0, Math.ceil(-Math.log10(e[1] - e[0])));
|
|
1245
1248
|
return e.map((n) => ({ value: n, label: n.toFixed(t) }));
|
|
1246
1249
|
}, oe = [];
|
|
1247
1250
|
for (let e = -12; e <= 12; e++)
|
|
1248
1251
|
oe.push(1 * 10 ** e), oe.push(2 * 10 ** e), oe.push(5 * 10 ** e);
|
|
1249
|
-
const pt = 1, Oe = 1e3 * pt,
|
|
1252
|
+
const pt = 1, Oe = 1e3 * pt, xe = 60 * Oe, J = 60 * xe, ce = 24 * J, yt = 30 * ce, gt = 365 * ce, vt = [
|
|
1250
1253
|
// second divisors
|
|
1251
1254
|
[1, "milliseconds"],
|
|
1252
1255
|
[2, "milliseconds"],
|
|
@@ -1306,7 +1309,7 @@ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, J = 60 * be, ce = 24 * J, yt = 30 * c
|
|
|
1306
1309
|
case "seconds":
|
|
1307
1310
|
return t * Oe;
|
|
1308
1311
|
case "minutes":
|
|
1309
|
-
return t *
|
|
1312
|
+
return t * xe;
|
|
1310
1313
|
case "hours":
|
|
1311
1314
|
return t * J;
|
|
1312
1315
|
case "days":
|
|
@@ -1319,10 +1322,10 @@ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, J = 60 * be, ce = 24 * J, yt = 30 * c
|
|
|
1319
1322
|
}, wt = (e, t) => {
|
|
1320
1323
|
const n = new Date(e);
|
|
1321
1324
|
return n.setUTCMilliseconds(n.getUTCMilliseconds() + t), n.getTime();
|
|
1322
|
-
},
|
|
1325
|
+
}, bt = (e, t) => {
|
|
1323
1326
|
const n = new Date(e);
|
|
1324
1327
|
return n.setUTCSeconds(n.getUTCSeconds() + t), n.getTime();
|
|
1325
|
-
},
|
|
1328
|
+
}, xt = (e, t) => {
|
|
1326
1329
|
const n = new Date(e);
|
|
1327
1330
|
return n.setUTCMinutes(n.getUTCMinutes() + t), n.getTime();
|
|
1328
1331
|
}, Tt = (e, t) => {
|
|
@@ -1331,7 +1334,7 @@ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, J = 60 * be, ce = 24 * J, yt = 30 * c
|
|
|
1331
1334
|
}, St = (e, t) => {
|
|
1332
1335
|
const n = new Date(e);
|
|
1333
1336
|
return n.setUTCDate(n.getUTCDate() + t), n.getTime();
|
|
1334
|
-
},
|
|
1337
|
+
}, De = (e, t) => {
|
|
1335
1338
|
const n = new Date(e);
|
|
1336
1339
|
return n.setUTCMonth(n.getUTCMonth() + t), n.getTime();
|
|
1337
1340
|
}, U = (e, t) => {
|
|
@@ -1340,17 +1343,17 @@ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, J = 60 * be, ce = 24 * J, yt = 30 * c
|
|
|
1340
1343
|
case "milliseconds":
|
|
1341
1344
|
return wt(e, n);
|
|
1342
1345
|
case "seconds":
|
|
1343
|
-
return xt(e, n);
|
|
1344
|
-
case "minutes":
|
|
1345
1346
|
return bt(e, n);
|
|
1347
|
+
case "minutes":
|
|
1348
|
+
return xt(e, n);
|
|
1346
1349
|
case "hours":
|
|
1347
1350
|
return Tt(e, n);
|
|
1348
1351
|
case "days":
|
|
1349
1352
|
return St(e, n);
|
|
1350
1353
|
case "months":
|
|
1351
|
-
return
|
|
1354
|
+
return De(e, n);
|
|
1352
1355
|
case "years":
|
|
1353
|
-
return
|
|
1356
|
+
return De(e, n * 12);
|
|
1354
1357
|
}
|
|
1355
1358
|
};
|
|
1356
1359
|
function H(e, t) {
|
|
@@ -1360,7 +1363,7 @@ function H(e, t) {
|
|
|
1360
1363
|
const Ct = (e, t, n = "UTC") => {
|
|
1361
1364
|
const [s, o] = t;
|
|
1362
1365
|
let i = new Date(e);
|
|
1363
|
-
const
|
|
1366
|
+
const c = () => {
|
|
1364
1367
|
i.setUTCHours(-H(i, n), 0, 0, 0);
|
|
1365
1368
|
};
|
|
1366
1369
|
switch (o) {
|
|
@@ -1377,17 +1380,17 @@ const Ct = (e, t, n = "UTC") => {
|
|
|
1377
1380
|
break;
|
|
1378
1381
|
case "minutes":
|
|
1379
1382
|
i.setUTCMinutes(
|
|
1380
|
-
Math.ceil(i.getTime() % J /
|
|
1383
|
+
Math.ceil(i.getTime() % J / xe / s) * s,
|
|
1381
1384
|
0,
|
|
1382
1385
|
0
|
|
1383
1386
|
);
|
|
1384
1387
|
break;
|
|
1385
1388
|
case "hours": {
|
|
1386
|
-
const
|
|
1389
|
+
const r = H(i, n);
|
|
1387
1390
|
i.setUTCHours(
|
|
1388
1391
|
Math.ceil(
|
|
1389
|
-
(i.getTime() +
|
|
1390
|
-
) * s -
|
|
1392
|
+
(i.getTime() + r * J) % ce / J / s
|
|
1393
|
+
) * s - r,
|
|
1391
1394
|
0,
|
|
1392
1395
|
0,
|
|
1393
1396
|
0
|
|
@@ -1395,7 +1398,7 @@ const Ct = (e, t, n = "UTC") => {
|
|
|
1395
1398
|
break;
|
|
1396
1399
|
}
|
|
1397
1400
|
case "days": {
|
|
1398
|
-
for (
|
|
1401
|
+
for (c(), i.setUTCDate(
|
|
1399
1402
|
1
|
|
1400
1403
|
); i.getTime() < e; )
|
|
1401
1404
|
i = new Date(U(i, [s, o]));
|
|
@@ -1403,7 +1406,7 @@ const Ct = (e, t, n = "UTC") => {
|
|
|
1403
1406
|
}
|
|
1404
1407
|
case "months":
|
|
1405
1408
|
case "years":
|
|
1406
|
-
o === "months" ? i.setUTCDate(1) : o === "years" && i.setUTCMonth(0, 1),
|
|
1409
|
+
o === "months" ? i.setUTCDate(1) : o === "years" && i.setUTCMonth(0, 1), c(), i.getTime() < e && (i = new Date(U(i, [1, o])));
|
|
1407
1410
|
break;
|
|
1408
1411
|
}
|
|
1409
1412
|
return i.getTime();
|
|
@@ -1413,42 +1416,42 @@ const Ct = (e, t, n = "UTC") => {
|
|
|
1413
1416
|
formatter: n,
|
|
1414
1417
|
locale: s,
|
|
1415
1418
|
showTimezone: o
|
|
1416
|
-
} = {}) => (i,
|
|
1417
|
-
const { min:
|
|
1418
|
-
if (!Number.isFinite(
|
|
1419
|
+
} = {}) => (i, c) => {
|
|
1420
|
+
const { min: r, max: u } = i;
|
|
1421
|
+
if (!Number.isFinite(r) || !Number.isFinite(u))
|
|
1419
1422
|
return [];
|
|
1420
|
-
const l = Math.floor(
|
|
1421
|
-
(v) => ie(v) >=
|
|
1423
|
+
const l = Math.floor(c.chartAreaCanvasPX.width / t) + 1, d = (u - r) / l, [a, g] = vt.find(
|
|
1424
|
+
(v) => ie(v) >= d
|
|
1422
1425
|
) ?? [1, "milliseconds"];
|
|
1423
1426
|
if (!a || !g)
|
|
1424
1427
|
return [];
|
|
1425
|
-
const
|
|
1428
|
+
const h = Ct(r, [a, g], e), p = H(h, e), f = [h];
|
|
1426
1429
|
let m;
|
|
1427
1430
|
for (; ; ) {
|
|
1428
|
-
if (
|
|
1431
|
+
if (f.length > 100)
|
|
1429
1432
|
return [];
|
|
1430
1433
|
switch (g) {
|
|
1431
1434
|
case "milliseconds":
|
|
1432
1435
|
case "seconds":
|
|
1433
1436
|
case "minutes":
|
|
1434
1437
|
case "hours": {
|
|
1435
|
-
const v = U(
|
|
1436
|
-
|
|
1438
|
+
const v = U(h, [
|
|
1439
|
+
f.length * a,
|
|
1437
1440
|
g
|
|
1438
1441
|
]);
|
|
1439
1442
|
m = U(v, [
|
|
1440
|
-
|
|
1443
|
+
p - H(v, e),
|
|
1441
1444
|
"hours"
|
|
1442
1445
|
]);
|
|
1443
1446
|
break;
|
|
1444
1447
|
}
|
|
1445
1448
|
case "days": {
|
|
1446
|
-
const v = U(
|
|
1447
|
-
|
|
1449
|
+
const v = U(h, [
|
|
1450
|
+
f.length * a,
|
|
1448
1451
|
g
|
|
1449
1452
|
]);
|
|
1450
1453
|
m = U(v, [
|
|
1451
|
-
|
|
1454
|
+
p - H(v, e),
|
|
1452
1455
|
"hours"
|
|
1453
1456
|
]);
|
|
1454
1457
|
break;
|
|
@@ -1456,14 +1459,14 @@ const Ct = (e, t, n = "UTC") => {
|
|
|
1456
1459
|
case "months":
|
|
1457
1460
|
case "years": {
|
|
1458
1461
|
const v = U(
|
|
1459
|
-
U(U(
|
|
1460
|
-
|
|
1462
|
+
U(U(h, [p, "hours"]), [
|
|
1463
|
+
f.length * a,
|
|
1461
1464
|
g
|
|
1462
1465
|
]),
|
|
1463
|
-
[-
|
|
1466
|
+
[-p, "hours"]
|
|
1464
1467
|
);
|
|
1465
1468
|
m = U(v, [
|
|
1466
|
-
|
|
1469
|
+
p - H(v, e),
|
|
1467
1470
|
"hours"
|
|
1468
1471
|
]);
|
|
1469
1472
|
break;
|
|
@@ -1471,13 +1474,13 @@ const Ct = (e, t, n = "UTC") => {
|
|
|
1471
1474
|
}
|
|
1472
1475
|
if (m > u)
|
|
1473
1476
|
break;
|
|
1474
|
-
|
|
1477
|
+
f[f.length - 1] !== m && f.push(m);
|
|
1475
1478
|
}
|
|
1476
1479
|
return (n ?? Pt({
|
|
1477
1480
|
locale: s,
|
|
1478
1481
|
showTimezone: o,
|
|
1479
1482
|
timeZone: e
|
|
1480
|
-
}))(
|
|
1483
|
+
}))(f);
|
|
1481
1484
|
}, Y = (e, t, n) => e.find((s) => s.type === n)?.value !== t.find((s) => s.type === n)?.value, Pt = ({
|
|
1482
1485
|
timeZone: e = Fe,
|
|
1483
1486
|
locale: t = dt,
|
|
@@ -1496,30 +1499,30 @@ const Ct = (e, t, n = "UTC") => {
|
|
|
1496
1499
|
timeZone: e
|
|
1497
1500
|
});
|
|
1498
1501
|
return (o) => {
|
|
1499
|
-
const i = o[1] - o[0],
|
|
1500
|
-
return o.map((l) => ({ value: l, label: s.formatToParts(new Date(l)) })).map((l,
|
|
1501
|
-
const a =
|
|
1502
|
-
if (
|
|
1503
|
-
const
|
|
1502
|
+
const i = o[1] - o[0], c = i < ie([1, "days"]), r = i < ie([1, "minutes"]), u = i < ie([1, "seconds"]);
|
|
1503
|
+
return o.map((l) => ({ value: l, label: s.formatToParts(new Date(l)) })).map((l, y, d) => {
|
|
1504
|
+
const a = d[y - 1], g = y === 0 || Y(l.label, a.label, "year"), h = y === 0 || Y(l.label, a.label, "day"), p = y === 0 || Y(l.label, a.label, "month"), f = y === 0 || Y(l.label, a.label, "hour"), m = y === 0 || Y(l.label, a.label, "timeZoneName"), v = y === 0 || Y(l.label, a.label, "minute"), b = y === 0 || Y(l.label, a.label, "second"), T = y === 0 || Y(l.label, a.label, "fractionalSecond"), w = [];
|
|
1505
|
+
if (c && (f || v || m || b || T)) {
|
|
1506
|
+
const x = l.label.find((P) => P.type === "hour")?.value, S = l.label.find((P) => P.type === "minute")?.value, E = l.label.find((P) => P.type === "timeZoneName")?.value;
|
|
1504
1507
|
let C = "";
|
|
1505
|
-
if (
|
|
1506
|
-
const P = l.label.find((z) => z.type === "second")?.value,
|
|
1508
|
+
if (r) {
|
|
1509
|
+
const P = l.label.find((z) => z.type === "second")?.value, D = l.label.find(
|
|
1507
1510
|
(z) => z.type === "fractionalSecond"
|
|
1508
1511
|
)?.value;
|
|
1509
|
-
C = `:${P}` + (u ? `.${
|
|
1512
|
+
C = `:${P}` + (u ? `.${D}` : "");
|
|
1510
1513
|
}
|
|
1511
1514
|
w.push(
|
|
1512
|
-
`${
|
|
1515
|
+
`${x}:${S}${C}` + (n && m ? ` ${E}` : "")
|
|
1513
1516
|
);
|
|
1514
1517
|
}
|
|
1515
|
-
return (
|
|
1518
|
+
return (h || p) && w.push(
|
|
1516
1519
|
[
|
|
1517
|
-
l.label.find((
|
|
1518
|
-
|
|
1520
|
+
l.label.find((x) => x.type === "month")?.value,
|
|
1521
|
+
h && l.label.find((x) => x.type === "day")?.value
|
|
1519
1522
|
].filter(Boolean).join(" ")
|
|
1520
|
-
), g && w.push(l.label.find((
|
|
1523
|
+
), g && w.push(l.label.find((x) => x.type === "year")?.value), {
|
|
1521
1524
|
value: l.value,
|
|
1522
|
-
label: w.filter((
|
|
1525
|
+
label: w.filter((x) => x).join(`
|
|
1523
1526
|
`)
|
|
1524
1527
|
};
|
|
1525
1528
|
});
|
|
@@ -1530,7 +1533,7 @@ export {
|
|
|
1530
1533
|
Nt as AxisOverlay,
|
|
1531
1534
|
Ut as BarPlot,
|
|
1532
1535
|
Ie as CANPLOT_LAYER,
|
|
1533
|
-
|
|
1536
|
+
Rt as CanPlot,
|
|
1534
1537
|
Kt as ChartAreaInteractions,
|
|
1535
1538
|
Bt as Crosshair,
|
|
1536
1539
|
Le as FrameDrawer,
|
|
@@ -1544,20 +1547,20 @@ export {
|
|
|
1544
1547
|
_ as applyStyles,
|
|
1545
1548
|
re as clamp,
|
|
1546
1549
|
V as clampXPosToChartArea,
|
|
1547
|
-
|
|
1550
|
+
q as clampYPosToChartArea,
|
|
1548
1551
|
O as deepEqual,
|
|
1549
1552
|
mt as defaultNumericalTicksFormatter,
|
|
1550
|
-
|
|
1553
|
+
At as findClosestIndex,
|
|
1551
1554
|
F as getScale,
|
|
1552
1555
|
$t as makeLinearTicks,
|
|
1553
1556
|
Pt as makeTimeTickFormat,
|
|
1554
1557
|
jt as makeTimeTicks,
|
|
1555
1558
|
X as posToVal,
|
|
1556
|
-
|
|
1557
|
-
|
|
1559
|
+
qe as pxToValDistance,
|
|
1560
|
+
kt as sum,
|
|
1558
1561
|
j as useDrawEffect,
|
|
1559
1562
|
Ue as useFrameState,
|
|
1560
|
-
|
|
1563
|
+
be as useInteractionsEvent,
|
|
1561
1564
|
de as valFits,
|
|
1562
1565
|
Z as valToPos,
|
|
1563
1566
|
ge as valToPxDistance
|