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