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