@canplot/react 0.1.5 → 0.1.6

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,10 +1,10 @@
1
1
  import { jsxs as at, jsx as X, Fragment as Et } from "react/jsx-runtime";
2
- import Z, { createContext as Mt, useContext as lt, useRef as L, useLayoutEffect as J, version as At, forwardRef as Pt, useMemo as St, useState as N, useId as Rt, useEffect as _t } from "react";
2
+ import Z, { createContext as Pt, useContext as lt, useRef as L, useLayoutEffect as J, version as Mt, forwardRef as At, useMemo as ut, useState as N, useId as Rt, useEffect as _t } from "react";
3
3
  import { createStore as Ut, useStore as vt } from "zustand";
4
4
  const V = (t, s, e) => Math.min(Math.max(t, s), e), Lt = (t, s, e, c) => {
5
- const { min: n, max: o } = P(t, e), a = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, l = (Q(t, e) ? a.width : a.height) / (o - n);
5
+ const { min: o, max: n } = A(t, e), a = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, l = (Q(t, e) ? a.width : a.height) / (n - o);
6
6
  return s / l;
7
- }, P = (t, s) => {
7
+ }, A = (t, s) => {
8
8
  const e = t.scales.find((c) => c.id === s);
9
9
  if (!e)
10
10
  throw new Error(`Scale ${s} not found`);
@@ -12,23 +12,23 @@ const V = (t, s, e) => Math.min(Math.max(t, s), e), Lt = (t, s, e, c) => {
12
12
  }, Q = (t, s) => t.scales.find((e) => e.id === s)?.origin === "x", ae = (t, s) => t.scales.find((e) => e.id === s)?.origin === "y", R = (t, s) => {
13
13
  const e = window.devicePixelRatio || 1;
14
14
  t.lineCap = s?.lineCap ?? "butt", t.lineDashOffset = e * (s?.lineDashOffset ?? 0), t.lineJoin = s?.lineJoin ?? "miter", t.lineWidth = e * (s?.lineWidth ?? 1), t.miterLimit = e * (s?.miterLimit ?? 10), t.strokeStyle = s?.strokeStyle ?? "black", t.fillStyle = s?.fillStyle ?? t.strokeStyle, t.font = s?.font ?? `${10 * e}px sans-serif`, t.textAlign = s?.textAlign ?? "start", t.direction = s?.direction ?? "inherit", t.textBaseline = s?.textBaseline ?? "alphabetic", t.fontKerning = s?.fontKerning ?? "auto";
15
- }, ut = (t, s, e, c) => {
16
- const n = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, { min: o, max: a } = P(t, e), l = (Q(t, e) ? n.width : n.height) / (a - o);
15
+ }, dt = (t, s, e, c) => {
16
+ const o = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, { min: n, max: a } = A(t, e), l = (Q(t, e) ? o.width : o.height) / (a - n);
17
17
  return s * l;
18
18
  }, j = (t, s, e, c) => {
19
- const { min: n } = P(t, e), o = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, a = ut(t, s - n, e, c);
19
+ const { min: o } = A(t, e), n = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, a = dt(t, s - o, e, c);
20
20
  return Q(t, e) ? V(
21
- o.x + a,
22
- o.x - 10 * o.width,
23
- o.x + 11 * o.width
21
+ n.x + a,
22
+ n.x - 10 * n.width,
23
+ n.x + 11 * n.width
24
24
  ) : V(
25
- o.y + o.height - a,
26
- o.y - 10 * o.height,
27
- o.y + 11 * o.height
25
+ n.y + n.height - a,
26
+ n.y - 10 * n.height,
27
+ n.y + 11 * n.height
28
28
  );
29
29
  }, le = (t, s, e) => {
30
- const { min: c, max: n } = P(t, e);
31
- return V(s, c, n);
30
+ const { min: c, max: o } = A(t, e);
31
+ return V(s, c, o);
32
32
  }, O = (t, s, e) => {
33
33
  const c = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
34
34
  return V(s, c.x, c.x + c.width);
@@ -36,11 +36,11 @@ const V = (t, s, e) => Math.min(Math.max(t, s), e), Lt = (t, s, e, c) => {
36
36
  const c = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
37
37
  return V(s, c.y, c.y + c.height);
38
38
  }, it = (t, s, e) => {
39
- const { min: c, max: n } = P(t, e);
40
- return s >= c && s <= n;
39
+ const { min: c, max: o } = A(t, e);
40
+ return s >= c && s <= o;
41
41
  }, D = (t, s, e, c) => {
42
- const { min: n, max: o } = P(t, e), a = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, l = Q(t, e) ? (s - a.x) / a.width : (a.height - s + a.y) / a.height;
43
- return n + l * (o - n);
42
+ const { min: o, max: n } = A(t, e), a = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, l = Q(t, e) ? (s - a.x) / a.width : (a.height - s + a.y) / a.height;
43
+ return o + l * (n - o);
44
44
  }, Dt = (t) => {
45
45
  const { ctx: s, scales: e } = t;
46
46
  for (const c of e) {
@@ -51,18 +51,18 @@ const V = (t, s, e) => Math.min(Math.max(t, s), e), Lt = (t, s, e, c) => {
51
51
  lineWidth: 1,
52
52
  ...c.axis.style
53
53
  });
54
- const n = c.axis.canvasRect;
54
+ const o = c.axis.canvasRect;
55
55
  if (c.origin === "x") {
56
56
  if (c.axis.position === "bottom")
57
- s.beginPath(), s.moveTo(n.x, n.y), s.lineTo(n.x + n.width, n.y), s.stroke();
57
+ s.beginPath(), s.moveTo(o.x, o.y), s.lineTo(o.x + o.width, o.y), s.stroke();
58
58
  else if (c.axis.position === "top") {
59
- const o = n.y + n.height;
60
- s.beginPath(), s.moveTo(n.x, o), s.lineTo(n.x + n.width, o), s.stroke();
59
+ const n = o.y + o.height;
60
+ s.beginPath(), s.moveTo(o.x, n), s.lineTo(o.x + o.width, n), s.stroke();
61
61
  }
62
62
  } else if (c.axis.position === "left") {
63
- const o = n.x + n.width;
64
- s.beginPath(), s.moveTo(o, n.y), s.lineTo(o, n.y + n.height), s.stroke();
65
- } else c.axis.position === "right" && (s.beginPath(), s.moveTo(n.x, n.y), s.lineTo(n.x, n.y + n.height), s.stroke());
63
+ const n = o.x + o.width;
64
+ s.beginPath(), s.moveTo(n, o.y), s.lineTo(n, o.y + o.height), s.stroke();
65
+ } else c.axis.position === "right" && (s.beginPath(), s.moveTo(o.x, o.y), s.lineTo(o.x, o.y + o.height), s.stroke());
66
66
  s.restore();
67
67
  }
68
68
  }, Xt = () => Ut((t, s) => {
@@ -75,30 +75,30 @@ const V = (t, s, e) => Math.min(Math.max(t, s), e), Lt = (t, s, e, c) => {
75
75
  _frame: null,
76
76
  getFrame: e,
77
77
  getCtx: () => e().ctx,
78
- clampXPosToChartArea: (c, n) => O(e(), c, n ?? "canvas"),
79
- clampYPosToChartArea: (c, n) => $(e(), c, n ?? "canvas"),
80
- valToPos: (c, n, o) => j(e(), c, n, o ?? "canvas"),
81
- valToPxDistance: (c, n, o) => ut(
78
+ clampXPosToChartArea: (c, o) => O(e(), c, o ?? "canvas"),
79
+ clampYPosToChartArea: (c, o) => $(e(), c, o ?? "canvas"),
80
+ valToPos: (c, o, n) => j(e(), c, o, n ?? "canvas"),
81
+ valToPxDistance: (c, o, n) => dt(
82
82
  e(),
83
83
  c,
84
- n,
85
- o ?? "canvas"
84
+ o,
85
+ n ?? "canvas"
86
86
  ),
87
- valFits: (c, n) => it(e(), c, n),
88
- getScale: (c) => P(e(), c)
87
+ valFits: (c, o) => it(e(), c, o),
88
+ getScale: (c) => A(e(), c)
89
89
  };
90
- }), dt = Mt(null), z = (t, s) => {
91
- const e = lt(dt);
90
+ }), ht = Pt(null), z = (t, s) => {
91
+ const e = lt(ht);
92
92
  if (!e)
93
93
  throw new Error("useFrame must be used within a CanPlot component");
94
94
  const c = L(t);
95
95
  c.current = t, J(() => {
96
- c.current(e.getState()), e.subscribe((n) => {
97
- n._frame && c.current(n);
96
+ c.current(e.getState()), e.subscribe((o) => {
97
+ o._frame && c.current(o);
98
98
  });
99
99
  }, [e, ...s]);
100
- }, ht = (t) => {
101
- const s = lt(dt);
100
+ }, ft = (t) => {
101
+ const s = lt(ht);
102
102
  if (!s)
103
103
  throw new Error("useFrame must be used within a CanPlot component");
104
104
  return vt(
@@ -115,8 +115,8 @@ function It(t) {
115
115
  return (s) => {
116
116
  const e = [];
117
117
  for (const c of t) {
118
- const n = rt(c, s), o = typeof n == "function";
119
- e.push(o ? n : () => rt(c, null));
118
+ const o = rt(c, s), n = typeof o == "function";
119
+ e.push(n ? o : () => rt(c, null));
120
120
  }
121
121
  return () => {
122
122
  for (const c of e) c();
@@ -128,21 +128,21 @@ function rt(t, s) {
128
128
  return t(s);
129
129
  t && (t.current = s);
130
130
  }
131
- var Ft = parseInt(At.split(".")[0], 10) >= 19 ? It : Kt;
132
- const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) => {
133
- const o = L(null), a = L(null), l = Yt(a), d = St(Xt, []);
131
+ var Ft = parseInt(Mt.split(".")[0], 10) >= 19 ? It : Kt;
132
+ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) => {
133
+ const n = L(null), a = L(null), l = Yt(a), d = ut(Xt, []);
134
134
  J(() => {
135
135
  d.setState({
136
- _frame: Ot(t, l, o.current)
136
+ _frame: Ot(t, l, n.current)
137
137
  });
138
- }, [t, l, o, d]), J(() => d.subscribe((r) => {
138
+ }, [t, l, n, d]), J(() => d.subscribe((r) => {
139
139
  r._frame && $t(r._frame);
140
140
  }), [d]);
141
141
  const u = window.devicePixelRatio || 1;
142
142
  return /* @__PURE__ */ at(
143
143
  "div",
144
144
  {
145
- ref: Ft([n, a]),
145
+ ref: Ft([o, a]),
146
146
  className: c,
147
147
  style: {
148
148
  position: "relative",
@@ -154,7 +154,7 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
154
154
  /* @__PURE__ */ X(
155
155
  "canvas",
156
156
  {
157
- ref: o,
157
+ ref: n,
158
158
  width: l.width * u,
159
159
  height: l.height * u,
160
160
  style: {
@@ -169,13 +169,13 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
169
169
  ]
170
170
  }
171
171
  );
172
- }), zt = ({ frameStore: t, children: s }) => vt(t, (c) => !!c._frame) ? /* @__PURE__ */ X(dt.Provider, { value: t, children: s }) : null, Yt = (t) => {
172
+ }), zt = ({ frameStore: t, children: s }) => vt(t, (c) => !!c._frame) ? /* @__PURE__ */ X(ht.Provider, { value: t, children: s }) : null, Yt = (t) => {
173
173
  const [s, e] = N({
174
174
  width: 0,
175
175
  height: 0
176
- }), [c] = N(() => new ResizeObserver((n) => {
177
- for (const o of n) {
178
- const a = Math.round(o.contentRect.width), l = Math.round(o.contentRect.height);
176
+ }), [c] = N(() => new ResizeObserver((o) => {
177
+ for (const n of o) {
178
+ const a = Math.round(n.contentRect.width), l = Math.round(n.contentRect.height);
179
179
  e(
180
180
  (d) => d.width !== a || d.height !== l ? { ...d, width: a, height: l } : d
181
181
  );
@@ -183,35 +183,35 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
183
183
  }));
184
184
  return J(() => {
185
185
  if (!t.current) return;
186
- const n = t.current.clientWidth, o = t.current.clientHeight;
186
+ const o = t.current.clientWidth, n = t.current.clientHeight;
187
187
  return e(
188
- (a) => a.width !== n || a.height !== o ? { ...a, width: n, height: o } : a
188
+ (a) => a.width !== o || a.height !== n ? { ...a, width: o, height: n } : a
189
189
  ), c.observe(t.current, { box: "border-box" }), () => c.disconnect();
190
190
  }, [c, t]), s;
191
191
  }, Ot = (t, s, e) => {
192
192
  const c = e?.getContext("2d");
193
193
  if (!c) return null;
194
- const n = window.devicePixelRatio || 1;
194
+ const o = window.devicePixelRatio || 1;
195
195
  if (s.width === 0 || s.height === 0)
196
196
  return null;
197
- const o = {
197
+ const n = {
198
198
  x: t.padding.left,
199
199
  y: t.padding.top,
200
200
  width: s.width - t.padding.left - t.padding.right,
201
201
  height: s.height - t.padding.top - t.padding.bottom
202
202
  };
203
203
  for (const h of t.scales)
204
- h.axis && (h.origin === "x" ? (h.axis.position === "bottom" || h.axis.position === "top") && (o.height = Math.max(
204
+ h.axis && (h.origin === "x" ? (h.axis.position === "bottom" || h.axis.position === "top") && (n.height = Math.max(
205
205
  0,
206
- o.height - h.axis.size
207
- ), h.axis.position === "top" && (o.y += h.axis.size)) : (h.axis.position === "left" || h.axis.position === "right") && (o.width = Math.max(0, o.width - h.axis.size), h.axis.position === "left" && (o.x += h.axis.size)));
206
+ n.height - h.axis.size
207
+ ), h.axis.position === "top" && (n.y += h.axis.size)) : (h.axis.position === "left" || h.axis.position === "right") && (n.width = Math.max(0, n.width - h.axis.size), h.axis.position === "left" && (n.x += h.axis.size)));
208
208
  const a = {
209
- x: o.x * n,
210
- y: o.y * n,
211
- width: o.width * n,
212
- height: o.height * n
209
+ x: n.x * o,
210
+ y: n.y * o,
211
+ width: n.width * o,
212
+ height: n.height * o
213
213
  }, l = [];
214
- let d = t.padding.left * n, u = c.canvas.width - t.padding.right * n, r = c.canvas.height - t.padding.bottom * n, p = t.padding.top * n;
214
+ let d = t.padding.left * o, u = c.canvas.width - t.padding.right * o, r = c.canvas.height - t.padding.bottom * o, p = t.padding.top * o;
215
215
  for (const h of t.scales) {
216
216
  if (!h.axis) {
217
217
  l.push({ ...h, axis: null });
@@ -221,18 +221,18 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
221
221
  if (h.origin === "x")
222
222
  switch (h.axis.position) {
223
223
  case "bottom":
224
- r -= h.axis.size * n, i = {
225
- x: o.x,
226
- y: r / n,
227
- width: o.width,
224
+ r -= h.axis.size * o, i = {
225
+ x: n.x,
226
+ y: r / o,
227
+ width: n.width,
228
228
  height: h.axis.size
229
229
  };
230
230
  break;
231
231
  case "top":
232
- p += h.axis.size * n, i = {
233
- x: o.x,
234
- y: p / n - h.axis.size,
235
- width: o.width,
232
+ p += h.axis.size * o, i = {
233
+ x: n.x,
234
+ y: p / o - h.axis.size,
235
+ width: n.width,
236
236
  height: h.axis.size
237
237
  };
238
238
  break;
@@ -243,19 +243,19 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
243
243
  else
244
244
  switch (h.axis.position) {
245
245
  case "left":
246
- d += h.axis.size * n, i = {
247
- x: d / n - h.axis.size,
248
- y: o.y,
246
+ d += h.axis.size * o, i = {
247
+ x: d / o - h.axis.size,
248
+ y: n.y,
249
249
  width: h.axis.size,
250
- height: o.height
250
+ height: n.height
251
251
  };
252
252
  break;
253
253
  case "right":
254
- u -= h.axis.size * n, i = {
255
- x: u / n,
256
- y: o.y,
254
+ u -= h.axis.size * o, i = {
255
+ x: u / o,
256
+ y: n.y,
257
257
  width: h.axis.size,
258
- height: o.height
258
+ height: n.height
259
259
  };
260
260
  break;
261
261
  case "top":
@@ -263,10 +263,10 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
263
263
  throw new Error("Invalid axis position for y origin");
264
264
  }
265
265
  const m = {
266
- x: i.x * n,
267
- y: i.y * n,
268
- width: i.width * n,
269
- height: i.height * n
266
+ x: i.x * o,
267
+ y: i.y * o,
268
+ width: i.width * o,
269
+ height: i.height * o
270
270
  };
271
271
  l.push({
272
272
  ...h,
@@ -279,28 +279,28 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
279
279
  }
280
280
  return {
281
281
  ctx: c,
282
- dpr: n,
282
+ dpr: o,
283
283
  padding: t.padding,
284
284
  scales: l,
285
- chartAreaCSS: o,
285
+ chartAreaCSS: n,
286
286
  chartAreaCanvasPX: a
287
287
  };
288
288
  }, $t = (t) => {
289
289
  t.ctx.clearRect(0, 0, t.ctx.canvas.width, t.ctx.canvas.height), Dt(t);
290
290
  }, de = ({ data: t, xScaleId: s, yScaleId: e, style: c }) => (z(
291
- ({ getCtx: n, clampXPosToChartArea: o, clampYPosToChartArea: a, valToPos: l }) => {
292
- const d = n();
291
+ ({ getCtx: o, clampXPosToChartArea: n, clampYPosToChartArea: a, valToPos: l }) => {
292
+ const d = o();
293
293
  d.save(), d.beginPath(), R(d, c);
294
294
  for (const u of t) {
295
- const r = o(l(u.x, s)), p = a(l(u.y, e));
295
+ const r = n(l(u.x, s)), p = a(l(u.y, e));
296
296
  d.lineTo(r, p);
297
297
  }
298
298
  d.stroke(), d.restore();
299
299
  },
300
300
  [t, s, e, c]
301
- ), null), he = ({ data: t, xScaleId: s, yScaleId: e, radius: c = 5, style: n }) => (z(({ getCtx: o, valToPos: a, valFits: l }) => {
302
- const d = o();
303
- d.save(), d.beginPath(), R(d, n);
301
+ ), null), he = ({ data: t, xScaleId: s, yScaleId: e, radius: c = 5, style: o }) => (z(({ getCtx: n, valToPos: a, valFits: l }) => {
302
+ const d = n();
303
+ d.save(), d.beginPath(), R(d, o);
304
304
  for (const u of t) {
305
305
  if (!l(u.x, s) || !l(u.y, e))
306
306
  continue;
@@ -308,13 +308,13 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
308
308
  d.moveTo(r + c, p), d.arc(r, p, c, 0, Math.PI * 2);
309
309
  }
310
310
  d.stroke(), d.fill(), d.restore();
311
- }, [t, s, e, c, n]), null), fe = ({
311
+ }, [t, s, e, c, o]), null), fe = ({
312
312
  data: t,
313
313
  xScaleId: s,
314
314
  yScaleId: e,
315
315
  style: c,
316
- barWidth: n,
317
- xPositionOffset: o,
316
+ barWidth: o,
317
+ xPositionOffset: n,
318
318
  radius: a
319
319
  }) => (z(
320
320
  ({
@@ -327,37 +327,37 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
327
327
  if (t.length === 0) return;
328
328
  const f = l();
329
329
  f.save(), R(f, c);
330
- const h = d(n, s);
330
+ const h = d(o, s);
331
331
  f.beginPath();
332
332
  for (const i of t) {
333
- const y = u(i.x, s) - h / 2 + o * h, x = p(u(0, e)), v = p(u(i.y, e)), g = x - v, S = r(y), w = r(y + h) - S;
333
+ const y = u(i.x, s) - h / 2 + n * h, x = p(u(0, e)), v = p(u(i.y, e)), g = x - v, S = r(y), C = r(y + h) - S;
334
334
  a ? f.roundRect(
335
335
  S,
336
336
  v,
337
- w,
337
+ C,
338
338
  g,
339
339
  a
340
- ) : f.rect(S, v, w, g);
340
+ ) : f.rect(S, v, C, g);
341
341
  }
342
342
  f.closePath(), f.fill(), c?.strokeStyle && f.stroke(), f.restore();
343
343
  },
344
- [t, s, e, c, n, o, a]
345
- ), null), me = ({ data: t, xScaleId: s, yScaleId: e, style: c }) => (z(({ getCtx: n, clampXPosToChartArea: o, clampYPosToChartArea: a, valToPos: l }) => {
344
+ [t, s, e, c, o, n, a]
345
+ ), null), me = ({ data: t, xScaleId: s, yScaleId: e, style: c }) => (z(({ getCtx: o, clampXPosToChartArea: n, clampYPosToChartArea: a, valToPos: l }) => {
346
346
  const d = [];
347
347
  for (const r of t) {
348
- const p = o(l(r.x, s)), f = a(l(r.y[0], e)), h = a(l(r.y[1], e));
348
+ const p = n(l(r.x, s)), f = a(l(r.y[0], e)), h = a(l(r.y[1], e));
349
349
  d.push({ x: p, y: f }), d.unshift({ x: p, y: h });
350
350
  }
351
- const u = n();
351
+ const u = o();
352
352
  if (d.length > 0) {
353
353
  u.save(), u.beginPath(), R(u, c), u.moveTo(d[0].x, d[0].y);
354
354
  for (const r of d)
355
355
  u.lineTo(r.x, r.y);
356
356
  u.closePath(), u.fill(), u.restore();
357
357
  }
358
- }, [t, s, e, c]), null), pe = ({ data: t, stroked: s, xScaleId: e, yScaleId: c, style: n }) => (z(
359
- ({ getCtx: o, clampXPosToChartArea: a, clampYPosToChartArea: l, valToPos: d }) => {
360
- const u = [], r = o();
358
+ }, [t, s, e, c]), null), pe = ({ data: t, stroked: s, xScaleId: e, yScaleId: c, style: o }) => (z(
359
+ ({ getCtx: n, clampXPosToChartArea: a, clampYPosToChartArea: l, valToPos: d }) => {
360
+ const u = [], r = n();
361
361
  for (const i of t) {
362
362
  const m = a(d(i.x, e)), y = l(d(i.y, c));
363
363
  u.push({ x: m, y });
@@ -366,7 +366,7 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
366
366
  if (!p || !f)
367
367
  return;
368
368
  const h = l(d(0, c));
369
- r.save(), r.beginPath(), R(r, n), r.moveTo(p.x, h);
369
+ r.save(), r.beginPath(), R(r, o), r.moveTo(p.x, h);
370
370
  for (const i of u)
371
371
  r.lineTo(i.x, i.y);
372
372
  if (r.lineTo(f.x, h), r.closePath(), r.fill(), s) {
@@ -377,13 +377,13 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
377
377
  }
378
378
  r.restore();
379
379
  },
380
- [t, s, e, c, n]
381
- ), null), ye = (t, s) => ht(
380
+ [t, s, e, c, o]
381
+ ), null), ye = (t, s) => ft(
382
382
  ({
383
383
  clampXPosToChartArea: e,
384
384
  clampYPosToChartArea: c,
385
- getScale: n,
386
- valToPos: o,
385
+ getScale: o,
386
+ valToPos: n,
387
387
  valFits: a
388
388
  }) => {
389
389
  const l = {};
@@ -392,32 +392,32 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
392
392
  switch (u.exceeding) {
393
393
  case "discard": {
394
394
  if (a(u.value, u.scaleId)) {
395
- const r = o(u.value, u.scaleId, s);
395
+ const r = n(u.value, u.scaleId, s);
396
396
  l[d] = r;
397
397
  }
398
398
  break;
399
399
  }
400
400
  case "clamp": {
401
- const r = o(u.value, u.scaleId, s);
402
- l[d] = n(u.scaleId)?.origin === "x" ? e(r, s) : c(r, s);
401
+ const r = n(u.value, u.scaleId, s);
402
+ l[d] = o(u.scaleId)?.origin === "x" ? e(r, s) : c(r, s);
403
403
  break;
404
404
  }
405
405
  }
406
406
  }
407
407
  return l;
408
408
  }
409
- ), xe = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: c, tickSize: n, ticks: o }) => (z(
409
+ ), xe = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: c, tickSize: o, ticks: n }) => (z(
410
410
  ({ getCtx: a, valToPos: l, getScale: d, getFrame: u }) => {
411
411
  const r = a(), p = d(t);
412
412
  if (!p || !p.axis || p.origin !== "x") return;
413
- const f = p.axis, h = f.position === "top" ? f.canvasRect.y + f.canvasRect.height : f.canvasRect.y, i = window.devicePixelRatio || 1, m = h, y = (n ?? 6) * i, x = f.position === "top" ? h - y : h + y, v = (c ?? 12) * i;
413
+ const f = p.axis, h = f.position === "top" ? f.canvasRect.y + f.canvasRect.height : f.canvasRect.y, i = window.devicePixelRatio || 1, m = h, y = (o ?? 6) * i, x = f.position === "top" ? h - y : h + y, v = (c ?? 12) * i;
414
414
  r.save(), r.fontKerning = "auto", R(r, {
415
415
  ...s
416
416
  }), r.beginPath();
417
- const g = Array.isArray(o) ? o : o({ ...p, axis: f }, u());
417
+ const g = Array.isArray(n) ? n : n({ ...p, axis: f }, u());
418
418
  for (const { value: S } of g) {
419
- const w = l(S, t, "canvas");
420
- r.moveTo(w, m), r.lineTo(w, x);
419
+ const C = l(S, t, "canvas");
420
+ r.moveTo(C, m), r.lineTo(C, x);
421
421
  }
422
422
  r.stroke(), r.restore(), r.save(), R(r, {
423
423
  textBaseline: f.position === "top" ? "bottom" : "top",
@@ -425,24 +425,24 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
425
425
  ...s,
426
426
  ...e
427
427
  });
428
- for (const { value: S, label: w } of g) {
429
- const b = l(S, t, "canvas"), k = w.split(`
428
+ for (const { value: S, label: C } of g) {
429
+ const w = l(S, t, "canvas"), b = C.split(`
430
430
  `);
431
- for (let C = 0; C < k.length; C++)
432
- r.fillText(k[C], b, x + i * 2 + C * v);
431
+ for (let k = 0; k < b.length; k++)
432
+ r.fillText(b[k], w, x + i * 2 + k * v);
433
433
  }
434
434
  r.restore();
435
435
  },
436
- [o, t, s, e]
437
- ), null), ge = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: c, tickSize: n, ticks: o }) => (z(
436
+ [n, t, s, e]
437
+ ), null), ge = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: c, tickSize: o, ticks: n }) => (z(
438
438
  ({ getCtx: a, valToPos: l, getScale: d, getFrame: u }) => {
439
439
  const r = a(), p = d(t);
440
440
  if (!p || !p.axis || p.origin !== "y") return;
441
- const f = p.axis, h = f.position === "left" ? f.canvasRect.x + f.canvasRect.width : f.canvasRect.x, i = window.devicePixelRatio || 1, m = h, y = (n ?? 6) * i, x = f.position === "left" ? h - y : h + y, v = (c ?? 12) * i, g = Array.isArray(o) ? o : o({ ...p, axis: f }, u());
441
+ const f = p.axis, h = f.position === "left" ? f.canvasRect.x + f.canvasRect.width : f.canvasRect.x, i = h, m = o ?? 6, y = f.position === "left" ? h - m : h + m, x = c ?? 12, v = Array.isArray(n) ? n : n({ ...p, axis: f }, u());
442
442
  r.save(), r.fontKerning = "auto", R(r, { ...s }), r.beginPath();
443
- for (const { value: S } of g) {
444
- const w = l(S, t, "canvas");
445
- r.moveTo(m, w), r.lineTo(x, w);
443
+ for (const { value: g } of v) {
444
+ const S = l(g, t, "canvas");
445
+ r.moveTo(i, S), r.lineTo(y, S);
446
446
  }
447
447
  r.stroke(), r.restore(), r.save(), R(r, {
448
448
  textBaseline: "middle",
@@ -450,15 +450,15 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
450
450
  ...s,
451
451
  ...e
452
452
  });
453
- for (const { value: S, label: w } of g) {
454
- const b = l(S, t, "canvas"), k = w.split(`
453
+ for (const { value: g, label: S } of v) {
454
+ const C = l(g, t, "canvas"), w = S.split(`
455
455
  `);
456
- for (let C = 0; C < k.length; C++)
457
- r.fillText(` ${k[C]} `, x, b + C * v);
456
+ for (let b = 0; b < w.length; b++)
457
+ r.fillText(` ${w[b]} `, y, C + b * x);
458
458
  }
459
459
  r.restore();
460
460
  },
461
- [o, t, s, e]
461
+ [n, t, s, e]
462
462
  ), null), E = () => {
463
463
  const t = [];
464
464
  return {
@@ -466,7 +466,7 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
466
466
  syncKey: s,
467
467
  callback: e
468
468
  }), () => {
469
- const c = t.findIndex((n) => n.callback === e);
469
+ const c = t.findIndex((o) => o.callback === e);
470
470
  c !== -1 && t.splice(c, 1);
471
471
  }),
472
472
  dispatchEvent: (s, e) => {
@@ -490,25 +490,25 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
490
490
  sync_mouseup: E(),
491
491
  sync_spanselect: E(),
492
492
  sync_pressandwheel: E()
493
- }, M = (t, s, e) => {
493
+ }, P = (t, s, e) => {
494
494
  const c = Z.useRef(e);
495
495
  c.current = e, Z.useEffect(() => T[t].addEventListener(
496
496
  s,
497
- (o, a) => {
498
- c.current(a, o);
497
+ (n, a) => {
498
+ c.current(a, n);
499
499
  }
500
500
  ), [s, t, c]);
501
- }, ft = Z.createContext(""), mt = (t, s) => {
502
- const e = Z.useContext(ft);
503
- return M(t, e, s);
504
- }, Bt = (t, s, e, c, n) => {
501
+ }, mt = Z.createContext(""), pt = (t, s) => {
502
+ const e = Z.useContext(mt);
503
+ return P(t, e, s);
504
+ }, Bt = (t, s, e, c, o) => {
505
505
  if (!s) return;
506
- const o = c ?? e.scales.find((p) => p.origin === "x")?.id, a = n ?? e.scales.find((p) => p.origin === "y")?.id;
507
- if (!o || !a)
506
+ const n = c ?? e.scales.find((p) => p.origin === "x")?.id, a = o ?? e.scales.find((p) => p.origin === "y")?.id;
507
+ if (!n || !a)
508
508
  return;
509
509
  const l = t.clientX - s.left, d = {
510
- scaleId: o,
511
- value: D(e, l, o, "css")
510
+ scaleId: n,
511
+ value: D(e, l, n, "css")
512
512
  }, u = t.clientY - s.top, r = {
513
513
  scaleId: a,
514
514
  value: D(e, u, a, "css")
@@ -530,13 +530,13 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
530
530
  cssX: e,
531
531
  cssY: c,
532
532
  scaled: Object.fromEntries(
533
- s.scales.map((n) => {
534
- const o = n.origin === "y" ? c : e;
535
- return [n.id, D(s, o, n.id, "css")];
533
+ s.scales.map((o) => {
534
+ const n = o.origin === "y" ? c : e;
535
+ return [o.id, D(s, n, o.id, "css")];
536
536
  })
537
537
  )
538
538
  };
539
- }, xt = (t, s, e) => {
539
+ }, gt = (t, s, e) => {
540
540
  if (!s) {
541
541
  const a = t === "x" ? e.chartAreaCSS.x : e.chartAreaCSS.y, l = t === "x" ? e.chartAreaCSS.x + e.chartAreaCSS.width : e.chartAreaCSS.y + e.chartAreaCSS.height;
542
542
  return {
@@ -545,7 +545,7 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
545
545
  scaled: e.scales.flatMap((d) => {
546
546
  if (d.origin !== t)
547
547
  return [];
548
- const { min: u, max: r } = P(e, d.id);
548
+ const { min: u, max: r } = A(e, d.id);
549
549
  return [{ scaleId: d.id, from: u, to: r }];
550
550
  })
551
551
  };
@@ -555,16 +555,16 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
555
555
  s.from,
556
556
  s.scaleId,
557
557
  "css"
558
- ), n = j(
558
+ ), o = j(
559
559
  e,
560
560
  s.to,
561
561
  s.scaleId,
562
562
  "css"
563
- ), o = e.scales.flatMap(
563
+ ), n = e.scales.flatMap(
564
564
  (a) => {
565
565
  if (a.origin !== t)
566
566
  return [];
567
- const l = D(e, c, a.id, "css"), d = D(e, n, a.id, "css");
567
+ const l = D(e, c, a.id, "css"), d = D(e, o, a.id, "css");
568
568
  return [
569
569
  {
570
570
  scaleId: a.id,
@@ -576,16 +576,16 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
576
576
  );
577
577
  return {
578
578
  fromCSS: c,
579
- toCSS: n,
580
- scaled: o
579
+ toCSS: o,
580
+ scaled: n
581
581
  };
582
582
  }, Se = ({
583
583
  id: t,
584
584
  onClick: s,
585
585
  onDblClick: e,
586
586
  onMouseMove: c,
587
- onMouseDown: n,
588
- onMouseUp: o,
587
+ onMouseDown: o,
588
+ onMouseUp: n,
589
589
  onDocumentMouseUp: a,
590
590
  onSpanSelect: l,
591
591
  className: d,
@@ -594,21 +594,21 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
594
594
  children: p
595
595
  }) => {
596
596
  const f = Rt(), h = t || f;
597
- return M("dblclick", h, (i) => {
597
+ return P("dblclick", h, (i) => {
598
598
  e?.(i);
599
- }), M("click", h, (i) => {
599
+ }), P("click", h, (i) => {
600
600
  s?.(i);
601
- }), M("move", h, (i) => {
601
+ }), P("move", h, (i) => {
602
602
  c?.(i);
603
- }), M("mousedown", h, (i) => {
604
- n?.(i);
605
- }), M("mouseup", h, (i) => {
603
+ }), P("mousedown", h, (i) => {
606
604
  o?.(i);
607
- }), M("documentmouseup", h, (i) => {
605
+ }), P("mouseup", h, (i) => {
606
+ n?.(i);
607
+ }), P("documentmouseup", h, (i) => {
608
608
  a?.(i);
609
- }), M("spanselect", h, (i) => {
609
+ }), P("spanselect", h, (i) => {
610
610
  l?.(i);
611
- }), /* @__PURE__ */ at(ft.Provider, { value: h, children: [
611
+ }), /* @__PURE__ */ at(mt.Provider, { value: h, children: [
612
612
  /* @__PURE__ */ X(
613
613
  Nt,
614
614
  {
@@ -620,9 +620,9 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
620
620
  p
621
621
  ] });
622
622
  }, Nt = ({ className: t, style: s, sync: e }) => {
623
- const c = L(null), n = ht(), o = L(n);
624
- o.current = n;
625
- const a = lt(ft), l = e?.key || a, d = L(null), u = L(null), r = L(null), p = () => {
623
+ const c = L(null), o = ft(), n = L(o);
624
+ n.current = o;
625
+ const a = lt(mt), l = e?.key || a, d = L(null), u = L(null), r = L(null), p = () => {
626
626
  const i = c.current?.parentElement;
627
627
  if (i) {
628
628
  if (i.dataset.canplotroot === void 0)
@@ -635,7 +635,7 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
635
635
  const y = Bt(
636
636
  i,
637
637
  p(),
638
- o.current,
638
+ n.current,
639
639
  e?.xViaScaleId,
640
640
  e?.yViaScaleId
641
641
  );
@@ -657,7 +657,7 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
657
657
  ...S,
658
658
  completed: !0
659
659
  }), T.documentmouseup.dispatchEvent(l, {
660
- frame: o.current,
660
+ frame: n.current,
661
661
  keys: {
662
662
  ctrlKey: g.ctrlKey,
663
663
  altKey: g.altKey,
@@ -671,49 +671,49 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
671
671
  altKey: g.altKey,
672
672
  shiftKey: g.shiftKey,
673
673
  metaKey: g.metaKey
674
- }, w = r.current;
675
- if (w && Object.entries(S).some(
676
- ([k, C]) => w.keys[k] !== C
674
+ }, C = r.current;
675
+ if (C && Object.entries(S).some(
676
+ ([b, k]) => C.keys[b] !== k
677
677
  )) {
678
- const k = { ...w, keys: S };
679
- r.current = k, T.sync_move.dispatchEvent(l, k);
678
+ const b = { ...C, keys: S };
679
+ r.current = b, T.sync_move.dispatchEvent(l, b);
680
680
  }
681
- const b = u.current;
682
- if (b && Object.entries(S).some(
683
- ([k, C]) => b.keys[k] !== C
681
+ const w = u.current;
682
+ if (w && Object.entries(S).some(
683
+ ([b, k]) => w.keys[b] !== k
684
684
  )) {
685
685
  g.stopPropagation(), g.preventDefault();
686
- const k = { ...b, keys: S };
687
- u.current = k, T.sync_spanselect.dispatchEvent(
686
+ const b = { ...w, keys: S };
687
+ u.current = b, T.sync_spanselect.dispatchEvent(
688
688
  l,
689
- k
689
+ b
690
690
  );
691
691
  }
692
692
  }, y = (g) => {
693
693
  h.current(
694
694
  g,
695
- (S, { cssX: w, cssY: b }, k) => {
696
- const C = d.current;
697
- if (!C || !S.x || !S.y) return;
698
- const _ = o.current, A = C.xRangeCss.start, B = w, F = C.yRangeCss.start, et = b, st = P(_, S.x.scaleId), nt = P(_, S.y.scaleId);
695
+ (S, { cssX: C, cssY: w }, b) => {
696
+ const k = d.current;
697
+ if (!k || !S.x || !S.y) return;
698
+ const _ = n.current, M = k.xRangeCss.start, B = C, F = k.yRangeCss.start, et = w, st = A(_, S.x.scaleId), nt = A(_, S.y.scaleId);
699
699
  d.current = {
700
- xRangeCss: { start: A, end: B },
700
+ xRangeCss: { start: M, end: B },
701
701
  yRangeCss: { start: F, end: et }
702
702
  };
703
703
  let U = "none";
704
- const ot = Math.abs(F - et), ct = Math.abs(A - B);
704
+ const ot = Math.abs(F - et), ct = Math.abs(M - B);
705
705
  ot < 10 && ct < 10 ? U = "none" : ot > 30 && ct > 30 ? U = "box" : ot > ct ? U = "y" : U = "x";
706
706
  const Tt = U === "x" || U === "box" ? {
707
707
  scaleId: st.id,
708
708
  from: D(
709
709
  _,
710
- O(o.current, A, "css"),
710
+ O(n.current, M, "css"),
711
711
  st.id,
712
712
  "css"
713
713
  ),
714
714
  to: D(
715
715
  _,
716
- O(o.current, B, "css"),
716
+ O(n.current, B, "css"),
717
717
  st.id,
718
718
  "css"
719
719
  )
@@ -721,40 +721,40 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
721
721
  scaleId: nt.id,
722
722
  from: D(
723
723
  _,
724
- $(o.current, F, "css"),
724
+ $(n.current, F, "css"),
725
725
  nt.id,
726
726
  "css"
727
727
  ),
728
728
  to: D(
729
729
  _,
730
- $(o.current, et, "css"),
730
+ $(n.current, et, "css"),
731
731
  nt.id,
732
732
  "css"
733
733
  )
734
- } : void 0, yt = {
734
+ } : void 0, xt = {
735
735
  mode: U,
736
736
  xRange: Tt,
737
737
  yRange: kt,
738
738
  completed: !1,
739
- keys: k
739
+ keys: b
740
740
  };
741
- u.current = yt, T.sync_spanselect.dispatchEvent(
741
+ u.current = xt, T.sync_spanselect.dispatchEvent(
742
742
  l,
743
- yt
743
+ xt
744
744
  );
745
745
  }
746
746
  );
747
747
  }, x = (g) => {
748
- h.current(g, (S, w, b) => {
749
- if (Object.values(b).some((C) => C)) {
748
+ h.current(g, (S, C, w) => {
749
+ if (Object.values(w).some((k) => k)) {
750
750
  g.preventDefault();
751
- const C = Math.abs(g.deltaY) > Math.abs(g.deltaX) ? g.deltaY : g.deltaX;
751
+ const k = Math.abs(g.deltaY) > Math.abs(g.deltaX) ? g.deltaY : g.deltaX;
752
752
  T.sync_pressandwheel.dispatchEvent(l, {
753
753
  positions: S,
754
- keys: b,
754
+ keys: w,
755
755
  deltaX: g.deltaX,
756
756
  deltaY: g.deltaY,
757
- deltaAbs: C
757
+ deltaAbs: k
758
758
  });
759
759
  }
760
760
  });
@@ -766,66 +766,66 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
766
766
  }), () => {
767
767
  document.removeEventListener("mouseup", i), document.removeEventListener("keydown", m), document.removeEventListener("keyup", m), document.removeEventListener("mousemove", y), v?.removeEventListener("wheel", x);
768
768
  };
769
- }, [o, l, h]), M("sync_dblclick", l, (i) => {
769
+ }, [n, l, h]), P("sync_dblclick", l, (i) => {
770
770
  const m = Y(
771
771
  i.positions,
772
- o.current
772
+ n.current
773
773
  );
774
774
  m && T.dblclick.dispatchEvent(a, {
775
- frame: o.current,
775
+ frame: n.current,
776
776
  pointer: m,
777
777
  keys: i.keys
778
778
  });
779
- }), M("sync_click", l, (i) => {
779
+ }), P("sync_click", l, (i) => {
780
780
  const m = Y(
781
781
  i.positions,
782
- o.current
782
+ n.current
783
783
  );
784
784
  m && T.click.dispatchEvent(a, {
785
- frame: o.current,
785
+ frame: n.current,
786
786
  pointer: m,
787
787
  keys: i.keys
788
788
  });
789
- }), M("sync_move", l, (i) => {
789
+ }), P("sync_move", l, (i) => {
790
790
  const m = i.positions ? Y(
791
791
  i.positions,
792
- o.current
792
+ n.current
793
793
  ) : null;
794
794
  r.current = i, T.move.dispatchEvent(a, {
795
- frame: o.current,
795
+ frame: n.current,
796
796
  pointer: m ?? null,
797
797
  keys: i.keys
798
798
  });
799
- }), M("sync_mousedown", l, (i) => {
799
+ }), P("sync_mousedown", l, (i) => {
800
800
  const m = Y(
801
801
  i.positions,
802
- o.current
802
+ n.current
803
803
  );
804
804
  m && T.mousedown.dispatchEvent(a, {
805
- frame: o.current,
805
+ frame: n.current,
806
806
  pointer: m,
807
807
  keys: i.keys
808
808
  });
809
- }), M("sync_mouseup", l, (i) => {
809
+ }), P("sync_mouseup", l, (i) => {
810
810
  const m = Y(
811
811
  i.positions,
812
- o.current
812
+ n.current
813
813
  );
814
814
  m && T.mouseup.dispatchEvent(a, {
815
- frame: o.current,
815
+ frame: n.current,
816
816
  pointer: m,
817
817
  keys: i.keys
818
818
  });
819
- }), M(
819
+ }), P(
820
820
  "sync_pressandwheel",
821
821
  l,
822
822
  (i) => {
823
823
  const m = Y(
824
824
  i.positions,
825
- o.current
825
+ n.current
826
826
  );
827
827
  m && T.pressandwheel.dispatchEvent(a, {
828
- frame: o.current,
828
+ frame: n.current,
829
829
  pointer: m,
830
830
  keys: i.keys,
831
831
  deltaX: i.deltaX,
@@ -833,19 +833,19 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
833
833
  deltaAbs: i.deltaAbs
834
834
  });
835
835
  }
836
- ), M("sync_spanselect", l, (i) => {
837
- const m = xt(
836
+ ), P("sync_spanselect", l, (i) => {
837
+ const m = gt(
838
838
  "x",
839
839
  i.xRange,
840
- o.current
841
- ), y = xt(
840
+ n.current
841
+ ), y = gt(
842
842
  "y",
843
843
  i.yRange,
844
- o.current
844
+ n.current
845
845
  ), x = m.scaled, v = y.scaled;
846
846
  i.completed && (d.current = null), T.spanselect.dispatchEvent(a, {
847
847
  mode: i.mode,
848
- frame: o.current,
848
+ frame: n.current,
849
849
  xRanges: x,
850
850
  yRanges: v,
851
851
  completed: i.completed,
@@ -861,10 +861,10 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
861
861
  className: t,
862
862
  style: {
863
863
  position: "absolute",
864
- left: n.chartAreaCSS.x,
865
- top: n.chartAreaCSS.y,
866
- width: n.chartAreaCSS.width,
867
- height: n.chartAreaCSS.height,
864
+ left: o.chartAreaCSS.x,
865
+ top: o.chartAreaCSS.y,
866
+ width: o.chartAreaCSS.width,
867
+ height: o.chartAreaCSS.height,
868
868
  zIndex: 25,
869
869
  ...s
870
870
  },
@@ -936,11 +936,11 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
936
936
  }
937
937
  );
938
938
  }, ve = ({ data: t, renderTooltip: s, xScaleId: e }) => {
939
- const [c, n] = N(null);
940
- mt("move", (a) => {
941
- n(a);
939
+ const [c, o] = N(null);
940
+ pt("move", (a) => {
941
+ o(a);
942
942
  });
943
- const o = St(() => {
943
+ const n = ut(() => {
944
944
  if (!c)
945
945
  return null;
946
946
  const { frame: a, pointer: l } = c, d = l?.scaled[e];
@@ -957,7 +957,7 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
957
957
  x < h && (h = x, f = m);
958
958
  }
959
959
  const i = p.points[f ?? -1];
960
- if (!i || ut(a, h, e, "css") > 30) {
960
+ if (!i || dt(a, h, e, "css") > 30) {
961
961
  u.push({ seriesId: p.seriesId, y: null });
962
962
  continue;
963
963
  }
@@ -972,20 +972,20 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
972
972
  points: u
973
973
  };
974
974
  }, [t, c, e]);
975
- return s(o);
975
+ return s(n);
976
976
  }, we = ({ makeXStyle: t, makeXClassName: s, makeYStyle: e, makeYClassName: c }) => {
977
- const [n, o] = N(null);
978
- if (mt("move", (r) => {
979
- o(r);
980
- }), !n)
977
+ const [o, n] = N(null);
978
+ if (pt("move", (r) => {
979
+ n(r);
980
+ }), !o)
981
981
  return null;
982
- const { frame: a, pointer: l } = n, d = O(a, l?.cssX ?? 0, "css"), u = $(a, l?.cssY ?? 0, "css");
982
+ const { frame: a, pointer: l } = o, d = O(a, l?.cssX ?? 0, "css"), u = $(a, l?.cssY ?? 0, "css");
983
983
  return /* @__PURE__ */ at(Et, { children: [
984
984
  /* @__PURE__ */ X(
985
985
  "div",
986
986
  {
987
987
  "data-show": !!l,
988
- className: s?.(n),
988
+ className: s?.(o),
989
989
  style: {
990
990
  position: "absolute",
991
991
  left: 0,
@@ -997,14 +997,14 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
997
997
  pointerEvents: "none",
998
998
  opacity: l ? 1 : 0,
999
999
  transform: `translateX(${d}px)`,
1000
- ...t?.(n)
1000
+ ...t?.(o)
1001
1001
  }
1002
1002
  }
1003
1003
  ),
1004
1004
  /* @__PURE__ */ X(
1005
1005
  "div",
1006
1006
  {
1007
- className: c?.(n),
1007
+ className: c?.(o),
1008
1008
  "data-show": !!l,
1009
1009
  style: {
1010
1010
  position: "absolute",
@@ -1016,80 +1016,84 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
1016
1016
  pointerEvents: "none",
1017
1017
  opacity: l ? 1 : 0,
1018
1018
  transform: `translateY(${u}px)`,
1019
- ...e?.(n)
1019
+ ...e?.(o)
1020
1020
  }
1021
1021
  }
1022
1022
  )
1023
1023
  ] });
1024
- }, Ce = ({ makeClassName: t, makeStyle: s }) => {
1024
+ }, be = ({ makeClassName: t, makeStyle: s }) => {
1025
1025
  const [e, c] = N(null);
1026
- if (mt("spanselect", (f) => {
1027
- c(f.mode === "none" || f.completed ? null : f);
1028
- }), !e)
1029
- return null;
1030
- const n = O(
1031
- e.frame,
1032
- e.x.fromCSS,
1033
- "css"
1034
- ), o = O(
1035
- e.frame,
1036
- e.x.toCSS,
1037
- "css"
1038
- ), a = $(
1039
- e.frame,
1040
- e.y.fromCSS,
1041
- "css"
1042
- ), l = $(
1043
- e.frame,
1044
- e.y.toCSS,
1045
- "css"
1046
- ), d = Math.min(n, o), u = Math.min(a, l), r = Math.abs(o - n), p = Math.abs(l - a);
1026
+ pt("spanselect", (n) => {
1027
+ c(n.mode === "none" || n.completed ? null : n);
1028
+ });
1029
+ const o = ut(() => {
1030
+ if (!e)
1031
+ return null;
1032
+ const n = O(
1033
+ e.frame,
1034
+ e.x.fromCSS,
1035
+ "css"
1036
+ ), a = O(
1037
+ e.frame,
1038
+ e.x.toCSS,
1039
+ "css"
1040
+ ), l = $(
1041
+ e.frame,
1042
+ e.y.fromCSS,
1043
+ "css"
1044
+ ), d = $(
1045
+ e.frame,
1046
+ e.y.toCSS,
1047
+ "css"
1048
+ ), u = Math.min(n, a), r = Math.min(l, d), p = Math.abs(a - n), f = Math.abs(d - l);
1049
+ return { leftPx: u, topPx: r, widthPx: p, heightPx: f };
1050
+ }, [e]);
1047
1051
  return /* @__PURE__ */ X(
1048
1052
  "div",
1049
1053
  {
1050
- className: t?.(e),
1054
+ className: e ? t?.(e) : void 0,
1051
1055
  style: {
1052
1056
  position: "absolute",
1053
- backgroundColor: "#0000ff22",
1054
- left: `${d}px`,
1055
- top: `${u}px`,
1056
- width: `${r}px`,
1057
- height: `${p}px`,
1057
+ visibility: e ? "visible" : "hidden",
1058
+ left: `${o?.leftPx ?? 0}px`,
1059
+ top: `${o?.topPx ?? 0}px`,
1060
+ width: `${o?.widthPx ?? 0}px`,
1061
+ height: `${o?.heightPx ?? 0}px`,
1058
1062
  pointerEvents: "none",
1059
- ...s?.(e)
1063
+ ...e ? s?.(e) : void 0
1060
1064
  }
1061
1065
  }
1062
1066
  );
1063
- }, be = ({ style: t, children: s, scaleId: e, ...c }) => {
1064
- const n = ht((o) => o.getScale(e)?.axis);
1065
- return n ? /* @__PURE__ */ X(
1067
+ }, Ce = ({ style: t, children: s, scaleId: e, ...c }) => {
1068
+ const o = ft((n) => n.getScale(e)?.axis);
1069
+ return o ? /* @__PURE__ */ X(
1066
1070
  "div",
1067
1071
  {
1068
1072
  style: {
1069
1073
  position: "absolute",
1070
1074
  backgroundColor: "#0000ff11",
1071
- left: n.cssRect.x,
1072
- top: n.cssRect.y,
1073
- height: n.cssRect.height,
1074
- width: n.cssRect.width,
1075
+ left: o.cssRect.x,
1076
+ top: o.cssRect.y,
1077
+ height: o.cssRect.height,
1078
+ width: o.cssRect.width,
1075
1079
  ...t
1076
1080
  },
1077
1081
  ...c,
1078
1082
  children: s
1079
1083
  }
1080
1084
  ) : null;
1081
- }, wt = 60, Vt = 30, Ct = "UTC", jt = "en-GB", Te = ({
1085
+ }, wt = 60, Vt = 30, bt = "UTC", jt = "en-GB", Te = ({
1082
1086
  space: t,
1083
1087
  formatter: s
1084
1088
  } = {}) => (e, c) => {
1085
- const { min: n, max: o } = e, a = [], l = window.devicePixelRatio || 1, d = (t ?? (e.origin === "x" ? wt : Vt)) * l, u = Lt(
1089
+ const { min: o, max: n } = e, a = [], l = window.devicePixelRatio || 1, d = (t ?? (e.origin === "x" ? wt : Vt)) * l, u = Lt(
1086
1090
  c,
1087
1091
  d,
1088
1092
  e.id,
1089
1093
  "canvas"
1090
1094
  ), r = H.find((f) => f > u) ?? 1;
1091
- let p = n % r < Number.EPSILON ? n : n + r - n % r;
1092
- for (; p <= o; )
1095
+ let p = o % r < Number.EPSILON ? o : o + r - o % r;
1096
+ for (; p <= n; )
1093
1097
  a.push(p), p += r;
1094
1098
  return (s ?? Ht)(a);
1095
1099
  }, Ht = (t) => {
@@ -1098,7 +1102,7 @@ const ue = Pt(({ configuration: t, children: s, style: e, className: c }, n) =>
1098
1102
  }, H = [];
1099
1103
  for (let t = -12; t <= 12; t++)
1100
1104
  H.push(1 * 10 ** t), H.push(2 * 10 ** t), H.push(5 * 10 ** t);
1101
- const Wt = 1, bt = 1e3 * Wt, pt = 60 * bt, q = 60 * pt, tt = 24 * q, Gt = 30 * tt, Zt = 365 * tt, Jt = [
1105
+ const Wt = 1, Ct = 1e3 * Wt, yt = 60 * Ct, q = 60 * yt, tt = 24 * q, Gt = 30 * tt, Zt = 365 * tt, Jt = [
1102
1106
  // second divisors
1103
1107
  [1, "milliseconds"],
1104
1108
  [2, "milliseconds"],
@@ -1156,9 +1160,9 @@ const Wt = 1, bt = 1e3 * Wt, pt = 60 * bt, q = 60 * pt, tt = 24 * q, Gt = 30 * t
1156
1160
  case "milliseconds":
1157
1161
  return s;
1158
1162
  case "seconds":
1159
- return s * bt;
1163
+ return s * Ct;
1160
1164
  case "minutes":
1161
- return s * pt;
1165
+ return s * yt;
1162
1166
  case "hours":
1163
1167
  return s * q;
1164
1168
  case "days":
@@ -1183,7 +1187,7 @@ const Wt = 1, bt = 1e3 * Wt, pt = 60 * bt, q = 60 * pt, tt = 24 * q, Gt = 30 * t
1183
1187
  }, se = (t, s) => {
1184
1188
  const e = new Date(t);
1185
1189
  return e.setUTCDate(e.getUTCDate() + s), e.getTime();
1186
- }, gt = (t, s) => {
1190
+ }, St = (t, s) => {
1187
1191
  const e = new Date(t);
1188
1192
  return e.setUTCMonth(e.getUTCMonth() + s), e.getTime();
1189
1193
  }, I = (t, s) => {
@@ -1200,43 +1204,43 @@ const Wt = 1, bt = 1e3 * Wt, pt = 60 * bt, q = 60 * pt, tt = 24 * q, Gt = 30 * t
1200
1204
  case "days":
1201
1205
  return se(t, e);
1202
1206
  case "months":
1203
- return gt(t, e);
1207
+ return St(t, e);
1204
1208
  case "years":
1205
- return gt(t, e * 12);
1209
+ return St(t, e * 12);
1206
1210
  }
1207
1211
  };
1208
1212
  function G(t, s) {
1209
- const e = new Date(t), c = new Date(e.toLocaleString("en-US", { timeZone: s })), n = new Date(e.toLocaleString("en-US", { timeZone: "UTC" }));
1210
- return (c.getTime() - n.getTime()) / (3600 * 1e3);
1213
+ const e = new Date(t), c = new Date(e.toLocaleString("en-US", { timeZone: s })), o = new Date(e.toLocaleString("en-US", { timeZone: "UTC" }));
1214
+ return (c.getTime() - o.getTime()) / (3600 * 1e3);
1211
1215
  }
1212
1216
  const ne = (t, s, e = "UTC") => {
1213
- const [c, n] = s;
1214
- let o = new Date(t);
1217
+ const [c, o] = s;
1218
+ let n = new Date(t);
1215
1219
  const a = () => {
1216
- o.setUTCHours(-G(o, e), 0, 0, 0);
1220
+ n.setUTCHours(-G(n, e), 0, 0, 0);
1217
1221
  };
1218
- switch (n) {
1222
+ switch (o) {
1219
1223
  case "milliseconds":
1220
- o.setUTCMilliseconds(
1221
- Math.ceil(o.getUTCMilliseconds() / c) * c
1224
+ n.setUTCMilliseconds(
1225
+ Math.ceil(n.getUTCMilliseconds() / c) * c
1222
1226
  );
1223
1227
  break;
1224
1228
  case "seconds":
1225
- o.setUTCSeconds(
1226
- Math.ceil(o.getUTCSeconds() / c) * c,
1229
+ n.setUTCSeconds(
1230
+ Math.ceil(n.getUTCSeconds() / c) * c,
1227
1231
  0
1228
1232
  );
1229
1233
  break;
1230
1234
  case "minutes":
1231
- o.setUTCMinutes(
1232
- Math.ceil(o.getTime() % q / pt / c) * c,
1235
+ n.setUTCMinutes(
1236
+ Math.ceil(n.getTime() % q / yt / c) * c,
1233
1237
  0,
1234
1238
  0
1235
1239
  );
1236
1240
  break;
1237
1241
  case "hours":
1238
- o.setUTCHours(
1239
- Math.ceil(o.getTime() % tt / q / c) * c,
1242
+ n.setUTCHours(
1243
+ Math.ceil(n.getTime() % tt / q / c) * c,
1240
1244
  0,
1241
1245
  0,
1242
1246
  0
@@ -1245,18 +1249,18 @@ const ne = (t, s, e = "UTC") => {
1245
1249
  case "days":
1246
1250
  case "months":
1247
1251
  case "years":
1248
- n === "months" ? o.setUTCDate(1) : n === "years" && o.setUTCMonth(0, 1), a(), o.getTime() < t && (o = new Date(I(o, [1, n])));
1252
+ o === "months" ? n.setUTCDate(1) : o === "years" && n.setUTCMonth(0, 1), a(), n.getTime() < t && (n = new Date(I(n, [1, o])));
1249
1253
  break;
1250
1254
  }
1251
- return o.getTime();
1255
+ return n.getTime();
1252
1256
  }, ke = ({
1253
- timeZone: t = Ct,
1257
+ timeZone: t = bt,
1254
1258
  space: s = wt,
1255
1259
  formatter: e,
1256
1260
  locale: c,
1257
- showTimezone: n
1258
- } = {}) => (o, a) => {
1259
- const { min: l, max: d } = o, u = Math.floor(a.chartAreaCanvasPX.width / s) + 1, p = (d - l) / u, [f, h] = Jt.find(
1261
+ showTimezone: o
1262
+ } = {}) => (n, a) => {
1263
+ const { min: l, max: d } = n, u = Math.floor(a.chartAreaCanvasPX.width / s) + 1, p = (d - l) / u, [f, h] = Jt.find(
1260
1264
  (v) => W(v) >= p
1261
1265
  ) ?? [1, "milliseconds"], i = ne(l, [f, h], t), m = G(i, t), y = [i];
1262
1266
  let x;
@@ -1302,11 +1306,11 @@ const ne = (t, s, e = "UTC") => {
1302
1306
  }
1303
1307
  return (e ?? oe({
1304
1308
  locale: c,
1305
- showTimezone: n,
1309
+ showTimezone: o,
1306
1310
  timeZone: t
1307
1311
  }))(y);
1308
1312
  }, K = (t, s, e) => t.find((c) => c.type === e)?.value !== s.find((c) => c.type === e)?.value, oe = ({
1309
- timeZone: t = Ct,
1313
+ timeZone: t = bt,
1310
1314
  locale: s = jt,
1311
1315
  showTimezone: e = !0
1312
1316
  }) => {
@@ -1322,31 +1326,31 @@ const ne = (t, s, e = "UTC") => {
1322
1326
  timeZoneName: "short",
1323
1327
  timeZone: t
1324
1328
  });
1325
- return (n) => {
1326
- const o = n[1] - n[0], a = o < W([1, "days"]), l = o < W([1, "minutes"]), d = o < W([1, "seconds"]);
1327
- return n.map((u) => ({ value: u, label: c.formatToParts(new Date(u)) })).map((u, r, p) => {
1328
- const f = p[r - 1], h = r === 0 || K(u.label, f.label, "year"), i = r === 0 || K(u.label, f.label, "day"), m = r === 0 || K(u.label, f.label, "month"), y = r === 0 || K(u.label, f.label, "hour"), x = r === 0 || K(u.label, f.label, "timeZoneName"), v = r === 0 || K(u.label, f.label, "minute"), g = r === 0 || K(u.label, f.label, "second"), S = r === 0 || K(u.label, f.label, "fractionalSecond"), w = [];
1329
+ return (o) => {
1330
+ const n = o[1] - o[0], a = n < W([1, "days"]), l = n < W([1, "minutes"]), d = n < W([1, "seconds"]);
1331
+ return o.map((u) => ({ value: u, label: c.formatToParts(new Date(u)) })).map((u, r, p) => {
1332
+ const f = p[r - 1], h = r === 0 || K(u.label, f.label, "year"), i = r === 0 || K(u.label, f.label, "day"), m = r === 0 || K(u.label, f.label, "month"), y = r === 0 || K(u.label, f.label, "hour"), x = r === 0 || K(u.label, f.label, "timeZoneName"), v = r === 0 || K(u.label, f.label, "minute"), g = r === 0 || K(u.label, f.label, "second"), S = r === 0 || K(u.label, f.label, "fractionalSecond"), C = [];
1329
1333
  if (a && (y || v || x || g || S)) {
1330
- const b = u.label.find((A) => A.type === "hour")?.value, k = u.label.find((A) => A.type === "minute")?.value, C = u.label.find((A) => A.type === "timeZoneName")?.value;
1334
+ const w = u.label.find((M) => M.type === "hour")?.value, b = u.label.find((M) => M.type === "minute")?.value, k = u.label.find((M) => M.type === "timeZoneName")?.value;
1331
1335
  let _ = "";
1332
1336
  if (l) {
1333
- const A = u.label.find((F) => F.type === "second")?.value, B = u.label.find(
1337
+ const M = u.label.find((F) => F.type === "second")?.value, B = u.label.find(
1334
1338
  (F) => F.type === "fractionalSecond"
1335
1339
  )?.value;
1336
- _ = `:${A}` + (d ? `.${B}` : "");
1340
+ _ = `:${M}` + (d ? `.${B}` : "");
1337
1341
  }
1338
- w.push(
1339
- `${b}:${k}${_}` + (e && x ? ` ${C}` : "")
1342
+ C.push(
1343
+ `${w}:${b}${_}` + (e && x ? ` ${k}` : "")
1340
1344
  );
1341
1345
  }
1342
- return (i || m) && w.push(
1346
+ return (i || m) && C.push(
1343
1347
  [
1344
- u.label.find((b) => b.type === "month")?.value,
1345
- i && u.label.find((b) => b.type === "day")?.value
1348
+ u.label.find((w) => w.type === "month")?.value,
1349
+ i && u.label.find((w) => w.type === "day")?.value
1346
1350
  ].filter(Boolean).join(" ")
1347
- ), h && w.push(u.label.find((b) => b.type === "year")?.value), {
1351
+ ), h && C.push(u.label.find((w) => w.type === "year")?.value), {
1348
1352
  value: u.value,
1349
- label: w.filter((b) => b).join(`
1353
+ label: C.filter((w) => w).join(`
1350
1354
  `)
1351
1355
  };
1352
1356
  });
@@ -1354,14 +1358,14 @@ const ne = (t, s, e = "UTC") => {
1354
1358
  };
1355
1359
  export {
1356
1360
  me as AreaPlot,
1357
- be as AxisOverlay,
1361
+ Ce as AxisOverlay,
1358
1362
  fe as BarPlot,
1359
1363
  ue as CanPlot,
1360
1364
  Se as ChartAreaInteractions,
1361
1365
  we as Crosshair,
1362
1366
  de as LinePlot,
1363
1367
  he as ScatterPlot,
1364
- Ce as SelectBox,
1368
+ be as SelectBox,
1365
1369
  pe as SparklinePlot,
1366
1370
  ve as TooltipsX,
1367
1371
  xe as XTicks,
@@ -1371,7 +1375,7 @@ export {
1371
1375
  O as clampXPosToChartArea,
1372
1376
  $ as clampYPosToChartArea,
1373
1377
  Ht as defaultNumericalTicksFormatter,
1374
- P as getScale,
1378
+ A as getScale,
1375
1379
  Q as isXScale,
1376
1380
  ae as isYScale,
1377
1381
  Te as makeLinearTicks,
@@ -1380,10 +1384,10 @@ export {
1380
1384
  D as posToVal,
1381
1385
  Lt as pxToValDistance,
1382
1386
  z as useDrawEffect,
1383
- ht as useFrameState,
1387
+ ft as useFrameState,
1384
1388
  ye as useXPositioned,
1385
1389
  it as valFits,
1386
1390
  j as valToPos,
1387
- ut as valToPxDistance
1391
+ dt as valToPxDistance
1388
1392
  };
1389
1393
  //# sourceMappingURL=canplot.mjs.map