@ledgerhq/lumen-ui-react-visualization 0.1.18 → 0.1.19
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/lib/Components/Axis/XAxis/XAxis.d.ts.map +1 -1
- package/dist/lib/Components/Axis/XAxis/XAxis.js +14 -14
- package/dist/lib/Components/Axis/YAxis/YAxis.d.ts.map +1 -1
- package/dist/lib/Components/Axis/YAxis/YAxis.js +30 -30
- package/dist/lib/Components/CartesianChart/CartesianChart.d.ts +1 -1
- package/dist/lib/Components/CartesianChart/CartesianChart.d.ts.map +1 -1
- package/dist/lib/Components/CartesianChart/CartesianChart.js +82 -75
- package/dist/lib/Components/CartesianChart/ChartEmptyLabel/ChartEmptyLabel.d.ts +11 -0
- package/dist/lib/Components/CartesianChart/ChartEmptyLabel/ChartEmptyLabel.d.ts.map +1 -0
- package/dist/lib/Components/CartesianChart/ChartEmptyLabel/ChartEmptyLabel.js +21 -0
- package/dist/lib/Components/CartesianChart/RevealClip/RevealClipDefs.d.ts.map +1 -1
- package/dist/lib/Components/CartesianChart/RevealClip/RevealClipDefs.js +11 -10
- package/dist/lib/Components/CartesianChart/RevealClip/types.d.ts +1 -1
- package/dist/lib/Components/CartesianChart/RevealClip/types.d.ts.map +1 -1
- package/dist/lib/Components/CartesianChart/hooks/useDataFingerprint.d.ts +9 -0
- package/dist/lib/Components/CartesianChart/hooks/useDataFingerprint.d.ts.map +1 -0
- package/dist/lib/Components/CartesianChart/hooks/useDataFingerprint.js +8 -0
- package/dist/lib/Components/CartesianChart/{RevealClip/utils.d.ts → hooks/useRevealClipAnimation.d.ts} +2 -5
- package/dist/lib/Components/CartesianChart/hooks/useRevealClipAnimation.d.ts.map +1 -0
- package/dist/lib/Components/CartesianChart/hooks/useRevealClipAnimation.js +20 -0
- package/dist/lib/Components/CartesianChart/hooks/useShimmerAnimation.d.ts +18 -0
- package/dist/lib/Components/CartesianChart/hooks/useShimmerAnimation.d.ts.map +1 -0
- package/dist/lib/Components/CartesianChart/hooks/useShimmerAnimation.js +14 -0
- package/dist/lib/Components/CartesianChart/types.d.ts +11 -0
- package/dist/lib/Components/CartesianChart/types.d.ts.map +1 -1
- package/dist/lib/Components/Line/Line.d.ts +1 -1
- package/dist/lib/Components/Line/Line.d.ts.map +1 -1
- package/dist/lib/Components/Line/Line.js +33 -33
- package/dist/lib/Components/Line/constants.d.ts +4 -0
- package/dist/lib/Components/Line/constants.d.ts.map +1 -0
- package/dist/lib/Components/Line/constants.js +7 -0
- package/dist/lib/Components/Line/index.d.ts +1 -1
- package/dist/lib/Components/Line/index.d.ts.map +1 -1
- package/dist/lib/Components/Line/types.d.ts +8 -0
- package/dist/lib/Components/Line/types.d.ts.map +1 -1
- package/dist/lib/Components/Line/utils.d.ts +3 -3
- package/dist/lib/Components/Line/utils.d.ts.map +1 -1
- package/dist/lib/Components/Line/utils.js +31 -18
- package/dist/lib/Components/LineChart/LineChart.d.ts +1 -1
- package/dist/lib/Components/LineChart/LineChart.d.ts.map +1 -1
- package/dist/lib/Components/LineChart/LineChart.js +141 -70
- package/dist/lib/Components/LineChart/LineChartEmptyState/LineChartEmptyState.d.ts +9 -0
- package/dist/lib/Components/LineChart/LineChartEmptyState/LineChartEmptyState.d.ts.map +1 -0
- package/dist/lib/Components/LineChart/LineChartEmptyState/LineChartEmptyState.js +51 -0
- package/dist/lib/Components/LineChart/LineChartEmptyState/index.d.ts +3 -0
- package/dist/lib/Components/LineChart/LineChartEmptyState/index.d.ts.map +1 -0
- package/dist/lib/Components/LineChart/LineChartEmptyState/types.d.ts +3 -0
- package/dist/lib/Components/LineChart/LineChartEmptyState/types.d.ts.map +1 -0
- package/dist/lib/Components/LineChart/LineChartEmptyState/utils.d.ts +14 -0
- package/dist/lib/Components/LineChart/LineChartEmptyState/utils.d.ts.map +1 -0
- package/dist/lib/Components/LineChart/LineChartEmptyState/utils.js +9 -0
- package/dist/lib/Components/LineChart/__stories__/chartStoryFixtures.d.ts +36 -3
- package/dist/lib/Components/LineChart/__stories__/chartStoryFixtures.d.ts.map +1 -1
- package/dist/lib/Components/LineChart/types.d.ts +28 -1
- package/dist/lib/Components/LineChart/types.d.ts.map +1 -1
- package/dist/lib/Components/LineChart/utils.d.ts +43 -0
- package/dist/lib/Components/LineChart/utils.d.ts.map +1 -0
- package/dist/lib/Components/LineChart/utils.js +37 -0
- package/dist/lib/Components/ReferenceLine/ReferenceLine.d.ts.map +1 -1
- package/dist/lib/Components/ReferenceLine/ReferenceLine.js +16 -16
- package/dist/lib/Components/ReferenceLine/constants.d.ts +3 -3
- package/dist/lib/Components/ReferenceLine/constants.d.ts.map +1 -1
- package/dist/lib/Components/ReferenceLine/constants.js +5 -5
- package/dist/lib/Components/ReferenceLine/utils.d.ts.map +1 -1
- package/dist/lib/Components/ReferenceLine/utils.js +15 -14
- package/dist/lib/Components/Scrubber/Scrubber.d.ts.map +1 -1
- package/dist/lib/Components/Scrubber/Scrubber.js +34 -29
- package/dist/lib/Components/Scrubber/ScrubberProvider.d.ts.map +1 -1
- package/dist/lib/Components/Scrubber/ScrubberProvider.js +68 -67
- package/dist/lib/Components/Scrubber/utils.d.ts.map +1 -1
- package/dist/lib/Components/Scrubber/utils.js +30 -32
- package/dist/lib/utils/index.d.ts +1 -1
- package/dist/lib/utils/index.d.ts.map +1 -1
- package/dist/lib/utils/numbers.d.ts +13 -0
- package/dist/lib/utils/numbers.d.ts.map +1 -0
- package/dist/lib/utils/numbers.js +5 -0
- package/dist/lib/utils/ticks/ticks.d.ts +1 -11
- package/dist/lib/utils/ticks/ticks.d.ts.map +1 -1
- package/dist/lib/utils/ticks/ticks.js +19 -21
- package/dist/lib/utils/types.d.ts +19 -1
- package/dist/lib/utils/types.d.ts.map +1 -1
- package/dist/node_modules/d3-shape/src/curve/monotone.js +69 -0
- package/dist/node_modules/d3-shape/src/curve/natural.js +41 -0
- package/dist/node_modules/d3-shape/src/curve/step.js +51 -0
- package/dist/package.json +2 -2
- package/package.json +3 -3
- package/dist/lib/Components/CartesianChart/RevealClip/utils.d.ts.map +0 -1
- package/dist/lib/Components/CartesianChart/RevealClip/utils.js +0 -23
|
@@ -1,84 +1,85 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsx as q } from "react/jsx-runtime";
|
|
2
|
+
import { useState as K, useRef as k, useMemo as X, useCallback as c, useEffect as j } from "react";
|
|
3
|
+
import { clamp as p } from "../../utils/numbers.js";
|
|
4
|
+
import { buildSortedMagnets as z, getDataIndexFromPosition as H, resolvePixelX as N, applyMagnetization as U } from "./utils.js";
|
|
5
|
+
import { useCartesianChartContext as V } from "../CartesianChart/context/cartesianChartContext.js";
|
|
6
|
+
import { useMagneticPointsContext as G } from "../Point/pointContext/magneticPointsContext.js";
|
|
7
|
+
import { ScrubberContextProvider as J } from "./context/scrubberContext.js";
|
|
8
|
+
function S({
|
|
9
|
+
children: R,
|
|
10
|
+
svgRef: D,
|
|
10
11
|
enableScrubbing: r,
|
|
11
|
-
onScrubberPositionChange:
|
|
12
|
-
magnetRadius:
|
|
12
|
+
onScrubberPositionChange: y,
|
|
13
|
+
magnetRadius: E = 8
|
|
13
14
|
}) {
|
|
14
|
-
const { getXScale: f, getXAxisConfig:
|
|
15
|
+
const { getXScale: f, getXAxisConfig: v, dataLength: n } = V(), { getMagneticPoints: w, version: T } = G(), [m, B] = K(
|
|
15
16
|
void 0
|
|
16
|
-
), h =
|
|
17
|
-
h.current =
|
|
18
|
-
const
|
|
19
|
-
const t =
|
|
20
|
-
return
|
|
17
|
+
), h = k(m);
|
|
18
|
+
h.current = m;
|
|
19
|
+
const g = k(null), l = k(0), A = X(() => {
|
|
20
|
+
const t = w();
|
|
21
|
+
return z({
|
|
21
22
|
magneticIndices: t,
|
|
22
|
-
getPixelForIndex: (e) =>
|
|
23
|
+
getPixelForIndex: (e) => N(e, f, v())
|
|
23
24
|
});
|
|
24
|
-
}, [
|
|
25
|
+
}, [T, w, f, v]), i = c(
|
|
25
26
|
(t) => {
|
|
26
|
-
const e = t === void 0 ? void 0 :
|
|
27
|
-
|
|
27
|
+
const e = t === void 0 || n <= 0 ? void 0 : p(t, 0, n - 1);
|
|
28
|
+
B(e), y?.(e);
|
|
28
29
|
},
|
|
29
|
-
[
|
|
30
|
-
),
|
|
30
|
+
[n, y]
|
|
31
|
+
), I = c(
|
|
31
32
|
(t) => {
|
|
32
33
|
const e = f();
|
|
33
|
-
if (!e || !r ||
|
|
34
|
-
const a =
|
|
35
|
-
let o =
|
|
34
|
+
if (!e || !r || n <= 0) return;
|
|
35
|
+
const a = v();
|
|
36
|
+
let o = H(
|
|
36
37
|
t,
|
|
37
38
|
e,
|
|
38
39
|
a,
|
|
39
|
-
|
|
40
|
+
n
|
|
40
41
|
);
|
|
41
|
-
|
|
42
|
+
E > 0 && (o = U({
|
|
42
43
|
resolvedIndex: o,
|
|
43
44
|
pixelX: t,
|
|
44
|
-
sortedMagnets:
|
|
45
|
-
magnetRadius:
|
|
45
|
+
sortedMagnets: A,
|
|
46
|
+
magnetRadius: E
|
|
46
47
|
})), o !== h.current && i(o);
|
|
47
48
|
},
|
|
48
49
|
[
|
|
49
50
|
r,
|
|
50
51
|
f,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
v,
|
|
53
|
+
n,
|
|
54
|
+
A,
|
|
55
|
+
E,
|
|
55
56
|
i
|
|
56
57
|
]
|
|
57
|
-
), u =
|
|
58
|
+
), u = c(
|
|
58
59
|
(t) => {
|
|
59
|
-
|
|
60
|
+
g.current = t, l.current || (l.current = requestAnimationFrame(() => {
|
|
60
61
|
l.current = 0;
|
|
61
|
-
const e =
|
|
62
|
-
e !== null && (
|
|
62
|
+
const e = g.current;
|
|
63
|
+
e !== null && (g.current = null, I(e));
|
|
63
64
|
}));
|
|
64
65
|
},
|
|
65
|
-
[
|
|
66
|
-
),
|
|
66
|
+
[I]
|
|
67
|
+
), s = c(() => {
|
|
67
68
|
r && i(void 0);
|
|
68
|
-
}, [r, i]),
|
|
69
|
+
}, [r, i]), L = c(
|
|
69
70
|
(t) => {
|
|
70
71
|
const a = t.currentTarget.getBoundingClientRect();
|
|
71
72
|
u(t.clientX - a.left);
|
|
72
73
|
},
|
|
73
74
|
[u]
|
|
74
|
-
),
|
|
75
|
+
), x = c(
|
|
75
76
|
(t) => {
|
|
76
77
|
if (!r || !t.touches.length) return;
|
|
77
78
|
const e = t.touches[0], o = t.currentTarget.getBoundingClientRect();
|
|
78
79
|
u(e.clientX - o.left);
|
|
79
80
|
},
|
|
80
81
|
[r, u]
|
|
81
|
-
),
|
|
82
|
+
), P = c(
|
|
82
83
|
(t) => {
|
|
83
84
|
if (!t.touches.length) return;
|
|
84
85
|
t.preventDefault();
|
|
@@ -86,17 +87,17 @@ function _({
|
|
|
86
87
|
u(e.clientX - o.left);
|
|
87
88
|
},
|
|
88
89
|
[u]
|
|
89
|
-
),
|
|
90
|
+
), C = c(
|
|
90
91
|
(t) => {
|
|
91
|
-
if (!r ||
|
|
92
|
-
const e =
|
|
92
|
+
if (!r || n <= 0) return;
|
|
93
|
+
const e = n - 1, a = h.current ?? e, o = t.shiftKey ? p(Math.floor(e * 0.1), 1, 10) : 1;
|
|
93
94
|
let d;
|
|
94
95
|
switch (t.key) {
|
|
95
96
|
case "ArrowLeft":
|
|
96
|
-
t.preventDefault(), d =
|
|
97
|
+
t.preventDefault(), d = p(a - o, 0, e);
|
|
97
98
|
break;
|
|
98
99
|
case "ArrowRight":
|
|
99
|
-
t.preventDefault(), d =
|
|
100
|
+
t.preventDefault(), d = p(a + o, 0, e);
|
|
100
101
|
break;
|
|
101
102
|
case "Home":
|
|
102
103
|
t.preventDefault(), d = 0;
|
|
@@ -112,36 +113,36 @@ function _({
|
|
|
112
113
|
}
|
|
113
114
|
i(d);
|
|
114
115
|
},
|
|
115
|
-
[r,
|
|
116
|
-
),
|
|
117
|
-
!r || h.current === void 0 ||
|
|
118
|
-
}, [r,
|
|
119
|
-
|
|
120
|
-
const t =
|
|
116
|
+
[r, n, i]
|
|
117
|
+
), M = c(() => {
|
|
118
|
+
!r || h.current === void 0 || s();
|
|
119
|
+
}, [r, s]);
|
|
120
|
+
j(() => {
|
|
121
|
+
const t = D.current;
|
|
121
122
|
if (!(!t || !r))
|
|
122
|
-
return t.addEventListener("mousemove",
|
|
123
|
-
t.removeEventListener("mousemove",
|
|
123
|
+
return t.addEventListener("mousemove", L), t.addEventListener("mouseleave", s), t.addEventListener("touchstart", x, { passive: !1 }), t.addEventListener("touchmove", P, { passive: !1 }), t.addEventListener("touchend", s), t.addEventListener("touchcancel", s), t.addEventListener("keydown", C), t.addEventListener("blur", M), () => {
|
|
124
|
+
t.removeEventListener("mousemove", L), t.removeEventListener("mouseleave", s), t.removeEventListener("touchstart", x), t.removeEventListener("touchmove", P), t.removeEventListener("touchend", s), t.removeEventListener("touchcancel", s), t.removeEventListener("keydown", C), t.removeEventListener("blur", M), cancelAnimationFrame(l.current), l.current = 0;
|
|
124
125
|
};
|
|
125
126
|
}, [
|
|
126
|
-
|
|
127
|
+
D,
|
|
127
128
|
r,
|
|
128
|
-
E,
|
|
129
|
-
n,
|
|
130
|
-
g,
|
|
131
129
|
L,
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
s,
|
|
131
|
+
x,
|
|
132
|
+
P,
|
|
133
|
+
C,
|
|
134
|
+
M
|
|
134
135
|
]);
|
|
135
|
-
const
|
|
136
|
+
const F = X(
|
|
136
137
|
() => ({
|
|
137
138
|
enableScrubbing: r,
|
|
138
|
-
scrubberPosition:
|
|
139
|
+
scrubberPosition: m,
|
|
139
140
|
onScrubberPositionChange: i
|
|
140
141
|
}),
|
|
141
|
-
[r,
|
|
142
|
+
[r, m, i]
|
|
142
143
|
);
|
|
143
|
-
return /* @__PURE__ */
|
|
144
|
+
return /* @__PURE__ */ q(J, { value: F, children: R });
|
|
144
145
|
}
|
|
145
146
|
export {
|
|
146
|
-
|
|
147
|
+
S as ScrubberProvider
|
|
147
148
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/utils.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAE1E,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,wCAGhC;IACD,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CACzD,KAAG,WAAW,EAad,CAAC;AAgCF;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GACnC,QAAQ,MAAM,EACd,OAAO,kBAAkB,EACzB,YAAY,OAAO,CAAC,aAAa,CAAC,GAAG,SAAS,EAC9C,YAAY,MAAM,KACjB,MAwBF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,GACxB,WAAW,MAAM,EACjB,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,SAAS,EACzC,WAAW,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,WAAW,CAAC,KAClE,MAAM,GAAG,SASX,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,WAAW,MAAM,EACjB,WAAW,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,WAAW,CAAC,EACnE,aAAa,aAAa,KACzB,MAAM,GAAG,SAMX,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,GACvB,eAAe,SAAS,WAAW,EAAE,EACrC,QAAQ,MAAM,KACb,MAsBF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,yDAKhC;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,SAAS,WAAW,EAAE,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC;CACtB,KAAG,MAWH,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { clamp as f } from "../../utils/numbers.js";
|
|
2
|
+
import { getPointOnScale as a, isNumericScale as u, isCategoricalScale as d } from "../../utils/scales/scales.js";
|
|
3
|
+
const E = 5, m = 2, A = 2, I = 0.5, O = 0.8, _ = 0.1, S = ({
|
|
3
4
|
magneticIndices: o,
|
|
4
5
|
getPixelForIndex: i
|
|
5
6
|
}) => {
|
|
@@ -10,7 +11,7 @@ const v = 5, E = 2, m = 2, p = 0.5, A = 0.8, I = 0.1, O = ({
|
|
|
10
11
|
t !== void 0 && n.push({ index: e, pixelX: t });
|
|
11
12
|
}
|
|
12
13
|
return n.sort((e, t) => e.pixelX - t.pixelX), n;
|
|
13
|
-
},
|
|
14
|
+
}, h = (o) => typeof o[0] == "number", l = (o, i, n) => {
|
|
14
15
|
let e = 0, t = 1 / 0;
|
|
15
16
|
for (let r = 0; r < o; r++) {
|
|
16
17
|
const c = n(r);
|
|
@@ -19,41 +20,38 @@ const v = 5, E = 2, m = 2, p = 0.5, A = 0.8, I = 0.1, O = ({
|
|
|
19
20
|
s < t && (t = s, e = r);
|
|
20
21
|
}
|
|
21
22
|
return e;
|
|
22
|
-
},
|
|
23
|
-
if (
|
|
23
|
+
}, b = (o, i, n, e) => {
|
|
24
|
+
if (d(i)) {
|
|
24
25
|
const t = i.domain(), r = i.bandwidth();
|
|
25
|
-
return
|
|
26
|
+
return l(t.length, o, (c) => {
|
|
26
27
|
const s = i(t[c]);
|
|
27
28
|
return s === void 0 ? void 0 : s + r / 2;
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
|
-
if (
|
|
31
|
+
if (u(i)) {
|
|
31
32
|
const t = n?.data;
|
|
32
|
-
if (t && t.length > 0 &&
|
|
33
|
-
return
|
|
33
|
+
if (t && t.length > 0 && h(t))
|
|
34
|
+
return l(
|
|
34
35
|
t.length,
|
|
35
36
|
o,
|
|
36
37
|
(c) => i(t[c])
|
|
37
38
|
);
|
|
38
39
|
const r = i.invert(o);
|
|
39
|
-
return Math.
|
|
40
|
-
0,
|
|
41
|
-
Math.min(Math.round(r), e - 1)
|
|
42
|
-
);
|
|
40
|
+
return f(Math.round(r), 0, e - 1);
|
|
43
41
|
}
|
|
44
42
|
return 0;
|
|
45
|
-
},
|
|
43
|
+
}, N = (o, i, n) => {
|
|
46
44
|
const e = n();
|
|
47
|
-
if (!e || !
|
|
45
|
+
if (!e || !u(e) || !i) return;
|
|
48
46
|
const t = i[o];
|
|
49
47
|
if (t != null)
|
|
50
48
|
return e(t);
|
|
51
|
-
},
|
|
49
|
+
}, T = (o, i, n) => {
|
|
52
50
|
const e = i();
|
|
53
51
|
if (!e) return;
|
|
54
52
|
const t = n?.data?.[o];
|
|
55
|
-
return
|
|
56
|
-
},
|
|
53
|
+
return a(typeof t == "number" ? t : o, e);
|
|
54
|
+
}, p = (o, i) => {
|
|
57
55
|
if (o.length === 0) return -1;
|
|
58
56
|
let n = 0, e = o.length;
|
|
59
57
|
for (; n < e; ) {
|
|
@@ -64,27 +62,27 @@ const v = 5, E = 2, m = 2, p = 0.5, A = 0.8, I = 0.1, O = ({
|
|
|
64
62
|
if (n === o.length) return n - 1;
|
|
65
63
|
const t = i - o[n - 1].pixelX, r = o[n].pixelX - i;
|
|
66
64
|
return t <= r ? n - 1 : n;
|
|
67
|
-
},
|
|
65
|
+
}, y = ({
|
|
68
66
|
resolvedIndex: o,
|
|
69
67
|
pixelX: i,
|
|
70
68
|
sortedMagnets: n,
|
|
71
69
|
magnetRadius: e
|
|
72
70
|
}) => {
|
|
73
71
|
if (e <= 0 || n.length === 0) return o;
|
|
74
|
-
const t =
|
|
72
|
+
const t = p(n, i);
|
|
75
73
|
return t >= 0 && Math.abs(n[t].pixelX - i) <= e ? n[t].index : o;
|
|
76
74
|
};
|
|
77
75
|
export {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
E as BEACON_RADIUS,
|
|
77
|
+
m as BEACON_STROKE_WIDTH,
|
|
78
|
+
_ as LINE_GRADIENT_EDGE_OPACITY,
|
|
79
|
+
I as OVERLAY_LINE_INSET,
|
|
80
|
+
A as OVERLAY_OFFSET,
|
|
81
|
+
O as OVERLAY_OPACITY,
|
|
82
|
+
y as applyMagnetization,
|
|
83
|
+
S as buildSortedMagnets,
|
|
84
|
+
b as getDataIndexFromPosition,
|
|
85
|
+
p as nearestIndex,
|
|
86
|
+
T as resolvePixelX,
|
|
87
|
+
N as resolvePixelY
|
|
90
88
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { CartesianChartContextValue, CategoricalScale, ChartInset, ChartScaleFunction, DrawingArea, NumericScale, Series, } from './types';
|
|
1
|
+
export type { CartesianChartContextValue, CategoricalScale, ChartInset, ChartScaleFunction, CurveType, DrawingArea, NumericScale, Series, } from './types';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,0BAA0B,EAC1B,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,MAAM,GACP,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,0BAA0B,EAC1B,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,MAAM,GACP,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard for a finite number. Narrows out `null`, `undefined`, `NaN` and
|
|
3
|
+
* `Infinity`, i.e. any value that cannot be projected to a valid coordinate or
|
|
4
|
+
* counted as a drawable data point.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isFiniteNumber: (value: unknown) => value is number;
|
|
7
|
+
/**
|
|
8
|
+
* Constrains `value` to the inclusive `[min, max]` range. For a degenerate
|
|
9
|
+
* range where `min > max` (e.g. an index range `[0, length - 1]` for empty
|
|
10
|
+
* data), `min` takes precedence and is returned — matching `lodash.clamp`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
13
|
+
//# sourceMappingURL=numbers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/numbers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MACjC,CAAC;AAEzB;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,MAC3B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseAxisProps } from '../../Components/Axis';
|
|
2
|
-
import { ChartScaleFunction
|
|
2
|
+
import { ChartScaleFunction } from '../types';
|
|
3
3
|
export declare const APPROXIMATE_TICK_COUNT = 5;
|
|
4
4
|
export type TickData = {
|
|
5
5
|
position: number;
|
|
@@ -32,14 +32,4 @@ export declare const getTickLabel: (tick: number, axisData: BaseAxisProps["data"
|
|
|
32
32
|
* Builds the complete tick data array from a scale and axis configuration.
|
|
33
33
|
*/
|
|
34
34
|
export declare const buildTicksData: (scale: ChartScaleFunction, axisConfig?: BaseAxisProps, explicitTicks?: number[], formatter?: (value: number | string) => string) => TickData[];
|
|
35
|
-
/**
|
|
36
|
-
* Excludes the X grid line at the Y-axis origin (left edge)
|
|
37
|
-
* to prevent overlap with the Y-axis solid line.
|
|
38
|
-
*/
|
|
39
|
-
export declare const isTickOnXAxisDomainEdge: (tick: TickData, drawingArea: DrawingArea) => boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Excludes the Y grid line at the X-axis origin (bottom edge)
|
|
42
|
-
* to prevent overlap with the X-axis solid line.
|
|
43
|
-
*/
|
|
44
|
-
export declare const isTickOnYAxisDomainEdge: (tick: TickData, drawingArea: DrawingArea) => boolean;
|
|
45
35
|
//# sourceMappingURL=ticks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ticks.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/ticks/ticks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"ticks.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/ticks/ticks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnD,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,kBAAkB,EACzB,gBAAgB,MAAM,EAAE,EACxB,WAAW,aAAa,CAAC,MAAM,CAAC,KAC/B,MAAM,EAUR,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,kBAAkB,EACzB,MAAM,MAAM,KACX,MAKF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,EACZ,UAAU,aAAa,CAAC,MAAM,CAAC,EAC/B,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,KAC7C,MAeF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,kBAAkB,EACzB,aAAa,aAAa,EAC1B,gBAAgB,MAAM,EAAE,EACxB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,KAC7C,QAAQ,EASV,CAAC"}
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import { isCategoricalScale as
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
if (
|
|
5
|
-
const t =
|
|
6
|
-
return String(
|
|
1
|
+
import { isCategoricalScale as g, isNumericScale as i } from "../scales/scales.js";
|
|
2
|
+
const f = 5, d = (r, n, e) => n && n.length > 0 ? n : e && e.length > 0 ? typeof e[0] == "number" ? e : e.map((o, t) => t) : g(r) ? r.domain() : i(r) ? r.ticks(f) : [], b = (r, n) => g(r) ? (r(n) ?? 0) + r.bandwidth() / 2 : r(n), l = (r, n, e) => {
|
|
3
|
+
const o = n && Array.isArray(n) && typeof n[0] == "string";
|
|
4
|
+
if (e) {
|
|
5
|
+
const t = o && n[r] !== void 0 ? n[r] : r;
|
|
6
|
+
return String(e(t));
|
|
7
7
|
}
|
|
8
|
-
return
|
|
9
|
-
},
|
|
10
|
-
const t =
|
|
11
|
-
return
|
|
12
|
-
position:
|
|
13
|
-
value:
|
|
14
|
-
label:
|
|
8
|
+
return o && n[r] !== void 0 ? String(n[r]) : String(r);
|
|
9
|
+
}, p = (r, n, e, o) => {
|
|
10
|
+
const t = n?.data;
|
|
11
|
+
return d(r, e, t).map((u) => ({
|
|
12
|
+
position: b(r, u),
|
|
13
|
+
value: u,
|
|
14
|
+
label: l(u, t, o)
|
|
15
15
|
}));
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
h as isTickOnXAxisDomainEdge,
|
|
24
|
-
l as isTickOnYAxisDomainEdge
|
|
18
|
+
f as APPROXIMATE_TICK_COUNT,
|
|
19
|
+
p as buildTicksData,
|
|
20
|
+
l as getTickLabel,
|
|
21
|
+
b as getTickPosition,
|
|
22
|
+
d as getTickValues
|
|
25
23
|
};
|
|
@@ -15,6 +15,18 @@ export type DrawingArea = {
|
|
|
15
15
|
width: number;
|
|
16
16
|
height: number;
|
|
17
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Interpolation used to draw a line (and its area) between data points.
|
|
20
|
+
* Each value maps to a [d3-shape](https://d3js.org/d3-shape/curve) curve:
|
|
21
|
+
* - `'bump'` — smooth cubic curve with horizontal tangents (`curveBumpX`).
|
|
22
|
+
* - `'natural'` — natural cubic spline through every point (`curveNatural`).
|
|
23
|
+
* - `'monotone'` — smooth curve that preserves monotonicity (`curveMonotoneX`).
|
|
24
|
+
* - `'linear'` — straight segments between points (`curveLinear`).
|
|
25
|
+
* - `'step'` — stepped, piecewise-constant line (`curveStep`).
|
|
26
|
+
* - `'stepAfter'` — stepped line where changes occur after the x-coordinate (`curveStepAfter`).
|
|
27
|
+
* - `'stepBefore'` — stepped line where changes occur before the x-coordinate (`curveStepBefore`).
|
|
28
|
+
*/
|
|
29
|
+
export type CurveType = 'bump' | 'natural' | 'monotone' | 'linear' | 'step' | 'stepAfter' | 'stepBefore';
|
|
18
30
|
export type Series = {
|
|
19
31
|
/**
|
|
20
32
|
* Unique identifier for the series.
|
|
@@ -30,8 +42,14 @@ export type Series = {
|
|
|
30
42
|
label?: string;
|
|
31
43
|
/**
|
|
32
44
|
* CSS color applied to the series line/mark.
|
|
45
|
+
* @default border-muted
|
|
46
|
+
*/
|
|
47
|
+
stroke?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Interpolation used to draw the line between data points.
|
|
50
|
+
* @default 'bump'
|
|
33
51
|
*/
|
|
34
|
-
|
|
52
|
+
curve?: CurveType;
|
|
35
53
|
};
|
|
36
54
|
export type NumericScale = ScaleLinear<number, number> | ScaleLogarithmic<number, number>;
|
|
37
55
|
export type CategoricalScale = ScaleBand<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,SAAS,GACT,UAAU,GACV,QAAQ,GACR,MAAM,GACN,WAAW,GACX,YAAY,CAAC;AAEjB,MAAM,MAAM,MAAM,GAAG;IACnB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GACpB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAErC,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAEjD,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,gBAAgB,CAAC;AAEjE,MAAM,MAAM,0BAA0B,GAAG;IACvC;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;OAEG;IACH,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B;;OAEG;IACH,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,kBAAkB,GAAG,SAAS,CAAC;IAC3D;;OAEG;IACH,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,kBAAkB,GAAG,SAAS,CAAC;IAC3D;;OAEG;IACH,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC;IAC3D;;OAEG;IACH,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC;IAC3D;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;IACzB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
function a(t) {
|
|
2
|
+
return t < 0 ? -1 : 1;
|
|
3
|
+
}
|
|
4
|
+
function p(t, i, n) {
|
|
5
|
+
var s = t._x1 - t._x0, _ = i - t._x1, e = (t._y1 - t._y0) / (s || _ < 0 && -0), o = (n - t._y1) / (_ || s < 0 && -0), h = (e * _ + o * s) / (s + _);
|
|
6
|
+
return (a(e) + a(o)) * Math.min(Math.abs(e), Math.abs(o), 0.5 * Math.abs(h)) || 0;
|
|
7
|
+
}
|
|
8
|
+
function u(t, i) {
|
|
9
|
+
var n = t._x1 - t._x0;
|
|
10
|
+
return n ? (3 * (t._y1 - t._y0) / n - i) / 2 : i;
|
|
11
|
+
}
|
|
12
|
+
function c(t, i, n) {
|
|
13
|
+
var s = t._x0, _ = t._y0, e = t._x1, o = t._y1, h = (e - s) / 3;
|
|
14
|
+
t._context.bezierCurveTo(s + h, _ + h * i, e - h, o - h * n, e, o);
|
|
15
|
+
}
|
|
16
|
+
function r(t) {
|
|
17
|
+
this._context = t;
|
|
18
|
+
}
|
|
19
|
+
r.prototype = {
|
|
20
|
+
areaStart: function() {
|
|
21
|
+
this._line = 0;
|
|
22
|
+
},
|
|
23
|
+
areaEnd: function() {
|
|
24
|
+
this._line = NaN;
|
|
25
|
+
},
|
|
26
|
+
lineStart: function() {
|
|
27
|
+
this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN, this._point = 0;
|
|
28
|
+
},
|
|
29
|
+
lineEnd: function() {
|
|
30
|
+
switch (this._point) {
|
|
31
|
+
case 2:
|
|
32
|
+
this._context.lineTo(this._x1, this._y1);
|
|
33
|
+
break;
|
|
34
|
+
case 3:
|
|
35
|
+
c(this, this._t0, u(this, this._t0));
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
(this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
|
|
39
|
+
},
|
|
40
|
+
point: function(t, i) {
|
|
41
|
+
var n = NaN;
|
|
42
|
+
if (t = +t, i = +i, !(t === this._x1 && i === this._y1)) {
|
|
43
|
+
switch (this._point) {
|
|
44
|
+
case 0:
|
|
45
|
+
this._point = 1, this._line ? this._context.lineTo(t, i) : this._context.moveTo(t, i);
|
|
46
|
+
break;
|
|
47
|
+
case 1:
|
|
48
|
+
this._point = 2;
|
|
49
|
+
break;
|
|
50
|
+
case 2:
|
|
51
|
+
this._point = 3, c(this, u(this, n = p(this, t, i)), n);
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
c(this, this._t0, n = p(this, t, i));
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
this._x0 = this._x1, this._x1 = t, this._y0 = this._y1, this._y1 = i, this._t0 = n;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
Object.create(r.prototype).point = function(t, i) {
|
|
62
|
+
r.prototype.point.call(this, i, t);
|
|
63
|
+
};
|
|
64
|
+
function l(t) {
|
|
65
|
+
return new r(t);
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
l as monotoneX
|
|
69
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function a(i) {
|
|
2
|
+
this._context = i;
|
|
3
|
+
}
|
|
4
|
+
a.prototype = {
|
|
5
|
+
areaStart: function() {
|
|
6
|
+
this._line = 0;
|
|
7
|
+
},
|
|
8
|
+
areaEnd: function() {
|
|
9
|
+
this._line = NaN;
|
|
10
|
+
},
|
|
11
|
+
lineStart: function() {
|
|
12
|
+
this._x = [], this._y = [];
|
|
13
|
+
},
|
|
14
|
+
lineEnd: function() {
|
|
15
|
+
var i = this._x, t = this._y, n = i.length;
|
|
16
|
+
if (n)
|
|
17
|
+
if (this._line ? this._context.lineTo(i[0], t[0]) : this._context.moveTo(i[0], t[0]), n === 2)
|
|
18
|
+
this._context.lineTo(i[1], t[1]);
|
|
19
|
+
else
|
|
20
|
+
for (var s = h(i), o = h(t), e = 0, r = 1; r < n; ++e, ++r)
|
|
21
|
+
this._context.bezierCurveTo(s[0][e], o[0][e], s[1][e], o[1][e], i[r], t[r]);
|
|
22
|
+
(this._line || this._line !== 0 && n === 1) && this._context.closePath(), this._line = 1 - this._line, this._x = this._y = null;
|
|
23
|
+
},
|
|
24
|
+
point: function(i, t) {
|
|
25
|
+
this._x.push(+i), this._y.push(+t);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function h(i) {
|
|
29
|
+
var t, n = i.length - 1, s, o = new Array(n), e = new Array(n), r = new Array(n);
|
|
30
|
+
for (o[0] = 0, e[0] = 2, r[0] = i[0] + 2 * i[1], t = 1; t < n - 1; ++t) o[t] = 1, e[t] = 4, r[t] = 4 * i[t] + 2 * i[t + 1];
|
|
31
|
+
for (o[n - 1] = 2, e[n - 1] = 7, r[n - 1] = 8 * i[n - 1] + i[n], t = 1; t < n; ++t) s = o[t] / e[t - 1], e[t] -= s, r[t] -= s * r[t - 1];
|
|
32
|
+
for (o[n - 1] = r[n - 1] / e[n - 1], t = n - 2; t >= 0; --t) o[t] = (r[t] - o[t + 1]) / e[t];
|
|
33
|
+
for (e[n - 1] = (i[n] + o[n - 1]) / 2, t = 0; t < n - 1; ++t) e[t] = 2 * i[t + 1] - o[t + 1];
|
|
34
|
+
return [o, e];
|
|
35
|
+
}
|
|
36
|
+
function l(i) {
|
|
37
|
+
return new a(i);
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
l as default
|
|
41
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
function n(t, i) {
|
|
2
|
+
this._context = t, this._t = i;
|
|
3
|
+
}
|
|
4
|
+
n.prototype = {
|
|
5
|
+
areaStart: function() {
|
|
6
|
+
this._line = 0;
|
|
7
|
+
},
|
|
8
|
+
areaEnd: function() {
|
|
9
|
+
this._line = NaN;
|
|
10
|
+
},
|
|
11
|
+
lineStart: function() {
|
|
12
|
+
this._x = this._y = NaN, this._point = 0;
|
|
13
|
+
},
|
|
14
|
+
lineEnd: function() {
|
|
15
|
+
0 < this._t && this._t < 1 && this._point === 2 && this._context.lineTo(this._x, this._y), (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line >= 0 && (this._t = 1 - this._t, this._line = 1 - this._line);
|
|
16
|
+
},
|
|
17
|
+
point: function(t, i) {
|
|
18
|
+
switch (t = +t, i = +i, this._point) {
|
|
19
|
+
case 0:
|
|
20
|
+
this._point = 1, this._line ? this._context.lineTo(t, i) : this._context.moveTo(t, i);
|
|
21
|
+
break;
|
|
22
|
+
case 1:
|
|
23
|
+
this._point = 2;
|
|
24
|
+
// falls through
|
|
25
|
+
default: {
|
|
26
|
+
if (this._t <= 0)
|
|
27
|
+
this._context.lineTo(this._x, i), this._context.lineTo(t, i);
|
|
28
|
+
else {
|
|
29
|
+
var e = this._x * (1 - this._t) + t * this._t;
|
|
30
|
+
this._context.lineTo(e, this._y), this._context.lineTo(e, i);
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
this._x = t, this._y = i;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
function s(t) {
|
|
39
|
+
return new n(t, 0.5);
|
|
40
|
+
}
|
|
41
|
+
function h(t) {
|
|
42
|
+
return new n(t, 0);
|
|
43
|
+
}
|
|
44
|
+
function _(t) {
|
|
45
|
+
return new n(t, 1);
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
s as default,
|
|
49
|
+
_ as stepAfter,
|
|
50
|
+
h as stepBefore
|
|
51
|
+
};
|