@canplot/react 0.1.19 → 0.1.21

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