@canplot/react 0.1.13 → 0.1.14
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 +3 -3
- package/dist/canplot.cjs.map +1 -1
- package/dist/canplot.mjs +244 -258
- package/dist/canplot.mjs.map +1 -1
- package/dist/interactions/SelectBox.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/canplot.mjs
CHANGED
|
@@ -7,9 +7,9 @@ const j = (t, s, e) => Math.min(Math.max(t, s), e), le = (t) => t.reduce((s, e)
|
|
|
7
7
|
Math.abs(t[o] - s) < Math.abs(t[e] - s) && (e = o);
|
|
8
8
|
return e;
|
|
9
9
|
}, Dt = (t, s, e, o) => {
|
|
10
|
-
const { min: n, max:
|
|
10
|
+
const { min: n, max: i, origin: a } = I(t, e), r = o === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, d = (a === "x" ? r.width : r.height) / (i - n);
|
|
11
11
|
return s / d;
|
|
12
|
-
},
|
|
12
|
+
}, I = (t, s) => {
|
|
13
13
|
const e = t.scales.find((o) => o.id === s);
|
|
14
14
|
if (!e)
|
|
15
15
|
throw new Error(`Scale ${s} not found`);
|
|
@@ -18,11 +18,11 @@ const j = (t, s, e) => Math.min(Math.max(t, s), e), le = (t) => t.reduce((s, e)
|
|
|
18
18
|
const e = window.devicePixelRatio || 1;
|
|
19
19
|
t.lineCap = s?.lineCap ?? "butt", t.lineDashOffset = e * (s?.lineDashOffset ?? 0), t.lineJoin = s?.lineJoin ?? "miter", t.lineWidth = e * (s?.lineWidth ?? 1), t.miterLimit = e * (s?.miterLimit ?? 10), t.strokeStyle = s?.strokeStyle ?? "black", t.fillStyle = s?.fillStyle ?? t.strokeStyle, t.font = s?.font ?? `${10 * e}px sans-serif`, t.textAlign = s?.textAlign ?? "start", t.direction = s?.direction ?? "inherit", t.textBaseline = s?.textBaseline ?? "alphabetic", t.fontKerning = s?.fontKerning ?? "auto";
|
|
20
20
|
}, ut = (t, s, e, o) => {
|
|
21
|
-
const n = o === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, { min:
|
|
21
|
+
const n = o === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, { min: i, max: a, origin: r } = I(t, e), d = (r === "x" ? n.width : n.height) / (a - i);
|
|
22
22
|
return s * d;
|
|
23
23
|
}, H = (t, s, e, o) => {
|
|
24
|
-
const { min: n, origin:
|
|
25
|
-
return
|
|
24
|
+
const { min: n, origin: i } = I(t, e), a = o === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, r = ut(t, s - n, e, o);
|
|
25
|
+
return i === "x" ? j(
|
|
26
26
|
a.x + r,
|
|
27
27
|
a.x - 10 * a.width,
|
|
28
28
|
a.x + 11 * a.width
|
|
@@ -32,7 +32,7 @@ const j = (t, s, e) => Math.min(Math.max(t, s), e), le = (t) => t.reduce((s, e)
|
|
|
32
32
|
a.y + 11 * a.height
|
|
33
33
|
);
|
|
34
34
|
}, de = (t, s, e) => {
|
|
35
|
-
const { min: o, max: n } =
|
|
35
|
+
const { min: o, max: n } = I(t, e);
|
|
36
36
|
return j(s, o, n);
|
|
37
37
|
}, Y = (t, s, e) => {
|
|
38
38
|
const o = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
|
|
@@ -41,12 +41,12 @@ const j = (t, s, e) => Math.min(Math.max(t, s), e), le = (t) => t.reduce((s, e)
|
|
|
41
41
|
const o = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
|
|
42
42
|
return j(s, o.y, o.y + o.height);
|
|
43
43
|
}, rt = (t, s, e) => {
|
|
44
|
-
const { min: o, max: n } =
|
|
44
|
+
const { min: o, max: n } = I(t, e);
|
|
45
45
|
return s >= o && s <= n;
|
|
46
46
|
}, D = (t, s, e, o) => {
|
|
47
|
-
const { min: n, max:
|
|
48
|
-
return n + d * (
|
|
49
|
-
},
|
|
47
|
+
const { min: n, max: i, origin: a } = I(t, e), r = o === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, d = a === "x" ? (s - r.x) / r.width : (r.height - s + r.y) / r.height;
|
|
48
|
+
return n + d * (i - n);
|
|
49
|
+
}, It = (t) => {
|
|
50
50
|
const { ctx: s, scales: e } = t;
|
|
51
51
|
for (const o of e) {
|
|
52
52
|
if (!o.axis) continue;
|
|
@@ -61,16 +61,16 @@ const j = (t, s, e) => Math.min(Math.max(t, s), e), le = (t) => t.reduce((s, e)
|
|
|
61
61
|
if (o.axis.position === "bottom")
|
|
62
62
|
s.beginPath(), s.moveTo(n.x, n.y), s.lineTo(n.x + n.width, n.y), s.stroke();
|
|
63
63
|
else if (o.axis.position === "top") {
|
|
64
|
-
const
|
|
65
|
-
s.beginPath(), s.moveTo(n.x,
|
|
64
|
+
const i = n.y + n.height;
|
|
65
|
+
s.beginPath(), s.moveTo(n.x, i), s.lineTo(n.x + n.width, i), s.stroke();
|
|
66
66
|
}
|
|
67
67
|
} else if (o.axis.position === "left") {
|
|
68
|
-
const
|
|
69
|
-
s.beginPath(), s.moveTo(
|
|
68
|
+
const i = n.x + n.width;
|
|
69
|
+
s.beginPath(), s.moveTo(i, n.y), s.lineTo(i, n.y + n.height), s.stroke();
|
|
70
70
|
} else o.axis.position === "right" && (s.beginPath(), s.moveTo(n.x, n.y), s.lineTo(n.x, n.y + n.height), s.stroke());
|
|
71
71
|
s.restore();
|
|
72
72
|
}
|
|
73
|
-
},
|
|
73
|
+
}, Lt = () => bt((t, s) => {
|
|
74
74
|
const e = () => {
|
|
75
75
|
const o = s()._frame;
|
|
76
76
|
if (!o) throw new Error("No frame set in frame store");
|
|
@@ -82,15 +82,15 @@ const j = (t, s, e) => Math.min(Math.max(t, s), e), le = (t) => t.reduce((s, e)
|
|
|
82
82
|
getCtx: () => e().ctx,
|
|
83
83
|
clampXPosToChartArea: (o, n) => Y(e(), o, n ?? "canvas"),
|
|
84
84
|
clampYPosToChartArea: (o, n) => O(e(), o, n ?? "canvas"),
|
|
85
|
-
valToPos: (o, n,
|
|
86
|
-
valToPxDistance: (o, n,
|
|
85
|
+
valToPos: (o, n, i) => H(e(), o, n, i ?? "canvas"),
|
|
86
|
+
valToPxDistance: (o, n, i) => ut(
|
|
87
87
|
e(),
|
|
88
88
|
o,
|
|
89
89
|
n,
|
|
90
|
-
|
|
90
|
+
i ?? "canvas"
|
|
91
91
|
),
|
|
92
92
|
valFits: (o, n) => rt(e(), o, n),
|
|
93
|
-
getScale: (o) =>
|
|
93
|
+
getScale: (o) => I(e(), o)
|
|
94
94
|
};
|
|
95
95
|
}), Xt = () => bt((t) => ({
|
|
96
96
|
notify: () => {
|
|
@@ -103,8 +103,8 @@ const j = (t, s, e) => Math.min(Math.max(t, s), e), le = (t) => t.reduce((s, e)
|
|
|
103
103
|
throw new Error("useFrame must be used within a CanPlot component");
|
|
104
104
|
const n = U(t);
|
|
105
105
|
n.current = t, N(() => {
|
|
106
|
-
n.current(e.getState()), e.subscribe((
|
|
107
|
-
|
|
106
|
+
n.current(e.getState()), e.subscribe((i) => {
|
|
107
|
+
i._frame && n.current(i);
|
|
108
108
|
});
|
|
109
109
|
}, [e]), wt(() => {
|
|
110
110
|
o.getState().notify();
|
|
@@ -127,8 +127,8 @@ function Ft(t) {
|
|
|
127
127
|
return (s) => {
|
|
128
128
|
const e = [];
|
|
129
129
|
for (const o of t) {
|
|
130
|
-
const n = at(o, s),
|
|
131
|
-
e.push(
|
|
130
|
+
const n = at(o, s), i = typeof n == "function";
|
|
131
|
+
e.push(i ? n : () => at(o, null));
|
|
132
132
|
}
|
|
133
133
|
return () => {
|
|
134
134
|
for (const o of e) o();
|
|
@@ -142,12 +142,12 @@ function at(t, s) {
|
|
|
142
142
|
}
|
|
143
143
|
var zt = parseInt(Rt.split(".")[0], 10) >= 19 ? Ft : Kt;
|
|
144
144
|
const he = At(({ configuration: t, children: s, style: e, className: o }, n) => {
|
|
145
|
-
const
|
|
145
|
+
const i = U(null), a = U(null), r = Ot(a), d = Q(Lt, []), u = Q(Xt, []);
|
|
146
146
|
N(() => {
|
|
147
147
|
d.setState({
|
|
148
|
-
_frame: Bt(t, r,
|
|
148
|
+
_frame: Bt(t, r, i.current)
|
|
149
149
|
});
|
|
150
|
-
}, [t, r,
|
|
150
|
+
}, [t, r, i, d]), N(() => d.subscribe((p) => {
|
|
151
151
|
p._frame && $t(p._frame);
|
|
152
152
|
}), [d]), N(() => {
|
|
153
153
|
let p = !1;
|
|
@@ -175,7 +175,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
175
175
|
/* @__PURE__ */ _(
|
|
176
176
|
"canvas",
|
|
177
177
|
{
|
|
178
|
-
ref:
|
|
178
|
+
ref: i,
|
|
179
179
|
width: r.width * l,
|
|
180
180
|
height: r.height * l,
|
|
181
181
|
style: {
|
|
@@ -202,8 +202,8 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
202
202
|
width: 0,
|
|
203
203
|
height: 0
|
|
204
204
|
}), [o] = V(() => new ResizeObserver((n) => {
|
|
205
|
-
for (const
|
|
206
|
-
const a = Math.round(
|
|
205
|
+
for (const i of n) {
|
|
206
|
+
const a = Math.round(i.contentRect.width), r = Math.round(i.contentRect.height);
|
|
207
207
|
e(
|
|
208
208
|
(d) => d.width !== a || d.height !== r ? { ...d, width: a, height: r } : d
|
|
209
209
|
);
|
|
@@ -211,9 +211,9 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
211
211
|
}));
|
|
212
212
|
return N(() => {
|
|
213
213
|
if (!t.current) return;
|
|
214
|
-
const n = t.current.clientWidth,
|
|
214
|
+
const n = t.current.clientWidth, i = t.current.clientHeight;
|
|
215
215
|
return e(
|
|
216
|
-
(a) => a.width !== n || a.height !==
|
|
216
|
+
(a) => a.width !== n || a.height !== i ? { ...a, width: n, height: i } : a
|
|
217
217
|
), o.observe(t.current, { box: "border-box" }), () => o.disconnect();
|
|
218
218
|
}, [o, t]), s;
|
|
219
219
|
}, Bt = (t, s, e) => {
|
|
@@ -222,22 +222,22 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
222
222
|
const n = window.devicePixelRatio || 1;
|
|
223
223
|
if (s.width === 0 || s.height === 0)
|
|
224
224
|
return null;
|
|
225
|
-
const
|
|
225
|
+
const i = {
|
|
226
226
|
x: t.padding.left,
|
|
227
227
|
y: t.padding.top,
|
|
228
228
|
width: s.width - t.padding.left - t.padding.right,
|
|
229
229
|
height: s.height - t.padding.top - t.padding.bottom
|
|
230
230
|
};
|
|
231
231
|
for (const f of t.scales)
|
|
232
|
-
f.axis && (f.origin === "x" ? (f.axis.position === "bottom" || f.axis.position === "top") && (
|
|
232
|
+
f.axis && (f.origin === "x" ? (f.axis.position === "bottom" || f.axis.position === "top") && (i.height = Math.max(
|
|
233
233
|
0,
|
|
234
|
-
|
|
235
|
-
), f.axis.position === "top" && (
|
|
234
|
+
i.height - f.axis.size
|
|
235
|
+
), f.axis.position === "top" && (i.y += f.axis.size)) : (f.axis.position === "left" || f.axis.position === "right") && (i.width = Math.max(0, i.width - f.axis.size), f.axis.position === "left" && (i.x += f.axis.size)));
|
|
236
236
|
const a = {
|
|
237
|
-
x:
|
|
238
|
-
y:
|
|
239
|
-
width:
|
|
240
|
-
height:
|
|
237
|
+
x: i.x * n,
|
|
238
|
+
y: i.y * n,
|
|
239
|
+
width: i.width * n,
|
|
240
|
+
height: i.height * n
|
|
241
241
|
}, r = [];
|
|
242
242
|
let d = t.padding.left * n, u = o.canvas.width - t.padding.right * n, l = o.canvas.height - t.padding.bottom * n, p = t.padding.top * n;
|
|
243
243
|
for (const f of t.scales) {
|
|
@@ -245,22 +245,22 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
245
245
|
r.push({ ...f, axis: null });
|
|
246
246
|
continue;
|
|
247
247
|
}
|
|
248
|
-
let
|
|
248
|
+
let c;
|
|
249
249
|
if (f.origin === "x")
|
|
250
250
|
switch (f.axis.position) {
|
|
251
251
|
case "bottom":
|
|
252
|
-
l -= f.axis.size * n,
|
|
253
|
-
x:
|
|
252
|
+
l -= f.axis.size * n, c = {
|
|
253
|
+
x: i.x,
|
|
254
254
|
y: l / n,
|
|
255
|
-
width:
|
|
255
|
+
width: i.width,
|
|
256
256
|
height: f.axis.size
|
|
257
257
|
};
|
|
258
258
|
break;
|
|
259
259
|
case "top":
|
|
260
|
-
p += f.axis.size * n,
|
|
261
|
-
x:
|
|
260
|
+
p += f.axis.size * n, c = {
|
|
261
|
+
x: i.x,
|
|
262
262
|
y: p / n - f.axis.size,
|
|
263
|
-
width:
|
|
263
|
+
width: i.width,
|
|
264
264
|
height: f.axis.size
|
|
265
265
|
};
|
|
266
266
|
break;
|
|
@@ -271,19 +271,19 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
271
271
|
else
|
|
272
272
|
switch (f.axis.position) {
|
|
273
273
|
case "left":
|
|
274
|
-
d += f.axis.size * n,
|
|
274
|
+
d += f.axis.size * n, c = {
|
|
275
275
|
x: d / n - f.axis.size,
|
|
276
|
-
y:
|
|
276
|
+
y: i.y,
|
|
277
277
|
width: f.axis.size,
|
|
278
|
-
height:
|
|
278
|
+
height: i.height
|
|
279
279
|
};
|
|
280
280
|
break;
|
|
281
281
|
case "right":
|
|
282
|
-
u -= f.axis.size * n,
|
|
282
|
+
u -= f.axis.size * n, c = {
|
|
283
283
|
x: u / n,
|
|
284
|
-
y:
|
|
284
|
+
y: i.y,
|
|
285
285
|
width: f.axis.size,
|
|
286
|
-
height:
|
|
286
|
+
height: i.height
|
|
287
287
|
};
|
|
288
288
|
break;
|
|
289
289
|
case "top":
|
|
@@ -291,16 +291,16 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
291
291
|
throw new Error("Invalid axis position for y origin");
|
|
292
292
|
}
|
|
293
293
|
const h = {
|
|
294
|
-
x:
|
|
295
|
-
y:
|
|
296
|
-
width:
|
|
297
|
-
height:
|
|
294
|
+
x: c.x * n,
|
|
295
|
+
y: c.y * n,
|
|
296
|
+
width: c.width * n,
|
|
297
|
+
height: c.height * n
|
|
298
298
|
};
|
|
299
299
|
r.push({
|
|
300
300
|
...f,
|
|
301
301
|
axis: {
|
|
302
302
|
...f.axis,
|
|
303
|
-
cssRect:
|
|
303
|
+
cssRect: c,
|
|
304
304
|
canvasRect: h
|
|
305
305
|
}
|
|
306
306
|
});
|
|
@@ -310,24 +310,24 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
310
310
|
dpr: n,
|
|
311
311
|
padding: t.padding,
|
|
312
312
|
scales: r,
|
|
313
|
-
chartAreaCSS:
|
|
313
|
+
chartAreaCSS: i,
|
|
314
314
|
chartAreaCanvasPX: a
|
|
315
315
|
};
|
|
316
316
|
}, $t = (t) => {
|
|
317
|
-
t.ctx.clearRect(0, 0, t.ctx.canvas.width, t.ctx.canvas.height),
|
|
317
|
+
t.ctx.clearRect(0, 0, t.ctx.canvas.width, t.ctx.canvas.height), It(t);
|
|
318
318
|
}, fe = ({ data: t, xScaleId: s, yScaleId: e, style: o }) => (z(
|
|
319
|
-
({ getCtx: n, clampXPosToChartArea:
|
|
319
|
+
({ getCtx: n, clampXPosToChartArea: i, clampYPosToChartArea: a, valToPos: r }) => {
|
|
320
320
|
const d = n();
|
|
321
321
|
d.save(), d.beginPath(), R(d, o);
|
|
322
322
|
for (const u of t) {
|
|
323
|
-
const l =
|
|
323
|
+
const l = i(r(u.x, s)), p = a(r(u.y, e));
|
|
324
324
|
d.lineTo(l, p);
|
|
325
325
|
}
|
|
326
326
|
d.stroke(), d.restore();
|
|
327
327
|
},
|
|
328
328
|
[t, s, e, o]
|
|
329
|
-
), null), me = ({ data: t, xScaleId: s, yScaleId: e, radius: o = 5, style: n }) => (z(({ getCtx:
|
|
330
|
-
const d =
|
|
329
|
+
), null), me = ({ data: t, xScaleId: s, yScaleId: e, radius: o = 5, style: n }) => (z(({ getCtx: i, valToPos: a, valFits: r }) => {
|
|
330
|
+
const d = i();
|
|
331
331
|
d.save(), d.beginPath(), R(d, n);
|
|
332
332
|
for (const u of t) {
|
|
333
333
|
if (!r(u.x, s) || !r(u.y, e))
|
|
@@ -342,7 +342,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
342
342
|
yScaleId: e,
|
|
343
343
|
style: o,
|
|
344
344
|
barWidth: n,
|
|
345
|
-
xPositionOffset:
|
|
345
|
+
xPositionOffset: i,
|
|
346
346
|
radius: a
|
|
347
347
|
}) => (z(
|
|
348
348
|
({
|
|
@@ -357,8 +357,8 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
357
357
|
m.save(), R(m, o);
|
|
358
358
|
const f = d(n, s);
|
|
359
359
|
m.beginPath();
|
|
360
|
-
for (const
|
|
361
|
-
const y = u(
|
|
360
|
+
for (const c of t) {
|
|
361
|
+
const y = u(c.x, s) - f / 2 + i * f, x = p(u(0, e)), w = p(u(c.y, e)), g = x - w, v = l(y), T = l(y + f) - v;
|
|
362
362
|
a ? m.roundRect(
|
|
363
363
|
v,
|
|
364
364
|
w,
|
|
@@ -369,11 +369,11 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
369
369
|
}
|
|
370
370
|
m.closePath(), m.fill(), o?.strokeStyle && m.stroke(), m.restore();
|
|
371
371
|
},
|
|
372
|
-
[t, s, e, o, n,
|
|
373
|
-
), null), ye = ({ data: t, xScaleId: s, yScaleId: e, style: o }) => (z(({ getCtx: n, clampXPosToChartArea:
|
|
372
|
+
[t, s, e, o, n, i, a]
|
|
373
|
+
), null), ye = ({ data: t, xScaleId: s, yScaleId: e, style: o }) => (z(({ getCtx: n, clampXPosToChartArea: i, clampYPosToChartArea: a, valToPos: r }) => {
|
|
374
374
|
const d = [];
|
|
375
375
|
for (const l of t) {
|
|
376
|
-
const p =
|
|
376
|
+
const p = i(r(l.x, s)), m = a(r(l.y[0], e)), f = a(r(l.y[1], e));
|
|
377
377
|
d.push({ x: p, y: m }), d.unshift({ x: p, y: f });
|
|
378
378
|
}
|
|
379
379
|
const u = n();
|
|
@@ -384,10 +384,10 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
384
384
|
u.closePath(), u.fill(), u.restore();
|
|
385
385
|
}
|
|
386
386
|
}, [t, s, e, o]), null), xe = ({ data: t, stroked: s, xScaleId: e, yScaleId: o, style: n }) => (z(
|
|
387
|
-
({ getCtx:
|
|
388
|
-
const u = [], l =
|
|
389
|
-
for (const
|
|
390
|
-
const h = a(d(
|
|
387
|
+
({ getCtx: i, clampXPosToChartArea: a, clampYPosToChartArea: r, valToPos: d }) => {
|
|
388
|
+
const u = [], l = i();
|
|
389
|
+
for (const c of t) {
|
|
390
|
+
const h = a(d(c.x, e)), y = r(d(c.y, o));
|
|
391
391
|
u.push({ x: h, y });
|
|
392
392
|
}
|
|
393
393
|
const p = u.at(0), m = u.at(-1);
|
|
@@ -395,12 +395,12 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
395
395
|
return;
|
|
396
396
|
const f = r(d(0, o));
|
|
397
397
|
l.save(), l.beginPath(), R(l, n), l.moveTo(p.x, f);
|
|
398
|
-
for (const
|
|
399
|
-
l.lineTo(
|
|
398
|
+
for (const c of u)
|
|
399
|
+
l.lineTo(c.x, c.y);
|
|
400
400
|
if (l.lineTo(m.x, f), l.closePath(), l.fill(), s) {
|
|
401
401
|
l.beginPath(), l.moveTo(p.x, p.y);
|
|
402
|
-
for (const
|
|
403
|
-
l.lineTo(
|
|
402
|
+
for (const c of u)
|
|
403
|
+
l.lineTo(c.x, c.y);
|
|
404
404
|
l.stroke();
|
|
405
405
|
}
|
|
406
406
|
l.restore();
|
|
@@ -411,7 +411,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
411
411
|
clampXPosToChartArea: e,
|
|
412
412
|
clampYPosToChartArea: o,
|
|
413
413
|
getScale: n,
|
|
414
|
-
valToPos:
|
|
414
|
+
valToPos: i,
|
|
415
415
|
valFits: a
|
|
416
416
|
}) => {
|
|
417
417
|
const r = {};
|
|
@@ -420,13 +420,13 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
420
420
|
switch (u.exceeding) {
|
|
421
421
|
case "discard": {
|
|
422
422
|
if (a(u.value, u.scaleId)) {
|
|
423
|
-
const l =
|
|
423
|
+
const l = i(u.value, u.scaleId, s);
|
|
424
424
|
r[d] = l;
|
|
425
425
|
}
|
|
426
426
|
break;
|
|
427
427
|
}
|
|
428
428
|
case "clamp": {
|
|
429
|
-
const l =
|
|
429
|
+
const l = i(u.value, u.scaleId, s);
|
|
430
430
|
r[d] = n(u.scaleId)?.origin === "x" ? e(l, s) : o(l, s);
|
|
431
431
|
break;
|
|
432
432
|
}
|
|
@@ -434,15 +434,15 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
434
434
|
}
|
|
435
435
|
return r;
|
|
436
436
|
}
|
|
437
|
-
), ve = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: o, tickSize: n, ticks:
|
|
437
|
+
), ve = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: o, tickSize: n, ticks: i }) => (z(
|
|
438
438
|
({ getCtx: a, valToPos: r, getScale: d, getFrame: u }) => {
|
|
439
439
|
const l = a(), p = d(t);
|
|
440
440
|
if (!p || !p.axis || p.origin !== "x") return;
|
|
441
|
-
const m = p.axis, f = m.position === "top" ? m.canvasRect.y + m.canvasRect.height : m.canvasRect.y,
|
|
441
|
+
const m = p.axis, f = m.position === "top" ? m.canvasRect.y + m.canvasRect.height : m.canvasRect.y, c = window.devicePixelRatio || 1, h = f, y = (n ?? 6) * c, x = m.position === "top" ? f - y : f + y, w = (o ?? 12) * c;
|
|
442
442
|
l.save(), l.fontKerning = "auto", R(l, {
|
|
443
443
|
...s
|
|
444
444
|
}), l.beginPath();
|
|
445
|
-
const g = Array.isArray(
|
|
445
|
+
const g = Array.isArray(i) ? i : i({ ...p, axis: m }, u());
|
|
446
446
|
for (const { value: v } of g) {
|
|
447
447
|
const T = r(v, t, "canvas");
|
|
448
448
|
l.moveTo(T, h), l.lineTo(T, x);
|
|
@@ -457,20 +457,20 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
457
457
|
const b = r(v, t, "canvas"), C = T.split(`
|
|
458
458
|
`);
|
|
459
459
|
for (let k = 0; k < C.length; k++)
|
|
460
|
-
l.fillText(C[k], b, x +
|
|
460
|
+
l.fillText(C[k], b, x + c * 2 + k * w);
|
|
461
461
|
}
|
|
462
462
|
l.restore();
|
|
463
463
|
},
|
|
464
|
-
[
|
|
465
|
-
), null), we = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: o, tickSize: n, ticks:
|
|
464
|
+
[i, t, s, e]
|
|
465
|
+
), null), we = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: o, tickSize: n, ticks: i }) => (z(
|
|
466
466
|
({ getCtx: a, valToPos: r, getScale: d, getFrame: u }) => {
|
|
467
467
|
const l = a(), p = d(t);
|
|
468
468
|
if (!p || !p.axis || p.origin !== "y") return;
|
|
469
|
-
const m = p.axis, f = m.position === "left" ? m.canvasRect.x + m.canvasRect.width : m.canvasRect.x,
|
|
469
|
+
const m = p.axis, f = m.position === "left" ? m.canvasRect.x + m.canvasRect.width : m.canvasRect.x, c = f, h = n ?? 6, y = m.position === "left" ? f - h : f + h, x = o ?? 12, w = Array.isArray(i) ? i : i({ ...p, axis: m }, u());
|
|
470
470
|
l.save(), l.fontKerning = "auto", R(l, { ...s }), l.beginPath();
|
|
471
471
|
for (const { value: g } of w) {
|
|
472
472
|
const v = r(g, t, "canvas");
|
|
473
|
-
l.moveTo(
|
|
473
|
+
l.moveTo(c, v), l.lineTo(y, v);
|
|
474
474
|
}
|
|
475
475
|
l.stroke(), l.restore(), l.save(), R(l, {
|
|
476
476
|
textBaseline: "middle",
|
|
@@ -486,7 +486,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
486
486
|
}
|
|
487
487
|
l.restore();
|
|
488
488
|
},
|
|
489
|
-
[
|
|
489
|
+
[i, t, s, e]
|
|
490
490
|
), null), E = () => {
|
|
491
491
|
const t = [];
|
|
492
492
|
return {
|
|
@@ -524,8 +524,8 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
524
524
|
const o = Z.useRef(e);
|
|
525
525
|
o.current = e, Z.useEffect(() => S[t].addEventListener(
|
|
526
526
|
s,
|
|
527
|
-
(
|
|
528
|
-
o.current(a,
|
|
527
|
+
(i, a) => {
|
|
528
|
+
o.current(a, i);
|
|
529
529
|
}
|
|
530
530
|
), [s, t, o]);
|
|
531
531
|
}, ft = Z.createContext(""), mt = (t, s) => {
|
|
@@ -533,12 +533,12 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
533
533
|
return M(t, e, s);
|
|
534
534
|
}, Nt = (t, s, e, o, n) => {
|
|
535
535
|
if (!s) return;
|
|
536
|
-
const
|
|
537
|
-
if (!
|
|
536
|
+
const i = o ?? e.scales.find((p) => p.origin === "x")?.id, a = n ?? e.scales.find((p) => p.origin === "y")?.id;
|
|
537
|
+
if (!i || !a)
|
|
538
538
|
return;
|
|
539
539
|
const r = t.clientX - s.left, d = {
|
|
540
|
-
scaleId:
|
|
541
|
-
value: D(e, r,
|
|
540
|
+
scaleId: i,
|
|
541
|
+
value: D(e, r, i, "css")
|
|
542
542
|
}, u = t.clientY - s.top, l = {
|
|
543
543
|
scaleId: a,
|
|
544
544
|
value: D(e, u, a, "css")
|
|
@@ -561,8 +561,8 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
561
561
|
cssY: o,
|
|
562
562
|
scaled: Object.fromEntries(
|
|
563
563
|
s.scales.map((n) => {
|
|
564
|
-
const
|
|
565
|
-
return [n.id, D(s,
|
|
564
|
+
const i = n.origin === "y" ? o : e;
|
|
565
|
+
return [n.id, D(s, i, n.id, "css")];
|
|
566
566
|
})
|
|
567
567
|
)
|
|
568
568
|
};
|
|
@@ -577,7 +577,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
577
577
|
s.to,
|
|
578
578
|
s.scaleId,
|
|
579
579
|
"css"
|
|
580
|
-
),
|
|
580
|
+
), i = e.scales.flatMap(
|
|
581
581
|
(a) => {
|
|
582
582
|
if (a.origin !== t)
|
|
583
583
|
return [];
|
|
@@ -594,7 +594,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
594
594
|
return {
|
|
595
595
|
fromCSS: o,
|
|
596
596
|
toCSS: n,
|
|
597
|
-
scaled:
|
|
597
|
+
scaled: i
|
|
598
598
|
};
|
|
599
599
|
}, be = ({
|
|
600
600
|
id: t,
|
|
@@ -602,7 +602,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
602
602
|
onDblClick: e,
|
|
603
603
|
onMouseMove: o,
|
|
604
604
|
onMouseDown: n,
|
|
605
|
-
onMouseUp:
|
|
605
|
+
onMouseUp: i,
|
|
606
606
|
onDocumentMouseUp: a,
|
|
607
607
|
onSpanSelect: r,
|
|
608
608
|
onContextMenu: d,
|
|
@@ -611,24 +611,24 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
611
611
|
sync: p,
|
|
612
612
|
children: m
|
|
613
613
|
}) => {
|
|
614
|
-
const f = Ut(),
|
|
615
|
-
return M("dblclick",
|
|
614
|
+
const f = Ut(), c = t || f;
|
|
615
|
+
return M("dblclick", c, (h) => {
|
|
616
616
|
e?.(h);
|
|
617
|
-
}), M("click",
|
|
617
|
+
}), M("click", c, (h) => {
|
|
618
618
|
s?.(h);
|
|
619
|
-
}), M("move",
|
|
619
|
+
}), M("move", c, (h) => {
|
|
620
620
|
o?.(h);
|
|
621
|
-
}), M("mousedown",
|
|
621
|
+
}), M("mousedown", c, (h) => {
|
|
622
622
|
n?.(h);
|
|
623
|
-
}), M("mouseup",
|
|
624
|
-
|
|
625
|
-
}), M("documentmouseup",
|
|
623
|
+
}), M("mouseup", c, (h) => {
|
|
624
|
+
i?.(h);
|
|
625
|
+
}), M("documentmouseup", c, (h) => {
|
|
626
626
|
a?.(h);
|
|
627
|
-
}), M("spanselect",
|
|
627
|
+
}), M("spanselect", c, (h) => {
|
|
628
628
|
r?.(h);
|
|
629
|
-
}), M("contextmenu",
|
|
629
|
+
}), M("contextmenu", c, (h) => {
|
|
630
630
|
d?.(h);
|
|
631
|
-
}), /* @__PURE__ */ lt(ft.Provider, { value:
|
|
631
|
+
}), /* @__PURE__ */ lt(ft.Provider, { value: c, children: [
|
|
632
632
|
/* @__PURE__ */ _(
|
|
633
633
|
Vt,
|
|
634
634
|
{
|
|
@@ -640,22 +640,22 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
640
640
|
m
|
|
641
641
|
] });
|
|
642
642
|
}, Vt = ({ className: t, style: s, sync: e }) => {
|
|
643
|
-
const o = U(null), n = ht(),
|
|
644
|
-
|
|
643
|
+
const o = U(null), n = ht(), i = U(n);
|
|
644
|
+
i.current = n;
|
|
645
645
|
const a = J(ft), r = e?.key || a, d = U(null), u = U(null), l = U(null), p = () => {
|
|
646
|
-
const
|
|
647
|
-
if (
|
|
648
|
-
if (
|
|
646
|
+
const c = o.current?.parentElement;
|
|
647
|
+
if (c) {
|
|
648
|
+
if (c.dataset.canplotroot === void 0)
|
|
649
649
|
throw new Error(
|
|
650
650
|
"ChartAreaInteractions must be used within a CanPlot component"
|
|
651
651
|
);
|
|
652
|
-
return
|
|
652
|
+
return c.getBoundingClientRect();
|
|
653
653
|
}
|
|
654
|
-
}, m = (
|
|
654
|
+
}, m = (c, h) => {
|
|
655
655
|
const y = Nt(
|
|
656
|
-
|
|
656
|
+
c,
|
|
657
657
|
p(),
|
|
658
|
-
|
|
658
|
+
i.current,
|
|
659
659
|
e?.xViaScaleId,
|
|
660
660
|
e?.yViaScaleId
|
|
661
661
|
);
|
|
@@ -663,21 +663,21 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
663
663
|
y.pointerSyncPosition,
|
|
664
664
|
{ cssX: y.cssX, cssY: y.cssY },
|
|
665
665
|
{
|
|
666
|
-
ctrlKey:
|
|
667
|
-
altKey:
|
|
668
|
-
shiftKey:
|
|
669
|
-
metaKey:
|
|
666
|
+
ctrlKey: c.ctrlKey,
|
|
667
|
+
altKey: c.altKey,
|
|
668
|
+
shiftKey: c.shiftKey,
|
|
669
|
+
metaKey: c.metaKey
|
|
670
670
|
}
|
|
671
671
|
);
|
|
672
672
|
}, f = U(m);
|
|
673
673
|
return f.current = m, wt(() => {
|
|
674
|
-
const
|
|
674
|
+
const c = (g) => {
|
|
675
675
|
const v = u.current;
|
|
676
676
|
v && S.sync_spanselect.dispatchEvent(r, {
|
|
677
677
|
...v,
|
|
678
678
|
completed: !0
|
|
679
679
|
}), S.documentmouseup.dispatchEvent(r, {
|
|
680
|
-
frame:
|
|
680
|
+
frame: i.current,
|
|
681
681
|
keys: {
|
|
682
682
|
ctrlKey: g.ctrlKey,
|
|
683
683
|
altKey: g.altKey,
|
|
@@ -715,25 +715,25 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
715
715
|
(v, { cssX: T, cssY: b }, C) => {
|
|
716
716
|
const k = d.current;
|
|
717
717
|
if (!k || !v.x || !v.y) return;
|
|
718
|
-
const A =
|
|
718
|
+
const A = i.current, P = k.xRangeCss.start, B = T, K = k.yRangeCss.start, st = b, nt = I(A, v.x.scaleId), ot = I(A, v.y.scaleId);
|
|
719
719
|
d.current = {
|
|
720
720
|
xRangeCss: { start: P, end: B },
|
|
721
721
|
yRangeCss: { start: K, end: st }
|
|
722
722
|
};
|
|
723
723
|
let $ = "below_threshold";
|
|
724
|
-
const
|
|
725
|
-
|
|
724
|
+
const it = Math.abs(K - st), ct = Math.abs(P - B);
|
|
725
|
+
it < 10 && ct < 10 ? $ = "below_threshold" : it > 30 && ct > 30 ? $ = "box" : it > ct ? $ = "y" : $ = "x";
|
|
726
726
|
const Mt = {
|
|
727
727
|
scaleId: nt.id,
|
|
728
728
|
from: D(
|
|
729
729
|
A,
|
|
730
|
-
Y(
|
|
730
|
+
Y(i.current, P, "css"),
|
|
731
731
|
nt.id,
|
|
732
732
|
"css"
|
|
733
733
|
),
|
|
734
734
|
to: D(
|
|
735
735
|
A,
|
|
736
|
-
Y(
|
|
736
|
+
Y(i.current, B, "css"),
|
|
737
737
|
nt.id,
|
|
738
738
|
"css"
|
|
739
739
|
)
|
|
@@ -741,13 +741,13 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
741
741
|
scaleId: ot.id,
|
|
742
742
|
from: D(
|
|
743
743
|
A,
|
|
744
|
-
O(
|
|
744
|
+
O(i.current, K, "css"),
|
|
745
745
|
ot.id,
|
|
746
746
|
"css"
|
|
747
747
|
),
|
|
748
748
|
to: D(
|
|
749
749
|
A,
|
|
750
|
-
O(
|
|
750
|
+
O(i.current, st, "css"),
|
|
751
751
|
ot.id,
|
|
752
752
|
"css"
|
|
753
753
|
)
|
|
@@ -779,96 +779,96 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
779
779
|
}
|
|
780
780
|
});
|
|
781
781
|
};
|
|
782
|
-
document.addEventListener("mouseup",
|
|
782
|
+
document.addEventListener("mouseup", c), document.addEventListener("keydown", h), document.addEventListener("keyup", h), document.addEventListener("mousemove", y);
|
|
783
783
|
const w = o.current;
|
|
784
784
|
return w?.addEventListener("wheel", x, {
|
|
785
785
|
passive: !1
|
|
786
786
|
}), () => {
|
|
787
|
-
document.removeEventListener("mouseup",
|
|
787
|
+
document.removeEventListener("mouseup", c), document.removeEventListener("keydown", h), document.removeEventListener("keyup", h), document.removeEventListener("mousemove", y), w?.removeEventListener("wheel", x);
|
|
788
788
|
};
|
|
789
|
-
}, [
|
|
789
|
+
}, [i, r, f]), M("sync_dblclick", r, (c) => {
|
|
790
790
|
const h = F(
|
|
791
|
-
|
|
792
|
-
|
|
791
|
+
c.positions,
|
|
792
|
+
i.current
|
|
793
793
|
);
|
|
794
794
|
h && S.dblclick.dispatchEvent(a, {
|
|
795
|
-
frame:
|
|
795
|
+
frame: i.current,
|
|
796
796
|
pointer: h,
|
|
797
|
-
keys:
|
|
797
|
+
keys: c.keys
|
|
798
798
|
});
|
|
799
|
-
}), M("sync_click", r, (
|
|
799
|
+
}), M("sync_click", r, (c) => {
|
|
800
800
|
const h = F(
|
|
801
|
-
|
|
802
|
-
|
|
801
|
+
c.positions,
|
|
802
|
+
i.current
|
|
803
803
|
);
|
|
804
804
|
h && S.click.dispatchEvent(a, {
|
|
805
|
-
frame:
|
|
805
|
+
frame: i.current,
|
|
806
806
|
pointer: h,
|
|
807
|
-
keys:
|
|
807
|
+
keys: c.keys
|
|
808
808
|
});
|
|
809
|
-
}), M("sync_contextmenu", r, (
|
|
809
|
+
}), M("sync_contextmenu", r, (c) => {
|
|
810
810
|
const h = F(
|
|
811
|
-
|
|
812
|
-
|
|
811
|
+
c.positions,
|
|
812
|
+
i.current
|
|
813
813
|
);
|
|
814
814
|
h && S.contextmenu.dispatchEvent(a, {
|
|
815
|
-
frame:
|
|
815
|
+
frame: i.current,
|
|
816
816
|
pointer: h,
|
|
817
|
-
keys:
|
|
817
|
+
keys: c.keys
|
|
818
818
|
});
|
|
819
|
-
}), M("sync_move", r, (
|
|
820
|
-
const h =
|
|
821
|
-
|
|
822
|
-
|
|
819
|
+
}), M("sync_move", r, (c) => {
|
|
820
|
+
const h = c.positions ? F(
|
|
821
|
+
c.positions,
|
|
822
|
+
i.current
|
|
823
823
|
) : null;
|
|
824
|
-
l.current =
|
|
825
|
-
frame:
|
|
824
|
+
l.current = c, S.move.dispatchEvent(a, {
|
|
825
|
+
frame: i.current,
|
|
826
826
|
pointer: h ?? null,
|
|
827
|
-
keys:
|
|
827
|
+
keys: c.keys
|
|
828
828
|
});
|
|
829
|
-
}), M("sync_mousedown", r, (
|
|
829
|
+
}), M("sync_mousedown", r, (c) => {
|
|
830
830
|
const h = F(
|
|
831
|
-
|
|
832
|
-
|
|
831
|
+
c.positions,
|
|
832
|
+
i.current
|
|
833
833
|
);
|
|
834
834
|
h && S.mousedown.dispatchEvent(a, {
|
|
835
|
-
frame:
|
|
835
|
+
frame: i.current,
|
|
836
836
|
pointer: h,
|
|
837
|
-
keys:
|
|
837
|
+
keys: c.keys
|
|
838
838
|
});
|
|
839
|
-
}), M("sync_mouseup", r, (
|
|
839
|
+
}), M("sync_mouseup", r, (c) => {
|
|
840
840
|
const h = F(
|
|
841
|
-
|
|
842
|
-
|
|
841
|
+
c.positions,
|
|
842
|
+
i.current
|
|
843
843
|
);
|
|
844
844
|
h && S.mouseup.dispatchEvent(a, {
|
|
845
|
-
frame:
|
|
845
|
+
frame: i.current,
|
|
846
846
|
pointer: h,
|
|
847
|
-
keys:
|
|
847
|
+
keys: c.keys
|
|
848
848
|
});
|
|
849
849
|
}), M(
|
|
850
850
|
"sync_pressandwheel",
|
|
851
851
|
r,
|
|
852
|
-
(
|
|
852
|
+
(c) => {
|
|
853
853
|
const h = F(
|
|
854
|
-
|
|
855
|
-
|
|
854
|
+
c.positions,
|
|
855
|
+
i.current
|
|
856
856
|
);
|
|
857
857
|
h && S.pressandwheel.dispatchEvent(a, {
|
|
858
|
-
frame:
|
|
858
|
+
frame: i.current,
|
|
859
859
|
pointer: h,
|
|
860
|
-
keys:
|
|
861
|
-
deltaX:
|
|
862
|
-
deltaY:
|
|
863
|
-
deltaAbs:
|
|
860
|
+
keys: c.keys,
|
|
861
|
+
deltaX: c.deltaX,
|
|
862
|
+
deltaY: c.deltaY,
|
|
863
|
+
deltaAbs: c.deltaAbs
|
|
864
864
|
});
|
|
865
865
|
}
|
|
866
|
-
), M("sync_spanselect", r, (
|
|
867
|
-
const h =
|
|
868
|
-
|
|
869
|
-
mode:
|
|
870
|
-
frame:
|
|
871
|
-
completed:
|
|
866
|
+
), M("sync_spanselect", r, (c) => {
|
|
867
|
+
const h = c.xRange && xt("x", c.xRange, i.current), y = c.yRange && xt("y", c.yRange, i.current), x = h?.scaled, w = y?.scaled;
|
|
868
|
+
c.completed && (d.current = null), S.spanselect.dispatchEvent(a, {
|
|
869
|
+
mode: c.mode,
|
|
870
|
+
frame: i.current,
|
|
871
|
+
completed: c.completed,
|
|
872
872
|
x: {
|
|
873
873
|
css: h && {
|
|
874
874
|
from: h.fromCSS,
|
|
@@ -883,7 +883,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
883
883
|
},
|
|
884
884
|
scaled: w ?? []
|
|
885
885
|
},
|
|
886
|
-
keys:
|
|
886
|
+
keys: c.keys
|
|
887
887
|
});
|
|
888
888
|
}), /* @__PURE__ */ _(
|
|
889
889
|
"div",
|
|
@@ -900,35 +900,35 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
900
900
|
zIndex: 25,
|
|
901
901
|
...s
|
|
902
902
|
},
|
|
903
|
-
onDragStart: (
|
|
904
|
-
|
|
903
|
+
onDragStart: (c) => {
|
|
904
|
+
c.preventDefault();
|
|
905
905
|
},
|
|
906
|
-
onClick: (
|
|
907
|
-
m(
|
|
906
|
+
onClick: (c) => {
|
|
907
|
+
m(c, (h, y, x) => {
|
|
908
908
|
S.sync_click.dispatchEvent(r, {
|
|
909
909
|
positions: h,
|
|
910
910
|
keys: x
|
|
911
911
|
});
|
|
912
912
|
});
|
|
913
913
|
},
|
|
914
|
-
onMouseLeave: (
|
|
915
|
-
m(
|
|
914
|
+
onMouseLeave: (c) => {
|
|
915
|
+
m(c, (h, y, x) => {
|
|
916
916
|
S.sync_move.dispatchEvent(r, {
|
|
917
917
|
positions: null,
|
|
918
918
|
keys: x
|
|
919
919
|
});
|
|
920
920
|
});
|
|
921
921
|
},
|
|
922
|
-
onMouseMove: (
|
|
923
|
-
m(
|
|
922
|
+
onMouseMove: (c) => {
|
|
923
|
+
m(c, (h, y, x) => {
|
|
924
924
|
S.sync_move.dispatchEvent(r, {
|
|
925
925
|
positions: h,
|
|
926
926
|
keys: x
|
|
927
927
|
});
|
|
928
928
|
});
|
|
929
929
|
},
|
|
930
|
-
onMouseDown: (
|
|
931
|
-
m(
|
|
930
|
+
onMouseDown: (c) => {
|
|
931
|
+
m(c, (h, { cssX: y, cssY: x }, w) => {
|
|
932
932
|
S.sync_mousedown.dispatchEvent(r, {
|
|
933
933
|
positions: h,
|
|
934
934
|
keys: w
|
|
@@ -938,8 +938,8 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
938
938
|
};
|
|
939
939
|
});
|
|
940
940
|
},
|
|
941
|
-
onMouseUp: (
|
|
942
|
-
m(
|
|
941
|
+
onMouseUp: (c) => {
|
|
942
|
+
m(c, (h, y, x) => {
|
|
943
943
|
S.sync_mouseup.dispatchEvent(r, {
|
|
944
944
|
positions: h,
|
|
945
945
|
keys: x
|
|
@@ -960,16 +960,16 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
960
960
|
}
|
|
961
961
|
});
|
|
962
962
|
},
|
|
963
|
-
onContextMenu: (
|
|
964
|
-
|
|
963
|
+
onContextMenu: (c) => {
|
|
964
|
+
c.preventDefault(), m(c, (h, y, x) => {
|
|
965
965
|
S.sync_contextmenu.dispatchEvent(r, {
|
|
966
966
|
positions: h,
|
|
967
967
|
keys: x
|
|
968
968
|
});
|
|
969
969
|
});
|
|
970
970
|
},
|
|
971
|
-
onDoubleClick: (
|
|
972
|
-
m(
|
|
971
|
+
onDoubleClick: (c) => {
|
|
972
|
+
m(c, (h, y, x) => {
|
|
973
973
|
S.sync_dblclick.dispatchEvent(r, {
|
|
974
974
|
positions: h,
|
|
975
975
|
keys: x
|
|
@@ -983,7 +983,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
983
983
|
mt("move", (a) => {
|
|
984
984
|
n(a);
|
|
985
985
|
});
|
|
986
|
-
const
|
|
986
|
+
const i = Q(() => {
|
|
987
987
|
if (!o)
|
|
988
988
|
return null;
|
|
989
989
|
const { frame: a, pointer: r } = o, d = r?.scaled[e];
|
|
@@ -999,14 +999,14 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
999
999
|
const x = Math.abs(y.x - d);
|
|
1000
1000
|
x < f && (f = x, m = h);
|
|
1001
1001
|
}
|
|
1002
|
-
const
|
|
1003
|
-
if (!
|
|
1002
|
+
const c = p.points[m ?? -1];
|
|
1003
|
+
if (!c || ut(a, f, e, "css") > 30) {
|
|
1004
1004
|
u.push({ seriesId: p.seriesId, y: null });
|
|
1005
1005
|
continue;
|
|
1006
1006
|
}
|
|
1007
|
-
l =
|
|
1007
|
+
l = c.x, u.push({
|
|
1008
1008
|
seriesId: p.seriesId,
|
|
1009
|
-
y:
|
|
1009
|
+
y: c.y
|
|
1010
1010
|
});
|
|
1011
1011
|
}
|
|
1012
1012
|
return {
|
|
@@ -1015,11 +1015,11 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
1015
1015
|
points: u
|
|
1016
1016
|
};
|
|
1017
1017
|
}, [t, o, e]);
|
|
1018
|
-
return s(
|
|
1018
|
+
return s(i);
|
|
1019
1019
|
}, Ce = ({ makeXStyle: t, makeXClassName: s, makeYStyle: e, makeYClassName: o }) => {
|
|
1020
|
-
const [n,
|
|
1020
|
+
const [n, i] = V(null);
|
|
1021
1021
|
if (mt("move", (l) => {
|
|
1022
|
-
|
|
1022
|
+
i(l);
|
|
1023
1023
|
}), !n)
|
|
1024
1024
|
return null;
|
|
1025
1025
|
const { frame: a, pointer: r } = n, d = Y(a, r?.cssX ?? 0, "css"), u = O(a, r?.cssY ?? 0, "css");
|
|
@@ -1066,30 +1066,16 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
1066
1066
|
] });
|
|
1067
1067
|
}, Te = ({ makeClassName: t, makeStyle: s }) => {
|
|
1068
1068
|
const [e, o] = V(null);
|
|
1069
|
-
mt("spanselect", (
|
|
1070
|
-
o(
|
|
1069
|
+
mt("spanselect", (i) => {
|
|
1070
|
+
o(
|
|
1071
|
+
i.mode === "below_threshold" || i.completed ? null : i
|
|
1072
|
+
);
|
|
1071
1073
|
});
|
|
1072
1074
|
const n = Q(() => {
|
|
1073
1075
|
if (!e || e.mode === "below_threshold")
|
|
1074
1076
|
return null;
|
|
1075
|
-
const
|
|
1076
|
-
|
|
1077
|
-
e.x.css?.from ?? -1 / 0,
|
|
1078
|
-
"css"
|
|
1079
|
-
), a = Y(
|
|
1080
|
-
e.frame,
|
|
1081
|
-
e.x.css?.to ?? 1 / 0,
|
|
1082
|
-
"css"
|
|
1083
|
-
), r = O(
|
|
1084
|
-
e.frame,
|
|
1085
|
-
e.y.css?.from ?? -1 / 0,
|
|
1086
|
-
"css"
|
|
1087
|
-
), d = O(
|
|
1088
|
-
e.frame,
|
|
1089
|
-
e.y.css?.to ?? 1 / 0,
|
|
1090
|
-
"css"
|
|
1091
|
-
), u = Math.min(c, a), l = Math.min(r, d), p = Math.abs(a - c), m = Math.abs(d - r);
|
|
1092
|
-
return { leftPx: u, topPx: l, widthPx: p, heightPx: m };
|
|
1077
|
+
const i = e.mode === "y" ? -1 / 0 : e.x.css?.from ?? -1 / 0, a = e.mode === "y" ? 1 / 0 : e.x.css?.to ?? 1 / 0, r = e.mode === "x" ? -1 / 0 : e.y.css?.from ?? -1 / 0, d = e.mode === "x" ? 1 / 0 : e.y.css?.from ?? 1 / 0, u = Y(e.frame, i, "css"), l = Y(e.frame, a, "css"), p = O(e.frame, r, "css"), m = O(e.frame, d, "css"), f = Math.min(u, l), c = Math.min(p, m), h = Math.abs(l - u), y = Math.abs(m - p);
|
|
1078
|
+
return { leftPx: f, topPx: c, widthPx: h, heightPx: y };
|
|
1093
1079
|
}, [e]);
|
|
1094
1080
|
return /* @__PURE__ */ _(
|
|
1095
1081
|
"div",
|
|
@@ -1108,7 +1094,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
1108
1094
|
}
|
|
1109
1095
|
);
|
|
1110
1096
|
}, ke = ({ style: t, children: s, scaleId: e, ...o }) => {
|
|
1111
|
-
const n = ht((
|
|
1097
|
+
const n = ht((i) => i.getScale(e)?.axis);
|
|
1112
1098
|
return n ? /* @__PURE__ */ _(
|
|
1113
1099
|
"div",
|
|
1114
1100
|
{
|
|
@@ -1130,16 +1116,16 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
|
|
|
1130
1116
|
formatter: s,
|
|
1131
1117
|
acceptableIncrements: e
|
|
1132
1118
|
} = {}) => (o, n) => {
|
|
1133
|
-
const { min:
|
|
1119
|
+
const { min: i, max: a } = o, r = [], d = window.devicePixelRatio || 1, u = (t ?? (o.origin === "x" ? Tt : jt)) * d, l = Dt(
|
|
1134
1120
|
n,
|
|
1135
1121
|
u,
|
|
1136
1122
|
o.id,
|
|
1137
1123
|
"canvas"
|
|
1138
|
-
), p = e ?? W, m = p.find((
|
|
1139
|
-
let f =
|
|
1124
|
+
), p = e ?? W, m = p.find((c) => c > l) ?? p.at(-1) ?? 1;
|
|
1125
|
+
let f = i;
|
|
1140
1126
|
if (Math.abs(f % m) > Number.EPSILON) {
|
|
1141
|
-
const
|
|
1142
|
-
f +=
|
|
1127
|
+
const c = (m - f % m) % m;
|
|
1128
|
+
f += c;
|
|
1143
1129
|
}
|
|
1144
1130
|
for (; f <= a && r.length < 1e3; )
|
|
1145
1131
|
r.push(f), f += m;
|
|
@@ -1263,32 +1249,32 @@ function G(t, s) {
|
|
|
1263
1249
|
}
|
|
1264
1250
|
const oe = (t, s, e = "UTC") => {
|
|
1265
1251
|
const [o, n] = s;
|
|
1266
|
-
let
|
|
1252
|
+
let i = new Date(t);
|
|
1267
1253
|
const a = () => {
|
|
1268
|
-
|
|
1254
|
+
i.setUTCHours(-G(i, e), 0, 0, 0);
|
|
1269
1255
|
};
|
|
1270
1256
|
switch (n) {
|
|
1271
1257
|
case "milliseconds":
|
|
1272
|
-
|
|
1273
|
-
Math.ceil(
|
|
1258
|
+
i.setUTCMilliseconds(
|
|
1259
|
+
Math.ceil(i.getUTCMilliseconds() / o) * o
|
|
1274
1260
|
);
|
|
1275
1261
|
break;
|
|
1276
1262
|
case "seconds":
|
|
1277
|
-
|
|
1278
|
-
Math.ceil(
|
|
1263
|
+
i.setUTCSeconds(
|
|
1264
|
+
Math.ceil(i.getUTCSeconds() / o) * o,
|
|
1279
1265
|
0
|
|
1280
1266
|
);
|
|
1281
1267
|
break;
|
|
1282
1268
|
case "minutes":
|
|
1283
|
-
|
|
1284
|
-
Math.ceil(
|
|
1269
|
+
i.setUTCMinutes(
|
|
1270
|
+
Math.ceil(i.getTime() % tt / pt / o) * o,
|
|
1285
1271
|
0,
|
|
1286
1272
|
0
|
|
1287
1273
|
);
|
|
1288
1274
|
break;
|
|
1289
1275
|
case "hours":
|
|
1290
|
-
|
|
1291
|
-
Math.ceil(
|
|
1276
|
+
i.setUTCHours(
|
|
1277
|
+
Math.ceil(i.getTime() % et / tt / o) * o,
|
|
1292
1278
|
0,
|
|
1293
1279
|
0,
|
|
1294
1280
|
0
|
|
@@ -1297,20 +1283,20 @@ const oe = (t, s, e = "UTC") => {
|
|
|
1297
1283
|
case "days":
|
|
1298
1284
|
case "months":
|
|
1299
1285
|
case "years":
|
|
1300
|
-
n === "months" ?
|
|
1286
|
+
n === "months" ? i.setUTCDate(1) : n === "years" && i.setUTCMonth(0, 1), a(), i.getTime() < t && (i = new Date(X(i, [1, n])));
|
|
1301
1287
|
break;
|
|
1302
1288
|
}
|
|
1303
|
-
return
|
|
1289
|
+
return i.getTime();
|
|
1304
1290
|
}, Me = ({
|
|
1305
1291
|
timeZone: t = kt,
|
|
1306
1292
|
space: s = Tt,
|
|
1307
1293
|
formatter: e,
|
|
1308
1294
|
locale: o,
|
|
1309
1295
|
showTimezone: n
|
|
1310
|
-
} = {}) => (
|
|
1311
|
-
const { min: r, max: d } =
|
|
1296
|
+
} = {}) => (i, a) => {
|
|
1297
|
+
const { min: r, max: d } = i, u = Math.floor(a.chartAreaCanvasPX.width / s) + 1, p = (d - r) / u, [m, f] = Jt.find(
|
|
1312
1298
|
(w) => q(w) >= p
|
|
1313
|
-
) ?? [1, "milliseconds"],
|
|
1299
|
+
) ?? [1, "milliseconds"], c = oe(r, [m, f], t), h = G(c, t), y = [c];
|
|
1314
1300
|
let x;
|
|
1315
1301
|
for (; ; ) {
|
|
1316
1302
|
switch (f) {
|
|
@@ -1318,11 +1304,11 @@ const oe = (t, s, e = "UTC") => {
|
|
|
1318
1304
|
case "seconds":
|
|
1319
1305
|
case "minutes":
|
|
1320
1306
|
case "hours": {
|
|
1321
|
-
x = X(
|
|
1307
|
+
x = X(c, [y.length * m, f]);
|
|
1322
1308
|
break;
|
|
1323
1309
|
}
|
|
1324
1310
|
case "days": {
|
|
1325
|
-
const w = X(
|
|
1311
|
+
const w = X(c, [
|
|
1326
1312
|
y.length * m,
|
|
1327
1313
|
f
|
|
1328
1314
|
]);
|
|
@@ -1335,7 +1321,7 @@ const oe = (t, s, e = "UTC") => {
|
|
|
1335
1321
|
case "months":
|
|
1336
1322
|
case "years": {
|
|
1337
1323
|
const w = X(
|
|
1338
|
-
X(X(
|
|
1324
|
+
X(X(c, [h, "hours"]), [
|
|
1339
1325
|
y.length * m,
|
|
1340
1326
|
f
|
|
1341
1327
|
]),
|
|
@@ -1352,12 +1338,12 @@ const oe = (t, s, e = "UTC") => {
|
|
|
1352
1338
|
break;
|
|
1353
1339
|
y.push(x);
|
|
1354
1340
|
}
|
|
1355
|
-
return (e ??
|
|
1341
|
+
return (e ?? ie({
|
|
1356
1342
|
locale: o,
|
|
1357
1343
|
showTimezone: n,
|
|
1358
1344
|
timeZone: t
|
|
1359
1345
|
}))(y);
|
|
1360
|
-
},
|
|
1346
|
+
}, L = (t, s, e) => t.find((o) => o.type === e)?.value !== s.find((o) => o.type === e)?.value, ie = ({
|
|
1361
1347
|
timeZone: t = kt,
|
|
1362
1348
|
locale: s = Ht,
|
|
1363
1349
|
showTimezone: e = !0
|
|
@@ -1375,9 +1361,9 @@ const oe = (t, s, e = "UTC") => {
|
|
|
1375
1361
|
timeZone: t
|
|
1376
1362
|
});
|
|
1377
1363
|
return (n) => {
|
|
1378
|
-
const
|
|
1364
|
+
const i = n[1] - n[0], a = i < q([1, "days"]), r = i < q([1, "minutes"]), d = i < q([1, "seconds"]);
|
|
1379
1365
|
return n.map((u) => ({ value: u, label: o.formatToParts(new Date(u)) })).map((u, l, p) => {
|
|
1380
|
-
const m = p[l - 1], f = l === 0 ||
|
|
1366
|
+
const m = p[l - 1], f = l === 0 || L(u.label, m.label, "year"), c = l === 0 || L(u.label, m.label, "day"), h = l === 0 || L(u.label, m.label, "month"), y = l === 0 || L(u.label, m.label, "hour"), x = l === 0 || L(u.label, m.label, "timeZoneName"), w = l === 0 || L(u.label, m.label, "minute"), g = l === 0 || L(u.label, m.label, "second"), v = l === 0 || L(u.label, m.label, "fractionalSecond"), T = [];
|
|
1381
1367
|
if (a && (y || w || x || g || v)) {
|
|
1382
1368
|
const b = u.label.find((P) => P.type === "hour")?.value, C = u.label.find((P) => P.type === "minute")?.value, k = u.label.find((P) => P.type === "timeZoneName")?.value;
|
|
1383
1369
|
let A = "";
|
|
@@ -1391,10 +1377,10 @@ const oe = (t, s, e = "UTC") => {
|
|
|
1391
1377
|
`${b}:${C}${A}` + (e && x ? ` ${k}` : "")
|
|
1392
1378
|
);
|
|
1393
1379
|
}
|
|
1394
|
-
return (
|
|
1380
|
+
return (c || h) && T.push(
|
|
1395
1381
|
[
|
|
1396
1382
|
u.label.find((b) => b.type === "month")?.value,
|
|
1397
|
-
|
|
1383
|
+
c && u.label.find((b) => b.type === "day")?.value
|
|
1398
1384
|
].filter(Boolean).join(" ")
|
|
1399
1385
|
), f && T.push(u.label.find((b) => b.type === "year")?.value), {
|
|
1400
1386
|
value: u.value,
|
|
@@ -1425,9 +1411,9 @@ export {
|
|
|
1425
1411
|
O as clampYPosToChartArea,
|
|
1426
1412
|
Wt as defaultNumericalTicksFormatter,
|
|
1427
1413
|
ue as findClosestIndex,
|
|
1428
|
-
|
|
1414
|
+
I as getScale,
|
|
1429
1415
|
Ee as makeLinearTicks,
|
|
1430
|
-
|
|
1416
|
+
ie as makeTimeTickFormat,
|
|
1431
1417
|
Me as makeTimeTicks,
|
|
1432
1418
|
D as posToVal,
|
|
1433
1419
|
Dt as pxToValDistance,
|