@canplot/react 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/canplot.mjs CHANGED
@@ -1,57 +1,57 @@
1
- var Ke = Object.defineProperty;
2
- var Ye = (e, t, n) => t in e ? Ke(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var F = (e, t, n) => Ye(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { jsxs as pe, jsx as R, Fragment as Be } from "react/jsx-runtime";
5
- import D, { version as ze, createContext as ye, forwardRef as Ne, useRef as A, useState as B, useMemo as Z, useLayoutEffect as $, useCallback as $e, useContext as q, useId as je, useEffect as Ve } from "react";
6
- const ie = (e, t, n) => Math.min(Math.max(e, t), n), kt = (e) => e.reduce((t, n) => t + (n ?? 0), 0), At = (e, t) => {
1
+ var Be = Object.defineProperty;
2
+ var ze = (e, t, n) => t in e ? Be(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var F = (e, t, n) => ze(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { jsxs as pe, jsx as R, Fragment as Ne } from "react/jsx-runtime";
5
+ import D, { version as $e, createContext as ye, forwardRef as je, useRef as k, useState as B, useMemo as Z, useLayoutEffect as $, useCallback as Ve, useContext as q, useEffect as ke, useId as He } from "react";
6
+ const re = (e, t, n) => Math.min(Math.max(e, t), n), kt = (e) => e.reduce((t, n) => t + (n ?? 0), 0), Rt = (e, t) => {
7
7
  let n = 0;
8
8
  for (let s = 0; s < e.length; s++)
9
9
  Math.abs(e[s] - t) < Math.abs(e[n] - t) && (n = s);
10
10
  return n;
11
- }, He = (e, t, n, s) => {
11
+ }, We = (e, t, n, s) => {
12
12
  const o = X(e, n);
13
13
  if (!o)
14
14
  return null;
15
- const i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, r = (o.origin === "x" ? i.width : i.height) / (o.max - o.min);
16
- return t / r;
15
+ const r = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, i = (o.origin === "x" ? r.width : r.height) / (o.max - o.min);
16
+ return t / i;
17
17
  }, X = (e, t) => e.scales.find((n) => n.id === t) ?? null, U = (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";
20
20
  }, ge = (e, t, n, s) => {
21
- const o = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, i = X(e, n);
22
- if (!i)
21
+ const o = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, r = X(e, n);
22
+ if (!r)
23
23
  return null;
24
- const r = (i.origin === "x" ? o.width : o.height) / (i.max - i.min);
25
- return t * r;
24
+ const i = (r.origin === "x" ? o.width : o.height) / (r.max - r.min);
25
+ return t * i;
26
26
  }, G = (e, t, n, s) => {
27
27
  const o = X(e, n);
28
28
  if (!o)
29
29
  return null;
30
- const i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, r = ge(
30
+ const r = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, i = ge(
31
31
  e,
32
32
  t - o.min,
33
33
  n,
34
34
  s
35
35
  );
36
- return r === null ? null : o.origin === "x" ? ie(
37
- i.x + r,
38
- i.x - 10 * i.width,
39
- i.x + 11 * i.width
40
- ) : ie(
41
- i.y + i.height - r,
42
- i.y - 10 * i.height,
43
- i.y + 11 * i.height
36
+ return i === null ? null : o.origin === "x" ? re(
37
+ r.x + i,
38
+ r.x - 10 * r.width,
39
+ r.x + 11 * r.width
40
+ ) : re(
41
+ r.y + r.height - i,
42
+ r.y - 10 * r.height,
43
+ r.y + 11 * r.height
44
44
  );
45
45
  }, V = (e, t, n) => {
46
46
  if (t === null)
47
47
  return null;
48
48
  const s = n === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS;
49
- return ie(t, s.x, s.x + s.width);
49
+ return re(t, s.x, s.x + s.width);
50
50
  }, H = (e, t, n) => {
51
51
  if (t === null)
52
52
  return null;
53
53
  const s = n === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS;
54
- return ie(t, s.y, s.y + s.height);
54
+ return re(t, s.y, s.y + s.height);
55
55
  }, fe = (e, t, n) => {
56
56
  if (t === null)
57
57
  return !1;
@@ -61,8 +61,8 @@ const ie = (e, t, n) => Math.min(Math.max(e, t), n), kt = (e) => e.reduce((t, n)
61
61
  const o = X(e, n);
62
62
  if (!o)
63
63
  return null;
64
- const i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, r = o.origin === "x" ? (t - i.x) / i.width : (i.height - t + i.y) / i.height;
65
- return o.min + r * (o.max - o.min);
64
+ const r = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, i = o.origin === "x" ? (t - r.x) / r.width : (r.height - t + r.y) / r.height;
65
+ return o.min + i * (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 ie = (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
- }, We = (e) => {
80
+ }, qe = (e) => {
81
81
  const { ctx: t, scales: n } = e;
82
82
  for (const s of n) {
83
83
  if (!s.axis) continue;
@@ -92,27 +92,27 @@ const ie = (e, t, n) => Math.min(Math.max(e, t), n), kt = (e) => e.reduce((t, n)
92
92
  if (s.axis.position === "bottom")
93
93
  t.beginPath(), t.moveTo(o.x, o.y), t.lineTo(o.x + o.width, o.y), t.stroke();
94
94
  else if (s.axis.position === "top") {
95
- const i = o.y + o.height;
96
- t.beginPath(), t.moveTo(o.x, i), t.lineTo(o.x + o.width, i), t.stroke();
95
+ const r = o.y + o.height;
96
+ t.beginPath(), t.moveTo(o.x, r), t.lineTo(o.x + o.width, r), t.stroke();
97
97
  }
98
98
  } else if (s.axis.position === "left") {
99
- const i = o.x + o.width;
100
- t.beginPath(), t.moveTo(i, o.y), t.lineTo(i, o.y + o.height), t.stroke();
99
+ const r = o.x + o.width;
100
+ t.beginPath(), t.moveTo(r, o.y), t.lineTo(r, o.y + o.height), t.stroke();
101
101
  } else s.axis.position === "right" && (t.beginPath(), t.moveTo(o.x, o.y), t.lineTo(o.x, o.y + o.height), t.stroke());
102
102
  t.restore();
103
103
  }
104
104
  };
105
- function qe(e) {
105
+ function Ge(e) {
106
106
  return (t) => {
107
107
  for (const n of e) me(n, t);
108
108
  };
109
109
  }
110
- function Ge(e) {
110
+ function Ze(e) {
111
111
  return (t) => {
112
112
  const n = [];
113
113
  for (const s of e) {
114
- const o = me(s, t), i = typeof o == "function";
115
- n.push(i ? o : () => me(s, null));
114
+ const o = me(s, t), r = typeof o == "function";
115
+ n.push(r ? o : () => me(s, null));
116
116
  }
117
117
  return () => {
118
118
  for (const s of n) s();
@@ -124,30 +124,30 @@ function me(e, t) {
124
124
  return e(t);
125
125
  e && (e.current = t);
126
126
  }
127
- var Ze = parseInt(ze.split(".")[0], 10) >= 19 ? Ge : qe;
128
- const Ae = ye({
127
+ var Je = parseInt($e.split(".")[0], 10) >= 19 ? Ze : Ge;
128
+ const Re = ye({
129
129
  listeners: [],
130
130
  subscribe: () => () => {
131
131
  },
132
132
  notifyListeners: () => {
133
133
  }
134
- }), Je = () => {
134
+ }), Qe = () => {
135
135
  const e = [];
136
- return { listeners: e, subscribe: (s, o) => (e.push([o, s]), e.sort((i, r) => i[0] - r[0]), () => {
137
- const i = e.findIndex(([, r]) => r === s);
138
- i !== -1 && e.splice(i, 1);
136
+ return { listeners: e, subscribe: (s, o) => (e.push([o, s]), e.sort((r, i) => r[0] - i[0]), () => {
137
+ const r = e.findIndex(([, i]) => i === s);
138
+ r !== -1 && e.splice(r, 1);
139
139
  }), notifyListeners: () => {
140
140
  for (const [, s] of e)
141
141
  s();
142
142
  } };
143
- }, ve = ye(null), Re = ye(() => {
144
- }), De = {
143
+ }, ve = ye(null), De = ye(() => {
144
+ }), Ie = {
145
145
  TOP: 400,
146
146
  MIDDLE: 300,
147
147
  BOTTOM: 200,
148
148
  BACKGROUND: 100
149
149
  };
150
- class Ie {
150
+ class Le {
151
151
  constructor() {
152
152
  F(this, "_frame", null);
153
153
  F(this, "clampXPosToChartArea", (t, n = "canvas") => V(this.frame, t, n));
@@ -169,19 +169,19 @@ class Ie {
169
169
  return this.frame.ctx;
170
170
  }
171
171
  }
172
- const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) => {
173
- const i = A(null), r = A(null), c = et(r), [l, u] = B(null), f = Z(
174
- () => tt(e, c, l),
172
+ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) => {
173
+ const r = k(null), i = k(null), c = tt(i), [l, u] = B(null), f = Z(
174
+ () => nt(e, c, l),
175
175
  [e, c, l]
176
176
  );
177
177
  $(() => {
178
- u(i.current?.getContext("2d") || null);
179
- }, [i]);
178
+ u(r.current?.getContext("2d") || null);
179
+ }, [r]);
180
180
  const m = window.devicePixelRatio || 1;
181
181
  return /* @__PURE__ */ pe(
182
182
  "div",
183
183
  {
184
- ref: Ze([o, r]),
184
+ ref: Je([o, i]),
185
185
  className: s,
186
186
  style: {
187
187
  position: "relative",
@@ -193,7 +193,7 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
193
193
  /* @__PURE__ */ R(
194
194
  "canvas",
195
195
  {
196
- ref: i,
196
+ ref: r,
197
197
  width: c.width * m,
198
198
  height: c.height * m,
199
199
  style: {
@@ -204,23 +204,23 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
204
204
  }
205
205
  }
206
206
  ),
207
- f && /* @__PURE__ */ R(Qe, { frame: f, children: t })
207
+ f && /* @__PURE__ */ R(et, { frame: f, children: t })
208
208
  ]
209
209
  }
210
210
  );
211
- }), Qe = ({
211
+ }), et = ({
212
212
  frame: e,
213
213
  children: t
214
214
  }) => {
215
- const n = Z(Je, []), [s, o] = B(0);
215
+ const n = Z(Qe, []), [s, o] = B(0);
216
216
  $(() => {
217
217
  e?.ctx.clearRect(0, 0, e.ctx.canvas.width, e.ctx.canvas.height);
218
218
  }, [e, s]);
219
- const i = A(null);
220
- i.current = e, $(() => {
219
+ const r = k(null);
220
+ r.current = e, $(() => {
221
221
  n.subscribe(() => {
222
- i.current && We(i.current);
223
- }, De.BOTTOM);
222
+ r.current && qe(r.current);
223
+ }, Ie.BOTTOM);
224
224
  }, [n]), $(() => {
225
225
  let c = null;
226
226
  return c = window.requestAnimationFrame(() => {
@@ -229,30 +229,30 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
229
229
  c && cancelAnimationFrame(c);
230
230
  };
231
231
  }, [s, e, n]);
232
- const r = $e(() => {
232
+ const i = Ve(() => {
233
233
  o((c) => c + 1);
234
234
  }, [o]);
235
- return /* @__PURE__ */ R(Ae.Provider, { value: n, children: /* @__PURE__ */ R(Re.Provider, { value: r, children: /* @__PURE__ */ R(ve.Provider, { value: e, children: t }) }) });
236
- }, et = (e) => {
235
+ return /* @__PURE__ */ R(Re.Provider, { value: n, children: /* @__PURE__ */ R(De.Provider, { value: i, children: /* @__PURE__ */ R(ve.Provider, { value: e, children: t }) }) });
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
- for (const i of o) {
242
- const r = Math.round(i.contentRect.width), c = Math.round(i.contentRect.height);
241
+ for (const r of o) {
242
+ const i = Math.round(r.contentRect.width), c = Math.round(r.contentRect.height);
243
243
  n(
244
- (l) => l.width !== r || l.height !== c ? { ...l, width: r, height: c } : l
244
+ (l) => l.width !== i || l.height !== c ? { ...l, width: i, height: c } : l
245
245
  );
246
246
  }
247
247
  }));
248
248
  return $(() => {
249
249
  if (!e.current) return;
250
- const o = e.current.clientWidth, i = e.current.clientHeight;
250
+ const o = e.current.clientWidth, r = e.current.clientHeight;
251
251
  return n(
252
- (r) => r.width !== o || r.height !== i ? { ...r, width: o, height: i } : r
252
+ (i) => i.width !== o || i.height !== r ? { ...i, width: o, height: r } : i
253
253
  ), s.observe(e.current, { box: "border-box" }), () => s.disconnect();
254
254
  }, [s, e]), t;
255
- }, tt = (e, t, n) => {
255
+ }, nt = (e, t, n) => {
256
256
  if (!n)
257
257
  return null;
258
258
  const s = window.devicePixelRatio || 1;
@@ -269,16 +269,16 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
269
269
  0,
270
270
  o.height - a.axis.size
271
271
  ), a.axis.position === "top" && (o.y += a.axis.size)) : (a.axis.position === "left" || a.axis.position === "right") && (o.width = Math.max(0, o.width - a.axis.size), a.axis.position === "left" && (o.x += a.axis.size)));
272
- const i = {
272
+ const r = {
273
273
  x: o.x * s,
274
274
  y: o.y * s,
275
275
  width: o.width * s,
276
276
  height: o.height * s
277
- }, r = [];
277
+ }, i = [];
278
278
  let c = e.padding.left * s, l = t.width * s - e.padding.right * s, u = t.height * s - e.padding.bottom * s, f = e.padding.top * s;
279
279
  for (const a of e.scales) {
280
280
  if (!a.axis) {
281
- r.push({ ...a, axis: null });
281
+ i.push({ ...a, axis: null });
282
282
  continue;
283
283
  }
284
284
  let p;
@@ -332,7 +332,7 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
332
332
  width: p.width * s,
333
333
  height: p.height * s
334
334
  };
335
- r.push({
335
+ i.push({
336
336
  ...a,
337
337
  axis: {
338
338
  ...a.axis,
@@ -345,54 +345,61 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
345
345
  ctx: n,
346
346
  dpr: s,
347
347
  padding: e.padding,
348
- scales: r,
348
+ scales: i,
349
349
  chartAreaCSS: o,
350
- chartAreaCanvasPX: i
350
+ chartAreaCanvasPX: r
351
351
  };
352
352
  }, j = (e, t, n) => {
353
- const s = q(ve), o = q(Re), i = q(Ae);
353
+ const s = q(ve), o = q(De), r = q(Re);
354
354
  if (!s || !o)
355
355
  throw new Error("useFrame must be used within a CanPlot component");
356
- const [r] = B(() => new Ie());
357
- r._updateFrame(s);
358
- const c = A(r);
359
- c.current = r;
360
- const l = A(t);
361
- l.current = t, $(() => i.subscribe(
362
- () => {
363
- l.current(r);
364
- },
365
- typeof e == "number" ? e : De[e]
366
- ), [i, e, r]), $(() => {
356
+ const [i] = B(() => new Le());
357
+ i._updateFrame(s);
358
+ const c = k(i);
359
+ c.current = i;
360
+ const l = k(t);
361
+ l.current = t, $(() => {
362
+ const u = r.subscribe(
363
+ () => {
364
+ l.current(i);
365
+ },
366
+ typeof e == "number" ? e : Ie[e]
367
+ );
368
+ return () => {
369
+ u();
370
+ };
371
+ }, [r, e, i]), $(() => {
367
372
  o();
368
- }, [o, ...n]);
369
- }, Le = () => {
373
+ }, [o, ...n]), ke(() => () => {
374
+ o();
375
+ }, [o]);
376
+ }, Ue = () => {
370
377
  const e = q(ve);
371
378
  if (!e)
372
379
  throw new Error("useFrame must be used within a CanPlot component");
373
380
  return Z(() => {
374
- const t = new Ie();
381
+ const t = new Le();
375
382
  return t._updateFrame(e), t;
376
383
  }, [e]);
377
- }, nt = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o }) => (j(
384
+ }, st = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o }) => (j(
378
385
  e,
379
- ({ ctx: i, clampXPosToChartArea: r, clampYPosToChartArea: c, valToPos: l }) => {
380
- i.save(), i.beginPath(), U(i, o);
386
+ ({ ctx: r, clampXPosToChartArea: i, clampYPosToChartArea: c, valToPos: l }) => {
387
+ r.save(), r.beginPath(), U(r, o);
381
388
  for (const u of t) {
382
- const f = r(l(u.x, n, "canvas")), m = c(l(u.y, s, "canvas"));
383
- f === null || m === null || i.lineTo(f, m);
389
+ const f = i(l(u.x, n, "canvas")), m = c(l(u.y, s, "canvas"));
390
+ f === null || m === null || r.lineTo(f, m);
384
391
  }
385
- i.stroke(), i.restore();
392
+ r.stroke(), r.restore();
386
393
  },
387
394
  [t, n, s, o]
388
- ), null), Dt = D.memo(nt, O), st = ({
395
+ ), null), It = D.memo(st, O), ot = ({
389
396
  layer: e = "MIDDLE",
390
397
  data: t,
391
398
  xScaleId: n,
392
399
  yScaleId: s,
393
400
  xStrategy: o = "clip",
394
- yStrategy: i = "clip",
395
- radius: r = 5,
401
+ yStrategy: r = "clip",
402
+ radius: i = 5,
396
403
  style: c,
397
404
  globalAlpha: l
398
405
  }) => (j(
@@ -422,7 +429,7 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
422
429
  break;
423
430
  }
424
431
  }
425
- switch (i) {
432
+ switch (r) {
426
433
  case "clip":
427
434
  if (!m(y.y, s))
428
435
  continue;
@@ -432,19 +439,19 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
432
439
  g = p(f(y.y, s), "canvas");
433
440
  break;
434
441
  }
435
- d === null || g === null || (h.moveTo(d + r, g), h.arc(d, g, r, 0, Math.PI * 2));
442
+ d === null || g === null || (h.moveTo(d + i, g), h.arc(d, g, i, 0, Math.PI * 2));
436
443
  }
437
444
  u.fill(h), u.stroke(h), u.restore();
438
445
  },
439
- [t, n, s, r, c, l]
440
- ), null), It = D.memo(st, O), ot = ({
446
+ [t, n, s, i, c, l]
447
+ ), null), Lt = D.memo(ot, O), rt = ({
441
448
  data: e,
442
449
  xScaleId: t,
443
450
  yScaleId: n,
444
451
  style: s,
445
452
  barWidth: o,
446
- xPositionOffset: i,
447
- radius: r,
453
+ xPositionOffset: r,
454
+ radius: i,
448
455
  layer: c = "MIDDLE"
449
456
  }) => (j(
450
457
  c,
@@ -463,7 +470,7 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
463
470
  const y = f(h.x, t);
464
471
  if (y === null)
465
472
  continue;
466
- const d = y - p / 2 + i * p, g = a(
473
+ const d = y - p / 2 + r * p, g = a(
467
474
  f(0, n, "canvas"),
468
475
  "canvas"
469
476
  );
@@ -476,23 +483,23 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
476
483
  if (w === null)
477
484
  continue;
478
485
  const x = g - w, b = m(d, "canvas"), v = m(d + p, "canvas") - b;
479
- r ? l.roundRect(
486
+ i ? l.roundRect(
480
487
  b,
481
488
  w,
482
489
  v,
483
490
  x,
484
- r
491
+ i
485
492
  ) : l.rect(b, w, v, x);
486
493
  }
487
494
  l.closePath(), l.fill(), s?.strokeStyle && l.stroke(), l.restore();
488
495
  },
489
- [e, t, n, s, o, i, r]
490
- ), null), Lt = D.memo(ot, O), it = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o }) => (j(
496
+ [e, t, n, s, o, r, i]
497
+ ), null), Ut = D.memo(rt, O), it = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o }) => (j(
491
498
  e,
492
- ({ ctx: i, clampXPosToChartArea: r, clampYPosToChartArea: c, valToPos: l }) => {
499
+ ({ ctx: r, clampXPosToChartArea: i, clampYPosToChartArea: c, valToPos: l }) => {
493
500
  const u = [];
494
501
  for (const m of t) {
495
- const a = r(l(m.x, n));
502
+ const a = i(l(m.x, n));
496
503
  if (a === null)
497
504
  continue;
498
505
  const p = c(l(m.y[0], s));
@@ -503,16 +510,16 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
503
510
  }
504
511
  const f = u[0];
505
512
  if (f) {
506
- i.save(), i.beginPath(), U(i, o), i.moveTo(f.x, f.y);
513
+ r.save(), r.beginPath(), U(r, o), r.moveTo(f.x, f.y);
507
514
  for (const m of u)
508
- i.lineTo(m.x, m.y);
509
- i.closePath(), i.fill(), i.restore();
515
+ r.lineTo(m.x, m.y);
516
+ r.closePath(), r.fill(), r.restore();
510
517
  }
511
518
  },
512
519
  [t, n, s, o]
513
- ), null), Ut = D.memo(it, O), rt = ({ layer: e = "MIDDLE", data: t, stroked: n, xScaleId: s, yScaleId: o, style: i }) => (j(
520
+ ), null), _t = D.memo(it, O), ct = ({ layer: e = "MIDDLE", data: t, stroked: n, xScaleId: s, yScaleId: o, style: r }) => (j(
514
521
  e,
515
- ({ ctx: r, clampXPosToChartArea: c, clampYPosToChartArea: l, valToPos: u }) => {
522
+ ({ ctx: i, clampXPosToChartArea: c, clampYPosToChartArea: l, valToPos: u }) => {
516
523
  const f = [];
517
524
  for (const h of t) {
518
525
  const y = c(u(h.x, s)), d = l(u(h.y, o));
@@ -523,37 +530,37 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
523
530
  return;
524
531
  const p = l(u(0, o));
525
532
  if (p !== null) {
526
- r.save(), r.beginPath(), U(r, i), r.moveTo(m.x, p);
533
+ i.save(), i.beginPath(), U(i, r), i.moveTo(m.x, p);
527
534
  for (const h of f)
528
- r.lineTo(h.x, h.y);
529
- if (r.lineTo(a.x, p), r.closePath(), r.fill(), n) {
530
- r.beginPath(), r.moveTo(m.x, m.y);
535
+ i.lineTo(h.x, h.y);
536
+ if (i.lineTo(a.x, p), i.closePath(), i.fill(), n) {
537
+ i.beginPath(), i.moveTo(m.x, m.y);
531
538
  for (const h of f)
532
- r.lineTo(h.x, h.y);
533
- r.stroke();
539
+ i.lineTo(h.x, h.y);
540
+ i.stroke();
534
541
  }
535
- r.restore();
542
+ i.restore();
536
543
  }
537
544
  },
538
- [t, n, s, o, i]
539
- ), null), _t = D.memo(rt, O), ct = ({
545
+ [t, n, s, o, r]
546
+ ), null), Xt = D.memo(ct, O), at = ({
540
547
  layer: e = "BOTTOM",
541
548
  scaleId: t,
542
549
  tickStyle: n,
543
550
  labelStyle: s,
544
551
  labelGap: o,
545
- tickSize: i,
546
- ticks: r
552
+ tickSize: r,
553
+ ticks: i
547
554
  }) => (j(
548
555
  e,
549
556
  ({ ctx: c, valToPos: l, getScale: u, frame: f }) => {
550
557
  const m = u(t);
551
558
  if (!m || !m.axis || m.origin !== "x") return;
552
- const a = m.axis, p = a.position === "top" ? a.canvasRect.y + a.canvasRect.height : a.canvasRect.y, h = window.devicePixelRatio || 1, y = p, d = (i ?? 6) * h, g = a.position === "top" ? p - d : p + d, w = (o ?? 12) * h;
559
+ const a = m.axis, p = a.position === "top" ? a.canvasRect.y + a.canvasRect.height : a.canvasRect.y, h = window.devicePixelRatio || 1, y = p, d = (r ?? 6) * h, g = a.position === "top" ? p - d : p + d, w = (o ?? 12) * h;
553
560
  c.save(), c.fontKerning = "auto", U(c, {
554
561
  ...n
555
562
  }), c.beginPath();
556
- const x = Array.isArray(r) ? r : r({ ...m, axis: a }, f);
563
+ const x = Array.isArray(i) ? i : i({ ...m, axis: a }, f);
557
564
  for (const { value: b } of x) {
558
565
  const v = l(b, t, "canvas");
559
566
  v !== null && (c.moveTo(v, y), c.lineTo(v, g));
@@ -562,34 +569,36 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
562
569
  textBaseline: a.position === "top" ? "bottom" : "top",
563
570
  textAlign: "center",
564
571
  ...n,
565
- ...s
572
+ ...s,
573
+ // alter font size for DPR
574
+ font: _e(s?.font ?? n?.font)
566
575
  });
567
576
  for (const { value: b, label: v } of x) {
568
577
  const T = l(b, t, "canvas");
569
578
  if (T === null)
570
579
  continue;
571
- const S = v.split(`
580
+ const C = v.split(`
572
581
  `);
573
- for (let E = 0; E < S.length; E++)
574
- c.fillText(S[E], T, g + h * 2 + E * w);
582
+ for (let E = 0; E < C.length; E++)
583
+ c.fillText(C[E], T, g + h * 2 + E * w);
575
584
  }
576
585
  c.restore();
577
586
  },
578
- [r, t, n, s]
579
- ), null), Xt = D.memo(ct, O), at = ({
587
+ [i, t, n, s]
588
+ ), null), Ot = D.memo(at, O), lt = ({
580
589
  layer: e = "BOTTOM",
581
590
  scaleId: t,
582
591
  tickStyle: n,
583
592
  labelStyle: s,
584
593
  labelGap: o,
585
- tickSize: i,
586
- ticks: r
594
+ tickSize: r,
595
+ ticks: i
587
596
  }) => (j(
588
597
  e,
589
598
  ({ ctx: c, valToPos: l, getScale: u, frame: f }) => {
590
599
  const m = u(t);
591
600
  if (!m || !m.axis || m.origin !== "y") return;
592
- const a = m.axis, p = a.position === "left" ? a.canvasRect.x + a.canvasRect.width : a.canvasRect.x, h = p, y = i ?? 6, d = a.position === "left" ? p - y : p + y, g = o ?? 12, w = Array.isArray(r) ? r : r({ ...m, axis: a }, f);
601
+ const a = m.axis, p = a.position === "left" ? a.canvasRect.x + a.canvasRect.width : a.canvasRect.x, h = p, y = r ?? 6, d = a.position === "left" ? p - y : p + y, g = o ?? 12, w = Array.isArray(i) ? i : i({ ...m, axis: a }, f);
593
602
  c.save(), c.fontKerning = "auto", U(c, { ...n }), c.beginPath();
594
603
  for (const { value: x } of w) {
595
604
  const b = l(x, t, "canvas");
@@ -599,7 +608,9 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
599
608
  textBaseline: "middle",
600
609
  textAlign: a.position === "left" ? "right" : "left",
601
610
  ...n,
602
- ...s
611
+ ...s,
612
+ // alter font size for DPR
613
+ font: _e(s?.font ?? n?.font)
603
614
  });
604
615
  for (const { value: x, label: b } of w) {
605
616
  const v = l(x, t, "canvas");
@@ -607,13 +618,20 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
607
618
  continue;
608
619
  const T = b.split(`
609
620
  `);
610
- for (let S = 0; S < T.length; S++)
611
- c.fillText(` ${T[S]} `, d, v + S * g);
621
+ for (let C = 0; C < T.length; C++)
622
+ c.fillText(` ${T[C]} `, d, v + C * g);
612
623
  }
613
624
  c.restore();
614
625
  },
615
- [r, t, n, s]
616
- ), null), Ot = D.memo(at, O), I = () => {
626
+ [i, t, n, s]
627
+ ), null), Ft = D.memo(lt, O), _e = (e) => {
628
+ if (e)
629
+ try {
630
+ return e.replace(/(\d+)px/, (t, n) => `${parseInt(n) * window.devicePixelRatio || 1}px`);
631
+ } catch {
632
+ }
633
+ return e;
634
+ }, I = () => {
617
635
  const e = [];
618
636
  return {
619
637
  addEventListener: (t, n) => (e.push({
@@ -643,32 +661,32 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
643
661
  const s = D.useRef(n);
644
662
  s.current = n, D.useEffect(() => M[e].addEventListener(
645
663
  t,
646
- (i, r) => {
647
- s.current(r, i);
664
+ (r, i) => {
665
+ s.current(i, r);
648
666
  }
649
667
  ), [t, e, s]);
650
668
  }, we = D.createContext(""), xe = (e, t) => {
651
669
  const n = D.useContext(we);
652
670
  return L(e, n, t);
653
- }, lt = (e, t, n, s, o) => {
671
+ }, ut = (e, t, n, s, o) => {
654
672
  if (!t) return;
655
- const i = s ?? n.scales.find((m) => m.origin === "x")?.id, r = o ?? n.scales.find((m) => m.origin === "y")?.id, c = e.clientX - t.left, l = i ? {
656
- scaleId: i,
657
- value: _(n, c, i, "css")
658
- } : null, u = e.clientY - t.top, f = r ? {
673
+ const r = s ?? n.scales.find((m) => m.origin === "x")?.id, i = o ?? n.scales.find((m) => m.origin === "y")?.id, c = e.clientX - t.left, l = r ? {
659
674
  scaleId: r,
660
- value: _(n, u, r, "css")
675
+ value: _(n, c, r, "css")
676
+ } : null, u = e.clientY - t.top, f = i ? {
677
+ scaleId: i,
678
+ value: _(n, u, i, "css")
661
679
  } : null;
662
680
  return { pointerSyncPosition: { x: l, y: f }, cssX: c, cssY: u };
663
681
  }, N = (e, t) => {
664
- const { x: n, y: s } = e, o = n && t.scales.some((r) => r.id === n.scaleId) ? G(t, n.value, n.scaleId, "css") : null, i = s && t.scales.some((r) => r.id === s.scaleId) ? G(t, s.value, s.scaleId, "css") : null;
682
+ const { x: n, y: s } = e, o = n && t.scales.some((i) => i.id === n.scaleId) ? G(t, n.value, n.scaleId, "css") : null, r = s && t.scales.some((i) => i.id === s.scaleId) ? G(t, s.value, s.scaleId, "css") : null;
665
683
  return {
666
684
  cssX: o,
667
- cssY: i,
685
+ cssY: r,
668
686
  scaled: Object.fromEntries(
669
- t.scales.flatMap((r) => {
670
- const c = r.origin === "y" ? i : o;
671
- return c === null ? [] : [[r.id, _(t, c, r.id, "css")]];
687
+ t.scales.flatMap((i) => {
688
+ const c = i.origin === "y" ? r : o;
689
+ return c === null ? [] : [[i.id, _(t, c, i.id, "css")]];
672
690
  })
673
691
  )
674
692
  };
@@ -686,14 +704,14 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
686
704
  );
687
705
  if (s === null || o === null)
688
706
  return null;
689
- const i = n.scales.flatMap(
690
- (r) => {
691
- if (r.origin !== e)
707
+ const r = n.scales.flatMap(
708
+ (i) => {
709
+ if (i.origin !== e)
692
710
  return [];
693
- const c = _(n, s, r.id, "css"), l = _(n, o, r.id, "css");
711
+ const c = _(n, s, i.id, "css"), l = _(n, o, i.id, "css");
694
712
  return c === null || l === null ? [] : [
695
713
  {
696
- scaleId: r.id,
714
+ scaleId: i.id,
697
715
  from: c,
698
716
  to: l
699
717
  }
@@ -703,16 +721,16 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
703
721
  return {
704
722
  fromCSS: s,
705
723
  toCSS: o,
706
- scaled: i
724
+ scaled: r
707
725
  };
708
- }, Ft = ({
726
+ }, Kt = ({
709
727
  id: e,
710
728
  onClick: t,
711
729
  onDblClick: n,
712
730
  onMouseMove: s,
713
731
  onMouseDown: o,
714
- onMouseUp: i,
715
- onDocumentMouseUp: r,
732
+ onMouseUp: r,
733
+ onDocumentMouseUp: i,
716
734
  onSpanSelect: c,
717
735
  onContextMenu: l,
718
736
  className: u,
@@ -721,7 +739,7 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
721
739
  innerChildren: a,
722
740
  children: p
723
741
  }) => {
724
- const h = je();
742
+ const h = He();
725
743
  return L("dblclick", h, (y) => {
726
744
  n?.(y);
727
745
  }), L("click", h, (y) => {
@@ -731,16 +749,16 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
731
749
  }), L("mousedown", h, (y) => {
732
750
  o?.(y);
733
751
  }), L("mouseup", h, (y) => {
734
- i?.(y);
735
- }), L("documentmouseup", h, (y) => {
736
752
  r?.(y);
753
+ }), L("documentmouseup", h, (y) => {
754
+ i?.(y);
737
755
  }), L("spanselect", h, (y) => {
738
756
  c?.(y);
739
757
  }), L("contextmenu", h, (y) => {
740
758
  l?.(y);
741
759
  }), /* @__PURE__ */ pe(we.Provider, { value: h, children: [
742
760
  /* @__PURE__ */ R(
743
- ut,
761
+ ht,
744
762
  {
745
763
  id: e,
746
764
  className: u,
@@ -751,11 +769,11 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
751
769
  ),
752
770
  p
753
771
  ] });
754
- }, ut = ({ id: e, className: t, style: n, sync: s, children: o }) => {
755
- const i = A(null), r = Le().frame, c = A(r);
756
- c.current = r;
757
- const l = q(we), u = s?.key || l, f = A(null), m = A(null), a = A(null), p = () => {
758
- const d = i.current?.parentElement;
772
+ }, ht = ({ id: e, className: t, style: n, sync: s, children: o }) => {
773
+ const r = k(null), i = Ue().frame, c = k(i);
774
+ c.current = i;
775
+ const l = q(we), u = s?.key || l, f = k(null), m = k(null), a = k(null), p = () => {
776
+ const d = r.current?.parentElement;
759
777
  if (d) {
760
778
  if (d.dataset.canplotroot === void 0)
761
779
  throw new Error(
@@ -764,7 +782,7 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
764
782
  return d.getBoundingClientRect();
765
783
  }
766
784
  }, h = (d, g) => {
767
- const w = lt(
785
+ const w = ut(
768
786
  d,
769
787
  p(),
770
788
  c.current,
@@ -781,8 +799,8 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
781
799
  metaKey: d.metaKey
782
800
  }
783
801
  );
784
- }, y = A(h);
785
- return y.current = h, Ve(() => {
802
+ }, y = k(h);
803
+ return y.current = h, ke(() => {
786
804
  const d = (v) => {
787
805
  const T = m.current;
788
806
  T && M.spanselect.dispatchEvent(l, {
@@ -803,30 +821,30 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
803
821
  altKey: v.altKey,
804
822
  shiftKey: v.shiftKey,
805
823
  metaKey: v.metaKey
806
- }, S = a.current;
807
- if (S && Object.entries(T).some(
808
- ([C, P]) => S.keys[C] !== P
824
+ }, C = a.current;
825
+ if (C && Object.entries(T).some(
826
+ ([S, P]) => C.keys[S] !== P
809
827
  )) {
810
- const C = { ...S, keys: T };
811
- a.current = C, M.sync_move.dispatchEvent(u, C);
828
+ const S = { ...C, keys: T };
829
+ a.current = S, M.sync_move.dispatchEvent(u, S);
812
830
  }
813
831
  const E = m.current;
814
832
  if (E && Object.entries(T).some(
815
- ([C, P]) => E.keys[C] !== P
833
+ ([S, P]) => E.keys[S] !== P
816
834
  )) {
817
835
  v.stopPropagation(), v.preventDefault();
818
- const C = { ...E, keys: T };
819
- m.current = C, M.spanselect.dispatchEvent(l, C);
836
+ const S = { ...E, keys: T };
837
+ m.current = S, M.spanselect.dispatchEvent(l, S);
820
838
  }
821
839
  }, w = (v) => {
822
840
  y.current(
823
841
  v,
824
- (T, { cssX: S, cssY: E }, C) => {
842
+ (T, { cssX: C, cssY: E }, S) => {
825
843
  const P = f.current;
826
844
  if (!P || !T.x || !T.y) return;
827
- const k = c.current, z = P.xRangeCss.start, ae = S, le = P.yRangeCss.start, ue = E, J = X(k, T.x.scaleId);
845
+ const A = c.current, z = P.xRangeCss.start, ae = C, le = P.yRangeCss.start, ue = E, J = X(A, T.x.scaleId);
828
846
  if (!J) return;
829
- const Q = X(k, T.y.scaleId);
847
+ const Q = X(A, T.y.scaleId);
830
848
  if (!Q) return;
831
849
  f.current = {
832
850
  xRangeCss: { start: z, end: ae },
@@ -836,28 +854,28 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
836
854
  const he = Math.abs(le - ue), de = Math.abs(z - ae);
837
855
  he < 10 && de < 10 ? W = "below_threshold" : he > 30 && de > 30 ? W = "box" : he > de ? W = "y" : W = "x";
838
856
  const Te = _(
839
- k,
857
+ A,
840
858
  V(c.current, z, "css"),
841
859
  J.id,
842
860
  "css"
843
861
  );
844
862
  if (Te === null) return;
845
- const Se = _(
846
- k,
863
+ const Ce = _(
864
+ A,
847
865
  V(c.current, ae, "css"),
848
866
  J.id,
849
867
  "css"
850
868
  );
851
- if (Se === null) return;
852
- const Ce = _(
853
- k,
869
+ if (Ce === null) return;
870
+ const Se = _(
871
+ A,
854
872
  H(c.current, le, "css"),
855
873
  Q.id,
856
874
  "css"
857
875
  );
858
- if (Ce === null) return;
876
+ if (Se === null) return;
859
877
  const Pe = _(
860
- k,
878
+ A,
861
879
  H(c.current, ue, "css"),
862
880
  Q.id,
863
881
  "css"
@@ -865,13 +883,13 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
865
883
  if (Pe === null) return;
866
884
  const ee = Ee(
867
885
  "x",
868
- { scaleId: J.id, from: Te, to: Se },
886
+ { scaleId: J.id, from: Te, to: Ce },
869
887
  c.current
870
888
  ), te = Ee(
871
889
  "y",
872
- { scaleId: Q.id, from: Ce, to: Pe },
890
+ { scaleId: Q.id, from: Se, to: Pe },
873
891
  c.current
874
- ), Oe = ee?.scaled, Fe = te?.scaled, Me = {
892
+ ), Ke = ee?.scaled, Ye = te?.scaled, Me = {
875
893
  mode: W,
876
894
  frame: c.current,
877
895
  completed: !1,
@@ -880,16 +898,16 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
880
898
  from: ee.fromCSS,
881
899
  to: ee.toCSS
882
900
  } : void 0,
883
- scaled: Oe ?? []
901
+ scaled: Ke ?? []
884
902
  },
885
903
  y: {
886
904
  css: te ? {
887
905
  from: te.fromCSS,
888
906
  to: te.toCSS
889
907
  } : void 0,
890
- scaled: Fe ?? []
908
+ scaled: Ye ?? []
891
909
  },
892
- keys: C
910
+ keys: S
893
911
  };
894
912
  m.current = Me, M.spanselect.dispatchEvent(
895
913
  l,
@@ -898,28 +916,28 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
898
916
  }
899
917
  );
900
918
  }, x = (v) => {
901
- y.current(v, (T, S, E) => {
902
- const C = N(
919
+ y.current(v, (T, C, E) => {
920
+ const S = N(
903
921
  T,
904
922
  c.current
905
923
  );
906
- if (!C) return;
907
- if (Object.values(E).some((k) => k)) {
924
+ if (!S) return;
925
+ if (Object.values(E).some((A) => A)) {
908
926
  v.preventDefault();
909
- const k = Math.abs(v.deltaY) > Math.abs(v.deltaX) ? v.deltaY : v.deltaX;
927
+ const A = Math.abs(v.deltaY) > Math.abs(v.deltaX) ? v.deltaY : v.deltaX;
910
928
  M.pressandwheel.dispatchEvent(l, {
911
- pointer: C,
929
+ pointer: S,
912
930
  frame: c.current,
913
931
  keys: E,
914
932
  deltaX: v.deltaX,
915
933
  deltaY: v.deltaY,
916
- deltaAbs: k
934
+ deltaAbs: A
917
935
  });
918
936
  }
919
937
  });
920
938
  };
921
939
  document.addEventListener("mouseup", d), document.addEventListener("keydown", g), document.addEventListener("keyup", g), document.addEventListener("mousemove", w);
922
- const b = i.current;
940
+ const b = r.current;
923
941
  return b?.addEventListener("wheel", x, {
924
942
  passive: !1
925
943
  }), () => {
@@ -939,15 +957,15 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
939
957
  }), /* @__PURE__ */ R(
940
958
  "div",
941
959
  {
942
- ref: i,
960
+ ref: r,
943
961
  id: e,
944
962
  className: t,
945
963
  style: {
946
964
  position: "absolute",
947
- left: r.chartAreaCSS.x,
948
- top: r.chartAreaCSS.y,
949
- width: r.chartAreaCSS.width,
950
- height: r.chartAreaCSS.height,
965
+ left: i.chartAreaCSS.x,
966
+ top: i.chartAreaCSS.y,
967
+ width: i.chartAreaCSS.width,
968
+ height: i.chartAreaCSS.height,
951
969
  zIndex: 25,
952
970
  ...n
953
971
  },
@@ -1017,14 +1035,14 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
1017
1035
  m.current = null;
1018
1036
  const T = f.current;
1019
1037
  if (f.current = null, T && v) {
1020
- const S = {
1038
+ const C = {
1021
1039
  ...v,
1022
1040
  keys: x,
1023
1041
  completed: !0
1024
1042
  };
1025
1043
  m.current = null, M.spanselect.dispatchEvent(
1026
1044
  l,
1027
- S
1045
+ C
1028
1046
  );
1029
1047
  }
1030
1048
  });
@@ -1058,28 +1076,28 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
1058
1076
  children: o
1059
1077
  }
1060
1078
  );
1061
- }, Kt = ({ data: e, renderTooltip: t, xScaleId: n }) => {
1079
+ }, Yt = ({ data: e, renderTooltip: t, xScaleId: n }) => {
1062
1080
  const [s, o] = B(null);
1063
- xe("move", (r) => {
1064
- o(r);
1081
+ xe("move", (i) => {
1082
+ o(i);
1065
1083
  });
1066
- const i = Z(() => {
1084
+ const r = Z(() => {
1067
1085
  if (!s)
1068
1086
  return null;
1069
- const { frame: r, pointer: c } = s, l = c?.scaled[n];
1070
- if (l === void 0 || !X(r, n))
1087
+ const { frame: i, pointer: c } = s, l = c?.scaled[n];
1088
+ if (l === void 0 || !X(i, n))
1071
1089
  return null;
1072
1090
  const f = [];
1073
1091
  let m = l;
1074
1092
  for (const a of e) {
1075
1093
  let p = null, h = 1 / 0;
1076
1094
  for (const [g, w] of a.points.entries()) {
1077
- if (!fe(r, w.x, n) || !fe(r, w.y, a.yScaleId))
1095
+ if (!fe(i, w.x, n) || !fe(i, w.y, a.yScaleId))
1078
1096
  continue;
1079
1097
  const x = Math.abs(w.x - l);
1080
1098
  x < h && (h = x, p = g);
1081
1099
  }
1082
- const y = a.points[p ?? -1], d = ge(r, h, n, "css");
1100
+ const y = a.points[p ?? -1], d = ge(i, h, n, "css");
1083
1101
  if (!y || d === null || d > 30) {
1084
1102
  f.push({ seriesId: a.seriesId, y: null });
1085
1103
  continue;
@@ -1090,20 +1108,20 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
1090
1108
  });
1091
1109
  }
1092
1110
  return {
1093
- frame: r,
1111
+ frame: i,
1094
1112
  x: m,
1095
1113
  points: f
1096
1114
  };
1097
1115
  }, [e, s, n]);
1098
- return t(i);
1099
- }, Yt = ({ makeXStyle: e, makeXClassName: t, makeYStyle: n, makeYClassName: s }) => {
1100
- const [o, i] = B(null);
1116
+ return t(r);
1117
+ }, Bt = ({ makeXStyle: e, makeXClassName: t, makeYStyle: n, makeYClassName: s }) => {
1118
+ const [o, r] = B(null);
1101
1119
  if (xe("move", (a) => {
1102
- i(a);
1120
+ r(a);
1103
1121
  }), !o)
1104
1122
  return null;
1105
- const { frame: r, pointer: c } = o, l = c?.cssX ?? null, u = c?.cssY ?? null, f = l ? V(r, l, "css") : 0, m = u ? H(r, u, "css") : 0;
1106
- return /* @__PURE__ */ pe(Be, { children: [
1123
+ const { frame: i, pointer: c } = o, l = c?.cssX ?? null, u = c?.cssY ?? null, f = l ? V(i, l, "css") : 0, m = u ? H(i, u, "css") : 0;
1124
+ return /* @__PURE__ */ pe(Ne, { children: [
1107
1125
  /* @__PURE__ */ R(
1108
1126
  "div",
1109
1127
  {
@@ -1113,8 +1131,8 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
1113
1131
  position: "absolute",
1114
1132
  left: 0,
1115
1133
  visibility: l === null ? "hidden" : "visible",
1116
- top: r.chartAreaCSS.y,
1117
- height: r.chartAreaCSS.height,
1134
+ top: i.chartAreaCSS.y,
1135
+ height: i.chartAreaCSS.height,
1118
1136
  borderColor: "red",
1119
1137
  borderLeftWidth: "1px",
1120
1138
  borderLeftStyle: "solid",
@@ -1136,8 +1154,8 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
1136
1154
  top: 0,
1137
1155
  height: 0,
1138
1156
  borderTop: "solid 1px red",
1139
- left: r.chartAreaCSS.x,
1140
- width: r.chartAreaCSS.width,
1157
+ left: i.chartAreaCSS.x,
1158
+ width: i.chartAreaCSS.width,
1141
1159
  pointerEvents: "none",
1142
1160
  opacity: c ? 1 : 0,
1143
1161
  transform: `translateY(${m}px)`,
@@ -1146,17 +1164,17 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
1146
1164
  }
1147
1165
  )
1148
1166
  ] });
1149
- }, Bt = ({ makeClassName: e, makeStyle: t }) => {
1167
+ }, zt = ({ makeClassName: e, makeStyle: t }) => {
1150
1168
  const [n, s] = B(null);
1151
- xe("spanselect", (i) => {
1169
+ xe("spanselect", (r) => {
1152
1170
  s(
1153
- i.mode === "below_threshold" || i.completed ? null : i
1171
+ r.mode === "below_threshold" || r.completed ? null : r
1154
1172
  );
1155
1173
  });
1156
1174
  const o = Z(() => {
1157
1175
  if (!n || n.mode === "below_threshold")
1158
1176
  return null;
1159
- const i = n.mode === "y" ? -1 / 0 : n.x.css?.from ?? -1 / 0, r = n.mode === "y" ? 1 / 0 : n.x.css?.to ?? 1 / 0, c = n.mode === "x" ? -1 / 0 : n.y.css?.from ?? -1 / 0, l = n.mode === "x" ? 1 / 0 : n.y.css?.to ?? 1 / 0, u = V(n.frame, i, "css"), f = V(n.frame, r, "css"), m = H(n.frame, c, "css"), a = H(n.frame, l, "css"), p = Math.min(u, f), h = Math.min(m, a), y = Math.abs(f - u), d = Math.abs(a - m);
1177
+ const r = n.mode === "y" ? -1 / 0 : n.x.css?.from ?? -1 / 0, i = n.mode === "y" ? 1 / 0 : n.x.css?.to ?? 1 / 0, c = n.mode === "x" ? -1 / 0 : n.y.css?.from ?? -1 / 0, l = n.mode === "x" ? 1 / 0 : n.y.css?.to ?? 1 / 0, u = V(n.frame, r, "css"), f = V(n.frame, i, "css"), m = H(n.frame, c, "css"), a = H(n.frame, l, "css"), p = Math.min(u, f), h = Math.min(m, a), y = Math.abs(f - u), d = Math.abs(a - m);
1160
1178
  return { leftPx: p, topPx: h, widthPx: y, heightPx: d };
1161
1179
  }, [n]);
1162
1180
  return /* @__PURE__ */ R(
@@ -1175,8 +1193,8 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
1175
1193
  }
1176
1194
  }
1177
1195
  );
1178
- }, zt = ({ style: e, children: t, scaleId: n, ...s }) => {
1179
- const o = Le().getScale(n)?.axis;
1196
+ }, Nt = ({ style: e, children: t, scaleId: n, ...s }) => {
1197
+ const o = Ue().getScale(n)?.axis;
1180
1198
  return o ? /* @__PURE__ */ R(
1181
1199
  "div",
1182
1200
  {
@@ -1193,12 +1211,12 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
1193
1211
  children: t
1194
1212
  }
1195
1213
  ) : null;
1196
- }, Ue = 60, ht = 30, _e = "UTC", dt = "en-GB", Nt = ({
1214
+ }, Xe = 60, dt = 30, Oe = "UTC", ft = "en-GB", $t = ({
1197
1215
  space: e,
1198
1216
  formatter: t,
1199
1217
  acceptableIncrements: n
1200
1218
  } = {}) => (s, o) => {
1201
- const { min: i, max: r } = s, c = [], l = window.devicePixelRatio || 1, u = (e ?? (s.origin === "x" ? Ue : ht)) * l, f = He(
1219
+ const { min: r, max: i } = s, c = [], l = window.devicePixelRatio || 1, u = (e ?? (s.origin === "x" ? Xe : dt)) * l, f = We(
1202
1220
  o,
1203
1221
  u,
1204
1222
  s.id,
@@ -1207,21 +1225,21 @@ const Rt = Ne(({ configuration: e, children: t, style: n, className: s }, o) =>
1207
1225
  if (f === null)
1208
1226
  return [];
1209
1227
  const m = n ?? ne, a = m.find((h) => h > f) ?? m.at(-1) ?? 1;
1210
- let p = i;
1228
+ let p = r;
1211
1229
  if (Math.abs(p % a) > Number.EPSILON) {
1212
1230
  const h = (a - p % a) % a;
1213
1231
  p += h;
1214
1232
  }
1215
- for (; p <= r && c.length < 1e3; )
1233
+ for (; p <= i && c.length < 1e3; )
1216
1234
  c.push(p), p += a;
1217
- return (t ?? ft)(c);
1218
- }, ft = (e) => {
1235
+ return (t ?? mt)(c);
1236
+ }, mt = (e) => {
1219
1237
  const t = Math.max(0, Math.ceil(-Math.log10(e[1] - e[0])));
1220
1238
  return e.map((n) => ({ value: n, label: n.toFixed(t) }));
1221
1239
  }, ne = [];
1222
1240
  for (let e = -12; e <= 12; e++)
1223
1241
  ne.push(1 * 10 ** e), ne.push(2 * 10 ** e), ne.push(5 * 10 ** e);
1224
- const mt = 1, Xe = 1e3 * mt, be = 60 * Xe, re = 60 * be, ce = 24 * re, pt = 30 * ce, yt = 365 * ce, gt = [
1242
+ const pt = 1, Fe = 1e3 * pt, be = 60 * Fe, ie = 60 * be, ce = 24 * ie, yt = 30 * ce, gt = 365 * ce, vt = [
1225
1243
  // second divisors
1226
1244
  [1, "milliseconds"],
1227
1245
  [2, "milliseconds"],
@@ -1279,53 +1297,53 @@ const mt = 1, Xe = 1e3 * mt, be = 60 * Xe, re = 60 * be, ce = 24 * re, pt = 30 *
1279
1297
  case "milliseconds":
1280
1298
  return t;
1281
1299
  case "seconds":
1282
- return t * Xe;
1300
+ return t * Fe;
1283
1301
  case "minutes":
1284
1302
  return t * be;
1285
1303
  case "hours":
1286
- return t * re;
1304
+ return t * ie;
1287
1305
  case "days":
1288
1306
  return t * ce;
1289
1307
  case "months":
1290
- return t * pt;
1291
- case "years":
1292
1308
  return t * yt;
1309
+ case "years":
1310
+ return t * gt;
1293
1311
  }
1294
- }, vt = (e, t) => {
1312
+ }, wt = (e, t) => {
1295
1313
  const n = new Date(e);
1296
1314
  return n.setUTCMilliseconds(n.getUTCMilliseconds() + t), n.getTime();
1297
- }, wt = (e, t) => {
1315
+ }, xt = (e, t) => {
1298
1316
  const n = new Date(e);
1299
1317
  return n.setUTCSeconds(n.getUTCSeconds() + t), n.getTime();
1300
- }, xt = (e, t) => {
1318
+ }, bt = (e, t) => {
1301
1319
  const n = new Date(e);
1302
1320
  return n.setUTCMinutes(n.getUTCMinutes() + t), n.getTime();
1303
- }, bt = (e, t) => {
1321
+ }, Tt = (e, t) => {
1304
1322
  const n = new Date(e);
1305
1323
  return n.setUTCHours(n.getUTCHours() + t), n.getTime();
1306
- }, Tt = (e, t) => {
1324
+ }, Ct = (e, t) => {
1307
1325
  const n = new Date(e);
1308
1326
  return n.setUTCDate(n.getUTCDate() + t), n.getTime();
1309
- }, ke = (e, t) => {
1327
+ }, Ae = (e, t) => {
1310
1328
  const n = new Date(e);
1311
1329
  return n.setUTCMonth(n.getUTCMonth() + t), n.getTime();
1312
1330
  }, Y = (e, t) => {
1313
1331
  const [n, s] = t;
1314
1332
  switch (s) {
1315
1333
  case "milliseconds":
1316
- return vt(e, n);
1317
- case "seconds":
1318
1334
  return wt(e, n);
1319
- case "minutes":
1335
+ case "seconds":
1320
1336
  return xt(e, n);
1321
- case "hours":
1337
+ case "minutes":
1322
1338
  return bt(e, n);
1323
- case "days":
1339
+ case "hours":
1324
1340
  return Tt(e, n);
1341
+ case "days":
1342
+ return Ct(e, n);
1325
1343
  case "months":
1326
- return ke(e, n);
1344
+ return Ae(e, n);
1327
1345
  case "years":
1328
- return ke(e, n * 12);
1346
+ return Ae(e, n * 12);
1329
1347
  }
1330
1348
  };
1331
1349
  function oe(e, t) {
@@ -1334,32 +1352,32 @@ function oe(e, t) {
1334
1352
  }
1335
1353
  const St = (e, t, n = "UTC") => {
1336
1354
  const [s, o] = t;
1337
- let i = new Date(e);
1338
- const r = () => {
1339
- i.setUTCHours(-oe(i, n), 0, 0, 0);
1355
+ let r = new Date(e);
1356
+ const i = () => {
1357
+ r.setUTCHours(-oe(r, n), 0, 0, 0);
1340
1358
  };
1341
1359
  switch (o) {
1342
1360
  case "milliseconds":
1343
- i.setUTCMilliseconds(
1344
- Math.ceil(i.getUTCMilliseconds() / s) * s
1361
+ r.setUTCMilliseconds(
1362
+ Math.ceil(r.getUTCMilliseconds() / s) * s
1345
1363
  );
1346
1364
  break;
1347
1365
  case "seconds":
1348
- i.setUTCSeconds(
1349
- Math.ceil(i.getUTCSeconds() / s) * s,
1366
+ r.setUTCSeconds(
1367
+ Math.ceil(r.getUTCSeconds() / s) * s,
1350
1368
  0
1351
1369
  );
1352
1370
  break;
1353
1371
  case "minutes":
1354
- i.setUTCMinutes(
1355
- Math.ceil(i.getTime() % re / be / s) * s,
1372
+ r.setUTCMinutes(
1373
+ Math.ceil(r.getTime() % ie / be / s) * s,
1356
1374
  0,
1357
1375
  0
1358
1376
  );
1359
1377
  break;
1360
1378
  case "hours":
1361
- i.setUTCHours(
1362
- Math.ceil(i.getTime() % ce / re / s) * s,
1379
+ r.setUTCHours(
1380
+ Math.ceil(r.getTime() % ce / ie / s) * s,
1363
1381
  0,
1364
1382
  0,
1365
1383
  0
@@ -1368,18 +1386,18 @@ const St = (e, t, n = "UTC") => {
1368
1386
  case "days":
1369
1387
  case "months":
1370
1388
  case "years":
1371
- o === "months" ? i.setUTCDate(1) : o === "years" && i.setUTCMonth(0, 1), r(), i.getTime() < e && (i = new Date(Y(i, [1, o])));
1389
+ o === "months" ? r.setUTCDate(1) : o === "years" && r.setUTCMonth(0, 1), i(), r.getTime() < e && (r = new Date(Y(r, [1, o])));
1372
1390
  break;
1373
1391
  }
1374
- return i.getTime();
1375
- }, $t = ({
1376
- timeZone: e = _e,
1377
- space: t = Ue,
1392
+ return r.getTime();
1393
+ }, jt = ({
1394
+ timeZone: e = Oe,
1395
+ space: t = Xe,
1378
1396
  formatter: n,
1379
1397
  locale: s,
1380
1398
  showTimezone: o
1381
- } = {}) => (i, r) => {
1382
- const { min: c, max: l } = i, u = Math.floor(r.chartAreaCanvasPX.width / t) + 1, m = (l - c) / u, [a, p] = gt.find(
1399
+ } = {}) => (r, i) => {
1400
+ const { min: c, max: l } = r, u = Math.floor(i.chartAreaCanvasPX.width / t) + 1, m = (l - c) / u, [a, p] = vt.find(
1383
1401
  (w) => se(w) >= m
1384
1402
  ) ?? [1, "milliseconds"], h = St(c, [a, p], e), y = oe(h, e), d = [h];
1385
1403
  let g;
@@ -1423,14 +1441,14 @@ const St = (e, t, n = "UTC") => {
1423
1441
  break;
1424
1442
  d.push(g);
1425
1443
  }
1426
- return (n ?? Ct({
1444
+ return (n ?? Pt({
1427
1445
  locale: s,
1428
1446
  showTimezone: o,
1429
1447
  timeZone: e
1430
1448
  }))(d);
1431
- }, K = (e, t, n) => e.find((s) => s.type === n)?.value !== t.find((s) => s.type === n)?.value, Ct = ({
1432
- timeZone: e = _e,
1433
- locale: t = dt,
1449
+ }, K = (e, t, n) => e.find((s) => s.type === n)?.value !== t.find((s) => s.type === n)?.value, Pt = ({
1450
+ timeZone: e = Oe,
1451
+ locale: t = ft,
1434
1452
  showTimezone: n = !0
1435
1453
  }) => {
1436
1454
  const s = new Intl.DateTimeFormat(t, {
@@ -1446,20 +1464,20 @@ const St = (e, t, n = "UTC") => {
1446
1464
  timeZone: e
1447
1465
  });
1448
1466
  return (o) => {
1449
- const i = o[1] - o[0], r = i < se([1, "days"]), c = i < se([1, "minutes"]), l = i < se([1, "seconds"]);
1467
+ const r = o[1] - o[0], i = r < se([1, "days"]), c = r < se([1, "minutes"]), l = r < se([1, "seconds"]);
1450
1468
  return o.map((u) => ({ value: u, label: s.formatToParts(new Date(u)) })).map((u, f, m) => {
1451
1469
  const a = m[f - 1], p = f === 0 || K(u.label, a.label, "year"), h = f === 0 || K(u.label, a.label, "day"), y = f === 0 || K(u.label, a.label, "month"), d = f === 0 || K(u.label, a.label, "hour"), g = f === 0 || K(u.label, a.label, "timeZoneName"), w = f === 0 || K(u.label, a.label, "minute"), x = f === 0 || K(u.label, a.label, "second"), b = f === 0 || K(u.label, a.label, "fractionalSecond"), v = [];
1452
- if (r && (d || w || g || x || b)) {
1453
- const T = u.label.find((P) => P.type === "hour")?.value, S = u.label.find((P) => P.type === "minute")?.value, E = u.label.find((P) => P.type === "timeZoneName")?.value;
1454
- let C = "";
1470
+ if (i && (d || w || g || x || b)) {
1471
+ const T = u.label.find((P) => P.type === "hour")?.value, C = u.label.find((P) => P.type === "minute")?.value, E = u.label.find((P) => P.type === "timeZoneName")?.value;
1472
+ let S = "";
1455
1473
  if (c) {
1456
- const P = u.label.find((z) => z.type === "second")?.value, k = u.label.find(
1474
+ const P = u.label.find((z) => z.type === "second")?.value, A = u.label.find(
1457
1475
  (z) => z.type === "fractionalSecond"
1458
1476
  )?.value;
1459
- C = `:${P}` + (l ? `.${k}` : "");
1477
+ S = `:${P}` + (l ? `.${A}` : "");
1460
1478
  }
1461
1479
  v.push(
1462
- `${T}:${S}${C}` + (n && g ? ` ${E}` : "")
1480
+ `${T}:${C}${S}` + (n && g ? ` ${E}` : "")
1463
1481
  );
1464
1482
  }
1465
1483
  return (h || y) && v.push(
@@ -1476,37 +1494,37 @@ const St = (e, t, n = "UTC") => {
1476
1494
  };
1477
1495
  };
1478
1496
  export {
1479
- Ut as AreaPlot,
1480
- zt as AxisOverlay,
1481
- Lt as BarPlot,
1482
- De as CANPLOT_LAYER,
1483
- Rt as CanPlot,
1484
- Ft as ChartAreaInteractions,
1485
- Yt as Crosshair,
1486
- Ie as FrameDrawer,
1487
- Dt as LinePlot,
1488
- It as ScatterPlot,
1489
- Bt as SelectBox,
1490
- _t as SparklinePlot,
1491
- Kt as TooltipsX,
1492
- Xt as XTicks,
1493
- Ot as YTicks,
1497
+ _t as AreaPlot,
1498
+ Nt as AxisOverlay,
1499
+ Ut as BarPlot,
1500
+ Ie as CANPLOT_LAYER,
1501
+ Dt as CanPlot,
1502
+ Kt as ChartAreaInteractions,
1503
+ Bt as Crosshair,
1504
+ Le as FrameDrawer,
1505
+ It as LinePlot,
1506
+ Lt as ScatterPlot,
1507
+ zt as SelectBox,
1508
+ Xt as SparklinePlot,
1509
+ Yt as TooltipsX,
1510
+ Ot as XTicks,
1511
+ Ft as YTicks,
1494
1512
  U as applyStyles,
1495
- ie as clamp,
1513
+ re as clamp,
1496
1514
  V as clampXPosToChartArea,
1497
1515
  H as clampYPosToChartArea,
1498
1516
  O as deepEqual,
1499
- ft as defaultNumericalTicksFormatter,
1500
- At as findClosestIndex,
1517
+ mt as defaultNumericalTicksFormatter,
1518
+ Rt as findClosestIndex,
1501
1519
  X as getScale,
1502
- Nt as makeLinearTicks,
1503
- Ct as makeTimeTickFormat,
1504
- $t as makeTimeTicks,
1520
+ $t as makeLinearTicks,
1521
+ Pt as makeTimeTickFormat,
1522
+ jt as makeTimeTicks,
1505
1523
  _ as posToVal,
1506
- He as pxToValDistance,
1524
+ We as pxToValDistance,
1507
1525
  kt as sum,
1508
1526
  j as useDrawEffect,
1509
- Le as useFrameState,
1527
+ Ue as useFrameState,
1510
1528
  xe as useInteractionsEvent,
1511
1529
  fe as valFits,
1512
1530
  G as valToPos,