@canplot/react 0.1.23 → 0.1.24

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