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