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