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