@ledgerhq/lumen-ui-react-visualization 0.1.15 → 0.1.16
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 +10 -11
- 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__/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/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
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { XAxisProps } from './XAxis';
|
|
2
|
+
import { YAxisProps } from './YAxis';
|
|
3
|
+
export declare const DEFAULT_AXIS_HEIGHT = 28;
|
|
4
|
+
export declare const DEFAULT_AXIS_WIDTH = 40;
|
|
5
|
+
export declare const TICK_MARK_SIZE = 4;
|
|
6
|
+
export declare const TICK_LABEL_OFFSET = 6;
|
|
7
|
+
export declare const defaultXAxisProps: XAxisProps;
|
|
8
|
+
export declare const defaultYAxisProps: YAxisProps;
|
|
9
|
+
//# sourceMappingURL=Axis.constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Axis.constants.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Axis/Axis.constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,eAAO,MAAM,iBAAiB,EAAE,UAO/B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,UAQ/B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const s = 28, e = 40, o = 4, i = 6, t = {
|
|
2
|
+
position: "bottom",
|
|
3
|
+
showGrid: !1,
|
|
4
|
+
showLine: !1,
|
|
5
|
+
showTickMark: !1,
|
|
6
|
+
scaleType: "linear",
|
|
7
|
+
nice: !1
|
|
8
|
+
}, a = {
|
|
9
|
+
position: "start",
|
|
10
|
+
showGrid: !1,
|
|
11
|
+
showLine: !1,
|
|
12
|
+
showTickMark: !1,
|
|
13
|
+
scaleType: "linear",
|
|
14
|
+
nice: !0,
|
|
15
|
+
width: 40
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
s as DEFAULT_AXIS_HEIGHT,
|
|
19
|
+
e as DEFAULT_AXIS_WIDTH,
|
|
20
|
+
i as TICK_LABEL_OFFSET,
|
|
21
|
+
o as TICK_MARK_SIZE,
|
|
22
|
+
t as defaultXAxisProps,
|
|
23
|
+
a as defaultYAxisProps
|
|
24
|
+
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export type AxisBounds = {
|
|
2
|
+
min: number;
|
|
3
|
+
max: number;
|
|
4
|
+
};
|
|
1
5
|
export type BaseAxisProps = {
|
|
2
6
|
/**
|
|
3
7
|
* Whether to render grid lines at each tick.
|
|
@@ -29,5 +33,38 @@ export type BaseAxisProps = {
|
|
|
29
33
|
* Receives the raw tick value (number or string label) and must return a string.
|
|
30
34
|
*/
|
|
31
35
|
tickLabelFormatter?: (value: number | string) => string;
|
|
36
|
+
/**
|
|
37
|
+
* Scale algorithm used by this axis.
|
|
38
|
+
* @default 'linear'
|
|
39
|
+
*/
|
|
40
|
+
scaleType?: 'linear' | 'log' | 'band';
|
|
41
|
+
/**
|
|
42
|
+
* Explicit data values for band scales or category labels.
|
|
43
|
+
* For band scales, provides the discrete domain. For numeric scales, string values
|
|
44
|
+
* are used as tick labels at corresponding indices.
|
|
45
|
+
*/
|
|
46
|
+
data?: string[] | number[];
|
|
47
|
+
/**
|
|
48
|
+
* Fixed domain bounds or a function that adjusts the computed bounds.
|
|
49
|
+
* A partial object overrides only the specified bound(s).
|
|
50
|
+
* A function receives the auto-computed bounds and returns adjusted ones.
|
|
51
|
+
*
|
|
52
|
+
* Applied before {@link BaseAxisProps.nice}. To keep your bounds exactly as
|
|
53
|
+
* provided, set `nice: false` alongside a full `{ min, max }` override.
|
|
54
|
+
*/
|
|
55
|
+
domain?: Partial<AxisBounds> | ((bounds: AxisBounds) => AxisBounds);
|
|
56
|
+
/**
|
|
57
|
+
* Round the domain outward to clean boundaries via d3's `.nice()`
|
|
58
|
+
* (e.g. `[4, 98]` becomes `[0, 100]`).
|
|
59
|
+
*
|
|
60
|
+
* Defaults to `true`. Set to `false` to keep the domain exactly as provided
|
|
61
|
+
* so data fills the plot area boundary-to-boundary — typically only useful
|
|
62
|
+
* when you also pass a full `domain: { min, max }` and don't have overlays
|
|
63
|
+
* (reference lines, scrubber positions, annotations) that may sit outside
|
|
64
|
+
* the data range.
|
|
65
|
+
*
|
|
66
|
+
* Applied after any {@link BaseAxisProps.domain} override.
|
|
67
|
+
*/
|
|
68
|
+
nice?: boolean;
|
|
32
69
|
};
|
|
33
70
|
//# sourceMappingURL=Axis.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Axis.types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Axis/Axis.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"Axis.types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Axis/Axis.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC;IACxD;;;OAGG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;IACtC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAC3B;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,UAAU,KAAK,UAAU,CAAC,CAAC;IACpE;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { XAxisProps } from './types';
|
|
2
|
-
export declare const DEFAULT_AXIS_HEIGHT = 28;
|
|
3
2
|
export declare function XAxis({ gridLineStyle, position, showGrid, showLine, showTickMark, ticks: ticksProp, tickLabelFormatter, }: XAxisProps): import("react/jsx-runtime").JSX.Element | null;
|
|
4
3
|
//# sourceMappingURL=XAxis.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XAxis.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/XAxis/XAxis.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"XAxis.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/XAxis/XAxis.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,wBAAgB,KAAK,CAAC,EACpB,aAAuB,EACvB,QAAmB,EACnB,QAAgB,EAChB,QAAgB,EAChB,YAAoB,EACpB,KAAK,EAAE,SAAS,EAChB,kBAAkB,GACnB,EAAE,UAAU,kDAuFZ"}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { buildTicksData as
|
|
4
|
-
import {
|
|
1
|
+
import { jsxs as A, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as C } from "react";
|
|
3
|
+
import { buildTicksData as T, isTickOnXAxisDomainEdge as $ } from "../../../utils/ticks/ticks.js";
|
|
4
|
+
import { TICK_MARK_SIZE as y, TICK_LABEL_OFFSET as D } from "../Axis.constants.js";
|
|
5
|
+
import { useCartesianChartContext as E } from "../../CartesianChart/context/cartesianChartContext.js";
|
|
5
6
|
import { cssVar as o } from "../../../../libs/design-core/dist/lib/cssVar/cssVar.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
gridLineStyle: p = "solid",
|
|
7
|
+
function W({
|
|
8
|
+
gridLineStyle: h = "solid",
|
|
9
9
|
position: l = "bottom",
|
|
10
|
-
showGrid:
|
|
11
|
-
showLine:
|
|
10
|
+
showGrid: u = !1,
|
|
11
|
+
showLine: c = !1,
|
|
12
12
|
showTickMark: g = !1,
|
|
13
13
|
ticks: d,
|
|
14
|
-
tickLabelFormatter:
|
|
14
|
+
tickLabelFormatter: m
|
|
15
15
|
}) {
|
|
16
|
-
const { getXScale: v, getXAxisConfig:
|
|
17
|
-
() => r ?
|
|
18
|
-
[r,
|
|
16
|
+
const { getXScale: v, getXAxisConfig: b, drawingArea: e } = E(), r = v(), x = b(), n = C(
|
|
17
|
+
() => r ? T(r, x, d, m) : [],
|
|
18
|
+
[r, x, d, m]
|
|
19
19
|
);
|
|
20
20
|
if (!r || e.width <= 0)
|
|
21
21
|
return null;
|
|
22
|
-
const f = l === "top", s = f ? e.y : e.y + e.height,
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
-
|
|
22
|
+
const f = l === "top", s = f ? e.y : e.y + e.height, p = f ? -1 : 1, k = s + p * (y + D);
|
|
23
|
+
return /* @__PURE__ */ A("g", { "data-testid": "x-axis", children: [
|
|
24
|
+
u && n.filter((t) => $(t, e)).map((t, i) => /* @__PURE__ */ a(
|
|
25
25
|
"line",
|
|
26
26
|
{
|
|
27
27
|
x1: t.position,
|
|
@@ -32,11 +32,11 @@ function K({
|
|
|
32
32
|
stroke: o("var(--border-muted-subtle-transparent)")
|
|
33
33
|
},
|
|
34
34
|
strokeWidth: o("var(--stroke-1)"),
|
|
35
|
-
strokeDasharray:
|
|
35
|
+
strokeDasharray: h === "dashed" ? "3 3" : void 0
|
|
36
36
|
},
|
|
37
37
|
`grid-${t.value}-${i}`
|
|
38
38
|
)),
|
|
39
|
-
|
|
39
|
+
c && /* @__PURE__ */ a(
|
|
40
40
|
"line",
|
|
41
41
|
{
|
|
42
42
|
x1: e.x,
|
|
@@ -55,7 +55,7 @@ function K({
|
|
|
55
55
|
x1: t.position,
|
|
56
56
|
y1: s,
|
|
57
57
|
x2: t.position,
|
|
58
|
-
y2: s +
|
|
58
|
+
y2: s + p * y,
|
|
59
59
|
style: { stroke: o("var(--border-muted)") },
|
|
60
60
|
strokeWidth: o("var(--stroke-1)")
|
|
61
61
|
},
|
|
@@ -65,7 +65,7 @@ function K({
|
|
|
65
65
|
"text",
|
|
66
66
|
{
|
|
67
67
|
x: t.position,
|
|
68
|
-
y:
|
|
68
|
+
y: k,
|
|
69
69
|
textAnchor: "middle",
|
|
70
70
|
dominantBaseline: l === "top" ? "auto" : "hanging",
|
|
71
71
|
style: {
|
|
@@ -80,6 +80,5 @@ function K({
|
|
|
80
80
|
] });
|
|
81
81
|
}
|
|
82
82
|
export {
|
|
83
|
-
|
|
84
|
-
K as XAxis
|
|
83
|
+
W as XAxis
|
|
85
84
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/XAxis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/XAxis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { YAxisProps } from './types';
|
|
2
|
-
export declare const DEFAULT_AXIS_WIDTH = 40;
|
|
3
2
|
export declare function YAxis({ gridLineStyle, position, showGrid, showLine, showTickMark, ticks: ticksProp, tickLabelFormatter, }: YAxisProps): import("react/jsx-runtime").JSX.Element | null;
|
|
4
3
|
//# sourceMappingURL=YAxis.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YAxis.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/YAxis/YAxis.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"YAxis.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/YAxis/YAxis.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,wBAAgB,KAAK,CAAC,EACpB,aAAuB,EACvB,QAAkB,EAClB,QAAgB,EAChB,QAAgB,EAChB,YAAoB,EACpB,KAAK,EAAE,SAAS,EAChB,kBAAkB,GACnB,EAAE,UAAU,kDAuFZ"}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as A, jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo as C } from "react";
|
|
3
|
-
import { buildTicksData as
|
|
4
|
-
import {
|
|
3
|
+
import { buildTicksData as S, isTickOnYAxisDomainEdge as $ } from "../../../utils/ticks/ticks.js";
|
|
4
|
+
import { TICK_MARK_SIZE as c, TICK_LABEL_OFFSET as D } from "../Axis.constants.js";
|
|
5
|
+
import { useCartesianChartContext as E } from "../../CartesianChart/context/cartesianChartContext.js";
|
|
5
6
|
import { cssVar as s } from "../../../../libs/design-core/dist/lib/cssVar/cssVar.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
gridLineStyle: h = "solid",
|
|
7
|
+
function W({
|
|
8
|
+
gridLineStyle: p = "solid",
|
|
9
9
|
position: l = "start",
|
|
10
|
-
showGrid:
|
|
10
|
+
showGrid: h = !1,
|
|
11
11
|
showLine: u = !1,
|
|
12
12
|
showTickMark: v = !1,
|
|
13
13
|
ticks: d,
|
|
14
14
|
tickLabelFormatter: x
|
|
15
15
|
}) {
|
|
16
|
-
const { getYScale: g, getYAxisConfig:
|
|
17
|
-
() => i ?
|
|
16
|
+
const { getYScale: g, getYAxisConfig: k, drawingArea: e } = E(), i = g(), m = k(), n = C(
|
|
17
|
+
() => i ? S(i, m, d, x) : [],
|
|
18
18
|
[i, m, d, x]
|
|
19
19
|
);
|
|
20
20
|
if (!i || e.height <= 0)
|
|
21
21
|
return null;
|
|
22
|
-
const
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
-
|
|
22
|
+
const f = l === "start", r = f ? e.x : e.x + e.width, y = f ? -1 : 1, b = r + y * (c + D);
|
|
23
|
+
return /* @__PURE__ */ A("g", { "data-testid": "y-axis", children: [
|
|
24
|
+
h && n.filter((t) => $(t, e)).map((t, o) => /* @__PURE__ */ a(
|
|
25
25
|
"line",
|
|
26
26
|
{
|
|
27
27
|
x1: e.x,
|
|
@@ -32,7 +32,7 @@ function F({
|
|
|
32
32
|
stroke: s("var(--border-muted-subtle-transparent)")
|
|
33
33
|
},
|
|
34
34
|
strokeWidth: s("var(--stroke-1)"),
|
|
35
|
-
strokeDasharray:
|
|
35
|
+
strokeDasharray: p === "dashed" ? "3 3" : void 0
|
|
36
36
|
},
|
|
37
37
|
`grid-${t.value}-${o}`
|
|
38
38
|
)),
|
|
@@ -54,7 +54,7 @@ function F({
|
|
|
54
54
|
{
|
|
55
55
|
x1: r,
|
|
56
56
|
y1: t.position,
|
|
57
|
-
x2: r +
|
|
57
|
+
x2: r + y * c,
|
|
58
58
|
y2: t.position,
|
|
59
59
|
style: { stroke: s("var(--border-muted)") },
|
|
60
60
|
strokeWidth: s("var(--stroke-1)")
|
|
@@ -64,7 +64,7 @@ function F({
|
|
|
64
64
|
n.map((t, o) => /* @__PURE__ */ a(
|
|
65
65
|
"text",
|
|
66
66
|
{
|
|
67
|
-
x:
|
|
67
|
+
x: b,
|
|
68
68
|
y: t.position,
|
|
69
69
|
textAnchor: l === "start" ? "end" : "start",
|
|
70
70
|
dominantBaseline: "central",
|
|
@@ -80,6 +80,5 @@ function F({
|
|
|
80
80
|
] });
|
|
81
81
|
}
|
|
82
82
|
export {
|
|
83
|
-
|
|
84
|
-
F as YAxis
|
|
83
|
+
W as YAxis
|
|
85
84
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/YAxis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/YAxis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Axis/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { CartesianChartProps } from './types';
|
|
2
|
-
export declare function CartesianChart({ series, xAxis, yAxis, width, height, inset, axisPadding, ariaLabel, enableScrubbing, onScrubberPositionChange, animate, children, }: CartesianChartProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function CartesianChart({ series, xAxis, yAxis, width, height, inset, axisPadding, ariaLabel, enableScrubbing, onScrubberPositionChange, animate, magnetRadius, children, }: CartesianChartProps): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=CartesianChart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CartesianChart.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/CartesianChart/CartesianChart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CartesianChart.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/CartesianChart/CartesianChart.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AASnD,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,KAAK,EACL,KAAK,EACL,KAAc,EACd,MAAuB,EACvB,KAAK,EACL,WAAW,EACX,SAAmB,EACnB,eAAuB,EACvB,wBAAwB,EACxB,OAAc,EACd,YAAY,EACZ,QAAQ,GACT,EAAE,mBAAmB,2CA0GrB"}
|
|
@@ -1,95 +1,99 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { ScrubberProvider as
|
|
4
|
-
import { resolveInset as
|
|
5
|
-
import { useBuildChartContext as
|
|
6
|
-
import { CartesianChartProvider as
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as R, useState as M, useCallback as z, useEffect as H, useMemo as b } from "react";
|
|
3
|
+
import { ScrubberProvider as L } from "../Scrubber/ScrubberProvider.js";
|
|
4
|
+
import { resolveInset as T, resolveAxisPadding as V, DEFAULT_HEIGHT as _, OVERFLOW_OFFSET as k, OVERFLOW_BUFFER as s } from "./utils.js";
|
|
5
|
+
import { useBuildChartContext as B } from "./context/useBuildChartContext.js";
|
|
6
|
+
import { CartesianChartProvider as D } from "./context/cartesianChartContext.js";
|
|
7
|
+
import { MagneticPointsProvider as U } from "../Point/pointContext/MagneticPointsProvider.js";
|
|
8
|
+
import { RevealClipDefs as j } from "./RevealClip/RevealClipDefs.js";
|
|
9
|
+
function Y({
|
|
10
|
+
series: a,
|
|
10
11
|
xAxis: C,
|
|
11
|
-
yAxis:
|
|
12
|
+
yAxis: y,
|
|
12
13
|
width: e = "100%",
|
|
13
|
-
height:
|
|
14
|
-
inset:
|
|
15
|
-
axisPadding:
|
|
16
|
-
ariaLabel:
|
|
14
|
+
height: l = _,
|
|
15
|
+
inset: c,
|
|
16
|
+
axisPadding: f,
|
|
17
|
+
ariaLabel: x = "Chart",
|
|
17
18
|
enableScrubbing: i = !1,
|
|
18
|
-
onScrubberPositionChange:
|
|
19
|
-
animate:
|
|
20
|
-
|
|
19
|
+
onScrubberPositionChange: E,
|
|
20
|
+
animate: F = !0,
|
|
21
|
+
magnetRadius: O,
|
|
22
|
+
children: P
|
|
21
23
|
}) {
|
|
22
|
-
const
|
|
24
|
+
const d = R(null), v = R(null), [W, A] = M(
|
|
23
25
|
typeof e == "number" ? e : void 0
|
|
24
|
-
),
|
|
25
|
-
const [
|
|
26
|
-
|
|
26
|
+
), r = typeof e != "number", u = z((n) => {
|
|
27
|
+
const [g] = n;
|
|
28
|
+
g && A(g.contentRect.width);
|
|
27
29
|
}, []);
|
|
28
|
-
|
|
29
|
-
if (!
|
|
30
|
+
H(() => {
|
|
31
|
+
if (!r || !d.current || typeof ResizeObserver > "u")
|
|
30
32
|
return;
|
|
31
33
|
const n = new ResizeObserver(u);
|
|
32
|
-
return n.observe(
|
|
33
|
-
}, [
|
|
34
|
-
const o = typeof e == "number" ? e :
|
|
35
|
-
() =>
|
|
36
|
-
[
|
|
37
|
-
),
|
|
38
|
-
series:
|
|
34
|
+
return n.observe(d.current), () => n.disconnect();
|
|
35
|
+
}, [r, u]);
|
|
36
|
+
const o = typeof e == "number" ? e : W ?? 0, m = o > 0 ? o + s.left + s.right : 0, h = l + s.top + s.bottom, w = b(() => T(c), [c]), I = b(
|
|
37
|
+
() => V(f),
|
|
38
|
+
[f]
|
|
39
|
+
), p = B({
|
|
40
|
+
series: a,
|
|
39
41
|
xAxis: C,
|
|
40
|
-
yAxis:
|
|
41
|
-
width:
|
|
42
|
-
height:
|
|
43
|
-
inset:
|
|
44
|
-
axisPadding:
|
|
42
|
+
yAxis: y,
|
|
43
|
+
width: m,
|
|
44
|
+
height: h,
|
|
45
|
+
inset: w,
|
|
46
|
+
axisPadding: I
|
|
45
47
|
});
|
|
46
|
-
return /* @__PURE__ */
|
|
48
|
+
return /* @__PURE__ */ t(
|
|
47
49
|
"div",
|
|
48
50
|
{
|
|
49
|
-
ref:
|
|
51
|
+
ref: r ? d : void 0,
|
|
50
52
|
"data-testid": "chart-container",
|
|
51
53
|
style: {
|
|
52
|
-
width:
|
|
53
|
-
height:
|
|
54
|
-
|
|
54
|
+
width: r ? e : o,
|
|
55
|
+
height: l,
|
|
56
|
+
overflow: "visible"
|
|
55
57
|
},
|
|
56
|
-
children: o > 0 && /* @__PURE__ */
|
|
58
|
+
children: o > 0 && /* @__PURE__ */ t(
|
|
57
59
|
"svg",
|
|
58
60
|
{
|
|
59
|
-
ref:
|
|
61
|
+
ref: v,
|
|
60
62
|
"data-testid": "chart-svg",
|
|
61
|
-
width:
|
|
62
|
-
height:
|
|
63
|
+
width: m,
|
|
64
|
+
height: h,
|
|
63
65
|
role: "img",
|
|
64
|
-
"aria-label":
|
|
66
|
+
"aria-label": x || "Chart",
|
|
65
67
|
tabIndex: i ? 0 : void 0,
|
|
66
68
|
style: {
|
|
67
69
|
display: "block",
|
|
68
70
|
overflow: "visible",
|
|
69
|
-
outline: i ? "none" : void 0
|
|
71
|
+
outline: i ? "none" : void 0,
|
|
72
|
+
...k
|
|
70
73
|
},
|
|
71
|
-
children: /* @__PURE__ */
|
|
72
|
-
|
|
74
|
+
children: /* @__PURE__ */ t(D, { value: p, children: /* @__PURE__ */ t(U, { children: /* @__PURE__ */ t(
|
|
75
|
+
L,
|
|
73
76
|
{
|
|
74
|
-
svgRef:
|
|
77
|
+
svgRef: v,
|
|
75
78
|
enableScrubbing: i,
|
|
76
|
-
onScrubberPositionChange:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
onScrubberPositionChange: E,
|
|
80
|
+
magnetRadius: O,
|
|
81
|
+
children: /* @__PURE__ */ t(
|
|
82
|
+
j,
|
|
79
83
|
{
|
|
80
|
-
drawingArea:
|
|
81
|
-
series:
|
|
82
|
-
animate:
|
|
83
|
-
children:
|
|
84
|
+
drawingArea: p.drawingArea,
|
|
85
|
+
series: a,
|
|
86
|
+
animate: F,
|
|
87
|
+
children: P
|
|
84
88
|
}
|
|
85
89
|
)
|
|
86
90
|
}
|
|
87
|
-
) })
|
|
91
|
+
) }) })
|
|
88
92
|
}
|
|
89
93
|
)
|
|
90
94
|
}
|
|
91
95
|
);
|
|
92
96
|
}
|
|
93
97
|
export {
|
|
94
|
-
|
|
98
|
+
Y as CartesianChart
|
|
95
99
|
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CartesianChartContextValue, ChartInset, ChartScaleFunction, DrawingArea, Series } from '../../../utils/types';
|
|
2
|
+
import { AxisBounds, BaseAxisProps } from '../../Axis';
|
|
3
|
+
import { XAxisProps } from '../../Axis/XAxis';
|
|
4
|
+
import { YAxisProps } from '../../Axis/YAxis';
|
|
2
5
|
type UseBuildChartContextParams = {
|
|
3
6
|
series: Series[];
|
|
4
|
-
xAxis?:
|
|
5
|
-
yAxis?:
|
|
7
|
+
xAxis?: XAxisProps;
|
|
8
|
+
yAxis?: YAxisProps;
|
|
6
9
|
width: number;
|
|
7
10
|
height: number;
|
|
8
11
|
inset: ChartInset;
|
|
@@ -16,7 +19,7 @@ export declare const computeAxisRange: (drawingArea: DrawingArea) => {
|
|
|
16
19
|
xRange: AxisRange;
|
|
17
20
|
yRange: AxisRange;
|
|
18
21
|
};
|
|
19
|
-
export declare const buildScale: (domain: AxisBounds, range: AxisRange, scaleType?:
|
|
22
|
+
export declare const buildScale: (domain: AxisBounds, range: AxisRange, scaleType?: BaseAxisProps["scaleType"], nice?: boolean) => ChartScaleFunction;
|
|
20
23
|
export declare const computeDrawingArea: (width: number, height: number, inset: ChartInset, axisPadding: ChartInset) => DrawingArea;
|
|
21
24
|
export declare const useBuildChartContext: ({ series, xAxis, yAxis, width, height, inset, axisPadding, }: UseBuildChartContextParams) => CartesianChartContextValue;
|
|
22
25
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBuildChartContext.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/CartesianChart/context/useBuildChartContext.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"useBuildChartContext.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/CartesianChart/context/useBuildChartContext.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,0BAA0B,EAC1B,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,MAAM,EACP,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,UAAU,CAAC;IAClB,WAAW,EAAE,UAAU,CAAC;CACzB,CAAC;AAEF,KAAK,SAAS,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9C,eAAO,MAAM,gBAAgB,GAC3B,aAAa,WAAW,KACvB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAMvC,CAAC;AAEH,eAAO,MAAM,UAAU,GACrB,QAAQ,UAAU,EAClB,OAAO,SAAS,EAChB,YAAW,aAAa,CAAC,WAAW,CAAY,EAChD,OAAO,OAAO,KACb,kBAGsD,CAAC;AAE1D,eAAO,MAAM,kBAAkB,GAC7B,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,OAAO,UAAU,EACjB,aAAa,UAAU,KACtB,WAaF,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,8DAQlC,0BAA0B,KAAG,0BAiC/B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo as u } from "react";
|
|
2
|
-
import { computeXDomain as
|
|
2
|
+
import { computeXDomain as y, computeYDomain as C, computeDataLength as M } from "../../../utils/domain/domain.js";
|
|
3
3
|
import { getCategoricalScale as R, getNumericScale as _, isBandScaleType as X } from "../../../utils/scales/scales.js";
|
|
4
4
|
const Y = (t) => ({
|
|
5
5
|
xRange: { min: t.x, max: t.x + t.width },
|
|
@@ -7,55 +7,55 @@ const Y = (t) => ({
|
|
|
7
7
|
min: t.y + t.height,
|
|
8
8
|
max: t.y
|
|
9
9
|
}
|
|
10
|
-
}), f = (t, e, o = "linear") => X(o) ? R({ domain: t, range: e }) : _({ scaleType: o, domain: t, range: e }), B = (t, e, o,
|
|
11
|
-
const
|
|
12
|
-
top: o.top +
|
|
13
|
-
right: o.right +
|
|
14
|
-
bottom: o.bottom +
|
|
15
|
-
left: o.left +
|
|
10
|
+
}), f = (t, e, o = "linear", c) => X(o) ? R({ domain: t, range: e }) : _({ scaleType: o, domain: t, range: e, nice: c }), B = (t, e, o, c) => {
|
|
11
|
+
const m = {
|
|
12
|
+
top: o.top + c.top,
|
|
13
|
+
right: o.right + c.right,
|
|
14
|
+
bottom: o.bottom + c.bottom,
|
|
15
|
+
left: o.left + c.left
|
|
16
16
|
};
|
|
17
17
|
return {
|
|
18
|
-
x:
|
|
19
|
-
y:
|
|
20
|
-
width: Math.max(0, t -
|
|
21
|
-
height: Math.max(0, e -
|
|
18
|
+
x: m.left,
|
|
19
|
+
y: m.top,
|
|
20
|
+
width: Math.max(0, t - m.left - m.right),
|
|
21
|
+
height: Math.max(0, e - m.top - m.bottom)
|
|
22
22
|
};
|
|
23
|
-
},
|
|
23
|
+
}, N = ({
|
|
24
24
|
series: t,
|
|
25
25
|
xAxis: e,
|
|
26
26
|
yAxis: o,
|
|
27
|
-
width:
|
|
28
|
-
height:
|
|
29
|
-
inset:
|
|
27
|
+
width: c,
|
|
28
|
+
height: m,
|
|
29
|
+
inset: l,
|
|
30
30
|
axisPadding: p
|
|
31
31
|
}) => {
|
|
32
|
-
const
|
|
33
|
-
() => B(
|
|
34
|
-
[
|
|
32
|
+
const a = u(
|
|
33
|
+
() => B(c, m, l, p),
|
|
34
|
+
[c, m, l, p]
|
|
35
35
|
);
|
|
36
36
|
return u(() => {
|
|
37
|
-
const { xRange: r, yRange: S } = Y(
|
|
37
|
+
const { xRange: r, yRange: S } = Y(a);
|
|
38
38
|
let h, g;
|
|
39
|
-
if (
|
|
40
|
-
const
|
|
41
|
-
h = f(
|
|
39
|
+
if (a.width > 0 && a.height > 0) {
|
|
40
|
+
const n = y(t, e), b = C(t, o);
|
|
41
|
+
h = f(n, r, e?.scaleType, e?.nice), g = f(b, S, o?.scaleType, o?.nice);
|
|
42
42
|
}
|
|
43
|
-
const i = M(t, e),
|
|
43
|
+
const i = M(t, e), D = new Map(t.map((n) => [n.id, n]));
|
|
44
44
|
return {
|
|
45
45
|
series: t,
|
|
46
|
-
seriesMap:
|
|
47
|
-
getXScale: (
|
|
48
|
-
getYScale: (
|
|
49
|
-
getXAxisConfig: (
|
|
50
|
-
getYAxisConfig: (
|
|
51
|
-
drawingArea:
|
|
46
|
+
seriesMap: D,
|
|
47
|
+
getXScale: (n) => h,
|
|
48
|
+
getYScale: (n) => g,
|
|
49
|
+
getXAxisConfig: (n) => e,
|
|
50
|
+
getYAxisConfig: (n) => o,
|
|
51
|
+
drawingArea: a,
|
|
52
52
|
dataLength: i
|
|
53
53
|
};
|
|
54
|
-
}, [t, e, o,
|
|
54
|
+
}, [t, e, o, a]);
|
|
55
55
|
};
|
|
56
56
|
export {
|
|
57
57
|
f as buildScale,
|
|
58
58
|
Y as computeAxisRange,
|
|
59
59
|
B as computeDrawingArea,
|
|
60
|
-
|
|
60
|
+
N as useBuildChartContext
|
|
61
61
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ChartInset, Series } from '../../utils/types';
|
|
3
|
+
import { BaseAxisProps } from '../Axis';
|
|
3
4
|
export type CartesianChartProps = {
|
|
4
5
|
/**
|
|
5
6
|
* Data series provided to child components via context.
|
|
@@ -8,11 +9,11 @@ export type CartesianChartProps = {
|
|
|
8
9
|
/**
|
|
9
10
|
* Scale and domain configuration for the x-axis.
|
|
10
11
|
*/
|
|
11
|
-
xAxis?: Partial<
|
|
12
|
+
xAxis?: Partial<BaseAxisProps>;
|
|
12
13
|
/**
|
|
13
14
|
* Scale and domain configuration for the y-axis.
|
|
14
15
|
*/
|
|
15
|
-
yAxis?: Partial<
|
|
16
|
+
yAxis?: Partial<BaseAxisProps>;
|
|
16
17
|
/**
|
|
17
18
|
* Width of the chart.
|
|
18
19
|
* A number is treated as pixels; a string (e.g. `'100%'`) fills the container
|
|
@@ -63,5 +64,12 @@ export type CartesianChartProps = {
|
|
|
63
64
|
* @default true
|
|
64
65
|
*/
|
|
65
66
|
animate?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Pixel radius within which the scrubber magnetically snaps to registered
|
|
69
|
+
* magnetic `<Point>` components. Requires `enableScrubbing` to be `true`.
|
|
70
|
+
* Set to `0` to disable magnetization.
|
|
71
|
+
* @default 8
|
|
72
|
+
*/
|
|
73
|
+
magnetRadius?: number;
|
|
66
74
|
};
|
|
67
75
|
//# sourceMappingURL=types.d.ts.map
|