@ledgerhq/lumen-ui-react-visualization 0.1.3 → 0.1.5
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/index.js +5 -2
- package/dist/lib/Components/Axis/Axis.types.d.ts +33 -0
- package/dist/lib/Components/Axis/Axis.types.d.ts.map +1 -0
- package/dist/lib/Components/Axis/XAxis/XAxis.d.ts +4 -0
- package/dist/lib/Components/Axis/XAxis/XAxis.d.ts.map +1 -0
- package/dist/lib/Components/Axis/XAxis/XAxis.js +83 -0
- package/dist/lib/Components/Axis/XAxis/index.d.ts.map +1 -0
- package/dist/lib/Components/Axis/XAxis/types.d.ts +9 -0
- package/dist/lib/Components/Axis/XAxis/types.d.ts.map +1 -0
- package/dist/lib/Components/Axis/YAxis/YAxis.d.ts +4 -0
- package/dist/lib/Components/Axis/YAxis/YAxis.d.ts.map +1 -0
- package/dist/lib/Components/Axis/YAxis/YAxis.js +83 -0
- package/dist/lib/Components/Axis/YAxis/index.d.ts.map +1 -0
- package/dist/lib/Components/Axis/YAxis/types.d.ts +14 -0
- package/dist/lib/Components/Axis/YAxis/types.d.ts.map +1 -0
- package/dist/lib/Components/CartesianChart/CartesianChart.d.ts.map +1 -1
- package/dist/lib/Components/CartesianChart/CartesianChart.js +60 -51
- package/dist/lib/Components/CartesianChart/types.d.ts +4 -2
- package/dist/lib/Components/CartesianChart/types.d.ts.map +1 -1
- package/dist/lib/Components/CartesianChart/utils.d.ts +19 -0
- package/dist/lib/Components/CartesianChart/utils.d.ts.map +1 -0
- package/dist/lib/Components/CartesianChart/utils.js +42 -0
- package/dist/lib/Components/Line/Line.d.ts.map +1 -1
- package/dist/lib/Components/Line/Line.js +52 -31
- package/dist/lib/Components/Line/utils.d.ts +1 -1
- package/dist/lib/Components/Line/utils.d.ts.map +1 -1
- package/dist/lib/Components/LineChart/LineChart.d.ts.map +1 -1
- package/dist/lib/Components/LineChart/LineChart.js +32 -31
- package/dist/lib/Components/LineChart/types.d.ts +5 -3
- package/dist/lib/Components/LineChart/types.d.ts.map +1 -1
- package/dist/lib/Components/Point/Point.d.ts +4 -0
- package/dist/lib/Components/Point/Point.d.ts.map +1 -0
- package/dist/lib/Components/Point/Point.js +85 -0
- package/dist/lib/Components/Point/index.d.ts +3 -0
- package/dist/lib/Components/Point/index.d.ts.map +1 -0
- package/dist/lib/Components/Point/types.d.ts +71 -0
- package/dist/lib/Components/Point/types.d.ts.map +1 -0
- package/dist/lib/Components/Point/utils.d.ts +24 -0
- package/dist/lib/Components/Point/utils.d.ts.map +1 -0
- package/dist/lib/Components/Point/utils.js +26 -0
- package/dist/lib/Components/index.d.ts +1 -0
- package/dist/lib/Components/index.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 +12 -0
- package/dist/lib/utils/scales/scales.d.ts.map +1 -1
- package/dist/lib/utils/scales/scales.js +17 -13
- package/dist/lib/utils/ticks/ticks.d.ts +11 -1
- package/dist/lib/utils/ticks/ticks.d.ts.map +1 -1
- package/dist/lib/utils/ticks/ticks.js +19 -17
- package/dist/lib/utils/types.d.ts +4 -43
- package/dist/lib/utils/types.d.ts.map +1 -1
- package/dist/libs/design-core/dist/lib/cssVar/cssVar.js +4 -0
- package/dist/package.json +3 -3
- package/package.json +2 -2
- package/dist/lib/Components/XAxis/XAxis.d.ts +0 -4
- package/dist/lib/Components/XAxis/XAxis.d.ts.map +0 -1
- package/dist/lib/Components/XAxis/XAxis.js +0 -79
- package/dist/lib/Components/XAxis/index.d.ts.map +0 -1
- package/dist/lib/Components/XAxis/types.d.ts +0 -3
- package/dist/lib/Components/XAxis/types.d.ts.map +0 -1
- package/dist/lib/Components/YAxis/YAxis.d.ts +0 -4
- package/dist/lib/Components/YAxis/YAxis.d.ts.map +0 -1
- package/dist/lib/Components/YAxis/YAxis.js +0 -79
- package/dist/lib/Components/YAxis/index.d.ts.map +0 -1
- package/dist/lib/Components/YAxis/types.d.ts +0 -3
- package/dist/lib/Components/YAxis/types.d.ts.map +0 -1
- /package/dist/lib/Components/{XAxis → Axis/XAxis}/index.d.ts +0 -0
- /package/dist/lib/Components/{YAxis → Axis/YAxis}/index.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { LineChart as
|
|
1
|
+
import { LineChart as t } from "./lib/Components/LineChart/LineChart.js";
|
|
2
|
+
import { Point as i, PointLabel as n } from "./lib/Components/Point/Point.js";
|
|
2
3
|
export {
|
|
3
|
-
|
|
4
|
+
t as LineChart,
|
|
5
|
+
i as Point,
|
|
6
|
+
n as PointLabel
|
|
4
7
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type BaseAxisProps = {
|
|
2
|
+
/**
|
|
3
|
+
* Whether to render grid lines at each tick.
|
|
4
|
+
* @default false
|
|
5
|
+
*/
|
|
6
|
+
showGrid?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Appearance of the grid lines.
|
|
9
|
+
* @default 'dashed'
|
|
10
|
+
*/
|
|
11
|
+
gridLineStyle?: 'solid' | 'dashed';
|
|
12
|
+
/**
|
|
13
|
+
* Whether to render the axis baseline.
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
showLine?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to render tick marks at each tick position.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
showTickMark?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Explicit tick positions along the axis.
|
|
24
|
+
* When omitted, ticks are computed automatically from the scale.
|
|
25
|
+
*/
|
|
26
|
+
ticks?: number[];
|
|
27
|
+
/**
|
|
28
|
+
* Formats a tick value into its display label.
|
|
29
|
+
* Receives the raw tick value (number or string label) and must return a string.
|
|
30
|
+
*/
|
|
31
|
+
tickLabelFormatter?: (value: number | string) => string;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=Axis.types.d.ts.map
|
|
@@ -0,0 +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;CACzD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { XAxisProps } from './types';
|
|
2
|
+
export declare const DEFAULT_AXIS_HEIGHT = 28;
|
|
3
|
+
export declare function XAxis({ gridLineStyle, position, showGrid, showLine, showTickMark, ticks: ticksProp, tickLabelFormatter, }: XAxisProps): import("react/jsx-runtime").JSX.Element | null;
|
|
4
|
+
//# sourceMappingURL=XAxis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XAxis.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/XAxis/XAxis.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI1C,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,wBAAgB,KAAK,CAAC,EACpB,aAAwB,EACxB,QAAmB,EACnB,QAAgB,EAChB,QAAgB,EAChB,YAAoB,EACpB,KAAK,EAAE,SAAS,EAChB,kBAAkB,GACnB,EAAE,UAAU,kDAqFZ"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsxs as k, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as T } from "react";
|
|
3
|
+
import { buildTicksData as C, isTickOnXAxisDomainEdge as E } from "../../../utils/ticks/ticks.js";
|
|
4
|
+
import { useCartesianChartContext as D } from "../../CartesianChart/context/cartesianChartContext.js";
|
|
5
|
+
import { cssVar as o } from "../../../../libs/design-core/dist/lib/cssVar/cssVar.js";
|
|
6
|
+
const c = 4, S = 6, F = 28;
|
|
7
|
+
function K({
|
|
8
|
+
gridLineStyle: h = "dashed",
|
|
9
|
+
position: l = "bottom",
|
|
10
|
+
showGrid: p = !1,
|
|
11
|
+
showLine: u = !1,
|
|
12
|
+
showTickMark: g = !1,
|
|
13
|
+
ticks: d,
|
|
14
|
+
tickLabelFormatter: x
|
|
15
|
+
}) {
|
|
16
|
+
const { getXScale: v, getXAxisConfig: A, drawingArea: e } = D(), r = v(), m = A(), n = T(
|
|
17
|
+
() => r ? C(r, m, d, x) : [],
|
|
18
|
+
[r, m, d, x]
|
|
19
|
+
);
|
|
20
|
+
if (!r || e.width <= 0)
|
|
21
|
+
return null;
|
|
22
|
+
const f = l === "top", s = f ? e.y : e.y + e.height, y = f ? -1 : 1, b = s + y * (c + S);
|
|
23
|
+
return /* @__PURE__ */ k("g", { "data-testid": "x-axis", children: [
|
|
24
|
+
p && n.filter((t) => E(t, e)).map((t, i) => /* @__PURE__ */ a(
|
|
25
|
+
"line",
|
|
26
|
+
{
|
|
27
|
+
x1: t.position,
|
|
28
|
+
y1: e.y,
|
|
29
|
+
x2: t.position,
|
|
30
|
+
y2: e.y + e.height,
|
|
31
|
+
style: { stroke: o("var(--border-muted-subtle)") },
|
|
32
|
+
strokeWidth: o("var(--stroke-1)"),
|
|
33
|
+
strokeDasharray: h === "dashed" ? "3 3" : void 0
|
|
34
|
+
},
|
|
35
|
+
`grid-${t.value}-${i}`
|
|
36
|
+
)),
|
|
37
|
+
u && /* @__PURE__ */ a(
|
|
38
|
+
"line",
|
|
39
|
+
{
|
|
40
|
+
x1: e.x,
|
|
41
|
+
y1: s,
|
|
42
|
+
x2: e.x + e.width,
|
|
43
|
+
y2: s,
|
|
44
|
+
style: { stroke: o("var(--border-muted)") },
|
|
45
|
+
strokeWidth: o("var(--stroke-1)"),
|
|
46
|
+
shapeRendering: "crispEdges",
|
|
47
|
+
strokeLinecap: "square"
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
g && n.map((t, i) => /* @__PURE__ */ a(
|
|
51
|
+
"line",
|
|
52
|
+
{
|
|
53
|
+
x1: t.position,
|
|
54
|
+
y1: s,
|
|
55
|
+
x2: t.position,
|
|
56
|
+
y2: s + y * c,
|
|
57
|
+
style: { stroke: o("var(--border-muted)") },
|
|
58
|
+
strokeWidth: o("var(--stroke-1)")
|
|
59
|
+
},
|
|
60
|
+
`tick-${t.value}-${i}`
|
|
61
|
+
)),
|
|
62
|
+
n.map((t, i) => /* @__PURE__ */ a(
|
|
63
|
+
"text",
|
|
64
|
+
{
|
|
65
|
+
x: t.position,
|
|
66
|
+
y: b,
|
|
67
|
+
textAnchor: "middle",
|
|
68
|
+
dominantBaseline: l === "top" ? "auto" : "hanging",
|
|
69
|
+
style: {
|
|
70
|
+
fill: o("var(--text-muted)"),
|
|
71
|
+
fontSize: o("var(--font-style-body-4-size)"),
|
|
72
|
+
fontFamily: o("var(--font-family-font)")
|
|
73
|
+
},
|
|
74
|
+
children: t.label
|
|
75
|
+
},
|
|
76
|
+
`label-${t.value}-${i}`
|
|
77
|
+
))
|
|
78
|
+
] });
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
F as DEFAULT_AXIS_HEIGHT,
|
|
82
|
+
K as XAxis
|
|
83
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/XAxis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACrD,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/XAxis/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG;IACvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;CAC7B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { YAxisProps } from './types';
|
|
2
|
+
export declare const DEFAULT_AXIS_WIDTH = 40;
|
|
3
|
+
export declare function YAxis({ gridLineStyle, position, showGrid, showLine, showTickMark, ticks: ticksProp, tickLabelFormatter, }: YAxisProps): import("react/jsx-runtime").JSX.Element | null;
|
|
4
|
+
//# sourceMappingURL=YAxis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YAxis.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/YAxis/YAxis.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI1C,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,wBAAgB,KAAK,CAAC,EACpB,aAAwB,EACxB,QAAkB,EAClB,QAAgB,EAChB,QAAgB,EAChB,YAAoB,EACpB,KAAK,EAAE,SAAS,EAChB,kBAAkB,GACnB,EAAE,UAAU,kDAqFZ"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsxs as b, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as C } from "react";
|
|
3
|
+
import { buildTicksData as D, isTickOnYAxisDomainEdge as S } from "../../../utils/ticks/ticks.js";
|
|
4
|
+
import { useCartesianChartContext as T } from "../../CartesianChart/context/cartesianChartContext.js";
|
|
5
|
+
import { cssVar as s } from "../../../../libs/design-core/dist/lib/cssVar/cssVar.js";
|
|
6
|
+
const f = 4, E = 6, w = 40;
|
|
7
|
+
function F({
|
|
8
|
+
gridLineStyle: h = "dashed",
|
|
9
|
+
position: l = "start",
|
|
10
|
+
showGrid: u = !1,
|
|
11
|
+
showLine: p = !1,
|
|
12
|
+
showTickMark: v = !1,
|
|
13
|
+
ticks: d,
|
|
14
|
+
tickLabelFormatter: x
|
|
15
|
+
}) {
|
|
16
|
+
const { getYScale: g, getYAxisConfig: A, drawingArea: e } = T(), i = g(), m = A(), n = C(
|
|
17
|
+
() => i ? D(i, m, d, x) : [],
|
|
18
|
+
[i, m, d, x]
|
|
19
|
+
);
|
|
20
|
+
if (!i || e.height <= 0)
|
|
21
|
+
return null;
|
|
22
|
+
const y = l === "start", r = y ? e.x : e.x + e.width, c = y ? -1 : 1, k = r + c * (f + E);
|
|
23
|
+
return /* @__PURE__ */ b("g", { "data-testid": "y-axis", children: [
|
|
24
|
+
u && n.filter((t) => S(t, e)).map((t, o) => /* @__PURE__ */ a(
|
|
25
|
+
"line",
|
|
26
|
+
{
|
|
27
|
+
x1: e.x,
|
|
28
|
+
y1: t.position,
|
|
29
|
+
x2: e.x + e.width,
|
|
30
|
+
y2: t.position,
|
|
31
|
+
style: { stroke: s("var(--border-muted-subtle)") },
|
|
32
|
+
strokeWidth: s("var(--stroke-1)"),
|
|
33
|
+
strokeDasharray: h === "dashed" ? "3 3" : void 0
|
|
34
|
+
},
|
|
35
|
+
`grid-${t.value}-${o}`
|
|
36
|
+
)),
|
|
37
|
+
p && /* @__PURE__ */ a(
|
|
38
|
+
"line",
|
|
39
|
+
{
|
|
40
|
+
x1: r,
|
|
41
|
+
y1: e.y,
|
|
42
|
+
x2: r,
|
|
43
|
+
y2: e.y + e.height,
|
|
44
|
+
style: { stroke: s("var(--border-muted)") },
|
|
45
|
+
strokeWidth: s("var(--stroke-1)"),
|
|
46
|
+
shapeRendering: "crispEdges",
|
|
47
|
+
strokeLinecap: "square"
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
v && n.map((t, o) => /* @__PURE__ */ a(
|
|
51
|
+
"line",
|
|
52
|
+
{
|
|
53
|
+
x1: r,
|
|
54
|
+
y1: t.position,
|
|
55
|
+
x2: r + c * f,
|
|
56
|
+
y2: t.position,
|
|
57
|
+
style: { stroke: s("var(--border-muted)") },
|
|
58
|
+
strokeWidth: s("var(--stroke-1)")
|
|
59
|
+
},
|
|
60
|
+
`tick-${t.value}-${o}`
|
|
61
|
+
)),
|
|
62
|
+
n.map((t, o) => /* @__PURE__ */ a(
|
|
63
|
+
"text",
|
|
64
|
+
{
|
|
65
|
+
x: k,
|
|
66
|
+
y: t.position,
|
|
67
|
+
textAnchor: l === "start" ? "end" : "start",
|
|
68
|
+
dominantBaseline: "central",
|
|
69
|
+
style: {
|
|
70
|
+
fill: s("var(--text-muted)"),
|
|
71
|
+
fontSize: s("var(--font-style-body-4-size)"),
|
|
72
|
+
fontFamily: s("var(--font-family-font)")
|
|
73
|
+
},
|
|
74
|
+
children: t.label
|
|
75
|
+
},
|
|
76
|
+
`label-${t.value}-${o}`
|
|
77
|
+
))
|
|
78
|
+
] });
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
w as DEFAULT_AXIS_WIDTH,
|
|
82
|
+
F as YAxis
|
|
83
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/YAxis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACpD,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseAxisProps } from '../Axis.types';
|
|
2
|
+
export type YAxisProps = BaseAxisProps & {
|
|
3
|
+
/**
|
|
4
|
+
* Where the y-axis is rendered relative to the drawing area.
|
|
5
|
+
* @default 'start'
|
|
6
|
+
*/
|
|
7
|
+
position?: 'start' | 'end';
|
|
8
|
+
/**
|
|
9
|
+
* Width of the axis in pixels.
|
|
10
|
+
* @default 40
|
|
11
|
+
*/
|
|
12
|
+
width?: number;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/YAxis/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG;IACvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC3B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -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":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAQnD,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,KAAK,EACL,KAAK,EACL,KAAc,EACd,MAAuB,EACvB,KAAK,EACL,WAAW,EACX,SAAmB,EACnB,QAAQ,GACT,EAAE,mBAAmB,2CA2FrB"}
|
|
@@ -1,69 +1,78 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
top: 8,
|
|
7
|
-
right: 0,
|
|
8
|
-
bottom: 0,
|
|
9
|
-
left: 0
|
|
10
|
-
}, O = { top: 0, right: 0, bottom: 0, left: 0 }, W = (t) => t === void 0 ? o : typeof t == "number" ? { top: t, right: t, bottom: t, left: t } : {
|
|
11
|
-
top: t.top ?? o.top,
|
|
12
|
-
right: t.right ?? o.right,
|
|
13
|
-
bottom: t.bottom ?? o.bottom,
|
|
14
|
-
left: t.left ?? o.left
|
|
15
|
-
}, _ = (t) => t === void 0 ? O : {
|
|
16
|
-
top: t.top ?? 0,
|
|
17
|
-
right: t.right ?? 0,
|
|
18
|
-
bottom: t.bottom ?? 0,
|
|
19
|
-
left: t.left ?? 0
|
|
20
|
-
};
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as I, useState as M, useCallback as O, useEffect as W, useMemo as v } from "react";
|
|
3
|
+
import { resolveInset as g, resolveAxisPadding as z, OVERFLOW_NEGATIVE_MARGIN as m, DEFAULT_HEIGHT as G } from "./utils.js";
|
|
4
|
+
import { useBuildChartContext as P } from "./context/useBuildChartContext.js";
|
|
5
|
+
import { CartesianChartProvider as T } from "./context/cartesianChartContext.js";
|
|
21
6
|
function L({
|
|
22
|
-
series:
|
|
7
|
+
series: b,
|
|
23
8
|
xAxis: p,
|
|
24
|
-
yAxis:
|
|
9
|
+
yAxis: C,
|
|
25
10
|
width: e = "100%",
|
|
26
|
-
height:
|
|
27
|
-
inset:
|
|
28
|
-
axisPadding:
|
|
29
|
-
ariaLabel:
|
|
30
|
-
children:
|
|
11
|
+
height: t = G,
|
|
12
|
+
inset: a,
|
|
13
|
+
axisPadding: d,
|
|
14
|
+
ariaLabel: y = "Chart",
|
|
15
|
+
children: h
|
|
31
16
|
}) {
|
|
32
|
-
const s =
|
|
17
|
+
const s = I(null), [c, R] = M(
|
|
33
18
|
typeof e == "number" ? e : void 0
|
|
34
|
-
),
|
|
35
|
-
const [
|
|
36
|
-
|
|
19
|
+
), o = typeof e != "number", l = O((r) => {
|
|
20
|
+
const [f] = r;
|
|
21
|
+
f && R(f.contentRect.width);
|
|
37
22
|
}, []);
|
|
38
|
-
|
|
39
|
-
if (!
|
|
23
|
+
W(() => {
|
|
24
|
+
if (!o || !s.current || typeof ResizeObserver > "u")
|
|
40
25
|
return;
|
|
41
|
-
const r = new ResizeObserver(
|
|
26
|
+
const r = new ResizeObserver(l);
|
|
42
27
|
return r.observe(s.current), () => r.disconnect();
|
|
43
|
-
}, [
|
|
44
|
-
const
|
|
45
|
-
() =>
|
|
46
|
-
[
|
|
47
|
-
),
|
|
48
|
-
series:
|
|
28
|
+
}, [o, l]);
|
|
29
|
+
const i = typeof e == "number" ? e : c ?? 0, x = v(() => g(a), [a]), E = v(
|
|
30
|
+
() => z(d),
|
|
31
|
+
[d]
|
|
32
|
+
), A = P({
|
|
33
|
+
series: b,
|
|
49
34
|
xAxis: p,
|
|
50
|
-
yAxis:
|
|
51
|
-
width:
|
|
52
|
-
height:
|
|
53
|
-
inset:
|
|
54
|
-
axisPadding:
|
|
55
|
-
}),
|
|
35
|
+
yAxis: C,
|
|
36
|
+
width: i,
|
|
37
|
+
height: t,
|
|
38
|
+
inset: x,
|
|
39
|
+
axisPadding: E
|
|
40
|
+
}), u = /* @__PURE__ */ n(
|
|
56
41
|
"svg",
|
|
57
42
|
{
|
|
58
|
-
|
|
59
|
-
|
|
43
|
+
"data-testid": "chart-svg",
|
|
44
|
+
width: i,
|
|
45
|
+
height: t,
|
|
60
46
|
role: "img",
|
|
61
|
-
"aria-label":
|
|
47
|
+
"aria-label": y || "Chart",
|
|
62
48
|
style: { display: "block", overflow: "visible" },
|
|
63
|
-
children: /* @__PURE__ */
|
|
49
|
+
children: /* @__PURE__ */ n(T, { value: A, children: h })
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
return o ? /* @__PURE__ */ n(
|
|
53
|
+
"div",
|
|
54
|
+
{
|
|
55
|
+
ref: s,
|
|
56
|
+
"data-testid": "chart-container",
|
|
57
|
+
style: {
|
|
58
|
+
width: e,
|
|
59
|
+
height: t,
|
|
60
|
+
...m
|
|
61
|
+
},
|
|
62
|
+
children: c !== void 0 && u
|
|
63
|
+
}
|
|
64
|
+
) : /* @__PURE__ */ n(
|
|
65
|
+
"div",
|
|
66
|
+
{
|
|
67
|
+
"data-testid": "chart-container",
|
|
68
|
+
style: {
|
|
69
|
+
width: i,
|
|
70
|
+
height: t,
|
|
71
|
+
...m
|
|
72
|
+
},
|
|
73
|
+
children: u
|
|
64
74
|
}
|
|
65
75
|
);
|
|
66
|
-
return l ? /* @__PURE__ */ f("div", { ref: s, style: { width: e, height: n }, children: u !== void 0 && b }) : b;
|
|
67
76
|
}
|
|
68
77
|
export {
|
|
69
78
|
L as CartesianChart
|
|
@@ -26,8 +26,10 @@ export type CartesianChartProps = {
|
|
|
26
26
|
*/
|
|
27
27
|
height?: number;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* Extra padding between the SVG edge and the drawing area, added on top of
|
|
30
|
+
* a built-in overflow buffer that prevents content (labels, points, ticks)
|
|
31
|
+
* from being clipped. A number applies uniformly; a partial object sets
|
|
32
|
+
* individual sides (unset sides default to `0`).
|
|
31
33
|
*/
|
|
32
34
|
inset?: number | Partial<ChartInset>;
|
|
33
35
|
/**
|
|
@@ -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,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE7E,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACjC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACjC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB
|
|
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,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE7E,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACjC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACjC;;;;;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;CACtB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ChartInset } from '../../utils/types';
|
|
2
|
+
import { CartesianChartProps } from './types';
|
|
3
|
+
export declare const DEFAULT_HEIGHT = 160;
|
|
4
|
+
/**
|
|
5
|
+
* Internal buffer that prevents SVG content (labels, points, ticks) from being
|
|
6
|
+
* clipped at the edge of the container. Compensated by negative margins on the
|
|
7
|
+
* wrapper so the chart's visual footprint stays unchanged.
|
|
8
|
+
*/
|
|
9
|
+
export declare const OVERFLOW_BUFFER: ChartInset;
|
|
10
|
+
export declare const OVERFLOW_NEGATIVE_MARGIN: {
|
|
11
|
+
marginTop: number;
|
|
12
|
+
marginRight: number;
|
|
13
|
+
marginBottom: number;
|
|
14
|
+
marginLeft: number;
|
|
15
|
+
};
|
|
16
|
+
export declare const ZERO_PADDING: ChartInset;
|
|
17
|
+
export declare const resolveInset: (inset: CartesianChartProps["inset"]) => ChartInset;
|
|
18
|
+
export declare const resolveAxisPadding: (padding: CartesianChartProps["axisPadding"]) => ChartInset;
|
|
19
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +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;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,UAK7B,CAAC;AACF,eAAO,MAAM,wBAAwB;;;;;CAKpC,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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const m = 160, r = {
|
|
2
|
+
top: 30,
|
|
3
|
+
right: 20,
|
|
4
|
+
bottom: 30,
|
|
5
|
+
left: 20
|
|
6
|
+
}, f = {
|
|
7
|
+
marginTop: -30,
|
|
8
|
+
marginRight: -20,
|
|
9
|
+
marginBottom: -30,
|
|
10
|
+
marginLeft: -20
|
|
11
|
+
}, e = {
|
|
12
|
+
top: 0,
|
|
13
|
+
right: 0,
|
|
14
|
+
bottom: 0,
|
|
15
|
+
left: 0
|
|
16
|
+
}, l = (t) => {
|
|
17
|
+
let o;
|
|
18
|
+
return t === void 0 ? o = e : typeof t == "number" ? o = { top: t, right: t, bottom: t, left: t } : o = {
|
|
19
|
+
top: t.top ?? 0,
|
|
20
|
+
right: t.right ?? 0,
|
|
21
|
+
bottom: t.bottom ?? 0,
|
|
22
|
+
left: t.left ?? 0
|
|
23
|
+
}, {
|
|
24
|
+
top: o.top + r.top,
|
|
25
|
+
right: o.right + r.right,
|
|
26
|
+
bottom: o.bottom + r.bottom,
|
|
27
|
+
left: o.left + r.left
|
|
28
|
+
};
|
|
29
|
+
}, g = (t) => t === void 0 ? e : {
|
|
30
|
+
top: t.top ?? 0,
|
|
31
|
+
right: t.right ?? 0,
|
|
32
|
+
bottom: t.bottom ?? 0,
|
|
33
|
+
left: t.left ?? 0
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
m as DEFAULT_HEIGHT,
|
|
37
|
+
r as OVERFLOW_BUFFER,
|
|
38
|
+
f as OVERFLOW_NEGATIVE_MARGIN,
|
|
39
|
+
e as ZERO_PADDING,
|
|
40
|
+
g as resolveAxisPadding,
|
|
41
|
+
l as resolveInset
|
|
42
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Line/Line.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Line/Line.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC,wBAAgB,IAAI,CAAC,EACnB,QAAQ,EACR,MAAM,EACN,QAAgB,EAChB,QAAQ,EAAE,SAAsB,GACjC,EAAE,SAAS,kDA6EX"}
|
|
@@ -1,47 +1,68 @@
|
|
|
1
1
|
import { jsxs as l, Fragment as m, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { useId as
|
|
2
|
+
import { useId as S, useMemo as d } from "react";
|
|
3
3
|
import { isNumericScale as A } from "../../utils/scales/scales.js";
|
|
4
|
-
import { toScaledPoints as P, buildLinePath as
|
|
5
|
-
import { useCartesianChartContext as
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { toScaledPoints as P, buildLinePath as I, buildAreaPath as L } from "./utils.js";
|
|
5
|
+
import { useCartesianChartContext as T } from "../CartesianChart/context/cartesianChartContext.js";
|
|
6
|
+
import { cssVar as j } from "../../../libs/design-core/dist/lib/cssVar/cssVar.js";
|
|
7
|
+
const O = 0.2;
|
|
8
|
+
function N({
|
|
8
9
|
seriesId: g,
|
|
9
10
|
stroke: h,
|
|
10
|
-
showArea:
|
|
11
|
-
areaType:
|
|
11
|
+
showArea: n = !1,
|
|
12
|
+
areaType: _ = "gradient"
|
|
12
13
|
}) {
|
|
13
|
-
const { getXScale: x, getYScale:
|
|
14
|
-
() =>
|
|
15
|
-
[
|
|
16
|
-
), f =
|
|
17
|
-
() => t ?
|
|
14
|
+
const { getXScale: x, getYScale: k, getXAxisConfig: C, drawingArea: i, seriesMap: y } = T(), s = x(), o = k(), c = C(), p = S(), r = y.get(g), a = h ?? r?.stroke, t = d(
|
|
15
|
+
() => r?.data && s && o && A(o) ? P(r.data, s, o, c?.data) : null,
|
|
16
|
+
[r, s, o, c]
|
|
17
|
+
), f = d(
|
|
18
|
+
() => t ? I(t) : null,
|
|
18
19
|
[t]
|
|
19
|
-
), u =
|
|
20
|
-
() =>
|
|
21
|
-
[
|
|
20
|
+
), u = d(
|
|
21
|
+
() => n && t && i ? L(t, i) : null,
|
|
22
|
+
[n, t, i]
|
|
22
23
|
);
|
|
23
24
|
return f ? /* @__PURE__ */ l(m, { children: [
|
|
24
|
-
|
|
25
|
-
/* @__PURE__ */ e("defs", { children: /* @__PURE__ */ l(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
n && u && a && /* @__PURE__ */ l(m, { children: [
|
|
26
|
+
/* @__PURE__ */ e("defs", { children: /* @__PURE__ */ l(
|
|
27
|
+
"linearGradient",
|
|
28
|
+
{
|
|
29
|
+
"data-testid": "line-gradient",
|
|
30
|
+
id: p,
|
|
31
|
+
x1: "0",
|
|
32
|
+
y1: "0",
|
|
33
|
+
x2: "0",
|
|
34
|
+
y2: "1",
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ e(
|
|
37
|
+
"stop",
|
|
38
|
+
{
|
|
39
|
+
offset: "0%",
|
|
40
|
+
stopColor: a,
|
|
41
|
+
stopOpacity: O
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
/* @__PURE__ */ e("stop", { offset: "100%", stopColor: a, stopOpacity: 0 })
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
) }),
|
|
48
|
+
/* @__PURE__ */ e(
|
|
49
|
+
"path",
|
|
50
|
+
{
|
|
51
|
+
"data-testid": "line-area",
|
|
52
|
+
d: u,
|
|
53
|
+
fill: `url(#${p})`,
|
|
54
|
+
stroke: "none"
|
|
55
|
+
}
|
|
56
|
+
)
|
|
37
57
|
] }),
|
|
38
58
|
/* @__PURE__ */ e(
|
|
39
59
|
"path",
|
|
40
60
|
{
|
|
61
|
+
"data-testid": "line-path",
|
|
41
62
|
d: f,
|
|
42
63
|
fill: "none",
|
|
43
|
-
stroke:
|
|
44
|
-
strokeWidth:
|
|
64
|
+
stroke: a,
|
|
65
|
+
strokeWidth: j("var(--stroke-2)"),
|
|
45
66
|
strokeLinecap: "round",
|
|
46
67
|
strokeLinejoin: "round"
|
|
47
68
|
}
|
|
@@ -49,5 +70,5 @@ function M({
|
|
|
49
70
|
] }) : null;
|
|
50
71
|
}
|
|
51
72
|
export {
|
|
52
|
-
|
|
73
|
+
N as Line
|
|
53
74
|
};
|
|
@@ -6,7 +6,7 @@ type Point = [x: number, y: number];
|
|
|
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
8
|
*/
|
|
9
|
-
export declare const toScaledPoints: (data:
|
|
9
|
+
export declare const toScaledPoints: (data: (number | null)[], xScale: ChartScaleFunction, yScale: NumericScale, xData?: readonly (string | number)[]) => Point[] | null;
|
|
10
10
|
/**
|
|
11
11
|
* Build the SVG `d` attribute for the line stroke.
|
|
12
12
|
*/
|
|
@@ -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;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,
|
|
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;;;;;GAKG;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,IAmBZ,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/LineChart/LineChart.tsx"],"names":[],"mappings":"AAQA,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,QAAQ,GACT,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/LineChart/LineChart.tsx"],"names":[],"mappings":"AAQA,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,QAAQ,GACT,EAAE,cAAc,2CAwEhB"}
|