@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":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/CartesianChart/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/CartesianChart/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAClC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/D;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
|
@@ -2,16 +2,27 @@ import { ChartInset } from '../../utils/types';
|
|
|
2
2
|
import { CartesianChartProps } from './types';
|
|
3
3
|
export declare const DEFAULT_HEIGHT = 160;
|
|
4
4
|
/**
|
|
5
|
-
* Internal buffer
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Internal buffer added around the drawing area so SVG content (labels, points,
|
|
6
|
+
* ticks) drawn at the edges is not clipped. The SVG canvas is enlarged by this
|
|
7
|
+
* buffer on every side and shifted back by {@link OVERFLOW_OFFSET} so
|
|
8
|
+
* the chart's layout footprint (and the drawing area) stays exactly the
|
|
9
|
+
* consumer-provided width/height.
|
|
8
10
|
*/
|
|
9
11
|
export declare const OVERFLOW_BUFFER: ChartInset;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Top/left offset applied to the (enlarged) SVG so its drawing area aligns with
|
|
14
|
+
* the container's top-left. The extra width/height added to the SVG overflows
|
|
15
|
+
* symmetrically on every side via `overflow: visible`.
|
|
16
|
+
*
|
|
17
|
+
* Uses `position: relative` rather than negative margins: a negative
|
|
18
|
+
* `margin-top` would collapse through the container (which has no border,
|
|
19
|
+
* padding, or block-formatting context), shifting the whole container instead
|
|
20
|
+
* of offsetting the SVG inside it.
|
|
21
|
+
*/
|
|
22
|
+
export declare const OVERFLOW_OFFSET: {
|
|
23
|
+
position: "relative";
|
|
24
|
+
top: number;
|
|
25
|
+
left: number;
|
|
15
26
|
};
|
|
16
27
|
export declare const ZERO_PADDING: ChartInset;
|
|
17
28
|
export declare const resolveInset: (inset: CartesianChartProps["inset"]) => ChartInset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/CartesianChart/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/CartesianChart/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,EAAE,UAK7B,CAAC;AACF;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;;CAI3B,CAAC;AACF,eAAO,MAAM,YAAY,EAAE,UAK1B,CAAC;AAEF,eAAO,MAAM,YAAY,GACvB,OAAO,mBAAmB,CAAC,OAAO,CAAC,KAClC,UAqBF,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,SAAS,mBAAmB,CAAC,aAAa,CAAC,KAC1C,UAQF,CAAC"}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
const
|
|
2
|
-
top:
|
|
3
|
-
right:
|
|
4
|
-
bottom:
|
|
5
|
-
left:
|
|
1
|
+
const l = 160, r = {
|
|
2
|
+
top: 25,
|
|
3
|
+
right: 25,
|
|
4
|
+
bottom: 25,
|
|
5
|
+
left: 25
|
|
6
6
|
}, f = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
marginLeft: -50
|
|
7
|
+
position: "relative",
|
|
8
|
+
top: -25,
|
|
9
|
+
left: -25
|
|
11
10
|
}, e = {
|
|
12
11
|
top: 0,
|
|
13
12
|
right: 0,
|
|
14
13
|
bottom: 0,
|
|
15
14
|
left: 0
|
|
16
|
-
},
|
|
15
|
+
}, m = (t) => {
|
|
17
16
|
let o;
|
|
18
17
|
return t === void 0 ? o = e : typeof t == "number" ? o = { top: t, right: t, bottom: t, left: t } : o = {
|
|
19
18
|
top: t.top ?? 0,
|
|
@@ -26,17 +25,17 @@ const m = 160, r = {
|
|
|
26
25
|
bottom: o.bottom + r.bottom,
|
|
27
26
|
left: o.left + r.left
|
|
28
27
|
};
|
|
29
|
-
},
|
|
28
|
+
}, b = (t) => t === void 0 ? e : {
|
|
30
29
|
top: t.top ?? 0,
|
|
31
30
|
right: t.right ?? 0,
|
|
32
31
|
bottom: t.bottom ?? 0,
|
|
33
32
|
left: t.left ?? 0
|
|
34
33
|
};
|
|
35
34
|
export {
|
|
36
|
-
|
|
35
|
+
l as DEFAULT_HEIGHT,
|
|
37
36
|
r as OVERFLOW_BUFFER,
|
|
38
|
-
f as
|
|
37
|
+
f as OVERFLOW_OFFSET,
|
|
39
38
|
e as ZERO_PADDING,
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
b as resolveAxisPadding,
|
|
40
|
+
m as resolveInset
|
|
42
41
|
};
|
|
@@ -5,6 +5,10 @@ type Point = [x: number, y: number];
|
|
|
5
5
|
*
|
|
6
6
|
* When `xData` contains numeric values, those values are fed into the scale
|
|
7
7
|
* instead of the array index so the points honour a numeric X domain.
|
|
8
|
+
*
|
|
9
|
+
* When `xData` is provided, iteration is capped at `xData.length` so a series
|
|
10
|
+
* with more points than the axis has labels does not overflow past the right
|
|
11
|
+
* edge of the chart. The axis is treated as authoritative for the X domain.
|
|
8
12
|
*/
|
|
9
13
|
export declare const toScaledPoints: (data: (number | null)[], xScale: ChartScaleFunction, yScale: NumericScale, xData?: readonly (string | number)[]) => Point[] | null;
|
|
10
14
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Line/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,kBAAkB,EAClB,WAAW,EACX,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B,KAAK,KAAK,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAEpC
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Line/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,kBAAkB,EAClB,WAAW,EACX,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B,KAAK,KAAK,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAEpC;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,EACvB,QAAQ,kBAAkB,EAC1B,QAAQ,YAAY,EACpB,QAAQ,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KACnC,KAAK,EAAE,GAAG,IAoBZ,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,KAAK,EAAE,KAAG,MAAM,GAAG,IAOxD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,KAAK,EAAE,EACf,aAAa,WAAW,KACvB,MAAM,GAAG,IAUX,CAAC"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { isCategoricalScale as p } from "../../utils/scales/scales.js";
|
|
2
|
-
import
|
|
2
|
+
import f from "../../../node_modules/d3-shape/src/line.js";
|
|
3
3
|
import { bumpX as s } from "../../../node_modules/d3-shape/src/curve/bump.js";
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
for (let r = 0; r <
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
10
|
-
const
|
|
11
|
-
|
|
4
|
+
import y from "../../../node_modules/d3-shape/src/area.js";
|
|
5
|
+
const d = (o, t, e, n) => {
|
|
6
|
+
const i = [], c = n ? Math.min(o.length, n.length) : o.length;
|
|
7
|
+
for (let r = 0; r < c; r++) {
|
|
8
|
+
const l = o[r];
|
|
9
|
+
if (l === null) continue;
|
|
10
|
+
const u = n && typeof n[r] == "number" ? n[r] : r, m = p(t) ? (t(u) ?? 0) + t.bandwidth() / 2 : t(u), h = e(l);
|
|
11
|
+
i.push([m, h]);
|
|
12
12
|
}
|
|
13
|
-
return
|
|
14
|
-
},
|
|
13
|
+
return i.length >= 2 ? i : null;
|
|
14
|
+
}, B = (o) => f().x((t) => t[0]).y((t) => t[1]).curve(s)(o) ?? null, C = (o, t) => {
|
|
15
15
|
const e = t.y + t.height;
|
|
16
|
-
return
|
|
16
|
+
return y().x((n) => n[0]).y0(e).y1((n) => n[1]).curve(s)(o) ?? null;
|
|
17
17
|
};
|
|
18
18
|
export {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
C as buildAreaPath,
|
|
20
|
+
B as buildLinePath,
|
|
21
|
+
d as toScaledPoints
|
|
22
22
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { LineChartProps } from './types';
|
|
2
|
-
export declare function LineChart({ series, showArea, areaType, showXAxis, showYAxis, xAxis, yAxis, width, height, inset, enableScrubbing, onScrubberPositionChange, animate, children, }: LineChartProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function LineChart({ series, showArea, areaType, showXAxis, showYAxis, xAxis, yAxis, width, height, inset, enableScrubbing, onScrubberPositionChange, animate, magnetRadius, children, }: LineChartProps): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=LineChart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/LineChart/LineChart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/LineChart/LineChart.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,wBAAgB,SAAS,CAAC,EACxB,MAAM,EACN,QAAgB,EAChB,QAAqB,EACrB,SAAiB,EACjB,SAAiB,EACjB,KAAK,EACL,KAAK,EACL,KAAc,EACd,MAAY,EACZ,KAAK,EACL,eAAe,EACf,wBAAwB,EACxB,OAAO,EACP,YAAY,EACZ,QAAQ,GACT,EAAE,cAAc,2CA8DhB"}
|
|
@@ -1,89 +1,79 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { jsxs as b, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as j } from "react";
|
|
3
|
+
import { defaultYAxisProps as y, DEFAULT_AXIS_HEIGHT as m, defaultXAxisProps as A } from "../Axis/Axis.constants.js";
|
|
4
|
+
import { CartesianChart as E } from "../CartesianChart/CartesianChart.js";
|
|
5
|
+
import { XAxis as H } from "../Axis/XAxis/XAxis.js";
|
|
6
|
+
import { YAxis as T } from "../Axis/YAxis/YAxis.js";
|
|
7
|
+
import { Line as _ } from "../Line/Line.js";
|
|
8
|
+
function k({
|
|
9
|
+
series: e,
|
|
10
|
+
showArea: f = !1,
|
|
11
|
+
areaType: a = "gradient",
|
|
12
|
+
showXAxis: i = !1,
|
|
13
|
+
showYAxis: o = !1,
|
|
14
|
+
xAxis: d,
|
|
15
|
+
yAxis: s,
|
|
16
|
+
width: l = "100%",
|
|
17
|
+
height: u = 160,
|
|
18
|
+
inset: x,
|
|
19
|
+
enableScrubbing: c,
|
|
20
|
+
onScrubberPositionChange: g,
|
|
21
|
+
animate: C,
|
|
22
|
+
magnetRadius: I,
|
|
23
|
+
children: L
|
|
22
24
|
}) {
|
|
23
|
-
const {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
...
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}, E = {
|
|
38
|
-
scaleType: L,
|
|
39
|
-
data: S,
|
|
40
|
-
domain: _
|
|
41
|
-
}, H = F(() => {
|
|
42
|
-
if (!t && !i) return;
|
|
43
|
-
const a = n.position === "top" ? "top" : "bottom", s = o.position === "end" ? "right" : "left", p = o.width ?? U;
|
|
44
|
-
return {
|
|
45
|
-
top: t && a === "top" ? m : 0,
|
|
46
|
-
bottom: t && a === "bottom" ? m : 0,
|
|
47
|
-
left: i && s === "left" ? p : 0,
|
|
48
|
-
right: i && s === "right" ? p : 0
|
|
49
|
-
};
|
|
25
|
+
const r = {
|
|
26
|
+
...A,
|
|
27
|
+
...d
|
|
28
|
+
}, t = {
|
|
29
|
+
...y,
|
|
30
|
+
...s
|
|
31
|
+
}, P = j(() => {
|
|
32
|
+
if (!(!i && !o))
|
|
33
|
+
return {
|
|
34
|
+
top: i && r.position === "top" ? m : 0,
|
|
35
|
+
bottom: i && r.position === "bottom" ? m : 0,
|
|
36
|
+
left: o && t.position === "start" ? t.width : 0,
|
|
37
|
+
right: o && t.position === "end" ? t.width : 0
|
|
38
|
+
};
|
|
50
39
|
}, [
|
|
51
|
-
t,
|
|
52
40
|
i,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
o,
|
|
42
|
+
r?.position,
|
|
43
|
+
t?.position,
|
|
44
|
+
t?.width
|
|
56
45
|
]);
|
|
57
|
-
return /* @__PURE__ */
|
|
58
|
-
|
|
46
|
+
return /* @__PURE__ */ b(
|
|
47
|
+
E,
|
|
59
48
|
{
|
|
60
|
-
series:
|
|
61
|
-
xAxis:
|
|
62
|
-
yAxis:
|
|
63
|
-
width:
|
|
64
|
-
height:
|
|
65
|
-
inset:
|
|
66
|
-
axisPadding:
|
|
67
|
-
enableScrubbing:
|
|
68
|
-
onScrubberPositionChange:
|
|
69
|
-
animate:
|
|
49
|
+
series: e ?? [],
|
|
50
|
+
xAxis: r,
|
|
51
|
+
yAxis: t,
|
|
52
|
+
width: l,
|
|
53
|
+
height: u,
|
|
54
|
+
inset: x,
|
|
55
|
+
axisPadding: P,
|
|
56
|
+
enableScrubbing: c,
|
|
57
|
+
onScrubberPositionChange: g,
|
|
58
|
+
animate: C,
|
|
59
|
+
magnetRadius: I,
|
|
70
60
|
children: [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
61
|
+
i && /* @__PURE__ */ n(H, { ...r }),
|
|
62
|
+
o && /* @__PURE__ */ n(T, { ...t }),
|
|
63
|
+
e?.map((p) => /* @__PURE__ */ n(
|
|
64
|
+
_,
|
|
75
65
|
{
|
|
76
|
-
seriesId:
|
|
77
|
-
showArea:
|
|
78
|
-
areaType:
|
|
66
|
+
seriesId: p.id,
|
|
67
|
+
showArea: f,
|
|
68
|
+
areaType: a
|
|
79
69
|
},
|
|
80
|
-
|
|
70
|
+
p.id
|
|
81
71
|
)),
|
|
82
|
-
|
|
72
|
+
L
|
|
83
73
|
]
|
|
84
74
|
}
|
|
85
75
|
);
|
|
86
76
|
}
|
|
87
77
|
export {
|
|
88
|
-
|
|
78
|
+
k as LineChart
|
|
89
79
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared fixtures for the Visualization Storybook stories.
|
|
3
|
+
*
|
|
4
|
+
* Every chart story renders through `<LineChart>` (never `<CartesianChart>`)
|
|
5
|
+
* and, where it makes sense, reuses the same dimensions and series so the
|
|
6
|
+
* examples stay visually consistent across the main component and its
|
|
7
|
+
* sub-components.
|
|
8
|
+
*/
|
|
9
|
+
/** Standard chart width (CSS length) shared by every story. */
|
|
10
|
+
export declare const CHART_WIDTH = "100%";
|
|
11
|
+
/** Standard chart height (px) shared by every story. */
|
|
12
|
+
export declare const CHART_HEIGHT = 250;
|
|
13
|
+
/**
|
|
14
|
+
* Canonical single-series dataset reused across stories. Declared with
|
|
15
|
+
* `satisfies` so `data` stays a concrete `number[]` (handy for index lookups
|
|
16
|
+
* in tooltip/label stories) while remaining assignable to `Series[]`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const sampleSeries: {
|
|
19
|
+
id: string;
|
|
20
|
+
stroke: string;
|
|
21
|
+
data: number[];
|
|
22
|
+
}[];
|
|
23
|
+
/** Canonical two-series dataset for multi-line examples. */
|
|
24
|
+
export declare const multiSeries: {
|
|
25
|
+
id: string;
|
|
26
|
+
label: string;
|
|
27
|
+
stroke: string;
|
|
28
|
+
data: number[];
|
|
29
|
+
}[];
|
|
30
|
+
/**
|
|
31
|
+
* Dense, deterministic single-series dataset (160 points) shaped like a real
|
|
32
|
+
* price series: a seeded random walk with mild mean reversion and occasional
|
|
33
|
+
* larger moves. Deterministic so stories (and visual snapshots) render
|
|
34
|
+
* identically every time. Useful for features that need many data points to
|
|
35
|
+
* read clearly, such as the magnetic scrubber: the scrubber glides over the
|
|
36
|
+
* many ordinary points but snaps onto the few magnetic ones.
|
|
37
|
+
*/
|
|
38
|
+
export declare const denseData: number[];
|
|
39
|
+
export declare const denseSeries: {
|
|
40
|
+
id: string;
|
|
41
|
+
stroke: string;
|
|
42
|
+
data: number[];
|
|
43
|
+
}[];
|
|
44
|
+
/** Month labels aligned to the 14-point `sampleSeries`, for axis/scrubber stories. */
|
|
45
|
+
export declare const monthLabels: string[];
|
|
46
|
+
//# sourceMappingURL=chartStoryFixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartStoryFixtures.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/LineChart/__stories__/chartStoryFixtures.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,+DAA+D;AAC/D,eAAO,MAAM,WAAW,SAAS,CAAC;AAElC,wDAAwD;AACxD,eAAO,MAAM,YAAY,MAAM,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;;GAML,CAAC;AAErB,4DAA4D;AAC5D,eAAO,MAAM,WAAW;;;;;GAaJ,CAAC;AAErB;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,UAqBlB,CAAC;AAEL,eAAO,MAAM,WAAW;;;;GAEJ,CAAC;AAErB,sFAAsF;AACtF,eAAO,MAAM,WAAW,UAevB,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { FormattedValue } from '@ledgerhq/lumen-ui-react';
|
|
2
|
+
import { ScrubberTooltipContent } from '../../Scrubber';
|
|
3
|
+
/**
|
|
4
|
+
* Deterministic fixtures and helpers backing the interactive LineChart story.
|
|
5
|
+
*
|
|
6
|
+
* This lives outside the story's render on purpose: composing the chart with
|
|
7
|
+
* design-system components is what the story demonstrates, while generating
|
|
8
|
+
* realistic market data is an app concern that consumers own themselves.
|
|
9
|
+
*/
|
|
10
|
+
export type Period = '24H' | '1W' | '1M' | '6M' | '1Y' | '5Y' | 'All';
|
|
11
|
+
export type TransactionType = 'buy' | 'sell';
|
|
12
|
+
export type Transaction = {
|
|
13
|
+
type: TransactionType;
|
|
14
|
+
value: number;
|
|
15
|
+
};
|
|
16
|
+
export type ChartMarker = {
|
|
17
|
+
index: number;
|
|
18
|
+
/**
|
|
19
|
+
* A single entry is a standalone transaction; multiple entries are a cluster
|
|
20
|
+
* of transactions that sit too close together to display individually.
|
|
21
|
+
*/
|
|
22
|
+
transactions: Transaction[];
|
|
23
|
+
};
|
|
24
|
+
export type ChartModel = {
|
|
25
|
+
data: number[];
|
|
26
|
+
markers: ChartMarker[];
|
|
27
|
+
markerByIndex: Map<number, ChartMarker>;
|
|
28
|
+
average: number;
|
|
29
|
+
isPositive: boolean;
|
|
30
|
+
highIndex: number;
|
|
31
|
+
lowIndex: number;
|
|
32
|
+
yDomain: {
|
|
33
|
+
min: number;
|
|
34
|
+
max: number;
|
|
35
|
+
};
|
|
36
|
+
xTicks: number[];
|
|
37
|
+
yTicks: number[];
|
|
38
|
+
};
|
|
39
|
+
type PeriodConfig = {
|
|
40
|
+
points: number;
|
|
41
|
+
label: string;
|
|
42
|
+
spanDays: number;
|
|
43
|
+
seed: number;
|
|
44
|
+
dateFormat: Intl.DateTimeFormatOptions;
|
|
45
|
+
};
|
|
46
|
+
export declare const PERIODS: Record<Period, PeriodConfig>;
|
|
47
|
+
export declare const ACTIONS: readonly [{
|
|
48
|
+
readonly label: "Receive";
|
|
49
|
+
readonly appearance: "base";
|
|
50
|
+
readonly icon: {
|
|
51
|
+
({ ref, className, disabled, ...props }: Omit<import('@ledgerhq/lumen-ui-react/Icon').IconProps, "children">): import('react').FunctionComponentElement<import('@ledgerhq/lumen-ui-react/Icon').IconProps>;
|
|
52
|
+
displayName: string;
|
|
53
|
+
};
|
|
54
|
+
}, {
|
|
55
|
+
readonly label: "Buy";
|
|
56
|
+
readonly appearance: "gray";
|
|
57
|
+
readonly icon: {
|
|
58
|
+
({ ref, className, disabled, ...props }: Omit<import('@ledgerhq/lumen-ui-react/Icon').IconProps, "children">): import('react').FunctionComponentElement<import('@ledgerhq/lumen-ui-react/Icon').IconProps>;
|
|
59
|
+
displayName: string;
|
|
60
|
+
};
|
|
61
|
+
}, {
|
|
62
|
+
readonly label: "Sell";
|
|
63
|
+
readonly appearance: "gray";
|
|
64
|
+
readonly icon: {
|
|
65
|
+
({ ref, className, disabled, ...props }: Omit<import('@ledgerhq/lumen-ui-react/Icon').IconProps, "children">): import('react').FunctionComponentElement<import('@ledgerhq/lumen-ui-react/Icon').IconProps>;
|
|
66
|
+
displayName: string;
|
|
67
|
+
};
|
|
68
|
+
}, {
|
|
69
|
+
readonly label: "Send";
|
|
70
|
+
readonly appearance: "gray";
|
|
71
|
+
readonly icon: {
|
|
72
|
+
({ ref, className, disabled, ...props }: Omit<import('@ledgerhq/lumen-ui-react/Icon').IconProps, "children">): import('react').FunctionComponentElement<import('@ledgerhq/lumen-ui-react/Icon').IconProps>;
|
|
73
|
+
displayName: string;
|
|
74
|
+
};
|
|
75
|
+
}];
|
|
76
|
+
export declare const usdFormatter: (value: number) => FormattedValue;
|
|
77
|
+
export declare const formatUsd: (value: number) => string;
|
|
78
|
+
export declare const getMarkerColor: (marker: ChartMarker) => string;
|
|
79
|
+
export declare const getMarkerTooltip: (marker: ChartMarker) => ScrubberTooltipContent;
|
|
80
|
+
/** Builds the full deterministic dataset (series, markers, ticks) for a period. */
|
|
81
|
+
export declare const buildChartModel: (period: Period) => ChartModel;
|
|
82
|
+
/** Builds an x-axis tick formatter that renders dates for the given period. */
|
|
83
|
+
export declare const createAxisDateFormatter: (period: Period, dataLength: number) => ((value: number | string) => string);
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=cryptoChartData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cryptoChartData.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/LineChart/__stories__/cryptoChartData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAQ/D,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAExB;;;;;;GAMG;AAEH,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAEtE,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,CAAC;AAE7C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAaF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,IAAI,CAAC,qBAAqB,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAkDhD,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKV,CAAC;AA+HX,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,cAS5C,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,MAIpC,CAAC;AAEP,eAAO,MAAM,cAAc,GAAI,QAAQ,WAAW,KAAG,MASpD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,WAAW,KAClB,sBAyBF,CAAC;AAEF,mFAAmF;AACnF,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,UAqChD,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,uBAAuB,GAClC,QAAQ,MAAM,EACd,YAAY,MAAM,KACjB,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,CAarC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ChartInset, Series } from '../../utils/types';
|
|
3
3
|
import { XAxisProps } from '../Axis/XAxis';
|
|
4
4
|
import { YAxisProps } from '../Axis/YAxis';
|
|
5
5
|
export type LineChartProps = {
|
|
@@ -33,12 +33,12 @@ export type LineChartProps = {
|
|
|
33
33
|
* Combined axis configuration and visual props for the x-axis.
|
|
34
34
|
* Includes scale/domain settings as well as visual options like `showGrid` and `showLine`.
|
|
35
35
|
*/
|
|
36
|
-
xAxis?:
|
|
36
|
+
xAxis?: XAxisProps;
|
|
37
37
|
/**
|
|
38
38
|
* Combined axis configuration and visual props for the y-axis.
|
|
39
39
|
* Includes scale/domain settings as well as visual options like `showGrid` and `showLine`.
|
|
40
40
|
*/
|
|
41
|
-
yAxis?:
|
|
41
|
+
yAxis?: YAxisProps;
|
|
42
42
|
/**
|
|
43
43
|
* Width of the chart.
|
|
44
44
|
* A number is treated as pixels; a string (e.g. `'100%'`) fills the container.
|
|
@@ -75,5 +75,12 @@ export type LineChartProps = {
|
|
|
75
75
|
* @default true
|
|
76
76
|
*/
|
|
77
77
|
animate?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Pixel radius within which the scrubber magnetically snaps to registered
|
|
80
|
+
* magnetic `<Point>` components. Requires `enableScrubbing` to be `true`.
|
|
81
|
+
* Set to `0` to disable magnetization.
|
|
82
|
+
* @default 8
|
|
83
|
+
*/
|
|
84
|
+
magnetRadius?: number;
|
|
78
85
|
};
|
|
79
86
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/LineChart/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/LineChart/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/D;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { PointLabelProps, PointProps } from './types';
|
|
2
2
|
export declare function PointLabel({ style, textAnchor, dominantBaseline, ...props }: Readonly<PointLabelProps>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
-
export declare function Point({ dataX, dataY, color, label, LabelComponent, labelPosition, hidePoint, showLabelArrow, size, onClick, }: Readonly<PointProps>): import("react/jsx-runtime").JSX.Element | null;
|
|
3
|
+
export declare function Point({ dataX, dataY, color, label, LabelComponent, labelPosition, hidePoint, showLabelArrow, size, onClick, magnetic, }: Readonly<PointProps>): import("react/jsx-runtime").JSX.Element | null;
|
|
4
4
|
//# sourceMappingURL=Point.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Point.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Point/Point.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Point.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Point/Point.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAS3D,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,UAAqB,EACrB,gBAAyB,EACzB,GAAG,KAAK,EACT,EAAE,QAAQ,CAAC,eAAe,CAAC,2CAe3B;AAED,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,cAAc,EACd,aAAqB,EACrB,SAAiB,EACjB,cAAqB,EACrB,IAAmB,EACnB,OAAO,EACP,QAAgB,GACjB,EAAE,QAAQ,CAAC,UAAU,CAAC,kDAgEtB"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { projectPoint as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { jsxs as k, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as E } from "react";
|
|
3
|
+
import { projectPoint as M } from "../../utils/scales/scales.js";
|
|
4
|
+
import { STROKE_WIDTH as R, DEFAULT_SIZE as T } from "./constants.js";
|
|
5
|
+
import { useMagneticRegistration as z, isWithinBounds as D, resolveLabel as F, buildArrowPoints as I, computeLabelY as Y } from "./utils.js";
|
|
6
|
+
import { useCartesianChartContext as _ } from "../CartesianChart/context/cartesianChartContext.js";
|
|
7
|
+
import { useRevealClip as B } from "../CartesianChart/RevealClip/context.js";
|
|
8
|
+
import { useMagneticPointsContext as H } from "./pointContext/magneticPointsContext.js";
|
|
7
9
|
import { cssVar as o } from "../../../libs/design-core/dist/lib/cssVar/cssVar.js";
|
|
8
|
-
function
|
|
10
|
+
function K({
|
|
9
11
|
style: e,
|
|
10
12
|
textAnchor: r = "middle",
|
|
11
13
|
dominantBaseline: i = "auto",
|
|
@@ -27,34 +29,37 @@ function Y({
|
|
|
27
29
|
}
|
|
28
30
|
);
|
|
29
31
|
}
|
|
30
|
-
function
|
|
32
|
+
function $({
|
|
31
33
|
dataX: e,
|
|
32
34
|
dataY: r,
|
|
33
35
|
color: i,
|
|
34
36
|
label: s,
|
|
35
|
-
LabelComponent:
|
|
36
|
-
labelPosition:
|
|
37
|
-
hidePoint:
|
|
38
|
-
showLabelArrow:
|
|
39
|
-
size:
|
|
40
|
-
onClick:
|
|
37
|
+
LabelComponent: d,
|
|
38
|
+
labelPosition: m = "top",
|
|
39
|
+
hidePoint: x = !1,
|
|
40
|
+
showLabelArrow: y = !0,
|
|
41
|
+
size: g = T,
|
|
42
|
+
onClick: u,
|
|
43
|
+
magnetic: b = !1
|
|
41
44
|
}) {
|
|
42
|
-
const { getXScale: v, getYScale:
|
|
45
|
+
const { getXScale: v, getYScale: h, getXAxisConfig: L, drawingArea: S } = _(), C = B(), w = H();
|
|
46
|
+
z(b, e, L, w);
|
|
47
|
+
const l = v(), a = h(), c = g / 2, A = i ?? o("var(--background-muted-strong)"), t = E(() => {
|
|
43
48
|
if (!(!l || !a))
|
|
44
|
-
return
|
|
49
|
+
return M(e, r, l, a);
|
|
45
50
|
}, [e, r, l, a]);
|
|
46
|
-
if (!t || !
|
|
51
|
+
if (!t || !D(t.x, t.y, S))
|
|
47
52
|
return null;
|
|
48
|
-
const
|
|
49
|
-
return /* @__PURE__ */
|
|
53
|
+
const f = F(s, e), P = f != null, p = y && P, W = Y(t.y, c, m, p), j = d ?? K;
|
|
54
|
+
return /* @__PURE__ */ k(
|
|
50
55
|
"g",
|
|
51
56
|
{
|
|
52
57
|
"data-testid": "point-group",
|
|
53
|
-
clipPath:
|
|
54
|
-
onClick:
|
|
55
|
-
style:
|
|
58
|
+
clipPath: C,
|
|
59
|
+
onClick: u,
|
|
60
|
+
style: u ? { cursor: "pointer" } : void 0,
|
|
56
61
|
children: [
|
|
57
|
-
!
|
|
62
|
+
!x && /* @__PURE__ */ n(
|
|
58
63
|
"circle",
|
|
59
64
|
{
|
|
60
65
|
"data-testid": "point-circle",
|
|
@@ -62,26 +67,26 @@ function V({
|
|
|
62
67
|
cy: t.y,
|
|
63
68
|
r: c,
|
|
64
69
|
style: {
|
|
65
|
-
fill:
|
|
70
|
+
fill: A,
|
|
66
71
|
stroke: o("var(--background-canvas)")
|
|
67
72
|
},
|
|
68
|
-
strokeWidth:
|
|
73
|
+
strokeWidth: R
|
|
69
74
|
}
|
|
70
75
|
),
|
|
71
|
-
|
|
76
|
+
p && /* @__PURE__ */ n(
|
|
72
77
|
"polygon",
|
|
73
78
|
{
|
|
74
79
|
"data-testid": "point-arrow",
|
|
75
|
-
points:
|
|
80
|
+
points: I(t.x, t.y, c, m),
|
|
76
81
|
style: { fill: o("var(--text-base)") }
|
|
77
82
|
}
|
|
78
83
|
),
|
|
79
|
-
|
|
84
|
+
f != null && /* @__PURE__ */ n(j, { x: t.x, y: W, children: f })
|
|
80
85
|
]
|
|
81
86
|
}
|
|
82
87
|
);
|
|
83
88
|
}
|
|
84
89
|
export {
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
$ as Point,
|
|
91
|
+
K as PointLabel
|
|
87
92
|
};
|