@canplot/react 0.1.4 → 0.1.5

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,48 +1,51 @@
1
- import { jsxs as at, jsx as L, Fragment as Et } from "react/jsx-runtime";
2
- import Z, { createContext as Mt, useContext as lt, useRef as R, useLayoutEffect as G, version as Pt, forwardRef as At, useMemo as gt, useState as N, useId as _t, useEffect as Rt } from "react";
3
- import { createStore as Ut, useStore as wt } from "zustand";
4
- const J = (t, s, e) => Math.min(Math.max(t, s), e), Lt = (t, s, e, c) => {
5
- const { min: n, max: o } = D(t, e), i = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, a = (Q(t, e) ? i.width : i.height) / (o - n);
6
- return s / a;
7
- }, D = (t, s) => {
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";
3
+ import { createStore as Ut, useStore as vt } from "zustand";
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);
6
+ return s / l;
7
+ }, P = (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`);
11
11
  return e;
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", O = (t, s) => {
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
15
  }, ut = (t, s, e, c) => {
16
- const n = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, { min: o, max: i } = D(t, e), a = (Q(t, e) ? n.width : n.height) / (i - o);
17
- return s * a;
18
- }, B = (t, s, e, c) => {
19
- const { min: n } = D(t, e), o = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, i = ut(t, s - n, e, c);
20
- return Q(t, e) ? J(
21
- o.x + i,
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);
17
+ return s * l;
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);
20
+ return Q(t, e) ? V(
21
+ o.x + a,
22
22
  o.x - 10 * o.width,
23
23
  o.x + 11 * o.width
24
- ) : J(
25
- o.y + o.height - i,
24
+ ) : V(
25
+ o.y + o.height - a,
26
26
  o.y - 10 * o.height,
27
27
  o.y + 11 * o.height
28
28
  );
29
- }, z = (t, s, e) => {
29
+ }, le = (t, s, e) => {
30
+ const { min: c, max: n } = P(t, e);
31
+ return V(s, c, n);
32
+ }, O = (t, s, e) => {
30
33
  const c = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
31
- return J(s, c.x, c.x + c.width);
32
- }, Y = (t, s, e) => {
34
+ return V(s, c.x, c.x + c.width);
35
+ }, $ = (t, s, e) => {
33
36
  const c = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
34
- return J(s, c.y, c.y + c.height);
35
- }, rt = (t, s, e) => {
36
- const { min: c, max: n } = D(t, e);
37
+ return V(s, c.y, c.y + c.height);
38
+ }, it = (t, s, e) => {
39
+ const { min: c, max: n } = P(t, e);
37
40
  return s >= c && s <= n;
38
- }, U = (t, s, e, c) => {
39
- const { min: n, max: o } = D(t, e), i = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, a = Q(t, e) ? (s - i.x) / i.width : (i.height - s + i.y) / i.height;
40
- return n + a * (o - n);
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);
41
44
  }, Dt = (t) => {
42
45
  const { ctx: s, scales: e } = t;
43
46
  for (const c of e) {
44
47
  if (!c.axis) continue;
45
- s.save(), O(s, {
48
+ s.save(), R(s, {
46
49
  strokeStyle: "black",
47
50
  fillStyle: "black",
48
51
  lineWidth: 1,
@@ -62,7 +65,7 @@ const J = (t, s, e) => Math.min(Math.max(t, s), e), Lt = (t, s, e, c) => {
62
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
66
  s.restore();
64
67
  }
65
- }, It = () => Ut((t, s) => {
68
+ }, Xt = () => Ut((t, s) => {
66
69
  const e = () => {
67
70
  const c = s()._frame;
68
71
  if (!c) throw new Error("No frame set in frame store");
@@ -72,24 +75,24 @@ const J = (t, s, e) => Math.min(Math.max(t, s), e), Lt = (t, s, e, c) => {
72
75
  _frame: null,
73
76
  getFrame: e,
74
77
  getCtx: () => e().ctx,
75
- clampXPosToChartArea: (c, n) => z(e(), c, n ?? "canvas"),
76
- clampYPosToChartArea: (c, n) => Y(e(), c, n ?? "canvas"),
77
- valToPos: (c, n, o) => B(e(), c, n, o ?? "canvas"),
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"),
78
81
  valToPxDistance: (c, n, o) => ut(
79
82
  e(),
80
83
  c,
81
84
  n,
82
85
  o ?? "canvas"
83
86
  ),
84
- valFits: (c, n) => rt(e(), c, n),
85
- getScale: (c) => D(e(), c)
87
+ valFits: (c, n) => it(e(), c, n),
88
+ getScale: (c) => P(e(), c)
86
89
  };
87
- }), dt = Mt(null), V = (t, s) => {
90
+ }), dt = Mt(null), z = (t, s) => {
88
91
  const e = lt(dt);
89
92
  if (!e)
90
93
  throw new Error("useFrame must be used within a CanPlot component");
91
- const c = R(t);
92
- c.current = t, G(() => {
94
+ const c = L(t);
95
+ c.current = t, J(() => {
93
96
  c.current(e.getState()), e.subscribe((n) => {
94
97
  n._frame && c.current(n);
95
98
  });
@@ -98,48 +101,48 @@ const J = (t, s, e) => Math.min(Math.max(t, s), e), Lt = (t, s, e, c) => {
98
101
  const s = lt(dt);
99
102
  if (!s)
100
103
  throw new Error("useFrame must be used within a CanPlot component");
101
- return wt(
104
+ return vt(
102
105
  s,
103
106
  t ?? ((e) => e.getFrame())
104
107
  );
105
108
  };
106
- function Xt(t) {
109
+ function Kt(t) {
107
110
  return (s) => {
108
- for (const e of t) it(e, s);
111
+ for (const e of t) rt(e, s);
109
112
  };
110
113
  }
111
- function Kt(t) {
114
+ function It(t) {
112
115
  return (s) => {
113
116
  const e = [];
114
117
  for (const c of t) {
115
- const n = it(c, s), o = typeof n == "function";
116
- e.push(o ? n : () => it(c, null));
118
+ const n = rt(c, s), o = typeof n == "function";
119
+ e.push(o ? n : () => rt(c, null));
117
120
  }
118
121
  return () => {
119
122
  for (const c of e) c();
120
123
  };
121
124
  };
122
125
  }
123
- function it(t, s) {
126
+ function rt(t, s) {
124
127
  if (typeof t == "function")
125
128
  return t(s);
126
129
  t && (t.current = s);
127
130
  }
128
- var Ft = parseInt(Pt.split(".")[0], 10) >= 19 ? Kt : Xt;
129
- const le = At(({ configuration: t, children: s, style: e, className: c }, n) => {
130
- const o = R(null), i = R(null), a = Yt(i), u = gt(It, []);
131
- G(() => {
132
- u.setState({
133
- _frame: Ot(t, a, o.current)
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, []);
134
+ J(() => {
135
+ d.setState({
136
+ _frame: Ot(t, l, o.current)
134
137
  });
135
- }, [t, a, o, u]), G(() => u.subscribe((d) => {
136
- d._frame && $t(d._frame);
137
- }), [u]);
138
- const l = window.devicePixelRatio || 1;
138
+ }, [t, l, o, d]), J(() => d.subscribe((r) => {
139
+ r._frame && $t(r._frame);
140
+ }), [d]);
141
+ const u = window.devicePixelRatio || 1;
139
142
  return /* @__PURE__ */ at(
140
143
  "div",
141
144
  {
142
- ref: Ft([n, i]),
145
+ ref: Ft([n, a]),
143
146
  className: c,
144
147
  style: {
145
148
  position: "relative",
@@ -148,41 +151,41 @@ const le = At(({ configuration: t, children: s, style: e, className: c }, n) =>
148
151
  },
149
152
  "data-canplotroot": !0,
150
153
  children: [
151
- /* @__PURE__ */ L(
154
+ /* @__PURE__ */ X(
152
155
  "canvas",
153
156
  {
154
157
  ref: o,
155
- width: a.width * l,
156
- height: a.height * l,
158
+ width: l.width * u,
159
+ height: l.height * u,
157
160
  style: {
158
161
  inset: 0,
159
162
  position: "absolute",
160
- width: `${a.width}px`,
161
- height: `${a.height}px`
163
+ width: `${l.width}px`,
164
+ height: `${l.height}px`
162
165
  }
163
166
  }
164
167
  ),
165
- /* @__PURE__ */ L(zt, { frameStore: u, children: s })
168
+ /* @__PURE__ */ X(zt, { frameStore: d, children: s })
166
169
  ]
167
170
  }
168
171
  );
169
- }), zt = ({ frameStore: t, children: s }) => wt(t, (c) => !!c._frame) ? /* @__PURE__ */ L(dt.Provider, { value: t, children: s }) : null, Yt = (t) => {
172
+ }), zt = ({ frameStore: t, children: s }) => vt(t, (c) => !!c._frame) ? /* @__PURE__ */ X(dt.Provider, { value: t, children: s }) : null, Yt = (t) => {
170
173
  const [s, e] = N({
171
174
  width: 0,
172
175
  height: 0
173
176
  }), [c] = N(() => new ResizeObserver((n) => {
174
177
  for (const o of n) {
175
- const i = Math.round(o.contentRect.width), a = Math.round(o.contentRect.height);
178
+ const a = Math.round(o.contentRect.width), l = Math.round(o.contentRect.height);
176
179
  e(
177
- (u) => u.width !== i || u.height !== a ? { ...u, width: i, height: a } : u
180
+ (d) => d.width !== a || d.height !== l ? { ...d, width: a, height: l } : d
178
181
  );
179
182
  }
180
183
  }));
181
- return G(() => {
184
+ return J(() => {
182
185
  if (!t.current) return;
183
186
  const n = t.current.clientWidth, o = t.current.clientHeight;
184
187
  return e(
185
- (i) => i.width !== n || i.height !== o ? { ...i, width: n, height: o } : i
188
+ (a) => a.width !== n || a.height !== o ? { ...a, width: n, height: o } : a
186
189
  ), c.observe(t.current, { box: "border-box" }), () => c.disconnect();
187
190
  }, [c, t]), s;
188
191
  }, Ot = (t, s, e) => {
@@ -202,31 +205,31 @@ const le = At(({ configuration: t, children: s, style: e, className: c }, n) =>
202
205
  0,
203
206
  o.height - h.axis.size
204
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)));
205
- const i = {
208
+ const a = {
206
209
  x: o.x * n,
207
210
  y: o.y * n,
208
211
  width: o.width * n,
209
212
  height: o.height * n
210
- }, a = [];
211
- let u = t.padding.left * n, l = c.canvas.width - t.padding.right * n, d = c.canvas.height - t.padding.bottom * n, p = t.padding.top * n;
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;
212
215
  for (const h of t.scales) {
213
216
  if (!h.axis) {
214
- a.push({ ...h, axis: null });
217
+ l.push({ ...h, axis: null });
215
218
  continue;
216
219
  }
217
- let r;
220
+ let i;
218
221
  if (h.origin === "x")
219
222
  switch (h.axis.position) {
220
223
  case "bottom":
221
- d -= h.axis.size * n, r = {
224
+ r -= h.axis.size * n, i = {
222
225
  x: o.x,
223
- y: d / n,
226
+ y: r / n,
224
227
  width: o.width,
225
228
  height: h.axis.size
226
229
  };
227
230
  break;
228
231
  case "top":
229
- p += h.axis.size * n, r = {
232
+ p += h.axis.size * n, i = {
230
233
  x: o.x,
231
234
  y: p / n - h.axis.size,
232
235
  width: o.width,
@@ -240,16 +243,16 @@ const le = At(({ configuration: t, children: s, style: e, className: c }, n) =>
240
243
  else
241
244
  switch (h.axis.position) {
242
245
  case "left":
243
- u += h.axis.size * n, r = {
244
- x: u / n - h.axis.size,
246
+ d += h.axis.size * n, i = {
247
+ x: d / n - h.axis.size,
245
248
  y: o.y,
246
249
  width: h.axis.size,
247
250
  height: o.height
248
251
  };
249
252
  break;
250
253
  case "right":
251
- l -= h.axis.size * n, r = {
252
- x: l / n,
254
+ u -= h.axis.size * n, i = {
255
+ x: u / n,
253
256
  y: o.y,
254
257
  width: h.axis.size,
255
258
  height: o.height
@@ -260,16 +263,16 @@ const le = At(({ configuration: t, children: s, style: e, className: c }, n) =>
260
263
  throw new Error("Invalid axis position for y origin");
261
264
  }
262
265
  const m = {
263
- x: r.x * n,
264
- y: r.y * n,
265
- width: r.width * n,
266
- height: r.height * n
266
+ x: i.x * n,
267
+ y: i.y * n,
268
+ width: i.width * n,
269
+ height: i.height * n
267
270
  };
268
- a.push({
271
+ l.push({
269
272
  ...h,
270
273
  axis: {
271
274
  ...h.axis,
272
- cssRect: r,
275
+ cssRect: i,
273
276
  canvasRect: m
274
277
  }
275
278
  });
@@ -278,132 +281,185 @@ const le = At(({ configuration: t, children: s, style: e, className: c }, n) =>
278
281
  ctx: c,
279
282
  dpr: n,
280
283
  padding: t.padding,
281
- scales: a,
284
+ scales: l,
282
285
  chartAreaCSS: o,
283
- chartAreaCanvasPX: i
286
+ chartAreaCanvasPX: a
284
287
  };
285
288
  }, $t = (t) => {
286
289
  t.ctx.clearRect(0, 0, t.ctx.canvas.width, t.ctx.canvas.height), Dt(t);
287
- }, ue = ({ data: t, xScaleId: s, yScaleId: e, style: c }) => (V(
288
- ({ getCtx: n, clampXPosToChartArea: o, clampYPosToChartArea: i, valToPos: a }) => {
289
- const u = n();
290
- u.save(), u.beginPath(), O(u, c);
291
- for (const l of t) {
292
- const d = o(a(l.x, s)), p = i(a(l.y, e));
293
- u.lineTo(d, p);
290
+ }, de = ({ data: t, xScaleId: s, yScaleId: e, style: c }) => (z(
291
+ ({ getCtx: n, clampXPosToChartArea: o, clampYPosToChartArea: a, valToPos: l }) => {
292
+ const d = n();
293
+ d.save(), d.beginPath(), R(d, c);
294
+ for (const u of t) {
295
+ const r = o(l(u.x, s)), p = a(l(u.y, e));
296
+ d.lineTo(r, p);
294
297
  }
295
- u.stroke(), u.restore();
298
+ d.stroke(), d.restore();
296
299
  },
297
300
  [t, s, e, c]
298
- ), null), de = ({ data: t, xScaleId: s, yScaleId: e, radius: c = 5, style: n }) => (V(({ getCtx: o, valToPos: i, valFits: a }) => {
299
- const u = o();
300
- u.save(), u.beginPath(), O(u, n);
301
- for (const l of t) {
302
- if (!a(l.x, s) || !a(l.y, e))
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);
304
+ for (const u of t) {
305
+ if (!l(u.x, s) || !l(u.y, e))
303
306
  continue;
304
- const d = i(l.x, s), p = i(l.y, e);
305
- u.moveTo(d + c, p), u.arc(d, p, c, 0, Math.PI * 2);
307
+ const r = a(u.x, s), p = a(u.y, e);
308
+ d.moveTo(r + c, p), d.arc(r, p, c, 0, Math.PI * 2);
306
309
  }
307
- u.stroke(), u.fill(), u.restore();
308
- }, [t, s, e, c, n]), null), he = ({
310
+ d.stroke(), d.fill(), d.restore();
311
+ }, [t, s, e, c, n]), null), fe = ({
309
312
  data: t,
310
313
  xScaleId: s,
311
314
  yScaleId: e,
312
315
  style: c,
313
316
  barWidth: n,
314
317
  xPositionOffset: o,
315
- radius: i
316
- }) => (V(
318
+ radius: a
319
+ }) => (z(
317
320
  ({
318
- getCtx: a,
319
- valToPxDistance: u,
320
- valToPos: l,
321
- clampXPosToChartArea: d,
321
+ getCtx: l,
322
+ valToPxDistance: d,
323
+ valToPos: u,
324
+ clampXPosToChartArea: r,
322
325
  clampYPosToChartArea: p
323
326
  }) => {
324
327
  if (t.length === 0) return;
325
- const f = a();
326
- f.save(), O(f, c);
327
- const h = u(n, s);
328
+ const f = l();
329
+ f.save(), R(f, c);
330
+ const h = d(n, s);
328
331
  f.beginPath();
329
- for (const r of t) {
330
- const y = l(r.x, s) - h / 2 + o * h, x = p(l(0, e)), g = p(l(r.y, e)), S = x - g, w = d(y), k = d(y + h) - w;
331
- i ? f.roundRect(
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;
334
+ a ? f.roundRect(
335
+ S,
336
+ v,
332
337
  w,
333
338
  g,
334
- k,
335
- S,
336
- i
337
- ) : f.rect(w, g, k, S);
339
+ a
340
+ ) : f.rect(S, v, w, g);
338
341
  }
339
342
  f.closePath(), f.fill(), c?.strokeStyle && f.stroke(), f.restore();
340
343
  },
341
- [t, s, e, c, n, o, i]
342
- ), null), me = ({ data: t, xScaleId: s, yScaleId: e, style: c }) => (V(({ getCtx: n, clampXPosToChartArea: o, clampYPosToChartArea: i, valToPos: a }) => {
343
- const u = [];
344
- for (const d of t) {
345
- const p = o(a(d.x, s)), f = i(a(d.y[0], e)), h = i(a(d.y[1], e));
346
- u.push({ x: p, y: f }), u.unshift({ x: p, y: h });
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 }) => {
346
+ const d = [];
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));
349
+ d.push({ x: p, y: f }), d.unshift({ x: p, y: h });
347
350
  }
348
- const l = n();
349
- if (u.length > 0) {
350
- l.save(), l.beginPath(), O(l, c), l.moveTo(u[0].x, u[0].y);
351
- for (const d of u)
352
- l.lineTo(d.x, d.y);
353
- l.closePath(), l.fill(), l.restore();
351
+ const u = n();
352
+ if (d.length > 0) {
353
+ u.save(), u.beginPath(), R(u, c), u.moveTo(d[0].x, d[0].y);
354
+ for (const r of d)
355
+ u.lineTo(r.x, r.y);
356
+ u.closePath(), u.fill(), u.restore();
354
357
  }
355
- }, [t, s, e, c]), null), fe = ({ data: t, stroked: s, xScaleId: e, yScaleId: c, style: n }) => (V(
356
- ({ getCtx: o, clampXPosToChartArea: i, clampYPosToChartArea: a, valToPos: u }) => {
357
- const l = [], d = o();
358
- for (const r of t) {
359
- const m = i(u(r.x, e)), y = a(u(r.y, c));
360
- l.push({ x: m, y });
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();
361
+ for (const i of t) {
362
+ const m = a(d(i.x, e)), y = l(d(i.y, c));
363
+ u.push({ x: m, y });
361
364
  }
362
- const p = l.at(0), f = l.at(-1);
365
+ const p = u.at(0), f = u.at(-1);
363
366
  if (!p || !f)
364
367
  return;
365
- const h = a(u(0, c));
366
- d.save(), d.beginPath(), O(d, n), d.moveTo(p.x, h);
367
- for (const r of l)
368
- d.lineTo(r.x, r.y);
369
- if (d.lineTo(f.x, h), d.closePath(), d.fill(), s) {
370
- d.beginPath(), d.moveTo(p.x, p.y);
371
- for (const r of l)
372
- d.lineTo(r.x, r.y);
373
- d.stroke();
368
+ const h = l(d(0, c));
369
+ r.save(), r.beginPath(), R(r, n), r.moveTo(p.x, h);
370
+ for (const i of u)
371
+ r.lineTo(i.x, i.y);
372
+ if (r.lineTo(f.x, h), r.closePath(), r.fill(), s) {
373
+ r.beginPath(), r.moveTo(p.x, p.y);
374
+ for (const i of u)
375
+ r.lineTo(i.x, i.y);
376
+ r.stroke();
374
377
  }
375
- d.restore();
378
+ r.restore();
376
379
  },
377
380
  [t, s, e, c, n]
378
- ), null), pe = (t, s) => ht(
381
+ ), null), ye = (t, s) => ht(
379
382
  ({
380
383
  clampXPosToChartArea: e,
381
384
  clampYPosToChartArea: c,
382
385
  getScale: n,
383
386
  valToPos: o,
384
- valFits: i
387
+ valFits: a
385
388
  }) => {
386
- const a = {};
387
- for (const u in t) {
388
- const l = t[u];
389
- switch (l.exceeding) {
389
+ const l = {};
390
+ for (const d in t) {
391
+ const u = t[d];
392
+ switch (u.exceeding) {
390
393
  case "discard": {
391
- if (i(l.value, l.scaleId)) {
392
- const d = o(l.value, l.scaleId, s);
393
- a[u] = d;
394
+ if (a(u.value, u.scaleId)) {
395
+ const r = o(u.value, u.scaleId, s);
396
+ l[d] = r;
394
397
  }
395
398
  break;
396
399
  }
397
400
  case "clamp": {
398
- const d = o(l.value, l.scaleId, s);
399
- a[u] = n(l.scaleId)?.origin === "x" ? e(d, s) : c(d, s);
401
+ const r = o(u.value, u.scaleId, s);
402
+ l[d] = n(u.scaleId)?.origin === "x" ? e(r, s) : c(r, s);
400
403
  break;
401
404
  }
402
405
  }
403
406
  }
404
- return a;
407
+ return l;
405
408
  }
406
- ), b = () => {
409
+ ), xe = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: c, tickSize: n, ticks: o }) => (z(
410
+ ({ getCtx: a, valToPos: l, getScale: d, getFrame: u }) => {
411
+ const r = a(), p = d(t);
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;
414
+ r.save(), r.fontKerning = "auto", R(r, {
415
+ ...s
416
+ }), r.beginPath();
417
+ const g = Array.isArray(o) ? o : o({ ...p, axis: f }, u());
418
+ for (const { value: S } of g) {
419
+ const w = l(S, t, "canvas");
420
+ r.moveTo(w, m), r.lineTo(w, x);
421
+ }
422
+ r.stroke(), r.restore(), r.save(), R(r, {
423
+ textBaseline: f.position === "top" ? "bottom" : "top",
424
+ textAlign: "center",
425
+ ...s,
426
+ ...e
427
+ });
428
+ for (const { value: S, label: w } of g) {
429
+ const b = l(S, t, "canvas"), k = w.split(`
430
+ `);
431
+ for (let C = 0; C < k.length; C++)
432
+ r.fillText(k[C], b, x + i * 2 + C * v);
433
+ }
434
+ r.restore();
435
+ },
436
+ [o, t, s, e]
437
+ ), null), ge = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: c, tickSize: n, ticks: o }) => (z(
438
+ ({ getCtx: a, valToPos: l, getScale: d, getFrame: u }) => {
439
+ const r = a(), p = d(t);
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());
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);
446
+ }
447
+ r.stroke(), r.restore(), r.save(), R(r, {
448
+ textBaseline: "middle",
449
+ textAlign: f.position === "left" ? "right" : "left",
450
+ ...s,
451
+ ...e
452
+ });
453
+ for (const { value: S, label: w } of g) {
454
+ const b = l(S, t, "canvas"), k = w.split(`
455
+ `);
456
+ for (let C = 0; C < k.length; C++)
457
+ r.fillText(` ${k[C]} `, x, b + C * v);
458
+ }
459
+ r.restore();
460
+ },
461
+ [o, t, s, e]
462
+ ), null), E = () => {
407
463
  const t = [];
408
464
  return {
409
465
  addEventListener: (s, e) => (t.push({
@@ -418,53 +474,53 @@ const le = At(({ configuration: t, children: s, style: e, className: c }, n) =>
418
474
  c.syncKey === s && c.callback(s, e);
419
475
  }
420
476
  };
421
- }, v = {
422
- dblclick: b(),
423
- click: b(),
424
- move: b(),
425
- mousedown: b(),
426
- mouseup: b(),
427
- spanselect: b(),
428
- documentmouseup: b(),
429
- pressandwheel: b(),
430
- sync_dblclick: b(),
431
- sync_click: b(),
432
- sync_move: b(),
433
- sync_mousedown: b(),
434
- sync_mouseup: b(),
435
- sync_spanselect: b(),
436
- sync_pressandwheel: b()
437
- }, T = (t, s, e) => {
477
+ }, T = {
478
+ dblclick: E(),
479
+ click: E(),
480
+ move: E(),
481
+ mousedown: E(),
482
+ mouseup: E(),
483
+ spanselect: E(),
484
+ documentmouseup: E(),
485
+ pressandwheel: E(),
486
+ sync_dblclick: E(),
487
+ sync_click: E(),
488
+ sync_move: E(),
489
+ sync_mousedown: E(),
490
+ sync_mouseup: E(),
491
+ sync_spanselect: E(),
492
+ sync_pressandwheel: E()
493
+ }, M = (t, s, e) => {
438
494
  const c = Z.useRef(e);
439
- c.current = e, Z.useEffect(() => v[t].addEventListener(
495
+ c.current = e, Z.useEffect(() => T[t].addEventListener(
440
496
  s,
441
- (o, i) => {
442
- c.current(i, o);
497
+ (o, a) => {
498
+ c.current(a, o);
443
499
  }
444
500
  ), [s, t, c]);
445
- }, mt = Z.createContext(""), ft = (t, s) => {
446
- const e = Z.useContext(mt);
447
- return T(t, e, s);
448
- }, Nt = (t, s, e, c, n) => {
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) => {
449
505
  if (!s) return;
450
- const o = c ?? e.scales.find((p) => p.origin === "x")?.id, i = n ?? e.scales.find((p) => p.origin === "y")?.id;
451
- if (!o || !i)
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)
452
508
  return;
453
- const a = t.clientX - s.left, u = {
509
+ const l = t.clientX - s.left, d = {
454
510
  scaleId: o,
455
- value: U(e, a, o, "css")
456
- }, l = t.clientY - s.top, d = {
457
- scaleId: i,
458
- value: U(e, l, i, "css")
511
+ value: D(e, l, o, "css")
512
+ }, u = t.clientY - s.top, r = {
513
+ scaleId: a,
514
+ value: D(e, u, a, "css")
459
515
  };
460
- return { pointerSyncPosition: { x: u, y: d }, cssX: a, cssY: l };
461
- }, F = (t, s) => {
462
- const e = t.x ? B(
516
+ return { pointerSyncPosition: { x: d, y: r }, cssX: l, cssY: u };
517
+ }, Y = (t, s) => {
518
+ const e = t.x ? j(
463
519
  s,
464
520
  t.x.value,
465
521
  t.x.scaleId,
466
522
  "css"
467
- ) : 0, c = t.y ? B(
523
+ ) : 0, c = t.y ? j(
468
524
  s,
469
525
  t.y.value,
470
526
  t.y.scaleId,
@@ -476,44 +532,44 @@ const le = At(({ configuration: t, children: s, style: e, className: c }, n) =>
476
532
  scaled: Object.fromEntries(
477
533
  s.scales.map((n) => {
478
534
  const o = n.origin === "y" ? c : e;
479
- return [n.id, U(s, o, n.id, "css")];
535
+ return [n.id, D(s, o, n.id, "css")];
480
536
  })
481
537
  )
482
538
  };
483
539
  }, xt = (t, s, e) => {
484
540
  if (!s) {
485
- const i = t === "x" ? e.chartAreaCSS.x : e.chartAreaCSS.y, a = t === "x" ? e.chartAreaCSS.x + e.chartAreaCSS.width : e.chartAreaCSS.y + e.chartAreaCSS.height;
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;
486
542
  return {
487
- fromCSS: i,
488
- toCSS: a,
489
- scaled: e.scales.flatMap((u) => {
490
- if (u.origin !== t)
543
+ fromCSS: a,
544
+ toCSS: l,
545
+ scaled: e.scales.flatMap((d) => {
546
+ if (d.origin !== t)
491
547
  return [];
492
- const { min: l, max: d } = D(e, u.id);
493
- return [{ scaleId: u.id, from: l, to: d }];
548
+ const { min: u, max: r } = P(e, d.id);
549
+ return [{ scaleId: d.id, from: u, to: r }];
494
550
  })
495
551
  };
496
552
  }
497
- const c = B(
553
+ const c = j(
498
554
  e,
499
555
  s.from,
500
556
  s.scaleId,
501
557
  "css"
502
- ), n = B(
558
+ ), n = j(
503
559
  e,
504
560
  s.to,
505
561
  s.scaleId,
506
562
  "css"
507
563
  ), o = e.scales.flatMap(
508
- (i) => {
509
- if (i.origin !== t)
564
+ (a) => {
565
+ if (a.origin !== t)
510
566
  return [];
511
- const a = U(e, c, i.id, "css"), u = U(e, n, i.id, "css");
567
+ const l = D(e, c, a.id, "css"), d = D(e, n, a.id, "css");
512
568
  return [
513
569
  {
514
- scaleId: i.id,
515
- from: a,
516
- to: u
570
+ scaleId: a.id,
571
+ from: l,
572
+ to: d
517
573
  }
518
574
  ];
519
575
  }
@@ -523,61 +579,61 @@ const le = At(({ configuration: t, children: s, style: e, className: c }, n) =>
523
579
  toCSS: n,
524
580
  scaled: o
525
581
  };
526
- }, ye = ({
582
+ }, Se = ({
527
583
  id: t,
528
584
  onClick: s,
529
585
  onDblClick: e,
530
586
  onMouseMove: c,
531
587
  onMouseDown: n,
532
588
  onMouseUp: o,
533
- onDocumentMouseUp: i,
534
- onSpanSelect: a,
535
- className: u,
536
- style: l,
537
- sync: d,
589
+ onDocumentMouseUp: a,
590
+ onSpanSelect: l,
591
+ className: d,
592
+ style: u,
593
+ sync: r,
538
594
  children: p
539
595
  }) => {
540
- const f = _t(), h = t || f;
541
- return T("dblclick", h, (r) => {
542
- e?.(r);
543
- }), T("click", h, (r) => {
544
- s?.(r);
545
- }), T("move", h, (r) => {
546
- c?.(r);
547
- }), T("mousedown", h, (r) => {
548
- n?.(r);
549
- }), T("mouseup", h, (r) => {
550
- o?.(r);
551
- }), T("documentmouseup", h, (r) => {
552
- i?.(r);
553
- }), T("spanselect", h, (r) => {
554
- a?.(r);
555
- }), /* @__PURE__ */ at(mt.Provider, { value: h, children: [
556
- /* @__PURE__ */ L(
557
- Bt,
596
+ const f = Rt(), h = t || f;
597
+ return M("dblclick", h, (i) => {
598
+ e?.(i);
599
+ }), M("click", h, (i) => {
600
+ s?.(i);
601
+ }), M("move", h, (i) => {
602
+ c?.(i);
603
+ }), M("mousedown", h, (i) => {
604
+ n?.(i);
605
+ }), M("mouseup", h, (i) => {
606
+ o?.(i);
607
+ }), M("documentmouseup", h, (i) => {
608
+ a?.(i);
609
+ }), M("spanselect", h, (i) => {
610
+ l?.(i);
611
+ }), /* @__PURE__ */ at(ft.Provider, { value: h, children: [
612
+ /* @__PURE__ */ X(
613
+ Nt,
558
614
  {
559
- className: u,
560
- style: l,
561
- sync: d
615
+ className: d,
616
+ style: u,
617
+ sync: r
562
618
  }
563
619
  ),
564
620
  p
565
621
  ] });
566
- }, Bt = ({ className: t, style: s, sync: e }) => {
567
- const c = R(null), n = ht(), o = R(n);
622
+ }, Nt = ({ className: t, style: s, sync: e }) => {
623
+ const c = L(null), n = ht(), o = L(n);
568
624
  o.current = n;
569
- const i = lt(mt), a = e?.key || i, u = R(null), l = R(null), d = R(null), p = () => {
570
- const r = c.current?.parentElement;
571
- if (r) {
572
- if (r.dataset.canplotroot === void 0)
625
+ const a = lt(ft), l = e?.key || a, d = L(null), u = L(null), r = L(null), p = () => {
626
+ const i = c.current?.parentElement;
627
+ if (i) {
628
+ if (i.dataset.canplotroot === void 0)
573
629
  throw new Error(
574
630
  "ChartAreaInteractions must be used within a CanPlot component"
575
631
  );
576
- return r.getBoundingClientRect();
632
+ return i.getBoundingClientRect();
577
633
  }
578
- }, f = (r, m) => {
579
- const y = Nt(
580
- r,
634
+ }, f = (i, m) => {
635
+ const y = Bt(
636
+ i,
581
637
  p(),
582
638
  o.current,
583
639
  e?.xViaScaleId,
@@ -587,217 +643,217 @@ const le = At(({ configuration: t, children: s, style: e, className: c }, n) =>
587
643
  y.pointerSyncPosition,
588
644
  { cssX: y.cssX, cssY: y.cssY },
589
645
  {
590
- ctrlKey: r.ctrlKey,
591
- altKey: r.altKey,
592
- shiftKey: r.shiftKey,
593
- metaKey: r.metaKey
646
+ ctrlKey: i.ctrlKey,
647
+ altKey: i.altKey,
648
+ shiftKey: i.shiftKey,
649
+ metaKey: i.metaKey
594
650
  }
595
651
  );
596
- }, h = R(f);
597
- return h.current = f, Rt(() => {
598
- const r = (S) => {
599
- const w = l.current;
600
- w && v.sync_spanselect.dispatchEvent(a, {
601
- ...w,
652
+ }, h = L(f);
653
+ return h.current = f, _t(() => {
654
+ const i = (g) => {
655
+ const S = u.current;
656
+ S && T.sync_spanselect.dispatchEvent(l, {
657
+ ...S,
602
658
  completed: !0
603
- }), v.documentmouseup.dispatchEvent(a, {
659
+ }), T.documentmouseup.dispatchEvent(l, {
604
660
  frame: o.current,
605
661
  keys: {
606
- ctrlKey: S.ctrlKey,
607
- altKey: S.altKey,
608
- shiftKey: S.shiftKey,
609
- metaKey: S.metaKey
662
+ ctrlKey: g.ctrlKey,
663
+ altKey: g.altKey,
664
+ shiftKey: g.shiftKey,
665
+ metaKey: g.metaKey
610
666
  }
611
667
  });
612
- }, m = (S) => {
613
- const w = {
614
- ctrlKey: S.ctrlKey,
615
- altKey: S.altKey,
616
- shiftKey: S.shiftKey,
617
- metaKey: S.metaKey
618
- }, k = d.current;
619
- if (k && Object.entries(w).some(
620
- ([E, M]) => k.keys[E] !== M
668
+ }, m = (g) => {
669
+ const S = {
670
+ ctrlKey: g.ctrlKey,
671
+ altKey: g.altKey,
672
+ shiftKey: g.shiftKey,
673
+ metaKey: g.metaKey
674
+ }, w = r.current;
675
+ if (w && Object.entries(S).some(
676
+ ([k, C]) => w.keys[k] !== C
621
677
  )) {
622
- const E = { ...k, keys: w };
623
- d.current = E, v.sync_move.dispatchEvent(a, E);
678
+ const k = { ...w, keys: S };
679
+ r.current = k, T.sync_move.dispatchEvent(l, k);
624
680
  }
625
- const C = l.current;
626
- if (C && Object.entries(w).some(
627
- ([E, M]) => C.keys[E] !== M
681
+ const b = u.current;
682
+ if (b && Object.entries(S).some(
683
+ ([k, C]) => b.keys[k] !== C
628
684
  )) {
629
- S.stopPropagation(), S.preventDefault();
630
- const E = { ...C, keys: w };
631
- l.current = E, v.sync_spanselect.dispatchEvent(
632
- a,
633
- E
685
+ g.stopPropagation(), g.preventDefault();
686
+ const k = { ...b, keys: S };
687
+ u.current = k, T.sync_spanselect.dispatchEvent(
688
+ l,
689
+ k
634
690
  );
635
691
  }
636
- }, y = (S) => {
692
+ }, y = (g) => {
637
693
  h.current(
638
- S,
639
- (w, { cssX: k, cssY: C }, E) => {
640
- const M = u.current;
641
- if (!M || !w.x || !w.y) return;
642
- const A = o.current, P = M.xRangeCss.start, $ = k, K = M.yRangeCss.start, et = C, st = D(A, w.x.scaleId), nt = D(A, w.y.scaleId);
643
- u.current = {
644
- xRangeCss: { start: P, end: $ },
645
- yRangeCss: { start: K, end: et }
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);
699
+ d.current = {
700
+ xRangeCss: { start: A, end: B },
701
+ yRangeCss: { start: F, end: et }
646
702
  };
647
- let _ = "none";
648
- const ot = Math.abs(K - et), ct = Math.abs(P - $);
649
- ot < 10 && ct < 10 ? _ = "none" : ot > 30 && ct > 30 ? _ = "box" : ot > ct ? _ = "y" : _ = "x";
650
- const Tt = _ === "x" || _ === "box" ? {
703
+ let U = "none";
704
+ const ot = Math.abs(F - et), ct = Math.abs(A - B);
705
+ ot < 10 && ct < 10 ? U = "none" : ot > 30 && ct > 30 ? U = "box" : ot > ct ? U = "y" : U = "x";
706
+ const Tt = U === "x" || U === "box" ? {
651
707
  scaleId: st.id,
652
- from: U(
653
- A,
654
- z(o.current, P, "css"),
708
+ from: D(
709
+ _,
710
+ O(o.current, A, "css"),
655
711
  st.id,
656
712
  "css"
657
713
  ),
658
- to: U(
659
- A,
660
- z(o.current, $, "css"),
714
+ to: D(
715
+ _,
716
+ O(o.current, B, "css"),
661
717
  st.id,
662
718
  "css"
663
719
  )
664
- } : void 0, kt = _ === "y" || _ === "box" ? {
720
+ } : void 0, kt = U === "y" || U === "box" ? {
665
721
  scaleId: nt.id,
666
- from: U(
667
- A,
668
- Y(o.current, K, "css"),
722
+ from: D(
723
+ _,
724
+ $(o.current, F, "css"),
669
725
  nt.id,
670
726
  "css"
671
727
  ),
672
- to: U(
673
- A,
674
- Y(o.current, et, "css"),
728
+ to: D(
729
+ _,
730
+ $(o.current, et, "css"),
675
731
  nt.id,
676
732
  "css"
677
733
  )
678
734
  } : void 0, yt = {
679
- mode: _,
735
+ mode: U,
680
736
  xRange: Tt,
681
737
  yRange: kt,
682
738
  completed: !1,
683
- keys: E
739
+ keys: k
684
740
  };
685
- l.current = yt, v.sync_spanselect.dispatchEvent(
686
- a,
741
+ u.current = yt, T.sync_spanselect.dispatchEvent(
742
+ l,
687
743
  yt
688
744
  );
689
745
  }
690
746
  );
691
- }, x = (S) => {
692
- h.current(S, (w, k, C) => {
693
- if (Object.values(C).some((M) => M)) {
694
- S.preventDefault();
695
- const M = Math.abs(S.deltaY) > Math.abs(S.deltaX) ? S.deltaY : S.deltaX;
696
- v.sync_pressandwheel.dispatchEvent(a, {
697
- positions: w,
698
- keys: C,
699
- deltaX: S.deltaX,
700
- deltaY: S.deltaY,
701
- deltaAbs: M
747
+ }, x = (g) => {
748
+ h.current(g, (S, w, b) => {
749
+ if (Object.values(b).some((C) => C)) {
750
+ g.preventDefault();
751
+ const C = Math.abs(g.deltaY) > Math.abs(g.deltaX) ? g.deltaY : g.deltaX;
752
+ T.sync_pressandwheel.dispatchEvent(l, {
753
+ positions: S,
754
+ keys: b,
755
+ deltaX: g.deltaX,
756
+ deltaY: g.deltaY,
757
+ deltaAbs: C
702
758
  });
703
759
  }
704
760
  });
705
761
  };
706
- document.addEventListener("mouseup", r), document.addEventListener("keydown", m), document.addEventListener("keyup", m), document.addEventListener("mousemove", y);
707
- const g = c.current;
708
- return g?.addEventListener("wheel", x, {
762
+ document.addEventListener("mouseup", i), document.addEventListener("keydown", m), document.addEventListener("keyup", m), document.addEventListener("mousemove", y);
763
+ const v = c.current;
764
+ return v?.addEventListener("wheel", x, {
709
765
  passive: !1
710
766
  }), () => {
711
- document.removeEventListener("mouseup", r), document.removeEventListener("keydown", m), document.removeEventListener("keyup", m), document.removeEventListener("mousemove", y), g?.removeEventListener("wheel", x);
767
+ document.removeEventListener("mouseup", i), document.removeEventListener("keydown", m), document.removeEventListener("keyup", m), document.removeEventListener("mousemove", y), v?.removeEventListener("wheel", x);
712
768
  };
713
- }, [o, a, h]), T("sync_dblclick", a, (r) => {
714
- const m = F(
715
- r.positions,
769
+ }, [o, l, h]), M("sync_dblclick", l, (i) => {
770
+ const m = Y(
771
+ i.positions,
716
772
  o.current
717
773
  );
718
- m && v.dblclick.dispatchEvent(i, {
774
+ m && T.dblclick.dispatchEvent(a, {
719
775
  frame: o.current,
720
776
  pointer: m,
721
- keys: r.keys
777
+ keys: i.keys
722
778
  });
723
- }), T("sync_click", a, (r) => {
724
- const m = F(
725
- r.positions,
779
+ }), M("sync_click", l, (i) => {
780
+ const m = Y(
781
+ i.positions,
726
782
  o.current
727
783
  );
728
- m && v.click.dispatchEvent(i, {
784
+ m && T.click.dispatchEvent(a, {
729
785
  frame: o.current,
730
786
  pointer: m,
731
- keys: r.keys
787
+ keys: i.keys
732
788
  });
733
- }), T("sync_move", a, (r) => {
734
- const m = r.positions ? F(
735
- r.positions,
789
+ }), M("sync_move", l, (i) => {
790
+ const m = i.positions ? Y(
791
+ i.positions,
736
792
  o.current
737
793
  ) : null;
738
- d.current = r, v.move.dispatchEvent(i, {
794
+ r.current = i, T.move.dispatchEvent(a, {
739
795
  frame: o.current,
740
796
  pointer: m ?? null,
741
- keys: r.keys
797
+ keys: i.keys
742
798
  });
743
- }), T("sync_mousedown", a, (r) => {
744
- const m = F(
745
- r.positions,
799
+ }), M("sync_mousedown", l, (i) => {
800
+ const m = Y(
801
+ i.positions,
746
802
  o.current
747
803
  );
748
- m && v.mousedown.dispatchEvent(i, {
804
+ m && T.mousedown.dispatchEvent(a, {
749
805
  frame: o.current,
750
806
  pointer: m,
751
- keys: r.keys
807
+ keys: i.keys
752
808
  });
753
- }), T("sync_mouseup", a, (r) => {
754
- const m = F(
755
- r.positions,
809
+ }), M("sync_mouseup", l, (i) => {
810
+ const m = Y(
811
+ i.positions,
756
812
  o.current
757
813
  );
758
- m && v.mouseup.dispatchEvent(i, {
814
+ m && T.mouseup.dispatchEvent(a, {
759
815
  frame: o.current,
760
816
  pointer: m,
761
- keys: r.keys
817
+ keys: i.keys
762
818
  });
763
- }), T(
819
+ }), M(
764
820
  "sync_pressandwheel",
765
- a,
766
- (r) => {
767
- const m = F(
768
- r.positions,
821
+ l,
822
+ (i) => {
823
+ const m = Y(
824
+ i.positions,
769
825
  o.current
770
826
  );
771
- m && v.pressandwheel.dispatchEvent(i, {
827
+ m && T.pressandwheel.dispatchEvent(a, {
772
828
  frame: o.current,
773
829
  pointer: m,
774
- keys: r.keys,
775
- deltaX: r.deltaX,
776
- deltaY: r.deltaY,
777
- deltaAbs: r.deltaAbs
830
+ keys: i.keys,
831
+ deltaX: i.deltaX,
832
+ deltaY: i.deltaY,
833
+ deltaAbs: i.deltaAbs
778
834
  });
779
835
  }
780
- ), T("sync_spanselect", a, (r) => {
836
+ ), M("sync_spanselect", l, (i) => {
781
837
  const m = xt(
782
838
  "x",
783
- r.xRange,
839
+ i.xRange,
784
840
  o.current
785
841
  ), y = xt(
786
842
  "y",
787
- r.yRange,
843
+ i.yRange,
788
844
  o.current
789
- ), x = m.scaled, g = y.scaled;
790
- r.completed && (u.current = null), v.spanselect.dispatchEvent(i, {
791
- mode: r.mode,
845
+ ), x = m.scaled, v = y.scaled;
846
+ i.completed && (d.current = null), T.spanselect.dispatchEvent(a, {
847
+ mode: i.mode,
792
848
  frame: o.current,
793
849
  xRanges: x,
794
- yRanges: g,
795
- completed: r.completed,
850
+ yRanges: v,
851
+ completed: i.completed,
796
852
  x: { fromCSS: m.fromCSS, toCSS: m.toCSS },
797
853
  y: { fromCSS: y.fromCSS, toCSS: y.toCSS },
798
- keys: r.keys
854
+ keys: i.keys
799
855
  });
800
- }), /* @__PURE__ */ L(
856
+ }), /* @__PURE__ */ X(
801
857
  "div",
802
858
  {
803
859
  ref: c,
@@ -812,66 +868,66 @@ const le = At(({ configuration: t, children: s, style: e, className: c }, n) =>
812
868
  zIndex: 25,
813
869
  ...s
814
870
  },
815
- onClick: (r) => {
816
- f(r, (m, y, x) => {
817
- v.sync_click.dispatchEvent(a, {
871
+ onClick: (i) => {
872
+ f(i, (m, y, x) => {
873
+ T.sync_click.dispatchEvent(l, {
818
874
  positions: m,
819
875
  keys: x
820
876
  });
821
877
  });
822
878
  },
823
- onMouseLeave: (r) => {
824
- f(r, (m, y, x) => {
825
- v.sync_move.dispatchEvent(a, {
879
+ onMouseLeave: (i) => {
880
+ f(i, (m, y, x) => {
881
+ T.sync_move.dispatchEvent(l, {
826
882
  positions: null,
827
883
  keys: x
828
884
  });
829
885
  });
830
886
  },
831
- onMouseMove: (r) => {
832
- f(r, (m, y, x) => {
833
- v.sync_move.dispatchEvent(a, {
887
+ onMouseMove: (i) => {
888
+ f(i, (m, y, x) => {
889
+ T.sync_move.dispatchEvent(l, {
834
890
  positions: m,
835
891
  keys: x
836
892
  });
837
893
  });
838
894
  },
839
- onMouseDown: (r) => {
840
- f(r, (m, { cssX: y, cssY: x }, g) => {
841
- v.sync_mousedown.dispatchEvent(a, {
895
+ onMouseDown: (i) => {
896
+ f(i, (m, { cssX: y, cssY: x }, v) => {
897
+ T.sync_mousedown.dispatchEvent(l, {
842
898
  positions: m,
843
- keys: g
844
- }), l.current = null, u.current = {
899
+ keys: v
900
+ }), u.current = null, d.current = {
845
901
  xRangeCss: { start: y, end: y },
846
902
  yRangeCss: { start: x, end: x }
847
903
  };
848
904
  });
849
905
  },
850
- onMouseUp: (r) => {
851
- f(r, (m, y, x) => {
852
- v.sync_mouseup.dispatchEvent(a, {
906
+ onMouseUp: (i) => {
907
+ f(i, (m, y, x) => {
908
+ T.sync_mouseup.dispatchEvent(l, {
853
909
  positions: m,
854
910
  keys: x
855
911
  });
856
- const g = l.current;
857
- l.current = null;
858
- const S = u.current;
859
- if (u.current = null, S && g) {
860
- const w = {
861
- ...g,
912
+ const v = u.current;
913
+ u.current = null;
914
+ const g = d.current;
915
+ if (d.current = null, g && v) {
916
+ const S = {
917
+ ...v,
862
918
  keys: x,
863
919
  completed: !0
864
920
  };
865
- v.sync_spanselect.dispatchEvent(
866
- a,
867
- w
921
+ T.sync_spanselect.dispatchEvent(
922
+ l,
923
+ S
868
924
  );
869
925
  }
870
926
  });
871
927
  },
872
- onDoubleClick: (r) => {
873
- f(r, (m, y, x) => {
874
- v.sync_dblclick.dispatchEvent(a, {
928
+ onDoubleClick: (i) => {
929
+ f(i, (m, y, x) => {
930
+ T.sync_dblclick.dispatchEvent(l, {
875
931
  positions: m,
876
932
  keys: x
877
933
  });
@@ -879,134 +935,134 @@ const le = At(({ configuration: t, children: s, style: e, className: c }, n) =>
879
935
  }
880
936
  }
881
937
  );
882
- }, xe = ({ data: t, renderTooltip: s, xScaleId: e }) => {
938
+ }, ve = ({ data: t, renderTooltip: s, xScaleId: e }) => {
883
939
  const [c, n] = N(null);
884
- ft("move", (i) => {
885
- n(i);
940
+ mt("move", (a) => {
941
+ n(a);
886
942
  });
887
- const o = gt(() => {
943
+ const o = St(() => {
888
944
  if (!c)
889
945
  return null;
890
- const { frame: i, pointer: a } = c, u = a?.scaled[e];
891
- if (u === void 0)
946
+ const { frame: a, pointer: l } = c, d = l?.scaled[e];
947
+ if (d === void 0)
892
948
  return null;
893
- const l = [];
894
- let d = u;
949
+ const u = [];
950
+ let r = d;
895
951
  for (const p of t) {
896
952
  let f = null, h = 1 / 0;
897
953
  for (const [m, y] of p.points.entries()) {
898
- if (!rt(i, y.x, e) || !rt(i, y.y, p.yScaleId))
954
+ if (!it(a, y.x, e) || !it(a, y.y, p.yScaleId))
899
955
  continue;
900
- const x = Math.abs(y.x - u);
956
+ const x = Math.abs(y.x - d);
901
957
  x < h && (h = x, f = m);
902
958
  }
903
- const r = p.points[f ?? -1];
904
- if (!r || ut(i, h, e, "css") > 30) {
905
- l.push({ seriesId: p.seriesId, y: null });
959
+ const i = p.points[f ?? -1];
960
+ if (!i || ut(a, h, e, "css") > 30) {
961
+ u.push({ seriesId: p.seriesId, y: null });
906
962
  continue;
907
963
  }
908
- d = r.x, l.push({
964
+ r = i.x, u.push({
909
965
  seriesId: p.seriesId,
910
- y: r.y
966
+ y: i.y
911
967
  });
912
968
  }
913
969
  return {
914
- frame: i,
915
- x: d,
916
- points: l
970
+ frame: a,
971
+ x: r,
972
+ points: u
917
973
  };
918
974
  }, [t, c, e]);
919
975
  return s(o);
920
- }, Se = ({ makeXStyle: t, makeXClassName: s, makeYStyle: e, makeYClassName: c }) => {
976
+ }, we = ({ makeXStyle: t, makeXClassName: s, makeYStyle: e, makeYClassName: c }) => {
921
977
  const [n, o] = N(null);
922
- if (ft("move", (d) => {
923
- o(d);
978
+ if (mt("move", (r) => {
979
+ o(r);
924
980
  }), !n)
925
981
  return null;
926
- const { frame: i, pointer: a } = n, u = z(i, a?.cssX ?? 0, "css"), l = Y(i, a?.cssY ?? 0, "css");
982
+ const { frame: a, pointer: l } = n, d = O(a, l?.cssX ?? 0, "css"), u = $(a, l?.cssY ?? 0, "css");
927
983
  return /* @__PURE__ */ at(Et, { children: [
928
- /* @__PURE__ */ L(
984
+ /* @__PURE__ */ X(
929
985
  "div",
930
986
  {
931
- "data-show": !!a,
987
+ "data-show": !!l,
932
988
  className: s?.(n),
933
989
  style: {
934
990
  position: "absolute",
935
991
  left: 0,
936
- top: i.chartAreaCSS.y,
937
- height: i.chartAreaCSS.height,
992
+ top: a.chartAreaCSS.y,
993
+ height: a.chartAreaCSS.height,
938
994
  borderColor: "red",
939
995
  borderLeftWidth: "1px",
940
996
  borderLeftStyle: "solid",
941
997
  pointerEvents: "none",
942
- opacity: a ? 1 : 0,
943
- transform: `translateX(${u}px)`,
998
+ opacity: l ? 1 : 0,
999
+ transform: `translateX(${d}px)`,
944
1000
  ...t?.(n)
945
1001
  }
946
1002
  }
947
1003
  ),
948
- /* @__PURE__ */ L(
1004
+ /* @__PURE__ */ X(
949
1005
  "div",
950
1006
  {
951
1007
  className: c?.(n),
952
- "data-show": !!a,
1008
+ "data-show": !!l,
953
1009
  style: {
954
1010
  position: "absolute",
955
1011
  top: 0,
956
1012
  height: 0,
957
1013
  borderTop: "solid 1px red",
958
- left: i.chartAreaCSS.x,
959
- width: i.chartAreaCSS.width,
1014
+ left: a.chartAreaCSS.x,
1015
+ width: a.chartAreaCSS.width,
960
1016
  pointerEvents: "none",
961
- opacity: a ? 1 : 0,
962
- transform: `translateY(${l}px)`,
1017
+ opacity: l ? 1 : 0,
1018
+ transform: `translateY(${u}px)`,
963
1019
  ...e?.(n)
964
1020
  }
965
1021
  }
966
1022
  )
967
1023
  ] });
968
- }, ge = ({ makeClassName: t, makeStyle: s }) => {
1024
+ }, Ce = ({ makeClassName: t, makeStyle: s }) => {
969
1025
  const [e, c] = N(null);
970
- if (ft("spanselect", (f) => {
1026
+ if (mt("spanselect", (f) => {
971
1027
  c(f.mode === "none" || f.completed ? null : f);
972
1028
  }), !e)
973
1029
  return null;
974
- const n = z(
1030
+ const n = O(
975
1031
  e.frame,
976
1032
  e.x.fromCSS,
977
1033
  "css"
978
- ), o = z(
1034
+ ), o = O(
979
1035
  e.frame,
980
1036
  e.x.toCSS,
981
1037
  "css"
982
- ), i = Y(
1038
+ ), a = $(
983
1039
  e.frame,
984
1040
  e.y.fromCSS,
985
1041
  "css"
986
- ), a = Y(
1042
+ ), l = $(
987
1043
  e.frame,
988
1044
  e.y.toCSS,
989
1045
  "css"
990
- ), u = Math.min(n, o), l = Math.min(i, a), d = Math.abs(o - n), p = Math.abs(a - i);
991
- return /* @__PURE__ */ L(
1046
+ ), d = Math.min(n, o), u = Math.min(a, l), r = Math.abs(o - n), p = Math.abs(l - a);
1047
+ return /* @__PURE__ */ X(
992
1048
  "div",
993
1049
  {
994
1050
  className: t?.(e),
995
1051
  style: {
996
1052
  position: "absolute",
997
1053
  backgroundColor: "#0000ff22",
998
- left: `${u}px`,
999
- top: `${l}px`,
1000
- width: `${d}px`,
1054
+ left: `${d}px`,
1055
+ top: `${u}px`,
1056
+ width: `${r}px`,
1001
1057
  height: `${p}px`,
1002
1058
  pointerEvents: "none",
1003
1059
  ...s?.(e)
1004
1060
  }
1005
1061
  }
1006
1062
  );
1007
- }, we = ({ style: t, children: s, scaleId: e, ...c }) => {
1063
+ }, be = ({ style: t, children: s, scaleId: e, ...c }) => {
1008
1064
  const n = ht((o) => o.getScale(e)?.axis);
1009
- return n ? /* @__PURE__ */ L(
1065
+ return n ? /* @__PURE__ */ X(
1010
1066
  "div",
1011
1067
  {
1012
1068
  style: {
@@ -1022,27 +1078,27 @@ const le = At(({ configuration: t, children: s, style: e, className: c }, n) =>
1022
1078
  children: s
1023
1079
  }
1024
1080
  ) : null;
1025
- }, vt = 60, Vt = 30, Ct = "UTC", Ht = "en-GB", ve = ({
1081
+ }, wt = 60, Vt = 30, Ct = "UTC", jt = "en-GB", Te = ({
1026
1082
  space: t,
1027
1083
  formatter: s
1028
1084
  } = {}) => (e, c) => {
1029
- const { min: n, max: o } = e, i = [], a = window.devicePixelRatio || 1, u = (t ?? (e.origin === "x" ? vt : Vt)) * a, l = Lt(
1085
+ const { min: n, max: o } = e, a = [], l = window.devicePixelRatio || 1, d = (t ?? (e.origin === "x" ? wt : Vt)) * l, u = Lt(
1030
1086
  c,
1031
- u,
1087
+ d,
1032
1088
  e.id,
1033
1089
  "canvas"
1034
- ), d = H.find((f) => f > l) ?? 1;
1035
- let p = n % d < Number.EPSILON ? n : n + d - n % d;
1090
+ ), r = H.find((f) => f > u) ?? 1;
1091
+ let p = n % r < Number.EPSILON ? n : n + r - n % r;
1036
1092
  for (; p <= o; )
1037
- i.push(p), p += d;
1038
- return (s ?? jt)(i);
1039
- }, jt = (t) => {
1093
+ a.push(p), p += r;
1094
+ return (s ?? Ht)(a);
1095
+ }, Ht = (t) => {
1040
1096
  const s = Math.max(0, Math.ceil(-Math.log10(t[1] - t[0])));
1041
1097
  return t.map((e) => ({ value: e, label: e.toFixed(s) }));
1042
1098
  }, H = [];
1043
1099
  for (let t = -12; t <= 12; t++)
1044
1100
  H.push(1 * 10 ** t), H.push(2 * 10 ** t), H.push(5 * 10 ** t);
1045
- const Wt = 1, bt = 1e3 * Wt, pt = 60 * bt, q = 60 * pt, tt = 24 * q, Zt = 30 * tt, Gt = 365 * tt, Jt = [
1101
+ const Wt = 1, bt = 1e3 * Wt, pt = 60 * bt, q = 60 * pt, tt = 24 * q, Gt = 30 * tt, Zt = 365 * tt, Jt = [
1046
1102
  // second divisors
1047
1103
  [1, "milliseconds"],
1048
1104
  [2, "milliseconds"],
@@ -1094,7 +1150,7 @@ const Wt = 1, bt = 1e3 * Wt, pt = 60 * bt, q = 60 * pt, tt = 24 * q, Zt = 30 * t
1094
1150
  [25, "years"],
1095
1151
  [50, "years"],
1096
1152
  [100, "years"]
1097
- ], j = (t) => {
1153
+ ], W = (t) => {
1098
1154
  const [s, e] = t;
1099
1155
  switch (e) {
1100
1156
  case "milliseconds":
@@ -1108,9 +1164,9 @@ const Wt = 1, bt = 1e3 * Wt, pt = 60 * bt, q = 60 * pt, tt = 24 * q, Zt = 30 * t
1108
1164
  case "days":
1109
1165
  return s * tt;
1110
1166
  case "months":
1111
- return s * Zt;
1112
- case "years":
1113
1167
  return s * Gt;
1168
+ case "years":
1169
+ return s * Zt;
1114
1170
  }
1115
1171
  }, qt = (t, s) => {
1116
1172
  const e = new Date(t);
@@ -1127,10 +1183,10 @@ const Wt = 1, bt = 1e3 * Wt, pt = 60 * bt, q = 60 * pt, tt = 24 * q, Zt = 30 * t
1127
1183
  }, se = (t, s) => {
1128
1184
  const e = new Date(t);
1129
1185
  return e.setUTCDate(e.getUTCDate() + s), e.getTime();
1130
- }, St = (t, s) => {
1186
+ }, gt = (t, s) => {
1131
1187
  const e = new Date(t);
1132
1188
  return e.setUTCMonth(e.getUTCMonth() + s), e.getTime();
1133
- }, X = (t, s) => {
1189
+ }, I = (t, s) => {
1134
1190
  const [e, c] = s;
1135
1191
  switch (c) {
1136
1192
  case "milliseconds":
@@ -1144,20 +1200,20 @@ const Wt = 1, bt = 1e3 * Wt, pt = 60 * bt, q = 60 * pt, tt = 24 * q, Zt = 30 * t
1144
1200
  case "days":
1145
1201
  return se(t, e);
1146
1202
  case "months":
1147
- return St(t, e);
1203
+ return gt(t, e);
1148
1204
  case "years":
1149
- return St(t, e * 12);
1205
+ return gt(t, e * 12);
1150
1206
  }
1151
1207
  };
1152
- function W(t, s) {
1208
+ function G(t, s) {
1153
1209
  const e = new Date(t), c = new Date(e.toLocaleString("en-US", { timeZone: s })), n = new Date(e.toLocaleString("en-US", { timeZone: "UTC" }));
1154
1210
  return (c.getTime() - n.getTime()) / (3600 * 1e3);
1155
1211
  }
1156
1212
  const ne = (t, s, e = "UTC") => {
1157
1213
  const [c, n] = s;
1158
1214
  let o = new Date(t);
1159
- const i = () => {
1160
- o.setUTCHours(-W(o, e), 0, 0, 0);
1215
+ const a = () => {
1216
+ o.setUTCHours(-G(o, e), 0, 0, 0);
1161
1217
  };
1162
1218
  switch (n) {
1163
1219
  case "milliseconds":
@@ -1189,20 +1245,20 @@ const ne = (t, s, e = "UTC") => {
1189
1245
  case "days":
1190
1246
  case "months":
1191
1247
  case "years":
1192
- n === "months" ? o.setUTCDate(1) : n === "years" && o.setUTCMonth(0, 1), i(), o.getTime() < t && (o = new Date(X(o, [1, n])));
1248
+ n === "months" ? o.setUTCDate(1) : n === "years" && o.setUTCMonth(0, 1), a(), o.getTime() < t && (o = new Date(I(o, [1, n])));
1193
1249
  break;
1194
1250
  }
1195
1251
  return o.getTime();
1196
- }, Ce = ({
1252
+ }, ke = ({
1197
1253
  timeZone: t = Ct,
1198
- space: s = vt,
1254
+ space: s = wt,
1199
1255
  formatter: e,
1200
1256
  locale: c,
1201
1257
  showTimezone: n
1202
- } = {}) => (o, i) => {
1203
- const { min: a, max: u } = o, l = Math.floor(i.chartAreaCanvasPX.width / s) + 1, p = (u - a) / l, [f, h] = Jt.find(
1204
- (g) => j(g) >= p
1205
- ) ?? [1, "milliseconds"], r = ne(a, [f, h], t), m = W(r, t), y = [r];
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(
1260
+ (v) => W(v) >= p
1261
+ ) ?? [1, "milliseconds"], i = ne(l, [f, h], t), m = G(i, t), y = [i];
1206
1262
  let x;
1207
1263
  for (; ; ) {
1208
1264
  switch (h) {
@@ -1210,37 +1266,37 @@ const ne = (t, s, e = "UTC") => {
1210
1266
  case "seconds":
1211
1267
  case "minutes":
1212
1268
  case "hours": {
1213
- x = X(r, [y.length * f, h]);
1269
+ x = I(i, [y.length * f, h]);
1214
1270
  break;
1215
1271
  }
1216
1272
  case "days": {
1217
- const g = X(r, [
1273
+ const v = I(i, [
1218
1274
  y.length * f,
1219
1275
  h
1220
1276
  ]);
1221
- x = X(g, [
1222
- m - W(g, t),
1277
+ x = I(v, [
1278
+ m - G(v, t),
1223
1279
  "hours"
1224
1280
  ]);
1225
1281
  break;
1226
1282
  }
1227
1283
  case "months":
1228
1284
  case "years": {
1229
- const g = X(
1230
- X(X(r, [m, "hours"]), [
1285
+ const v = I(
1286
+ I(I(i, [m, "hours"]), [
1231
1287
  y.length * f,
1232
1288
  h
1233
1289
  ]),
1234
1290
  [-m, "hours"]
1235
1291
  );
1236
- x = X(g, [
1237
- m - W(g, t),
1292
+ x = I(v, [
1293
+ m - G(v, t),
1238
1294
  "hours"
1239
1295
  ]);
1240
1296
  break;
1241
1297
  }
1242
1298
  }
1243
- if (x > u)
1299
+ if (x > d)
1244
1300
  break;
1245
1301
  y.push(x);
1246
1302
  }
@@ -1249,9 +1305,9 @@ const ne = (t, s, e = "UTC") => {
1249
1305
  showTimezone: n,
1250
1306
  timeZone: t
1251
1307
  }))(y);
1252
- }, I = (t, s, e) => t.find((c) => c.type === e)?.value !== s.find((c) => c.type === e)?.value, oe = ({
1308
+ }, K = (t, s, e) => t.find((c) => c.type === e)?.value !== s.find((c) => c.type === e)?.value, oe = ({
1253
1309
  timeZone: t = Ct,
1254
- locale: s = Ht,
1310
+ locale: s = jt,
1255
1311
  showTimezone: e = !0
1256
1312
  }) => {
1257
1313
  const c = new Intl.DateTimeFormat(s, {
@@ -1267,30 +1323,30 @@ const ne = (t, s, e = "UTC") => {
1267
1323
  timeZone: t
1268
1324
  });
1269
1325
  return (n) => {
1270
- const o = n[1] - n[0], i = o < j([1, "days"]), a = o < j([1, "minutes"]), u = o < j([1, "seconds"]);
1271
- return n.map((l) => ({ value: l, label: c.formatToParts(new Date(l)) })).map((l, d, p) => {
1272
- const f = p[d - 1], h = d === 0 || I(l.label, f.label, "year"), r = d === 0 || I(l.label, f.label, "day"), m = d === 0 || I(l.label, f.label, "month"), y = d === 0 || I(l.label, f.label, "hour"), x = d === 0 || I(l.label, f.label, "timeZoneName"), g = d === 0 || I(l.label, f.label, "minute"), S = d === 0 || I(l.label, f.label, "second"), w = d === 0 || I(l.label, f.label, "fractionalSecond"), k = [];
1273
- if (i && (y || g || x || S || w)) {
1274
- const C = l.label.find((P) => P.type === "hour")?.value, E = l.label.find((P) => P.type === "minute")?.value, M = l.label.find((P) => P.type === "timeZoneName")?.value;
1275
- let A = "";
1276
- if (a) {
1277
- const P = l.label.find((K) => K.type === "second")?.value, $ = l.label.find(
1278
- (K) => K.type === "fractionalSecond"
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
+ 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;
1331
+ let _ = "";
1332
+ if (l) {
1333
+ const A = u.label.find((F) => F.type === "second")?.value, B = u.label.find(
1334
+ (F) => F.type === "fractionalSecond"
1279
1335
  )?.value;
1280
- A = `:${P}` + (u ? `.${$}` : "");
1336
+ _ = `:${A}` + (d ? `.${B}` : "");
1281
1337
  }
1282
- k.push(
1283
- `${C}:${E}${A}` + (e && x ? ` ${M}` : "")
1338
+ w.push(
1339
+ `${b}:${k}${_}` + (e && x ? ` ${C}` : "")
1284
1340
  );
1285
1341
  }
1286
- return (r || m) && k.push(
1342
+ return (i || m) && w.push(
1287
1343
  [
1288
- l.label.find((C) => C.type === "month")?.value,
1289
- r && l.label.find((C) => C.type === "day")?.value
1344
+ u.label.find((b) => b.type === "month")?.value,
1345
+ i && u.label.find((b) => b.type === "day")?.value
1290
1346
  ].filter(Boolean).join(" ")
1291
- ), h && k.push(l.label.find((C) => C.type === "year")?.value), {
1292
- value: l.value,
1293
- label: k.filter((C) => C).join(`
1347
+ ), h && w.push(u.label.find((b) => b.type === "year")?.value), {
1348
+ value: u.value,
1349
+ label: w.filter((b) => b).join(`
1294
1350
  `)
1295
1351
  };
1296
1352
  });
@@ -1298,33 +1354,36 @@ const ne = (t, s, e = "UTC") => {
1298
1354
  };
1299
1355
  export {
1300
1356
  me as AreaPlot,
1301
- we as AxisOverlay,
1302
- he as BarPlot,
1303
- le as CanPlot,
1304
- ye as ChartAreaInteractions,
1305
- Se as Crosshair,
1306
- ue as LinePlot,
1307
- de as ScatterPlot,
1308
- ge as SelectBox,
1309
- fe as SparklinePlot,
1310
- xe as TooltipsX,
1311
- O as applyStyles,
1312
- z as clampXPosToChartArea,
1313
- Y as clampYPosToChartArea,
1314
- jt as defaultNumericalTicksFormatter,
1315
- D as getScale,
1357
+ be as AxisOverlay,
1358
+ fe as BarPlot,
1359
+ ue as CanPlot,
1360
+ Se as ChartAreaInteractions,
1361
+ we as Crosshair,
1362
+ de as LinePlot,
1363
+ he as ScatterPlot,
1364
+ Ce as SelectBox,
1365
+ pe as SparklinePlot,
1366
+ ve as TooltipsX,
1367
+ xe as XTicks,
1368
+ ge as YTicks,
1369
+ R as applyStyles,
1370
+ le as clampUnfit,
1371
+ O as clampXPosToChartArea,
1372
+ $ as clampYPosToChartArea,
1373
+ Ht as defaultNumericalTicksFormatter,
1374
+ P as getScale,
1316
1375
  Q as isXScale,
1317
1376
  ae as isYScale,
1318
- ve as makeLinearTicks,
1377
+ Te as makeLinearTicks,
1319
1378
  oe as makeTimeTickFormat,
1320
- Ce as makeTimeTicks,
1321
- U as posToVal,
1379
+ ke as makeTimeTicks,
1380
+ D as posToVal,
1322
1381
  Lt as pxToValDistance,
1323
- V as useDrawEffect,
1382
+ z as useDrawEffect,
1324
1383
  ht as useFrameState,
1325
- pe as usePositioned,
1326
- rt as valFits,
1327
- B as valToPos,
1384
+ ye as useXPositioned,
1385
+ it as valFits,
1386
+ j as valToPos,
1328
1387
  ut as valToPxDistance
1329
1388
  };
1330
1389
  //# sourceMappingURL=canplot.mjs.map