@ledgerhq/lumen-ui-react-visualization 0.1.15 → 0.1.17
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/Axis.constants.d.ts +9 -0
- package/dist/lib/Components/Axis/Axis.constants.d.ts.map +1 -0
- package/dist/lib/Components/Axis/Axis.constants.js +24 -0
- package/dist/lib/Components/Axis/Axis.types.d.ts +37 -0
- package/dist/lib/Components/Axis/Axis.types.d.ts.map +1 -1
- package/dist/lib/Components/Axis/XAxis/XAxis.d.ts +0 -1
- package/dist/lib/Components/Axis/XAxis/XAxis.d.ts.map +1 -1
- package/dist/lib/Components/Axis/XAxis/XAxis.js +21 -22
- package/dist/lib/Components/Axis/XAxis/index.d.ts +1 -1
- package/dist/lib/Components/Axis/XAxis/index.d.ts.map +1 -1
- package/dist/lib/Components/Axis/YAxis/YAxis.d.ts +0 -1
- package/dist/lib/Components/Axis/YAxis/YAxis.d.ts.map +1 -1
- package/dist/lib/Components/Axis/YAxis/YAxis.js +16 -17
- package/dist/lib/Components/Axis/YAxis/index.d.ts +1 -1
- package/dist/lib/Components/Axis/YAxis/index.d.ts.map +1 -1
- package/dist/lib/Components/Axis/index.d.ts +3 -0
- package/dist/lib/Components/Axis/index.d.ts.map +1 -0
- 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 +62 -58
- package/dist/lib/Components/CartesianChart/context/useBuildChartContext.d.ts +7 -4
- package/dist/lib/Components/CartesianChart/context/useBuildChartContext.d.ts.map +1 -1
- package/dist/lib/Components/CartesianChart/context/useBuildChartContext.js +31 -31
- package/dist/lib/Components/CartesianChart/types.d.ts +11 -3
- package/dist/lib/Components/CartesianChart/types.d.ts.map +1 -1
- package/dist/lib/Components/CartesianChart/utils.d.ts +19 -8
- package/dist/lib/Components/CartesianChart/utils.d.ts.map +1 -1
- package/dist/lib/Components/CartesianChart/utils.js +14 -15
- package/dist/lib/Components/Line/utils.d.ts +4 -0
- package/dist/lib/Components/Line/utils.d.ts.map +1 -1
- package/dist/lib/Components/Line/utils.js +15 -15
- 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 +64 -74
- package/dist/lib/Components/LineChart/__stories__/chartStoryFixtures.d.ts +46 -0
- package/dist/lib/Components/LineChart/__stories__/chartStoryFixtures.d.ts.map +1 -0
- package/dist/lib/Components/LineChart/__stories__/cryptoChartData.d.ts +85 -0
- package/dist/lib/Components/LineChart/__stories__/cryptoChartData.d.ts.map +1 -0
- package/dist/lib/Components/LineChart/types.d.ts +10 -3
- package/dist/lib/Components/LineChart/types.d.ts.map +1 -1
- package/dist/lib/Components/Point/Point.d.ts +1 -1
- package/dist/lib/Components/Point/Point.d.ts.map +1 -1
- package/dist/lib/Components/Point/Point.js +35 -30
- package/dist/lib/Components/Point/constants.d.ts +7 -0
- package/dist/lib/Components/Point/constants.d.ts.map +1 -0
- package/dist/lib/Components/Point/constants.js +9 -0
- package/dist/lib/Components/Point/pointContext/MagneticPointsProvider.d.ts +7 -0
- package/dist/lib/Components/Point/pointContext/MagneticPointsProvider.d.ts.map +1 -0
- package/dist/lib/Components/Point/pointContext/MagneticPointsProvider.js +19 -0
- package/dist/lib/Components/Point/pointContext/index.d.ts +3 -0
- package/dist/lib/Components/Point/pointContext/index.d.ts.map +1 -0
- package/dist/lib/Components/Point/pointContext/magneticPointsContext.d.ts +13 -0
- package/dist/lib/Components/Point/pointContext/magneticPointsContext.d.ts.map +1 -0
- package/dist/lib/Components/Point/pointContext/magneticPointsContext.js +9 -0
- package/dist/lib/Components/Point/types.d.ts +7 -0
- package/dist/lib/Components/Point/types.d.ts.map +1 -1
- package/dist/lib/Components/Point/utils.d.ts +8 -6
- package/dist/lib/Components/Point/utils.d.ts.map +1 -1
- package/dist/lib/Components/Point/utils.js +32 -20
- package/dist/lib/Components/ReferenceLine/constants.d.ts +1 -1
- package/dist/lib/Components/ReferenceLine/constants.d.ts.map +1 -1
- package/dist/lib/Components/ReferenceLine/utils.d.ts +3 -2
- package/dist/lib/Components/ReferenceLine/utils.d.ts.map +1 -1
- package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/ChartTooltipItem.js +14 -14
- package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/DefaultScrubberTooltip.d.ts.map +1 -1
- package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/DefaultScrubberTooltip.js +38 -38
- package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/constants.d.ts +1 -2
- package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/constants.d.ts.map +1 -1
- package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/constants.js +8 -9
- package/dist/lib/Components/Scrubber/ScrubberProvider.d.ts +1 -1
- package/dist/lib/Components/Scrubber/ScrubberProvider.d.ts.map +1 -1
- package/dist/lib/Components/Scrubber/ScrubberProvider.js +97 -72
- package/dist/lib/Components/Scrubber/types.d.ts +6 -0
- package/dist/lib/Components/Scrubber/types.d.ts.map +1 -1
- package/dist/lib/Components/Scrubber/utils.d.ts +33 -3
- package/dist/lib/Components/Scrubber/utils.d.ts.map +1 -1
- package/dist/lib/Components/Scrubber/utils.js +71 -37
- package/dist/lib/utils/domain/domain.d.ts +5 -4
- package/dist/lib/utils/domain/domain.d.ts.map +1 -1
- package/dist/lib/utils/index.d.ts +1 -1
- package/dist/lib/utils/index.d.ts.map +1 -1
- package/dist/lib/utils/scales/scales.d.ts +11 -5
- package/dist/lib/utils/scales/scales.d.ts.map +1 -1
- package/dist/lib/utils/scales/scales.js +19 -15
- package/dist/lib/utils/ticks/ticks.d.ts +13 -5
- package/dist/lib/utils/ticks/ticks.d.ts.map +1 -1
- package/dist/lib/utils/ticks/ticks.js +20 -20
- package/dist/lib/utils/types.d.ts +3 -28
- package/dist/lib/utils/types.d.ts.map +1 -1
- package/dist/package.json +4 -4
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrubberProvider.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/ScrubberProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScrubberProvider.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/ScrubberProvider.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAwB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAQ3E,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,MAAM,EACN,eAAe,EACf,wBAAwB,EACxB,YAAgB,GACjB,EAAE,QAAQ,CAAC,qBAAqB,CAAC,2CA+NjC"}
|
|
@@ -1,77 +1,102 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { getDataIndexFromPosition as
|
|
4
|
-
import { useCartesianChartContext as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { jsx as F } from "react/jsx-runtime";
|
|
2
|
+
import { useState as q, useRef as C, useMemo as I, useCallback as s, useEffect as K } from "react";
|
|
3
|
+
import { buildSortedMagnets as j, getDataIndexFromPosition as z, resolvePixelX as H, applyMagnetization as N } from "./utils.js";
|
|
4
|
+
import { useCartesianChartContext as U } from "../CartesianChart/context/cartesianChartContext.js";
|
|
5
|
+
import { useMagneticPointsContext as V } from "../Point/pointContext/magneticPointsContext.js";
|
|
6
|
+
import { ScrubberContextProvider as G } from "./context/scrubberContext.js";
|
|
7
|
+
function _({
|
|
8
|
+
children: X,
|
|
9
|
+
svgRef: k,
|
|
10
|
+
enableScrubbing: r,
|
|
11
|
+
onScrubberPositionChange: D,
|
|
12
|
+
magnetRadius: p = 8
|
|
11
13
|
}) {
|
|
12
|
-
const { getXScale:
|
|
14
|
+
const { getXScale: f, getXAxisConfig: m, dataLength: c } = U(), { getMagneticPoints: y, version: R } = V(), [v, T] = q(
|
|
13
15
|
void 0
|
|
14
|
-
),
|
|
15
|
-
|
|
16
|
-
const
|
|
16
|
+
), h = C(v);
|
|
17
|
+
h.current = v;
|
|
18
|
+
const x = C(null), l = C(0), w = I(() => {
|
|
19
|
+
const t = y();
|
|
20
|
+
return j({
|
|
21
|
+
magneticIndices: t,
|
|
22
|
+
getPixelForIndex: (e) => H(e, f, m())
|
|
23
|
+
});
|
|
24
|
+
}, [R, y, f, m]), i = s(
|
|
17
25
|
(t) => {
|
|
18
|
-
const e = t === void 0 ? void 0 : Math.max(0, Math.min(t,
|
|
19
|
-
|
|
26
|
+
const e = t === void 0 ? void 0 : Math.max(0, Math.min(t, c - 1));
|
|
27
|
+
T(e), D?.(e);
|
|
20
28
|
},
|
|
21
|
-
[
|
|
22
|
-
),
|
|
29
|
+
[c, D]
|
|
30
|
+
), A = s(
|
|
23
31
|
(t) => {
|
|
24
|
-
const e =
|
|
25
|
-
if (!e || !
|
|
26
|
-
const
|
|
32
|
+
const e = f();
|
|
33
|
+
if (!e || !r || c <= 0) return;
|
|
34
|
+
const a = m();
|
|
35
|
+
let o = z(
|
|
27
36
|
t,
|
|
28
37
|
e,
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
a,
|
|
39
|
+
c
|
|
31
40
|
);
|
|
32
|
-
|
|
41
|
+
p > 0 && (o = N({
|
|
42
|
+
resolvedIndex: o,
|
|
43
|
+
pixelX: t,
|
|
44
|
+
sortedMagnets: w,
|
|
45
|
+
magnetRadius: p
|
|
46
|
+
})), o !== h.current && i(o);
|
|
33
47
|
},
|
|
34
48
|
[
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
49
|
+
r,
|
|
50
|
+
f,
|
|
51
|
+
m,
|
|
52
|
+
c,
|
|
53
|
+
w,
|
|
54
|
+
p,
|
|
55
|
+
i
|
|
40
56
|
]
|
|
41
|
-
),
|
|
42
|
-
o && c(void 0);
|
|
43
|
-
}, [o, c]), h = a(
|
|
57
|
+
), u = s(
|
|
44
58
|
(t) => {
|
|
45
|
-
|
|
46
|
-
|
|
59
|
+
x.current = t, l.current || (l.current = requestAnimationFrame(() => {
|
|
60
|
+
l.current = 0;
|
|
61
|
+
const e = x.current;
|
|
62
|
+
e !== null && (x.current = null, A(e));
|
|
63
|
+
}));
|
|
47
64
|
},
|
|
48
|
-
[
|
|
49
|
-
),
|
|
65
|
+
[A]
|
|
66
|
+
), n = s(() => {
|
|
67
|
+
r && i(void 0);
|
|
68
|
+
}, [r, i]), E = s(
|
|
50
69
|
(t) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
i(e.clientX - u.left);
|
|
70
|
+
const a = t.currentTarget.getBoundingClientRect();
|
|
71
|
+
u(t.clientX - a.left);
|
|
54
72
|
},
|
|
55
|
-
[
|
|
56
|
-
),
|
|
73
|
+
[u]
|
|
74
|
+
), g = s(
|
|
75
|
+
(t) => {
|
|
76
|
+
if (!r || !t.touches.length) return;
|
|
77
|
+
const e = t.touches[0], o = t.currentTarget.getBoundingClientRect();
|
|
78
|
+
u(e.clientX - o.left);
|
|
79
|
+
},
|
|
80
|
+
[r, u]
|
|
81
|
+
), L = s(
|
|
57
82
|
(t) => {
|
|
58
83
|
if (!t.touches.length) return;
|
|
59
84
|
t.preventDefault();
|
|
60
|
-
const e = t.touches[0],
|
|
61
|
-
|
|
85
|
+
const e = t.touches[0], o = t.currentTarget.getBoundingClientRect();
|
|
86
|
+
u(e.clientX - o.left);
|
|
62
87
|
},
|
|
63
|
-
[
|
|
64
|
-
),
|
|
88
|
+
[u]
|
|
89
|
+
), M = s(
|
|
65
90
|
(t) => {
|
|
66
|
-
if (!
|
|
67
|
-
const e =
|
|
91
|
+
if (!r || c <= 0) return;
|
|
92
|
+
const e = c - 1, a = h.current ?? e, o = t.shiftKey ? Math.min(10, Math.max(1, Math.floor(e * 0.1))) : 1;
|
|
68
93
|
let d;
|
|
69
94
|
switch (t.key) {
|
|
70
95
|
case "ArrowLeft":
|
|
71
|
-
t.preventDefault(), d = Math.max(0,
|
|
96
|
+
t.preventDefault(), d = Math.max(0, a - o);
|
|
72
97
|
break;
|
|
73
98
|
case "ArrowRight":
|
|
74
|
-
t.preventDefault(), d = Math.min(e,
|
|
99
|
+
t.preventDefault(), d = Math.min(e, a + o);
|
|
75
100
|
break;
|
|
76
101
|
case "Home":
|
|
77
102
|
t.preventDefault(), d = 0;
|
|
@@ -85,38 +110,38 @@ function N({
|
|
|
85
110
|
default:
|
|
86
111
|
return;
|
|
87
112
|
}
|
|
88
|
-
|
|
113
|
+
i(d);
|
|
89
114
|
},
|
|
90
|
-
[
|
|
91
|
-
),
|
|
92
|
-
!
|
|
93
|
-
}, [
|
|
94
|
-
|
|
95
|
-
const t =
|
|
96
|
-
if (!(!t || !
|
|
97
|
-
return t.addEventListener("mousemove",
|
|
98
|
-
t.removeEventListener("mousemove",
|
|
115
|
+
[r, c, i]
|
|
116
|
+
), P = s(() => {
|
|
117
|
+
!r || h.current === void 0 || n();
|
|
118
|
+
}, [r, n]);
|
|
119
|
+
K(() => {
|
|
120
|
+
const t = k.current;
|
|
121
|
+
if (!(!t || !r))
|
|
122
|
+
return t.addEventListener("mousemove", E), t.addEventListener("mouseleave", n), t.addEventListener("touchstart", g, { passive: !1 }), t.addEventListener("touchmove", L, { passive: !1 }), t.addEventListener("touchend", n), t.addEventListener("touchcancel", n), t.addEventListener("keydown", M), t.addEventListener("blur", P), () => {
|
|
123
|
+
t.removeEventListener("mousemove", E), t.removeEventListener("mouseleave", n), t.removeEventListener("touchstart", g), t.removeEventListener("touchmove", L), t.removeEventListener("touchend", n), t.removeEventListener("touchcancel", n), t.removeEventListener("keydown", M), t.removeEventListener("blur", P), cancelAnimationFrame(l.current), l.current = 0;
|
|
99
124
|
};
|
|
100
125
|
}, [
|
|
101
|
-
|
|
102
|
-
o,
|
|
103
|
-
h,
|
|
126
|
+
k,
|
|
104
127
|
r,
|
|
105
|
-
f,
|
|
106
|
-
l,
|
|
107
128
|
E,
|
|
108
|
-
|
|
129
|
+
n,
|
|
130
|
+
g,
|
|
131
|
+
L,
|
|
132
|
+
M,
|
|
133
|
+
P
|
|
109
134
|
]);
|
|
110
|
-
const
|
|
135
|
+
const B = I(
|
|
111
136
|
() => ({
|
|
112
|
-
enableScrubbing:
|
|
113
|
-
scrubberPosition:
|
|
114
|
-
onScrubberPositionChange:
|
|
137
|
+
enableScrubbing: r,
|
|
138
|
+
scrubberPosition: v,
|
|
139
|
+
onScrubberPositionChange: i
|
|
115
140
|
}),
|
|
116
|
-
[
|
|
141
|
+
[r, v, i]
|
|
117
142
|
);
|
|
118
|
-
return /* @__PURE__ */
|
|
143
|
+
return /* @__PURE__ */ F(G, { value: B, children: X });
|
|
119
144
|
}
|
|
120
145
|
export {
|
|
121
|
-
|
|
146
|
+
_ as ScrubberProvider
|
|
122
147
|
};
|
|
@@ -28,6 +28,12 @@ export type ScrubberProviderProps = {
|
|
|
28
28
|
* Optional external callback fired whenever the scrubber position changes.
|
|
29
29
|
*/
|
|
30
30
|
onScrubberPositionChange?: (index: number | undefined) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Pixel radius within which the scrubber magnetically snaps to registered
|
|
33
|
+
* magnetic points. Set to `0` to disable magnetization.
|
|
34
|
+
* @default 8
|
|
35
|
+
*/
|
|
36
|
+
magnetRadius?: number;
|
|
31
37
|
};
|
|
32
38
|
/**
|
|
33
39
|
* Valid content for an SVG `<text>` element: a plain string,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC;;OAEG;IACH,wBAAwB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,MAAM,EAAE,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IACxC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC;;OAEG;IACH,wBAAwB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,MAAM,EAAE,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IACxC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/D;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,MAAM,GACN,MAAM,GACN,YAAY,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,CAAC;AAErD,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,KAAK,EAAE,cAAc,CAAC;IACtB;;OAEG;IACH,KAAK,EAAE,cAAc,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,GAAG;IACzD;;;OAGG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;;OAGG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,0BAA0B,GAAG;IAC9D;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC;IACzB;;;OAGG;IACH,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB;;OAEG;IACH,KAAK,EAAE,oBAAoB,EAAE,CAAC;CAC/B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,0BAA0B,GAAG;IAChE;;;OAGG;IACH,KAAK,CAAC,EAAE,cAAc,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,cAAc,GAAG,SAAS,CAAC,CAAC;IACzE;;OAEG;IACH,KAAK,EAAE,oBAAoB,EAAE,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,sBAAsB,CAAC;CACzD,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChartScaleFunction } from '../../utils/types';
|
|
2
|
+
import { BaseAxisProps } from '../Axis';
|
|
2
3
|
import { useCartesianChartContext } from '../CartesianChart/context';
|
|
3
4
|
export declare const BEACON_RADIUS = 5;
|
|
4
5
|
export declare const BEACON_STROKE_WIDTH = 2;
|
|
@@ -7,6 +8,19 @@ export declare const OVERLAY_OFFSET = 2;
|
|
|
7
8
|
export declare const OVERLAY_LINE_INSET = 0.5;
|
|
8
9
|
export declare const OVERLAY_OPACITY = 0.8;
|
|
9
10
|
export declare const LINE_GRADIENT_EDGE_OPACITY = 0.1;
|
|
11
|
+
export type MagnetEntry = {
|
|
12
|
+
index: number;
|
|
13
|
+
pixelX: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Resolves each magnetic index to its pixel position and returns them sorted
|
|
17
|
+
* by `pixelX` ascending. Indices that cannot be projected are filtered out.
|
|
18
|
+
* The sorted output enables early-exit in {@link applyMagnetization}.
|
|
19
|
+
*/
|
|
20
|
+
export declare const buildSortedMagnets: ({ magneticIndices, getPixelForIndex, }: {
|
|
21
|
+
magneticIndices: ReadonlySet<number>;
|
|
22
|
+
getPixelForIndex: (index: number) => number | undefined;
|
|
23
|
+
}) => MagnetEntry[];
|
|
10
24
|
/**
|
|
11
25
|
* Converts a pixel position along the x-axis into the nearest data index.
|
|
12
26
|
*
|
|
@@ -14,7 +28,7 @@ export declare const LINE_GRADIENT_EDGE_OPACITY = 0.1;
|
|
|
14
28
|
* `pixelX`. For numeric scales, uses `scale.invert()` and rounds to the
|
|
15
29
|
* nearest integer, clamped to the valid index range.
|
|
16
30
|
*/
|
|
17
|
-
export declare const getDataIndexFromPosition: (pixelX: number, scale: ChartScaleFunction, axisConfig: Partial<
|
|
31
|
+
export declare const getDataIndexFromPosition: (pixelX: number, scale: ChartScaleFunction, axisConfig: Partial<BaseAxisProps> | undefined, dataLength: number) => number;
|
|
18
32
|
/**
|
|
19
33
|
* Resolves the pixel y-coordinate for a given series data point at a data index.
|
|
20
34
|
* Returns undefined when the value is null/missing or the scale is unavailable.
|
|
@@ -26,5 +40,21 @@ export declare const resolvePixelY: (dataIndex: number, seriesData: (number | nu
|
|
|
26
40
|
* otherwise the data index is used as the x input.
|
|
27
41
|
* Returns undefined when the scale is unavailable or the value cannot be mapped.
|
|
28
42
|
*/
|
|
29
|
-
export declare const resolvePixelX: (dataIndex: number, getXScale: ReturnType<typeof useCartesianChartContext>["getXScale"], axisConfig?:
|
|
43
|
+
export declare const resolvePixelX: (dataIndex: number, getXScale: ReturnType<typeof useCartesianChartContext>["getXScale"], axisConfig?: BaseAxisProps) => number | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Binary search for the magnet whose `pixelX` is closest to `pixelX`.
|
|
46
|
+
* Returns -1 when the array is empty. Favors the left neighbor on ties.
|
|
47
|
+
*/
|
|
48
|
+
export declare const nearestIndex: (sortedMagnets: readonly MagnetEntry[], pixelX: number) => number;
|
|
49
|
+
/**
|
|
50
|
+
* Given a resolved data index and the raw pixel position, checks whether any
|
|
51
|
+
* magnetic point is within `magnetRadius` pixels of `pixelX`. If so, returns
|
|
52
|
+
* the closest magnetic index; otherwise returns the original `resolvedIndex`.
|
|
53
|
+
*/
|
|
54
|
+
export declare const applyMagnetization: ({ resolvedIndex, pixelX, sortedMagnets, magnetRadius, }: {
|
|
55
|
+
resolvedIndex: number;
|
|
56
|
+
pixelX: number;
|
|
57
|
+
sortedMagnets: readonly MagnetEntry[];
|
|
58
|
+
magnetRadius: number;
|
|
59
|
+
}) => number;
|
|
30
60
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/utils.ts"],"names":[],"mappings":"AAKA,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,MA2BF,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,56 +1,90 @@
|
|
|
1
|
-
import { getPointOnScale as
|
|
2
|
-
const
|
|
1
|
+
import { getPointOnScale as f, isNumericScale as l, isCategoricalScale as a } from "../../utils/scales/scales.js";
|
|
2
|
+
const v = 5, E = 2, m = 2, p = 0.5, A = 0.8, I = 0.1, O = ({
|
|
3
|
+
magneticIndices: o,
|
|
4
|
+
getPixelForIndex: i
|
|
5
|
+
}) => {
|
|
6
|
+
if (o.size === 0) return [];
|
|
7
|
+
const n = [];
|
|
8
|
+
for (const e of o) {
|
|
9
|
+
const t = i(e);
|
|
10
|
+
t !== void 0 && n.push({ index: e, pixelX: t });
|
|
11
|
+
}
|
|
12
|
+
return n.sort((e, t) => e.pixelX - t.pixelX), n;
|
|
13
|
+
}, d = (o) => typeof o[0] == "number", u = (o, i, n) => {
|
|
3
14
|
let e = 0, t = 1 / 0;
|
|
4
|
-
for (let
|
|
5
|
-
const
|
|
6
|
-
if (
|
|
7
|
-
const
|
|
8
|
-
|
|
15
|
+
for (let r = 0; r < o; r++) {
|
|
16
|
+
const c = n(r);
|
|
17
|
+
if (c === void 0) continue;
|
|
18
|
+
const s = Math.abs(i - c);
|
|
19
|
+
s < t && (t = s, e = r);
|
|
9
20
|
}
|
|
10
21
|
return e;
|
|
11
|
-
},
|
|
12
|
-
if (
|
|
13
|
-
const t =
|
|
14
|
-
return
|
|
15
|
-
const
|
|
16
|
-
return
|
|
22
|
+
}, _ = (o, i, n, e) => {
|
|
23
|
+
if (a(i)) {
|
|
24
|
+
const t = i.domain(), r = i.bandwidth();
|
|
25
|
+
return u(t.length, o, (c) => {
|
|
26
|
+
const s = i(t[c]);
|
|
27
|
+
return s === void 0 ? void 0 : s + r / 2;
|
|
17
28
|
});
|
|
18
29
|
}
|
|
19
|
-
if (
|
|
20
|
-
const t =
|
|
21
|
-
if (t && t.length > 0 &&
|
|
22
|
-
return
|
|
30
|
+
if (l(i)) {
|
|
31
|
+
const t = n?.data;
|
|
32
|
+
if (t && t.length > 0 && d(t))
|
|
33
|
+
return u(
|
|
23
34
|
t.length,
|
|
24
35
|
o,
|
|
25
|
-
(
|
|
36
|
+
(c) => i(t[c])
|
|
26
37
|
);
|
|
27
|
-
const
|
|
38
|
+
const r = i.invert(o);
|
|
28
39
|
return Math.max(
|
|
29
40
|
0,
|
|
30
|
-
Math.min(Math.round(
|
|
41
|
+
Math.min(Math.round(r), e - 1)
|
|
31
42
|
);
|
|
32
43
|
}
|
|
33
44
|
return 0;
|
|
34
|
-
},
|
|
35
|
-
const e =
|
|
36
|
-
if (!e || !
|
|
37
|
-
const t =
|
|
45
|
+
}, S = (o, i, n) => {
|
|
46
|
+
const e = n();
|
|
47
|
+
if (!e || !l(e) || !i) return;
|
|
48
|
+
const t = i[o];
|
|
38
49
|
if (t != null)
|
|
39
50
|
return e(t);
|
|
40
|
-
},
|
|
41
|
-
const e =
|
|
51
|
+
}, b = (o, i, n) => {
|
|
52
|
+
const e = i();
|
|
42
53
|
if (!e) return;
|
|
43
|
-
const t =
|
|
44
|
-
return
|
|
54
|
+
const t = n?.data?.[o];
|
|
55
|
+
return f(typeof t == "number" ? t : o, e);
|
|
56
|
+
}, h = (o, i) => {
|
|
57
|
+
if (o.length === 0) return -1;
|
|
58
|
+
let n = 0, e = o.length;
|
|
59
|
+
for (; n < e; ) {
|
|
60
|
+
const c = Math.floor((n + e) / 2);
|
|
61
|
+
o[c].pixelX < i ? n = c + 1 : e = c;
|
|
62
|
+
}
|
|
63
|
+
if (n === 0) return 0;
|
|
64
|
+
if (n === o.length) return n - 1;
|
|
65
|
+
const t = i - o[n - 1].pixelX, r = o[n].pixelX - i;
|
|
66
|
+
return t <= r ? n - 1 : n;
|
|
67
|
+
}, N = ({
|
|
68
|
+
resolvedIndex: o,
|
|
69
|
+
pixelX: i,
|
|
70
|
+
sortedMagnets: n,
|
|
71
|
+
magnetRadius: e
|
|
72
|
+
}) => {
|
|
73
|
+
if (e <= 0 || n.length === 0) return o;
|
|
74
|
+
const t = h(n, i);
|
|
75
|
+
return t >= 0 && Math.abs(n[t].pixelX - i) <= e ? n[t].index : o;
|
|
45
76
|
};
|
|
46
77
|
export {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
78
|
+
v as BEACON_RADIUS,
|
|
79
|
+
E as BEACON_STROKE_WIDTH,
|
|
80
|
+
I as LINE_GRADIENT_EDGE_OPACITY,
|
|
81
|
+
p as OVERLAY_LINE_INSET,
|
|
82
|
+
m as OVERLAY_OFFSET,
|
|
83
|
+
A as OVERLAY_OPACITY,
|
|
84
|
+
N as applyMagnetization,
|
|
85
|
+
O as buildSortedMagnets,
|
|
86
|
+
_ as getDataIndexFromPosition,
|
|
87
|
+
h as nearestIndex,
|
|
88
|
+
b as resolvePixelX,
|
|
89
|
+
S as resolvePixelY
|
|
56
90
|
};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { AxisBounds,
|
|
1
|
+
import { AxisBounds, BaseAxisProps } from '../../Components/Axis';
|
|
2
|
+
import { Series } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* Compute the X domain (index-based) from series data and axis config.
|
|
4
5
|
* For the X axis the domain is typically 0..N-1 where N = longest series length,
|
|
5
6
|
* unless explicit `data` is provided on the axis config.
|
|
6
7
|
*/
|
|
7
|
-
export declare const computeXDomain: (series: Series[], axisConfig?: Partial<
|
|
8
|
+
export declare const computeXDomain: (series: Series[], axisConfig?: Partial<BaseAxisProps>) => AxisBounds;
|
|
8
9
|
/**
|
|
9
10
|
* Compute the Y domain (value-based) from series data and axis config.
|
|
10
11
|
* Scans all non-null values across all series to find min/max.
|
|
11
12
|
*/
|
|
12
|
-
export declare const computeYDomain: (series: Series[], axisConfig?: Partial<
|
|
13
|
+
export declare const computeYDomain: (series: Series[], axisConfig?: Partial<BaseAxisProps>) => AxisBounds;
|
|
13
14
|
/**
|
|
14
15
|
* Compute the data length (number of discrete positions on the index axis).
|
|
15
16
|
*/
|
|
16
|
-
export declare const computeDataLength: (series: Series[], axisConfig?: Partial<
|
|
17
|
+
export declare const computeDataLength: (series: Series[], axisConfig?: Partial<BaseAxisProps>) => number;
|
|
17
18
|
//# sourceMappingURL=domain.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/domain/domain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/domain/domain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;GAIG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EAAE,EAChB,aAAa,OAAO,CAAC,aAAa,CAAC,KAClC,UA4BF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EAAE,EAChB,aAAa,OAAO,CAAC,aAAa,CAAC,KAClC,UAwBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,EAAE,EAChB,aAAa,OAAO,CAAC,aAAa,CAAC,KAClC,MAKF,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { CartesianChartContextValue, CategoricalScale, ChartInset, ChartScaleFunction, 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,
|
|
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,12 +1,18 @@
|
|
|
1
|
-
import { AxisBounds,
|
|
1
|
+
import { AxisBounds, BaseAxisProps } from '../../Components/Axis';
|
|
2
|
+
import { CategoricalScale, ChartScaleFunction, NumericScale } from '../types';
|
|
2
3
|
/**
|
|
3
|
-
* Creates a numeric scale
|
|
4
|
-
*
|
|
4
|
+
* Creates a numeric scale.
|
|
5
|
+
*
|
|
6
|
+
* When `nice` is `true` (default), the domain is rounded outward to clean
|
|
7
|
+
* boundaries via d3's `.nice()` (e.g. `[4, 98]` → `[0, 100]`). Set `nice` to
|
|
8
|
+
* `false` to keep the domain exactly as provided so data fills the range
|
|
9
|
+
* boundary-to-boundary.
|
|
5
10
|
*/
|
|
6
|
-
export declare const getNumericScale: ({ scaleType, domain, range, }: {
|
|
11
|
+
export declare const getNumericScale: ({ scaleType, domain, range, nice, }: {
|
|
7
12
|
scaleType: "linear" | "log";
|
|
8
13
|
domain: AxisBounds;
|
|
9
14
|
range: AxisBounds;
|
|
15
|
+
nice?: boolean;
|
|
10
16
|
}) => NumericScale;
|
|
11
17
|
export declare const getCategoricalScale: ({ domain, range, padding, }: {
|
|
12
18
|
domain: AxisBounds;
|
|
@@ -16,7 +22,7 @@ export declare const getCategoricalScale: ({ domain, range, padding, }: {
|
|
|
16
22
|
/**
|
|
17
23
|
* Checks if a scale type config value refers to a band (categorical) scale.
|
|
18
24
|
*/
|
|
19
|
-
export declare const isBandScaleType: (scaleType:
|
|
25
|
+
export declare const isBandScaleType: (scaleType: BaseAxisProps["scaleType"]) => scaleType is "band";
|
|
20
26
|
/**
|
|
21
27
|
* Checks if a scale is a categorical scale.
|
|
22
28
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scales.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/scales/scales.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"scales.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/scales/scales.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACb,MAAM,UAAU,CAAC;AAElB;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,qCAK7B;IACD,SAAS,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC5B,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,KAAG,YAOH,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,6BAIjC;IACD,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,KAAG,gBAUH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAC1B,WAAW,aAAa,CAAC,WAAW,CAAC,KACpC,SAAS,IAAI,MAA8B,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,kBAAkB,KACxB,KAAK,IAAI,gBAEX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,kBAAkB,KACxB,KAAK,IAAI,YAEX,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,MAAM,EACb,OAAO,kBAAkB,KACxB,MAKF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,MAAM,EACb,OAAO,MAAM,EACb,QAAQ,kBAAkB,EAC1B,QAAQ,kBAAkB,KACzB;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAGvB,CAAC"}
|
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
1
|
+
import m from "../../../node_modules/d3-scale/src/band.js";
|
|
2
|
+
import d from "../../../node_modules/d3-scale/src/log.js";
|
|
3
|
+
import u from "../../../node_modules/d3-scale/src/linear.js";
|
|
4
|
+
const l = ({
|
|
5
5
|
scaleType: n,
|
|
6
6
|
domain: t,
|
|
7
|
-
range: r
|
|
8
|
-
|
|
7
|
+
range: r,
|
|
8
|
+
nice: i = !0
|
|
9
|
+
}) => {
|
|
10
|
+
const o = n === "log" ? d() : u();
|
|
11
|
+
return o.domain([t.min, t.max]), i && o.nice(), o.range([r.min, r.max]);
|
|
12
|
+
}, p = ({
|
|
9
13
|
domain: n,
|
|
10
14
|
range: t,
|
|
11
15
|
padding: r = 0.1
|
|
12
16
|
}) => {
|
|
13
17
|
const i = Array.from(
|
|
14
18
|
{ length: n.max - n.min + 1 },
|
|
15
|
-
(
|
|
19
|
+
(o, c) => n.min + c
|
|
16
20
|
);
|
|
17
|
-
return
|
|
18
|
-
}, x = (n) => n === "band",
|
|
19
|
-
x:
|
|
20
|
-
y:
|
|
21
|
+
return m().domain(i).range([t.min, t.max]).paddingInner(r).paddingOuter(r / 2);
|
|
22
|
+
}, x = (n) => n === "band", a = (n) => "bandwidth" in n && typeof n.bandwidth == "function", S = (n) => !a(n), e = (n, t) => a(t) ? (t(n) ?? 0) + t.bandwidth() / 2 : t(n), b = (n, t, r, i) => ({
|
|
23
|
+
x: e(n, r),
|
|
24
|
+
y: e(t, i)
|
|
21
25
|
});
|
|
22
26
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
p as getCategoricalScale,
|
|
28
|
+
l as getNumericScale,
|
|
29
|
+
e as getPointOnScale,
|
|
26
30
|
x as isBandScaleType,
|
|
27
|
-
|
|
31
|
+
a as isCategoricalScale,
|
|
28
32
|
S as isNumericScale,
|
|
29
33
|
b as projectPoint
|
|
30
34
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseAxisProps } from '../../Components/Axis';
|
|
2
|
+
import { ChartScaleFunction, DrawingArea } from '../types';
|
|
2
3
|
export declare const APPROXIMATE_TICK_COUNT = 5;
|
|
3
4
|
export type TickData = {
|
|
4
5
|
position: number;
|
|
@@ -7,9 +8,16 @@ export type TickData = {
|
|
|
7
8
|
};
|
|
8
9
|
/**
|
|
9
10
|
* Resolves which numeric tick values should appear on the axis.
|
|
10
|
-
*
|
|
11
|
+
*
|
|
12
|
+
* Priority:
|
|
13
|
+
* 1. Explicit `ticks` provided by the consumer.
|
|
14
|
+
* 2. Axis `data` — when provided, ticks come from the data itself (numeric
|
|
15
|
+
* values for numeric data, indices for string data) so the rendered ticks
|
|
16
|
+
* mirror exactly what the consumer asked for, with no d3-invented
|
|
17
|
+
* intermediate values.
|
|
18
|
+
* 3. Scale-specific defaults (band domain, or `scale.ticks()` for numeric).
|
|
11
19
|
*/
|
|
12
|
-
export declare const getTickValues: (scale: ChartScaleFunction, explicitTicks?: number[]) => number[];
|
|
20
|
+
export declare const getTickValues: (scale: ChartScaleFunction, explicitTicks?: number[], axisData?: BaseAxisProps["data"]) => number[];
|
|
13
21
|
/**
|
|
14
22
|
* Converts a tick value to its pixel position on the axis.
|
|
15
23
|
* Band scales are centered within the band.
|
|
@@ -19,11 +27,11 @@ export declare const getTickPosition: (scale: ChartScaleFunction, tick: number)
|
|
|
19
27
|
* Resolves the display label for a tick value.
|
|
20
28
|
* Priority: formatter > string label lookup > raw value.
|
|
21
29
|
*/
|
|
22
|
-
export declare const getTickLabel: (tick: number, axisData:
|
|
30
|
+
export declare const getTickLabel: (tick: number, axisData: BaseAxisProps["data"], formatter?: (value: number | string) => string) => string;
|
|
23
31
|
/**
|
|
24
32
|
* Builds the complete tick data array from a scale and axis configuration.
|
|
25
33
|
*/
|
|
26
|
-
export declare const buildTicksData: (scale: ChartScaleFunction, axisConfig?:
|
|
34
|
+
export declare const buildTicksData: (scale: ChartScaleFunction, axisConfig?: BaseAxisProps, explicitTicks?: number[], formatter?: (value: number | string) => string) => TickData[];
|
|
27
35
|
/**
|
|
28
36
|
* Excludes the X grid line at the Y-axis origin (left edge)
|
|
29
37
|
* to prevent overlap with the Y-axis solid line.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ticks.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/ticks/ticks.ts"],"names":[],"mappings":"
|
|
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,WAAW,EAAE,MAAM,UAAU,CAAC;AAEhE,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;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,MAAM,QAAQ,EACd,aAAa,WAAW,KACvB,OAEF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,MAAM,QAAQ,EACd,aAAa,WAAW,KACvB,OAEF,CAAC"}
|