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