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