@canplot/react 0.5.12 → 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 +406 -405
- package/dist/canplot.mjs.map +1 -1
- package/dist/plot/LinePlot.d.ts +1 -0
- package/dist/plot/LinePlot.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/canplot.mjs
CHANGED
|
@@ -8,12 +8,12 @@ const re = (e, t, n) => Math.min(Math.max(e, t), n), kt = (e) => e.reduce((t, n)
|
|
|
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), kt = (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), kt = (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), kt = (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), kt = (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;
|
|
@@ -133,8 +133,8 @@ const Ae = 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)
|
|
@@ -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));
|
|
@@ -170,18 +170,18 @@ class Le {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
173
|
-
const i = k(null),
|
|
174
|
-
() => nt(e,
|
|
175
|
-
[e,
|
|
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",
|
|
@@ -194,17 +194,17 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
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
|
);
|
|
@@ -219,29 +219,29 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
219
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__ */ A(Ae.Provider, { value: n, children: /* @__PURE__ */ A(Re.Provider, { value:
|
|
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 Rt = 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 Rt = 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 Rt = 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 Rt = 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 Rt = 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,7 +345,7 @@ const Rt = 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
|
};
|
|
@@ -353,22 +353,22 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
353
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
|
-
|
|
356
|
+
const [c] = B(() => new Le());
|
|
357
|
+
c._updateFrame(s);
|
|
358
|
+
const r = k(c);
|
|
359
|
+
r.current = c;
|
|
360
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
373
|
}, [o, ...n]), ke(() => () => {
|
|
374
374
|
o();
|
|
@@ -381,19 +381,20 @@ const Rt = 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:
|
|
386
|
+
({ ctx: r, clampXPosToChartArea: u, clampYPosToChartArea: l, valToPos: y }) => {
|
|
387
387
|
r.save(), r.beginPath(), _(r, o);
|
|
388
|
-
const
|
|
388
|
+
const d = r.getLineDash();
|
|
389
389
|
o?.lineDash && r.setLineDash(o.lineDash), i !== void 0 && (r.globalAlpha = i);
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
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);
|
|
393
394
|
}
|
|
394
|
-
r.stroke(),
|
|
395
|
+
r.stroke(), d && r.setLineDash(d), r.restore();
|
|
395
396
|
},
|
|
396
|
-
[t, n, s, o, i]
|
|
397
|
+
[t, n, s, o, i, c]
|
|
397
398
|
), null), It = R.memo(st, O), ot = ({
|
|
398
399
|
layer: e = "MIDDLE",
|
|
399
400
|
data: t,
|
|
@@ -401,51 +402,51 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
401
402
|
yScaleId: s,
|
|
402
403
|
xStrategy: o = "clip",
|
|
403
404
|
yStrategy: i = "clip",
|
|
404
|
-
radius:
|
|
405
|
-
style:
|
|
405
|
+
radius: c = 5,
|
|
406
|
+
style: r,
|
|
406
407
|
globalAlpha: u
|
|
407
408
|
}) => (j(
|
|
408
409
|
e,
|
|
409
410
|
({
|
|
410
411
|
ctx: l,
|
|
411
|
-
valToPos:
|
|
412
|
-
valFits:
|
|
412
|
+
valToPos: y,
|
|
413
|
+
valFits: d,
|
|
413
414
|
clampXPosToChartArea: a,
|
|
414
415
|
clampYPosToChartArea: g
|
|
415
416
|
}) => {
|
|
416
|
-
l.save(), _(l,
|
|
417
|
-
const
|
|
418
|
-
for (const
|
|
419
|
-
let
|
|
420
|
-
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);
|
|
421
422
|
if (v === null) continue;
|
|
422
423
|
if (o === "clip") {
|
|
423
|
-
if (!
|
|
424
|
-
|
|
424
|
+
if (!d(p.x, n)) continue;
|
|
425
|
+
f = v;
|
|
425
426
|
} else
|
|
426
|
-
|
|
427
|
-
const
|
|
428
|
-
if (
|
|
427
|
+
f = a(v, "canvas");
|
|
428
|
+
const b = y(p.y, s);
|
|
429
|
+
if (b !== null) {
|
|
429
430
|
if (i === "clip") {
|
|
430
|
-
if (!
|
|
431
|
-
m =
|
|
431
|
+
if (!d(p.y, s)) continue;
|
|
432
|
+
m = b;
|
|
432
433
|
} else
|
|
433
|
-
m = g(
|
|
434
|
-
|
|
434
|
+
m = g(b, "canvas");
|
|
435
|
+
f === null || m === null || h.push({ x: f, y: m });
|
|
435
436
|
}
|
|
436
437
|
}
|
|
437
|
-
if (
|
|
438
|
-
for (const
|
|
439
|
-
l.beginPath(), l.arc(
|
|
440
|
-
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) {
|
|
441
442
|
l.beginPath();
|
|
442
|
-
for (const
|
|
443
|
-
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);
|
|
444
445
|
l.stroke();
|
|
445
446
|
}
|
|
446
447
|
l.restore();
|
|
447
448
|
},
|
|
448
|
-
[t, n, s,
|
|
449
|
+
[t, n, s, c, r, u]
|
|
449
450
|
), null), Lt = R.memo(ot, O), it = ({
|
|
450
451
|
data: e,
|
|
451
452
|
xScaleId: t,
|
|
@@ -453,102 +454,102 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
453
454
|
style: s,
|
|
454
455
|
barWidth: o,
|
|
455
456
|
xPositionOffset: i,
|
|
456
|
-
globalAlpha:
|
|
457
|
-
radius:
|
|
457
|
+
globalAlpha: c,
|
|
458
|
+
radius: r,
|
|
458
459
|
layer: u = "MIDDLE"
|
|
459
460
|
}) => (j(
|
|
460
461
|
u,
|
|
461
462
|
({
|
|
462
463
|
ctx: l,
|
|
463
|
-
valToPxDistance:
|
|
464
|
-
valToPos:
|
|
464
|
+
valToPxDistance: y,
|
|
465
|
+
valToPos: d,
|
|
465
466
|
clampXPosToChartArea: a,
|
|
466
467
|
clampYPosToChartArea: g
|
|
467
468
|
}) => {
|
|
468
469
|
if (e.length === 0) return;
|
|
469
|
-
const
|
|
470
|
-
|
|
470
|
+
const h = g(
|
|
471
|
+
d(0, n, "canvas"),
|
|
471
472
|
"canvas"
|
|
472
473
|
);
|
|
473
|
-
if (
|
|
474
|
+
if (h === null)
|
|
474
475
|
return;
|
|
475
|
-
const
|
|
476
|
+
const p = y(o, t, "canvas") ?? 0, f = [];
|
|
476
477
|
for (const m of e) {
|
|
477
|
-
const v =
|
|
478
|
+
const v = d(m.x, t, "canvas");
|
|
478
479
|
if (v === null)
|
|
479
480
|
continue;
|
|
480
|
-
const
|
|
481
|
-
|
|
481
|
+
const b = v - p / 2 + i * p, T = g(
|
|
482
|
+
d(m.y, n, "canvas"),
|
|
482
483
|
"canvas"
|
|
483
484
|
);
|
|
484
485
|
if (T === null)
|
|
485
486
|
continue;
|
|
486
|
-
const w =
|
|
487
|
-
|
|
488
|
-
x
|
|
487
|
+
const w = h - T, x = a(b, "canvas"), S = a(b + p, "canvas") - x;
|
|
488
|
+
f.push({
|
|
489
|
+
x,
|
|
489
490
|
y: T,
|
|
490
491
|
width: S,
|
|
491
492
|
height: w
|
|
492
493
|
});
|
|
493
494
|
}
|
|
494
|
-
if (l.save(), _(l, s),
|
|
495
|
-
for (const m of
|
|
496
|
-
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();
|
|
497
498
|
if (s?.strokeStyle) {
|
|
498
499
|
l.beginPath();
|
|
499
|
-
for (const m of
|
|
500
|
-
|
|
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);
|
|
501
502
|
l.stroke();
|
|
502
503
|
}
|
|
503
504
|
l.restore();
|
|
504
505
|
},
|
|
505
|
-
[e, t, n, s, o, i,
|
|
506
|
+
[e, t, n, s, o, i, r, c]
|
|
506
507
|
), null), Ut = R.memo(it, O), rt = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o }) => (j(
|
|
507
508
|
e,
|
|
508
|
-
({ ctx: i, clampXPosToChartArea:
|
|
509
|
+
({ ctx: i, clampXPosToChartArea: c, clampYPosToChartArea: r, valToPos: u }) => {
|
|
509
510
|
const l = [];
|
|
510
|
-
for (const
|
|
511
|
-
const a =
|
|
511
|
+
for (const d of t) {
|
|
512
|
+
const a = c(u(d.x, n));
|
|
512
513
|
if (a === null)
|
|
513
514
|
continue;
|
|
514
|
-
const g =
|
|
515
|
+
const g = r(u(d.y[0], s));
|
|
515
516
|
if (g === null)
|
|
516
517
|
continue;
|
|
517
|
-
const
|
|
518
|
-
|
|
518
|
+
const h = r(u(d.y[1], s));
|
|
519
|
+
h !== null && (l.push({ x: a, y: g }), l.unshift({ x: a, y: h }));
|
|
519
520
|
}
|
|
520
|
-
const
|
|
521
|
-
if (
|
|
522
|
-
i.save(), i.beginPath(), _(i, o), i.moveTo(
|
|
523
|
-
for (const
|
|
524
|
-
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);
|
|
525
526
|
i.closePath(), i.fill(), i.restore();
|
|
526
527
|
}
|
|
527
528
|
},
|
|
528
529
|
[t, n, s, o]
|
|
529
530
|
), null), _t = R.memo(rt, O), ct = ({ layer: e = "MIDDLE", data: t, stroked: n, xScaleId: s, yScaleId: o, style: i }) => (j(
|
|
530
531
|
e,
|
|
531
|
-
({ ctx:
|
|
532
|
-
const
|
|
533
|
-
for (const
|
|
534
|
-
const
|
|
535
|
-
|
|
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 });
|
|
536
537
|
}
|
|
537
|
-
const
|
|
538
|
-
if (!
|
|
538
|
+
const d = y.at(0), a = y.at(-1);
|
|
539
|
+
if (!d || !a)
|
|
539
540
|
return;
|
|
540
541
|
const g = u(l(0, o));
|
|
541
542
|
if (g !== null) {
|
|
542
|
-
|
|
543
|
-
for (const
|
|
544
|
-
|
|
545
|
-
if (
|
|
546
|
-
|
|
547
|
-
for (const
|
|
548
|
-
|
|
549
|
-
|
|
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();
|
|
550
551
|
}
|
|
551
|
-
|
|
552
|
+
c.restore();
|
|
552
553
|
}
|
|
553
554
|
},
|
|
554
555
|
[t, n, s, o, i]
|
|
@@ -559,22 +560,22 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
559
560
|
labelStyle: s,
|
|
560
561
|
labelGap: o,
|
|
561
562
|
tickSize: i,
|
|
562
|
-
ticks:
|
|
563
|
+
ticks: c
|
|
563
564
|
}) => (j(
|
|
564
565
|
e,
|
|
565
|
-
({ ctx:
|
|
566
|
-
const
|
|
567
|
-
if (!
|
|
568
|
-
const a =
|
|
569
|
-
|
|
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, {
|
|
570
571
|
...n
|
|
571
|
-
}),
|
|
572
|
-
const
|
|
573
|
-
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) {
|
|
574
575
|
const w = u(T, t, "canvas");
|
|
575
|
-
w !== null && (
|
|
576
|
+
w !== null && (r.moveTo(w, p), r.lineTo(w, m));
|
|
576
577
|
}
|
|
577
|
-
|
|
578
|
+
r.stroke(), r.restore(), r.save(), _(r, {
|
|
578
579
|
textBaseline: a.position === "top" ? "bottom" : "top",
|
|
579
580
|
textAlign: "center",
|
|
580
581
|
...n,
|
|
@@ -582,18 +583,18 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
582
583
|
// alter font size for DPR
|
|
583
584
|
font: _e(s?.font ?? n?.font)
|
|
584
585
|
});
|
|
585
|
-
for (const { value: T, label: w } of
|
|
586
|
-
const
|
|
587
|
-
if (
|
|
586
|
+
for (const { value: T, label: w } of b) {
|
|
587
|
+
const x = u(T, t, "canvas");
|
|
588
|
+
if (x === null)
|
|
588
589
|
continue;
|
|
589
590
|
const S = w.split(`
|
|
590
591
|
`);
|
|
591
592
|
for (let E = 0; E < S.length; E++)
|
|
592
|
-
|
|
593
|
+
r.fillText(S[E], x, m + h * 2 + E * v);
|
|
593
594
|
}
|
|
594
|
-
|
|
595
|
+
r.restore();
|
|
595
596
|
},
|
|
596
|
-
[
|
|
597
|
+
[c, t, n, s]
|
|
597
598
|
), null), Ft = R.memo(at, O), lt = ({
|
|
598
599
|
layer: e = "BOTTOM",
|
|
599
600
|
scaleId: t,
|
|
@@ -601,19 +602,19 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
601
602
|
labelStyle: s,
|
|
602
603
|
labelGap: o,
|
|
603
604
|
tickSize: i,
|
|
604
|
-
ticks:
|
|
605
|
+
ticks: c
|
|
605
606
|
}) => (j(
|
|
606
607
|
e,
|
|
607
|
-
({ ctx:
|
|
608
|
-
const
|
|
609
|
-
if (!
|
|
610
|
-
const a =
|
|
611
|
-
|
|
612
|
-
for (const { value:
|
|
613
|
-
const T = u(
|
|
614
|
-
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));
|
|
615
616
|
}
|
|
616
|
-
|
|
617
|
+
r.stroke(), r.restore(), r.save(), _(r, {
|
|
617
618
|
textBaseline: "middle",
|
|
618
619
|
textAlign: a.position === "left" ? "right" : "left",
|
|
619
620
|
...n,
|
|
@@ -621,18 +622,18 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
621
622
|
// alter font size for DPR
|
|
622
623
|
font: _e(s?.font ?? n?.font)
|
|
623
624
|
});
|
|
624
|
-
for (const { value:
|
|
625
|
-
const w = u(
|
|
625
|
+
for (const { value: b, label: T } of v) {
|
|
626
|
+
const w = u(b, t, "canvas");
|
|
626
627
|
if (w === null)
|
|
627
628
|
continue;
|
|
628
|
-
const
|
|
629
|
+
const x = T.split(`
|
|
629
630
|
`);
|
|
630
|
-
for (let S = 0; S <
|
|
631
|
-
|
|
631
|
+
for (let S = 0; S < x.length; S++)
|
|
632
|
+
r.fillText(` ${x[S]} `, f, w + S * m);
|
|
632
633
|
}
|
|
633
|
-
|
|
634
|
+
r.restore();
|
|
634
635
|
},
|
|
635
|
-
[
|
|
636
|
+
[c, t, n, s]
|
|
636
637
|
), null), Ot = R.memo(lt, O), _e = (e) => {
|
|
637
638
|
if (e)
|
|
638
639
|
try {
|
|
@@ -670,32 +671,32 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
670
671
|
const s = R.useRef(n);
|
|
671
672
|
s.current = n, R.useEffect(() => M[e].addEventListener(
|
|
672
673
|
t,
|
|
673
|
-
(i,
|
|
674
|
-
s.current(
|
|
674
|
+
(i, c) => {
|
|
675
|
+
s.current(c, i);
|
|
675
676
|
}
|
|
676
677
|
), [t, e, s]);
|
|
677
|
-
}, we = R.createContext(""),
|
|
678
|
+
}, we = R.createContext(""), be = (e, t) => {
|
|
678
679
|
const n = R.useContext(we);
|
|
679
680
|
return L(e, n, t);
|
|
680
681
|
}, ut = (e, t, n, s, o) => {
|
|
681
682
|
if (!t) return;
|
|
682
|
-
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 ? {
|
|
683
684
|
scaleId: i,
|
|
684
|
-
value: X(n,
|
|
685
|
-
} : null, l = e.clientY - t.top,
|
|
686
|
-
scaleId:
|
|
687
|
-
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")
|
|
688
689
|
} : null;
|
|
689
|
-
return { pointerSyncPosition: { x: u, y
|
|
690
|
+
return { pointerSyncPosition: { x: u, y }, cssX: r, cssY: l };
|
|
690
691
|
}, N = (e, t) => {
|
|
691
|
-
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;
|
|
692
693
|
return {
|
|
693
694
|
cssX: o,
|
|
694
695
|
cssY: i,
|
|
695
696
|
scaled: Object.fromEntries(
|
|
696
|
-
t.scales.flatMap((
|
|
697
|
-
const
|
|
698
|
-
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")]];
|
|
699
700
|
})
|
|
700
701
|
)
|
|
701
702
|
};
|
|
@@ -714,14 +715,14 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
714
715
|
if (s === null || o === null)
|
|
715
716
|
return null;
|
|
716
717
|
const i = n.scales.flatMap(
|
|
717
|
-
(
|
|
718
|
-
if (
|
|
718
|
+
(c) => {
|
|
719
|
+
if (c.origin !== e)
|
|
719
720
|
return [];
|
|
720
|
-
const
|
|
721
|
-
return
|
|
721
|
+
const r = X(n, s, c.id, "css"), u = X(n, o, c.id, "css");
|
|
722
|
+
return r === null || u === null ? [] : [
|
|
722
723
|
{
|
|
723
|
-
scaleId:
|
|
724
|
-
from:
|
|
724
|
+
scaleId: c.id,
|
|
725
|
+
from: r,
|
|
725
726
|
to: u
|
|
726
727
|
}
|
|
727
728
|
];
|
|
@@ -739,62 +740,62 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
739
740
|
onMouseMove: s,
|
|
740
741
|
onMouseDown: o,
|
|
741
742
|
onMouseUp: i,
|
|
742
|
-
onDocumentMouseUp:
|
|
743
|
-
onSpanSelect:
|
|
743
|
+
onDocumentMouseUp: c,
|
|
744
|
+
onSpanSelect: r,
|
|
744
745
|
onContextMenu: u,
|
|
745
746
|
className: l,
|
|
746
|
-
style:
|
|
747
|
-
sync:
|
|
747
|
+
style: y,
|
|
748
|
+
sync: d,
|
|
748
749
|
innerChildren: a,
|
|
749
750
|
children: g
|
|
750
751
|
}) => {
|
|
751
|
-
const
|
|
752
|
-
return L("dblclick",
|
|
753
|
-
n?.(
|
|
754
|
-
}), L("click",
|
|
755
|
-
t?.(
|
|
756
|
-
}), L("move",
|
|
757
|
-
s?.(
|
|
758
|
-
}), L("mousedown",
|
|
759
|
-
o?.(
|
|
760
|
-
}), L("mouseup",
|
|
761
|
-
i?.(
|
|
762
|
-
}), L("documentmouseup",
|
|
763
|
-
|
|
764
|
-
}), L("spanselect",
|
|
765
|
-
|
|
766
|
-
}), L("contextmenu",
|
|
767
|
-
u?.(
|
|
768
|
-
}), /* @__PURE__ */ pe(we.Provider, { value:
|
|
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: [
|
|
769
770
|
/* @__PURE__ */ A(
|
|
770
771
|
ht,
|
|
771
772
|
{
|
|
772
773
|
id: e,
|
|
773
774
|
className: l,
|
|
774
|
-
style:
|
|
775
|
-
sync:
|
|
775
|
+
style: y,
|
|
776
|
+
sync: d,
|
|
776
777
|
children: a
|
|
777
778
|
}
|
|
778
779
|
),
|
|
779
780
|
g
|
|
780
781
|
] });
|
|
781
782
|
}, ht = ({ id: e, className: t, style: n, sync: s, children: o }) => {
|
|
782
|
-
const i = k(null),
|
|
783
|
-
|
|
784
|
-
const u = G(we), l = s?.key || u,
|
|
785
|
-
const
|
|
786
|
-
if (
|
|
787
|
-
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)
|
|
788
789
|
throw new Error(
|
|
789
790
|
"ChartAreaInteractions must be used within a CanPlot component"
|
|
790
791
|
);
|
|
791
|
-
return
|
|
792
|
+
return f.getBoundingClientRect();
|
|
792
793
|
}
|
|
793
|
-
},
|
|
794
|
+
}, h = (f, m) => {
|
|
794
795
|
const v = ut(
|
|
795
|
-
|
|
796
|
+
f,
|
|
796
797
|
g(),
|
|
797
|
-
|
|
798
|
+
r.current,
|
|
798
799
|
s?.xViaScaleId,
|
|
799
800
|
s?.yViaScaleId
|
|
800
801
|
);
|
|
@@ -802,21 +803,21 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
802
803
|
v.pointerSyncPosition,
|
|
803
804
|
{ cssX: v.cssX, cssY: v.cssY },
|
|
804
805
|
{
|
|
805
|
-
ctrlKey:
|
|
806
|
-
altKey:
|
|
807
|
-
shiftKey:
|
|
808
|
-
metaKey:
|
|
806
|
+
ctrlKey: f.ctrlKey,
|
|
807
|
+
altKey: f.altKey,
|
|
808
|
+
shiftKey: f.shiftKey,
|
|
809
|
+
metaKey: f.metaKey
|
|
809
810
|
}
|
|
810
811
|
);
|
|
811
|
-
},
|
|
812
|
-
return
|
|
813
|
-
const
|
|
814
|
-
const
|
|
815
|
-
|
|
816
|
-
...
|
|
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,
|
|
817
818
|
completed: !0
|
|
818
819
|
}), M.documentmouseup.dispatchEvent(u, {
|
|
819
|
-
frame:
|
|
820
|
+
frame: r.current,
|
|
820
821
|
keys: {
|
|
821
822
|
ctrlKey: w.ctrlKey,
|
|
822
823
|
altKey: w.altKey,
|
|
@@ -825,67 +826,67 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
825
826
|
}
|
|
826
827
|
});
|
|
827
828
|
}, m = (w) => {
|
|
828
|
-
const
|
|
829
|
+
const x = {
|
|
829
830
|
ctrlKey: w.ctrlKey,
|
|
830
831
|
altKey: w.altKey,
|
|
831
832
|
shiftKey: w.shiftKey,
|
|
832
833
|
metaKey: w.metaKey
|
|
833
834
|
}, S = a.current;
|
|
834
|
-
if (S && Object.entries(
|
|
835
|
+
if (S && Object.entries(x).some(
|
|
835
836
|
([C, P]) => S.keys[C] !== P
|
|
836
837
|
)) {
|
|
837
|
-
const C = { ...S, keys:
|
|
838
|
+
const C = { ...S, keys: x };
|
|
838
839
|
a.current = C, M.sync_move.dispatchEvent(l, C);
|
|
839
840
|
}
|
|
840
|
-
const E =
|
|
841
|
-
if (E && Object.entries(
|
|
841
|
+
const E = d.current;
|
|
842
|
+
if (E && Object.entries(x).some(
|
|
842
843
|
([C, P]) => E.keys[C] !== P
|
|
843
844
|
)) {
|
|
844
845
|
w.stopPropagation(), w.preventDefault();
|
|
845
|
-
const C = { ...E, keys:
|
|
846
|
-
|
|
846
|
+
const C = { ...E, keys: x };
|
|
847
|
+
d.current = C, M.spanselect.dispatchEvent(u, C);
|
|
847
848
|
}
|
|
848
849
|
}, v = (w) => {
|
|
849
|
-
|
|
850
|
+
p.current(
|
|
850
851
|
w,
|
|
851
|
-
(
|
|
852
|
-
const P =
|
|
853
|
-
if (!P || !
|
|
854
|
-
const D =
|
|
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);
|
|
855
856
|
if (!ee) return;
|
|
856
|
-
const te = F(D,
|
|
857
|
+
const te = F(D, x.y.scaleId);
|
|
857
858
|
if (!te) return;
|
|
858
|
-
|
|
859
|
+
y.current = {
|
|
859
860
|
xRangeCss: { start: z, end: ae },
|
|
860
861
|
yRangeCss: { start: le, end: ue }
|
|
861
862
|
};
|
|
862
|
-
let
|
|
863
|
+
let W = "below_threshold";
|
|
863
864
|
const he = Math.abs(le - ue), fe = Math.abs(z - ae);
|
|
864
|
-
he < 10 && fe < 10 ?
|
|
865
|
+
he < 10 && fe < 10 ? W = "below_threshold" : he > 30 && fe > 30 ? W = "box" : he > fe ? W = "y" : W = "x";
|
|
865
866
|
const Te = X(
|
|
866
867
|
D,
|
|
867
|
-
V(
|
|
868
|
+
V(r.current, z, "css"),
|
|
868
869
|
ee.id,
|
|
869
870
|
"css"
|
|
870
871
|
);
|
|
871
872
|
if (Te === null) return;
|
|
872
873
|
const Se = X(
|
|
873
874
|
D,
|
|
874
|
-
V(
|
|
875
|
+
V(r.current, ae, "css"),
|
|
875
876
|
ee.id,
|
|
876
877
|
"css"
|
|
877
878
|
);
|
|
878
879
|
if (Se === null) return;
|
|
879
880
|
const Ce = X(
|
|
880
881
|
D,
|
|
881
|
-
|
|
882
|
+
q(r.current, le, "css"),
|
|
882
883
|
te.id,
|
|
883
884
|
"css"
|
|
884
885
|
);
|
|
885
886
|
if (Ce === null) return;
|
|
886
887
|
const Pe = X(
|
|
887
888
|
D,
|
|
888
|
-
|
|
889
|
+
q(r.current, ue, "css"),
|
|
889
890
|
te.id,
|
|
890
891
|
"css"
|
|
891
892
|
);
|
|
@@ -893,14 +894,14 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
893
894
|
const ne = Ee(
|
|
894
895
|
"x",
|
|
895
896
|
{ scaleId: ee.id, from: Te, to: Se },
|
|
896
|
-
|
|
897
|
+
r.current
|
|
897
898
|
), se = Ee(
|
|
898
899
|
"y",
|
|
899
900
|
{ scaleId: te.id, from: Ce, to: Pe },
|
|
900
|
-
|
|
901
|
+
r.current
|
|
901
902
|
), Ke = ne?.scaled, Ye = se?.scaled, Me = {
|
|
902
|
-
mode:
|
|
903
|
-
frame:
|
|
903
|
+
mode: W,
|
|
904
|
+
frame: r.current,
|
|
904
905
|
completed: !1,
|
|
905
906
|
x: {
|
|
906
907
|
css: ne ? {
|
|
@@ -918,17 +919,17 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
918
919
|
},
|
|
919
920
|
keys: C
|
|
920
921
|
};
|
|
921
|
-
|
|
922
|
+
d.current = Me, M.spanselect.dispatchEvent(
|
|
922
923
|
u,
|
|
923
924
|
Me
|
|
924
925
|
);
|
|
925
926
|
}
|
|
926
927
|
);
|
|
927
|
-
},
|
|
928
|
-
|
|
928
|
+
}, b = (w) => {
|
|
929
|
+
p.current(w, (x, S, E) => {
|
|
929
930
|
const C = N(
|
|
930
|
-
|
|
931
|
-
|
|
931
|
+
x,
|
|
932
|
+
r.current
|
|
932
933
|
);
|
|
933
934
|
if (!C) return;
|
|
934
935
|
if (Object.values(E).some((D) => D)) {
|
|
@@ -936,7 +937,7 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
936
937
|
const D = Math.abs(w.deltaY) > Math.abs(w.deltaX) ? w.deltaY : w.deltaX;
|
|
937
938
|
M.pressandwheel.dispatchEvent(u, {
|
|
938
939
|
pointer: C,
|
|
939
|
-
frame:
|
|
940
|
+
frame: r.current,
|
|
940
941
|
keys: E,
|
|
941
942
|
deltaX: w.deltaX,
|
|
942
943
|
deltaY: w.deltaY,
|
|
@@ -945,23 +946,23 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
945
946
|
}
|
|
946
947
|
});
|
|
947
948
|
};
|
|
948
|
-
document.addEventListener("mouseup",
|
|
949
|
+
document.addEventListener("mouseup", f), document.addEventListener("keydown", m), document.addEventListener("keyup", m), document.addEventListener("mousemove", v);
|
|
949
950
|
const T = i.current;
|
|
950
|
-
return T?.addEventListener("wheel",
|
|
951
|
+
return T?.addEventListener("wheel", b, {
|
|
951
952
|
passive: !1
|
|
952
953
|
}), () => {
|
|
953
|
-
document.removeEventListener("mouseup",
|
|
954
|
+
document.removeEventListener("mouseup", f), document.removeEventListener("keydown", m), document.removeEventListener("keyup", m), document.removeEventListener("mousemove", v), T?.removeEventListener("wheel", b);
|
|
954
955
|
};
|
|
955
|
-
}, [
|
|
956
|
-
const m =
|
|
957
|
-
|
|
958
|
-
|
|
956
|
+
}, [r, u, l, p]), L("sync_move", l, (f) => {
|
|
957
|
+
const m = f.positions ? N(
|
|
958
|
+
f.positions,
|
|
959
|
+
r.current
|
|
959
960
|
) : null;
|
|
960
|
-
a.current =
|
|
961
|
-
frame:
|
|
961
|
+
a.current = f, M.move.dispatchEvent(u, {
|
|
962
|
+
frame: r.current,
|
|
962
963
|
pointer: m ?? null,
|
|
963
|
-
keys:
|
|
964
|
-
source:
|
|
964
|
+
keys: f.keys,
|
|
965
|
+
source: f.originInteractionsId === u ? "own" : "sync"
|
|
965
966
|
});
|
|
966
967
|
}), /* @__PURE__ */ A(
|
|
967
968
|
"div",
|
|
@@ -971,114 +972,114 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
971
972
|
className: t,
|
|
972
973
|
style: {
|
|
973
974
|
position: "absolute",
|
|
974
|
-
left:
|
|
975
|
-
top:
|
|
976
|
-
width:
|
|
977
|
-
height:
|
|
975
|
+
left: c.chartAreaCSS.x,
|
|
976
|
+
top: c.chartAreaCSS.y,
|
|
977
|
+
width: c.chartAreaCSS.width,
|
|
978
|
+
height: c.chartAreaCSS.height,
|
|
978
979
|
zIndex: 25,
|
|
979
980
|
...n
|
|
980
981
|
},
|
|
981
|
-
onDragStart: (
|
|
982
|
-
|
|
982
|
+
onDragStart: (f) => {
|
|
983
|
+
f.preventDefault();
|
|
983
984
|
},
|
|
984
|
-
onClick: (
|
|
985
|
-
|
|
985
|
+
onClick: (f) => {
|
|
986
|
+
h(f, (m, v, b) => {
|
|
986
987
|
const T = N(
|
|
987
988
|
m,
|
|
988
|
-
|
|
989
|
+
r.current
|
|
989
990
|
);
|
|
990
991
|
T && M.click.dispatchEvent(u, {
|
|
991
992
|
pointer: T,
|
|
992
|
-
frame:
|
|
993
|
-
keys:
|
|
993
|
+
frame: r.current,
|
|
994
|
+
keys: b
|
|
994
995
|
});
|
|
995
996
|
});
|
|
996
997
|
},
|
|
997
|
-
onMouseLeave: (
|
|
998
|
-
|
|
998
|
+
onMouseLeave: (f) => {
|
|
999
|
+
h(f, (m, v, b) => {
|
|
999
1000
|
M.sync_move.dispatchEvent(l, {
|
|
1000
1001
|
positions: null,
|
|
1001
|
-
keys:
|
|
1002
|
+
keys: b,
|
|
1002
1003
|
originInteractionsId: u
|
|
1003
1004
|
});
|
|
1004
1005
|
});
|
|
1005
1006
|
},
|
|
1006
|
-
onMouseMove: (
|
|
1007
|
-
|
|
1007
|
+
onMouseMove: (f) => {
|
|
1008
|
+
h(f, (m, v, b) => {
|
|
1008
1009
|
M.sync_move.dispatchEvent(l, {
|
|
1009
1010
|
positions: m,
|
|
1010
|
-
keys:
|
|
1011
|
+
keys: b,
|
|
1011
1012
|
originInteractionsId: u
|
|
1012
1013
|
});
|
|
1013
1014
|
});
|
|
1014
1015
|
},
|
|
1015
|
-
onMouseDown: (
|
|
1016
|
-
|
|
1016
|
+
onMouseDown: (f) => {
|
|
1017
|
+
h(f, (m, { cssX: v, cssY: b }, T) => {
|
|
1017
1018
|
const w = N(
|
|
1018
1019
|
m,
|
|
1019
|
-
|
|
1020
|
+
r.current
|
|
1020
1021
|
);
|
|
1021
1022
|
w && (M.mousedown.dispatchEvent(u, {
|
|
1022
1023
|
pointer: w,
|
|
1023
|
-
frame:
|
|
1024
|
+
frame: r.current,
|
|
1024
1025
|
keys: T
|
|
1025
|
-
}),
|
|
1026
|
+
}), y.current = {
|
|
1026
1027
|
xRangeCss: { start: v, end: v },
|
|
1027
|
-
yRangeCss: { start:
|
|
1028
|
+
yRangeCss: { start: b, end: b }
|
|
1028
1029
|
});
|
|
1029
1030
|
});
|
|
1030
1031
|
},
|
|
1031
|
-
onMouseUp: (
|
|
1032
|
-
|
|
1032
|
+
onMouseUp: (f) => {
|
|
1033
|
+
h(f, (m, v, b) => {
|
|
1033
1034
|
const T = N(
|
|
1034
1035
|
m,
|
|
1035
|
-
|
|
1036
|
+
r.current
|
|
1036
1037
|
);
|
|
1037
1038
|
if (!T) return;
|
|
1038
1039
|
M.mouseup.dispatchEvent(u, {
|
|
1039
|
-
frame:
|
|
1040
|
+
frame: r.current,
|
|
1040
1041
|
pointer: T,
|
|
1041
|
-
keys:
|
|
1042
|
+
keys: b
|
|
1042
1043
|
});
|
|
1043
|
-
const w =
|
|
1044
|
-
|
|
1045
|
-
const
|
|
1046
|
-
if (
|
|
1044
|
+
const w = d.current;
|
|
1045
|
+
d.current = null;
|
|
1046
|
+
const x = y.current;
|
|
1047
|
+
if (y.current = null, x && w) {
|
|
1047
1048
|
const S = {
|
|
1048
1049
|
...w,
|
|
1049
|
-
keys:
|
|
1050
|
+
keys: b,
|
|
1050
1051
|
completed: !0
|
|
1051
1052
|
};
|
|
1052
|
-
|
|
1053
|
+
d.current = null, M.spanselect.dispatchEvent(
|
|
1053
1054
|
u,
|
|
1054
1055
|
S
|
|
1055
1056
|
);
|
|
1056
1057
|
}
|
|
1057
1058
|
});
|
|
1058
1059
|
},
|
|
1059
|
-
onContextMenu: (
|
|
1060
|
-
|
|
1060
|
+
onContextMenu: (f) => {
|
|
1061
|
+
f.preventDefault(), h(f, (m, v, b) => {
|
|
1061
1062
|
const T = N(
|
|
1062
1063
|
m,
|
|
1063
|
-
|
|
1064
|
+
r.current
|
|
1064
1065
|
);
|
|
1065
1066
|
T && M.contextmenu.dispatchEvent(u, {
|
|
1066
|
-
frame:
|
|
1067
|
+
frame: r.current,
|
|
1067
1068
|
pointer: T,
|
|
1068
|
-
keys:
|
|
1069
|
+
keys: b
|
|
1069
1070
|
});
|
|
1070
1071
|
});
|
|
1071
1072
|
},
|
|
1072
|
-
onDoubleClick: (
|
|
1073
|
-
|
|
1073
|
+
onDoubleClick: (f) => {
|
|
1074
|
+
h(f, (m, v, b) => {
|
|
1074
1075
|
const T = N(
|
|
1075
1076
|
m,
|
|
1076
|
-
|
|
1077
|
+
r.current
|
|
1077
1078
|
);
|
|
1078
1079
|
T && M.dblclick.dispatchEvent(u, {
|
|
1079
|
-
frame:
|
|
1080
|
+
frame: r.current,
|
|
1080
1081
|
pointer: T,
|
|
1081
|
-
keys:
|
|
1082
|
+
keys: b
|
|
1082
1083
|
});
|
|
1083
1084
|
});
|
|
1084
1085
|
},
|
|
@@ -1087,67 +1088,67 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1087
1088
|
);
|
|
1088
1089
|
}, Yt = ({ data: e, renderTooltip: t, xScaleId: n }) => {
|
|
1089
1090
|
const [s, o] = B(null);
|
|
1090
|
-
|
|
1091
|
-
o(
|
|
1091
|
+
be("move", (c) => {
|
|
1092
|
+
o(c);
|
|
1092
1093
|
});
|
|
1093
1094
|
const i = Q(() => {
|
|
1094
1095
|
if (!s)
|
|
1095
1096
|
return null;
|
|
1096
|
-
const { frame:
|
|
1097
|
-
if (u === void 0 || !F(
|
|
1097
|
+
const { frame: c, pointer: r } = s, u = r?.scaled[n];
|
|
1098
|
+
if (u === void 0 || !F(c, n))
|
|
1098
1099
|
return null;
|
|
1099
|
-
const
|
|
1100
|
-
let
|
|
1100
|
+
const y = [];
|
|
1101
|
+
let d = u;
|
|
1101
1102
|
for (const a of e) {
|
|
1102
|
-
let g = null,
|
|
1103
|
+
let g = null, h = 1 / 0;
|
|
1103
1104
|
for (const [m, v] of a.points.entries()) {
|
|
1104
|
-
if (!de(
|
|
1105
|
+
if (!de(c, v.x, n) || !de(c, v.y, a.yScaleId))
|
|
1105
1106
|
continue;
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1107
|
+
const b = Math.abs(v.x - u);
|
|
1108
|
+
b < h && (h = b, g = m);
|
|
1108
1109
|
}
|
|
1109
|
-
const
|
|
1110
|
-
if (!
|
|
1111
|
-
|
|
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 });
|
|
1112
1113
|
continue;
|
|
1113
1114
|
}
|
|
1114
|
-
|
|
1115
|
+
d = p.x, y.push({
|
|
1115
1116
|
seriesId: a.seriesId,
|
|
1116
|
-
y:
|
|
1117
|
+
y: p.y
|
|
1117
1118
|
});
|
|
1118
1119
|
}
|
|
1119
1120
|
return {
|
|
1120
|
-
frame:
|
|
1121
|
-
x:
|
|
1122
|
-
points:
|
|
1121
|
+
frame: c,
|
|
1122
|
+
x: d,
|
|
1123
|
+
points: y
|
|
1123
1124
|
};
|
|
1124
1125
|
}, [e, s, n]);
|
|
1125
1126
|
return t(i);
|
|
1126
1127
|
}, Bt = ({ makeXStyle: e, makeXClassName: t, makeYStyle: n, makeYClassName: s }) => {
|
|
1127
1128
|
const [o, i] = B(null);
|
|
1128
|
-
if (
|
|
1129
|
+
if (be("move", (a) => {
|
|
1129
1130
|
i(a);
|
|
1130
1131
|
}), !o)
|
|
1131
1132
|
return null;
|
|
1132
|
-
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;
|
|
1133
1134
|
return /* @__PURE__ */ pe(Ne, { children: [
|
|
1134
1135
|
/* @__PURE__ */ A(
|
|
1135
1136
|
"div",
|
|
1136
1137
|
{
|
|
1137
|
-
"data-show": !!
|
|
1138
|
+
"data-show": !!r,
|
|
1138
1139
|
className: t?.(o),
|
|
1139
1140
|
style: {
|
|
1140
1141
|
position: "absolute",
|
|
1141
1142
|
left: 0,
|
|
1142
1143
|
visibility: u === null ? "hidden" : "visible",
|
|
1143
|
-
top:
|
|
1144
|
-
height:
|
|
1144
|
+
top: c.chartAreaCSS.y,
|
|
1145
|
+
height: c.chartAreaCSS.height,
|
|
1145
1146
|
borderColor: "red",
|
|
1146
1147
|
borderLeftWidth: "1px",
|
|
1147
1148
|
borderLeftStyle: "solid",
|
|
1148
1149
|
pointerEvents: "none",
|
|
1149
|
-
opacity:
|
|
1150
|
-
transform: `translateX(${
|
|
1150
|
+
opacity: r ? 1 : 0,
|
|
1151
|
+
transform: `translateX(${y}px)`,
|
|
1151
1152
|
...e?.(o)
|
|
1152
1153
|
}
|
|
1153
1154
|
}
|
|
@@ -1156,18 +1157,18 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1156
1157
|
"div",
|
|
1157
1158
|
{
|
|
1158
1159
|
className: s?.(o),
|
|
1159
|
-
"data-show": !!
|
|
1160
|
+
"data-show": !!r,
|
|
1160
1161
|
style: {
|
|
1161
1162
|
position: "absolute",
|
|
1162
1163
|
visibility: l === null ? "hidden" : "visible",
|
|
1163
1164
|
top: 0,
|
|
1164
1165
|
height: 0,
|
|
1165
1166
|
borderTop: "solid 1px red",
|
|
1166
|
-
left:
|
|
1167
|
-
width:
|
|
1167
|
+
left: c.chartAreaCSS.x,
|
|
1168
|
+
width: c.chartAreaCSS.width,
|
|
1168
1169
|
pointerEvents: "none",
|
|
1169
|
-
opacity:
|
|
1170
|
-
transform: `translateY(${
|
|
1170
|
+
opacity: r ? 1 : 0,
|
|
1171
|
+
transform: `translateY(${d}px)`,
|
|
1171
1172
|
...n?.(o)
|
|
1172
1173
|
}
|
|
1173
1174
|
}
|
|
@@ -1175,7 +1176,7 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1175
1176
|
] });
|
|
1176
1177
|
}, zt = ({ makeClassName: e, makeStyle: t }) => {
|
|
1177
1178
|
const [n, s] = B(null);
|
|
1178
|
-
|
|
1179
|
+
be("spanselect", (i) => {
|
|
1179
1180
|
s(
|
|
1180
1181
|
i.mode === "below_threshold" || i.completed ? null : i
|
|
1181
1182
|
);
|
|
@@ -1183,8 +1184,8 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1183
1184
|
const o = Q(() => {
|
|
1184
1185
|
if (!n || n.mode === "below_threshold")
|
|
1185
1186
|
return null;
|
|
1186
|
-
const i = n.mode === "y" ? -1 / 0 : n.x.css?.from ?? -1 / 0,
|
|
1187
|
-
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 };
|
|
1188
1189
|
}, [n]);
|
|
1189
1190
|
return /* @__PURE__ */ A(
|
|
1190
1191
|
"div",
|
|
@@ -1225,30 +1226,30 @@ const Rt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
|
|
|
1225
1226
|
formatter: t,
|
|
1226
1227
|
acceptableIncrements: n
|
|
1227
1228
|
} = {}) => (s, o) => {
|
|
1228
|
-
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(
|
|
1229
1230
|
o,
|
|
1230
1231
|
l,
|
|
1231
1232
|
s.id,
|
|
1232
1233
|
"canvas"
|
|
1233
1234
|
);
|
|
1234
|
-
if (
|
|
1235
|
+
if (y === null)
|
|
1235
1236
|
return [];
|
|
1236
|
-
const
|
|
1237
|
+
const d = n ?? oe, a = d.find((h) => h > y) ?? d.at(-1) ?? 1;
|
|
1237
1238
|
let g = i;
|
|
1238
1239
|
if (Math.abs(g % a) > Number.EPSILON) {
|
|
1239
|
-
const
|
|
1240
|
-
g +=
|
|
1240
|
+
const h = (a - g % a) % a;
|
|
1241
|
+
g += h;
|
|
1241
1242
|
}
|
|
1242
|
-
for (; g <=
|
|
1243
|
-
|
|
1244
|
-
return (t ?? mt)(
|
|
1243
|
+
for (; g <= c && r.length < 1e3; )
|
|
1244
|
+
r.push(g), g += a;
|
|
1245
|
+
return (t ?? mt)(r);
|
|
1245
1246
|
}, mt = (e) => {
|
|
1246
1247
|
const t = Math.max(0, Math.ceil(-Math.log10(e[1] - e[0])));
|
|
1247
1248
|
return e.map((n) => ({ value: n, label: n.toFixed(t) }));
|
|
1248
1249
|
}, oe = [];
|
|
1249
1250
|
for (let e = -12; e <= 12; e++)
|
|
1250
1251
|
oe.push(1 * 10 ** e), oe.push(2 * 10 ** e), oe.push(5 * 10 ** e);
|
|
1251
|
-
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 = [
|
|
1252
1253
|
// second divisors
|
|
1253
1254
|
[1, "milliseconds"],
|
|
1254
1255
|
[2, "milliseconds"],
|
|
@@ -1308,7 +1309,7 @@ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, J = 60 * be, ce = 24 * J, yt = 30 * c
|
|
|
1308
1309
|
case "seconds":
|
|
1309
1310
|
return t * Oe;
|
|
1310
1311
|
case "minutes":
|
|
1311
|
-
return t *
|
|
1312
|
+
return t * xe;
|
|
1312
1313
|
case "hours":
|
|
1313
1314
|
return t * J;
|
|
1314
1315
|
case "days":
|
|
@@ -1321,10 +1322,10 @@ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, J = 60 * be, ce = 24 * J, yt = 30 * c
|
|
|
1321
1322
|
}, wt = (e, t) => {
|
|
1322
1323
|
const n = new Date(e);
|
|
1323
1324
|
return n.setUTCMilliseconds(n.getUTCMilliseconds() + t), n.getTime();
|
|
1324
|
-
},
|
|
1325
|
+
}, bt = (e, t) => {
|
|
1325
1326
|
const n = new Date(e);
|
|
1326
1327
|
return n.setUTCSeconds(n.getUTCSeconds() + t), n.getTime();
|
|
1327
|
-
},
|
|
1328
|
+
}, xt = (e, t) => {
|
|
1328
1329
|
const n = new Date(e);
|
|
1329
1330
|
return n.setUTCMinutes(n.getUTCMinutes() + t), n.getTime();
|
|
1330
1331
|
}, Tt = (e, t) => {
|
|
@@ -1342,9 +1343,9 @@ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, J = 60 * be, ce = 24 * J, yt = 30 * c
|
|
|
1342
1343
|
case "milliseconds":
|
|
1343
1344
|
return wt(e, n);
|
|
1344
1345
|
case "seconds":
|
|
1345
|
-
return xt(e, n);
|
|
1346
|
-
case "minutes":
|
|
1347
1346
|
return bt(e, n);
|
|
1347
|
+
case "minutes":
|
|
1348
|
+
return xt(e, n);
|
|
1348
1349
|
case "hours":
|
|
1349
1350
|
return Tt(e, n);
|
|
1350
1351
|
case "days":
|
|
@@ -1362,7 +1363,7 @@ function H(e, t) {
|
|
|
1362
1363
|
const Ct = (e, t, n = "UTC") => {
|
|
1363
1364
|
const [s, o] = t;
|
|
1364
1365
|
let i = new Date(e);
|
|
1365
|
-
const
|
|
1366
|
+
const c = () => {
|
|
1366
1367
|
i.setUTCHours(-H(i, n), 0, 0, 0);
|
|
1367
1368
|
};
|
|
1368
1369
|
switch (o) {
|
|
@@ -1379,17 +1380,17 @@ const Ct = (e, t, n = "UTC") => {
|
|
|
1379
1380
|
break;
|
|
1380
1381
|
case "minutes":
|
|
1381
1382
|
i.setUTCMinutes(
|
|
1382
|
-
Math.ceil(i.getTime() % J /
|
|
1383
|
+
Math.ceil(i.getTime() % J / xe / s) * s,
|
|
1383
1384
|
0,
|
|
1384
1385
|
0
|
|
1385
1386
|
);
|
|
1386
1387
|
break;
|
|
1387
1388
|
case "hours": {
|
|
1388
|
-
const
|
|
1389
|
+
const r = H(i, n);
|
|
1389
1390
|
i.setUTCHours(
|
|
1390
1391
|
Math.ceil(
|
|
1391
|
-
(i.getTime() +
|
|
1392
|
-
) * s -
|
|
1392
|
+
(i.getTime() + r * J) % ce / J / s
|
|
1393
|
+
) * s - r,
|
|
1393
1394
|
0,
|
|
1394
1395
|
0,
|
|
1395
1396
|
0
|
|
@@ -1397,7 +1398,7 @@ const Ct = (e, t, n = "UTC") => {
|
|
|
1397
1398
|
break;
|
|
1398
1399
|
}
|
|
1399
1400
|
case "days": {
|
|
1400
|
-
for (
|
|
1401
|
+
for (c(), i.setUTCDate(
|
|
1401
1402
|
1
|
|
1402
1403
|
); i.getTime() < e; )
|
|
1403
1404
|
i = new Date(U(i, [s, o]));
|
|
@@ -1405,7 +1406,7 @@ const Ct = (e, t, n = "UTC") => {
|
|
|
1405
1406
|
}
|
|
1406
1407
|
case "months":
|
|
1407
1408
|
case "years":
|
|
1408
|
-
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])));
|
|
1409
1410
|
break;
|
|
1410
1411
|
}
|
|
1411
1412
|
return i.getTime();
|
|
@@ -1415,42 +1416,42 @@ const Ct = (e, t, n = "UTC") => {
|
|
|
1415
1416
|
formatter: n,
|
|
1416
1417
|
locale: s,
|
|
1417
1418
|
showTimezone: o
|
|
1418
|
-
} = {}) => (i,
|
|
1419
|
-
const { min:
|
|
1420
|
-
if (!Number.isFinite(
|
|
1419
|
+
} = {}) => (i, c) => {
|
|
1420
|
+
const { min: r, max: u } = i;
|
|
1421
|
+
if (!Number.isFinite(r) || !Number.isFinite(u))
|
|
1421
1422
|
return [];
|
|
1422
|
-
const l = Math.floor(
|
|
1423
|
-
(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
|
|
1424
1425
|
) ?? [1, "milliseconds"];
|
|
1425
1426
|
if (!a || !g)
|
|
1426
1427
|
return [];
|
|
1427
|
-
const
|
|
1428
|
+
const h = Ct(r, [a, g], e), p = H(h, e), f = [h];
|
|
1428
1429
|
let m;
|
|
1429
1430
|
for (; ; ) {
|
|
1430
|
-
if (
|
|
1431
|
+
if (f.length > 100)
|
|
1431
1432
|
return [];
|
|
1432
1433
|
switch (g) {
|
|
1433
1434
|
case "milliseconds":
|
|
1434
1435
|
case "seconds":
|
|
1435
1436
|
case "minutes":
|
|
1436
1437
|
case "hours": {
|
|
1437
|
-
const v = U(
|
|
1438
|
-
|
|
1438
|
+
const v = U(h, [
|
|
1439
|
+
f.length * a,
|
|
1439
1440
|
g
|
|
1440
1441
|
]);
|
|
1441
1442
|
m = U(v, [
|
|
1442
|
-
|
|
1443
|
+
p - H(v, e),
|
|
1443
1444
|
"hours"
|
|
1444
1445
|
]);
|
|
1445
1446
|
break;
|
|
1446
1447
|
}
|
|
1447
1448
|
case "days": {
|
|
1448
|
-
const v = U(
|
|
1449
|
-
|
|
1449
|
+
const v = U(h, [
|
|
1450
|
+
f.length * a,
|
|
1450
1451
|
g
|
|
1451
1452
|
]);
|
|
1452
1453
|
m = U(v, [
|
|
1453
|
-
|
|
1454
|
+
p - H(v, e),
|
|
1454
1455
|
"hours"
|
|
1455
1456
|
]);
|
|
1456
1457
|
break;
|
|
@@ -1458,14 +1459,14 @@ const Ct = (e, t, n = "UTC") => {
|
|
|
1458
1459
|
case "months":
|
|
1459
1460
|
case "years": {
|
|
1460
1461
|
const v = U(
|
|
1461
|
-
U(U(
|
|
1462
|
-
|
|
1462
|
+
U(U(h, [p, "hours"]), [
|
|
1463
|
+
f.length * a,
|
|
1463
1464
|
g
|
|
1464
1465
|
]),
|
|
1465
|
-
[-
|
|
1466
|
+
[-p, "hours"]
|
|
1466
1467
|
);
|
|
1467
1468
|
m = U(v, [
|
|
1468
|
-
|
|
1469
|
+
p - H(v, e),
|
|
1469
1470
|
"hours"
|
|
1470
1471
|
]);
|
|
1471
1472
|
break;
|
|
@@ -1473,13 +1474,13 @@ const Ct = (e, t, n = "UTC") => {
|
|
|
1473
1474
|
}
|
|
1474
1475
|
if (m > u)
|
|
1475
1476
|
break;
|
|
1476
|
-
|
|
1477
|
+
f[f.length - 1] !== m && f.push(m);
|
|
1477
1478
|
}
|
|
1478
1479
|
return (n ?? Pt({
|
|
1479
1480
|
locale: s,
|
|
1480
1481
|
showTimezone: o,
|
|
1481
1482
|
timeZone: e
|
|
1482
|
-
}))(
|
|
1483
|
+
}))(f);
|
|
1483
1484
|
}, Y = (e, t, n) => e.find((s) => s.type === n)?.value !== t.find((s) => s.type === n)?.value, Pt = ({
|
|
1484
1485
|
timeZone: e = Fe,
|
|
1485
1486
|
locale: t = dt,
|
|
@@ -1498,30 +1499,30 @@ const Ct = (e, t, n = "UTC") => {
|
|
|
1498
1499
|
timeZone: e
|
|
1499
1500
|
});
|
|
1500
1501
|
return (o) => {
|
|
1501
|
-
const i = o[1] - o[0],
|
|
1502
|
-
return o.map((l) => ({ value: l, label: s.formatToParts(new Date(l)) })).map((l,
|
|
1503
|
-
const a =
|
|
1504
|
-
if (
|
|
1505
|
-
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;
|
|
1506
1507
|
let C = "";
|
|
1507
|
-
if (
|
|
1508
|
+
if (r) {
|
|
1508
1509
|
const P = l.label.find((z) => z.type === "second")?.value, D = l.label.find(
|
|
1509
1510
|
(z) => z.type === "fractionalSecond"
|
|
1510
1511
|
)?.value;
|
|
1511
1512
|
C = `:${P}` + (u ? `.${D}` : "");
|
|
1512
1513
|
}
|
|
1513
1514
|
w.push(
|
|
1514
|
-
`${
|
|
1515
|
+
`${x}:${S}${C}` + (n && m ? ` ${E}` : "")
|
|
1515
1516
|
);
|
|
1516
1517
|
}
|
|
1517
|
-
return (
|
|
1518
|
+
return (h || p) && w.push(
|
|
1518
1519
|
[
|
|
1519
|
-
l.label.find((
|
|
1520
|
-
|
|
1520
|
+
l.label.find((x) => x.type === "month")?.value,
|
|
1521
|
+
h && l.label.find((x) => x.type === "day")?.value
|
|
1521
1522
|
].filter(Boolean).join(" ")
|
|
1522
|
-
), g && w.push(l.label.find((
|
|
1523
|
+
), g && w.push(l.label.find((x) => x.type === "year")?.value), {
|
|
1523
1524
|
value: l.value,
|
|
1524
|
-
label: w.filter((
|
|
1525
|
+
label: w.filter((x) => x).join(`
|
|
1525
1526
|
`)
|
|
1526
1527
|
};
|
|
1527
1528
|
});
|
|
@@ -1546,7 +1547,7 @@ export {
|
|
|
1546
1547
|
_ as applyStyles,
|
|
1547
1548
|
re as clamp,
|
|
1548
1549
|
V as clampXPosToChartArea,
|
|
1549
|
-
|
|
1550
|
+
q as clampYPosToChartArea,
|
|
1550
1551
|
O as deepEqual,
|
|
1551
1552
|
mt as defaultNumericalTicksFormatter,
|
|
1552
1553
|
At as findClosestIndex,
|
|
@@ -1555,11 +1556,11 @@ export {
|
|
|
1555
1556
|
Pt as makeTimeTickFormat,
|
|
1556
1557
|
jt as makeTimeTicks,
|
|
1557
1558
|
X as posToVal,
|
|
1558
|
-
|
|
1559
|
+
qe as pxToValDistance,
|
|
1559
1560
|
kt as sum,
|
|
1560
1561
|
j as useDrawEffect,
|
|
1561
1562
|
Ue as useFrameState,
|
|
1562
|
-
|
|
1563
|
+
be as useInteractionsEvent,
|
|
1563
1564
|
de as valFits,
|
|
1564
1565
|
Z as valToPos,
|
|
1565
1566
|
ge as valToPxDistance
|