@ledgerhq/lumen-ui-react-visualization 0.1.2 → 0.1.3

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.
Files changed (119) hide show
  1. package/dist/lib/Components/CartesianChart/CartesianChart.d.ts +3 -0
  2. package/dist/lib/Components/CartesianChart/CartesianChart.d.ts.map +1 -0
  3. package/dist/lib/Components/CartesianChart/CartesianChart.js +70 -0
  4. package/dist/lib/Components/CartesianChart/context/cartesianChartContext.d.ts +8 -0
  5. package/dist/lib/Components/CartesianChart/context/cartesianChartContext.d.ts.map +1 -0
  6. package/dist/lib/Components/CartesianChart/context/cartesianChartContext.js +9 -0
  7. package/dist/lib/Components/CartesianChart/context/index.d.ts +3 -0
  8. package/dist/lib/Components/CartesianChart/context/index.d.ts.map +1 -0
  9. package/dist/lib/Components/CartesianChart/context/useBuildChartContext.d.ts +23 -0
  10. package/dist/lib/Components/CartesianChart/context/useBuildChartContext.d.ts.map +1 -0
  11. package/dist/lib/Components/CartesianChart/context/useBuildChartContext.js +61 -0
  12. package/dist/lib/Components/CartesianChart/index.d.ts +4 -0
  13. package/dist/lib/Components/CartesianChart/index.d.ts.map +1 -0
  14. package/dist/lib/Components/CartesianChart/types.d.ts +48 -0
  15. package/dist/lib/Components/CartesianChart/types.d.ts.map +1 -0
  16. package/dist/lib/Components/Line/Line.d.ts +3 -0
  17. package/dist/lib/Components/Line/Line.d.ts.map +1 -0
  18. package/dist/lib/Components/Line/Line.js +53 -0
  19. package/dist/lib/Components/Line/index.d.ts +3 -0
  20. package/dist/lib/Components/Line/index.d.ts.map +1 -0
  21. package/dist/lib/Components/Line/types.d.ts +24 -0
  22. package/dist/lib/Components/Line/types.d.ts.map +1 -0
  23. package/dist/lib/Components/Line/utils.d.ts +19 -0
  24. package/dist/lib/Components/Line/utils.d.ts.map +1 -0
  25. package/dist/lib/Components/Line/utils.js +22 -0
  26. package/dist/lib/Components/LineChart/LineChart.d.ts +2 -8
  27. package/dist/lib/Components/LineChart/LineChart.d.ts.map +1 -1
  28. package/dist/lib/Components/LineChart/LineChart.js +78 -23
  29. package/dist/lib/Components/LineChart/index.d.ts +1 -0
  30. package/dist/lib/Components/LineChart/index.d.ts.map +1 -1
  31. package/dist/lib/Components/LineChart/types.d.ts +61 -0
  32. package/dist/lib/Components/LineChart/types.d.ts.map +1 -0
  33. package/dist/lib/Components/XAxis/XAxis.d.ts +4 -0
  34. package/dist/lib/Components/XAxis/XAxis.d.ts.map +1 -0
  35. package/dist/lib/Components/XAxis/XAxis.js +79 -0
  36. package/dist/lib/Components/XAxis/index.d.ts +3 -0
  37. package/dist/lib/Components/XAxis/index.d.ts.map +1 -0
  38. package/dist/lib/Components/XAxis/types.d.ts +3 -0
  39. package/dist/lib/Components/XAxis/types.d.ts.map +1 -0
  40. package/dist/lib/Components/YAxis/YAxis.d.ts +4 -0
  41. package/dist/lib/Components/YAxis/YAxis.d.ts.map +1 -0
  42. package/dist/lib/Components/YAxis/YAxis.js +79 -0
  43. package/dist/lib/Components/YAxis/index.d.ts +3 -0
  44. package/dist/lib/Components/YAxis/index.d.ts.map +1 -0
  45. package/dist/lib/Components/YAxis/types.d.ts +3 -0
  46. package/dist/lib/Components/YAxis/types.d.ts.map +1 -0
  47. package/dist/lib/utils/domain/domain.d.ts +17 -0
  48. package/dist/lib/utils/domain/domain.d.ts.map +1 -0
  49. package/dist/lib/utils/domain/domain.js +38 -0
  50. package/dist/lib/utils/index.d.ts +1 -1
  51. package/dist/lib/utils/index.d.ts.map +1 -1
  52. package/dist/lib/utils/scales/scales.d.ts +24 -0
  53. package/dist/lib/utils/scales/scales.d.ts.map +1 -0
  54. package/dist/lib/utils/scales/scales.js +25 -0
  55. package/dist/lib/utils/ticks/ticks.d.ts +27 -0
  56. package/dist/lib/utils/ticks/ticks.d.ts.map +1 -0
  57. package/dist/lib/utils/ticks/ticks.js +23 -0
  58. package/dist/lib/utils/types.d.ts +132 -6
  59. package/dist/lib/utils/types.d.ts.map +1 -1
  60. package/dist/libs/utils-shared/dist/index.js +35 -0
  61. package/dist/node_modules/d3-array/src/ascending.js +6 -0
  62. package/dist/node_modules/d3-array/src/bisect.js +9 -0
  63. package/dist/node_modules/d3-array/src/bisector.js +37 -0
  64. package/dist/node_modules/d3-array/src/descending.js +6 -0
  65. package/dist/node_modules/d3-array/src/number.js +6 -0
  66. package/dist/node_modules/d3-array/src/range.js +9 -0
  67. package/dist/node_modules/d3-array/src/ticks.js +32 -0
  68. package/dist/node_modules/d3-color/src/color.js +305 -0
  69. package/dist/node_modules/d3-color/src/define.js +12 -0
  70. package/dist/node_modules/d3-format/src/defaultLocale.js +15 -0
  71. package/dist/node_modules/d3-format/src/exponent.js +7 -0
  72. package/dist/node_modules/d3-format/src/formatDecimal.js +15 -0
  73. package/dist/node_modules/d3-format/src/formatGroup.js +10 -0
  74. package/dist/node_modules/d3-format/src/formatNumerals.js +10 -0
  75. package/dist/node_modules/d3-format/src/formatPrefixAuto.js +12 -0
  76. package/dist/node_modules/d3-format/src/formatRounded.js +10 -0
  77. package/dist/node_modules/d3-format/src/formatSpecifier.js +28 -0
  78. package/dist/node_modules/d3-format/src/formatTrim.js +19 -0
  79. package/dist/node_modules/d3-format/src/formatTypes.js +21 -0
  80. package/dist/node_modules/d3-format/src/identity.js +6 -0
  81. package/dist/node_modules/d3-format/src/locale.js +68 -0
  82. package/dist/node_modules/d3-format/src/precisionFixed.js +7 -0
  83. package/dist/node_modules/d3-format/src/precisionPrefix.js +7 -0
  84. package/dist/node_modules/d3-format/src/precisionRound.js +7 -0
  85. package/dist/node_modules/d3-interpolate/src/array.js +13 -0
  86. package/dist/node_modules/d3-interpolate/src/color.js +24 -0
  87. package/dist/node_modules/d3-interpolate/src/constant.js +4 -0
  88. package/dist/node_modules/d3-interpolate/src/date.js +9 -0
  89. package/dist/node_modules/d3-interpolate/src/number.js +8 -0
  90. package/dist/node_modules/d3-interpolate/src/numberArray.js +15 -0
  91. package/dist/node_modules/d3-interpolate/src/object.js +14 -0
  92. package/dist/node_modules/d3-interpolate/src/rgb.js +15 -0
  93. package/dist/node_modules/d3-interpolate/src/round.js +8 -0
  94. package/dist/node_modules/d3-interpolate/src/string.js +24 -0
  95. package/dist/node_modules/d3-interpolate/src/value.js +16 -0
  96. package/dist/node_modules/d3-path/src/path.js +64 -0
  97. package/dist/node_modules/d3-scale/src/band.js +41 -0
  98. package/dist/node_modules/d3-scale/src/constant.js +8 -0
  99. package/dist/node_modules/d3-scale/src/continuous.js +75 -0
  100. package/dist/node_modules/d3-scale/src/init.js +16 -0
  101. package/dist/node_modules/d3-scale/src/linear.js +39 -0
  102. package/dist/node_modules/d3-scale/src/log.js +86 -0
  103. package/dist/node_modules/d3-scale/src/nice.js +8 -0
  104. package/dist/node_modules/d3-scale/src/number.js +6 -0
  105. package/dist/node_modules/d3-scale/src/ordinal.js +31 -0
  106. package/dist/node_modules/d3-scale/src/tickFormat.js +32 -0
  107. package/dist/node_modules/d3-shape/src/area.js +56 -0
  108. package/dist/node_modules/d3-shape/src/array.js +6 -0
  109. package/dist/node_modules/d3-shape/src/constant.js +8 -0
  110. package/dist/node_modules/d3-shape/src/curve/bump.js +39 -0
  111. package/dist/node_modules/d3-shape/src/curve/linear.js +36 -0
  112. package/dist/node_modules/d3-shape/src/line.js +29 -0
  113. package/dist/node_modules/d3-shape/src/path.js +18 -0
  114. package/dist/node_modules/d3-shape/src/point.js +10 -0
  115. package/dist/node_modules/internmap/src/index.js +35 -0
  116. package/dist/package.json +15 -3
  117. package/package.json +13 -1
  118. package/dist/lib/utils/math/index.d.ts +0 -1
  119. package/dist/lib/utils/math/index.d.ts.map +0 -1
@@ -0,0 +1,3 @@
1
+ import { CartesianChartProps } from './types';
2
+ export declare function CartesianChart({ series, xAxis, yAxis, width, height, inset, axisPadding, ariaLabel, children, }: CartesianChartProps): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=CartesianChart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CartesianChart.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/CartesianChart/CartesianChart.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAoCnD,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,KAAK,EACL,KAAK,EACL,KAAc,EACd,MAAuB,EACvB,KAAK,EACL,WAAW,EACX,SAAmB,EACnB,QAAQ,GACT,EAAE,mBAAmB,2CAuErB"}
@@ -0,0 +1,70 @@
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import { useRef as A, useState as I, useCallback as D, useEffect as P, useMemo as d } from "react";
3
+ import { useBuildChartContext as T } from "./context/useBuildChartContext.js";
4
+ import { CartesianChartProvider as z } from "./context/cartesianChartContext.js";
5
+ const M = 160, o = {
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
+ };
21
+ function L({
22
+ series: t,
23
+ xAxis: p,
24
+ yAxis: h,
25
+ width: e = "100%",
26
+ height: n = M,
27
+ inset: i,
28
+ axisPadding: c,
29
+ ariaLabel: C = "Chart",
30
+ children: y
31
+ }) {
32
+ const s = A(null), [u, g] = I(
33
+ typeof e == "number" ? e : void 0
34
+ ), l = typeof e != "number", m = D((r) => {
35
+ const [v] = r;
36
+ v && g(v.contentRect.width);
37
+ }, []);
38
+ P(() => {
39
+ if (!l || !s.current || typeof ResizeObserver > "u")
40
+ return;
41
+ const r = new ResizeObserver(m);
42
+ return r.observe(s.current), () => r.disconnect();
43
+ }, [l, m]);
44
+ const a = typeof e == "number" ? e : u ?? 0, R = d(() => W(i), [i]), x = d(
45
+ () => _(c),
46
+ [c]
47
+ ), E = T({
48
+ series: t,
49
+ xAxis: p,
50
+ yAxis: h,
51
+ width: a,
52
+ height: n,
53
+ inset: R,
54
+ axisPadding: x
55
+ }), b = /* @__PURE__ */ f(
56
+ "svg",
57
+ {
58
+ width: a,
59
+ height: n,
60
+ role: "img",
61
+ "aria-label": C || "Chart",
62
+ style: { display: "block", overflow: "visible" },
63
+ children: /* @__PURE__ */ f(z, { value: E, children: y })
64
+ }
65
+ );
66
+ return l ? /* @__PURE__ */ f("div", { ref: s, style: { width: e, height: n }, children: u !== void 0 && b }) : b;
67
+ }
68
+ export {
69
+ L as CartesianChart
70
+ };
@@ -0,0 +1,8 @@
1
+ import { CartesianChartContextValue } from '../../../utils/types';
2
+ declare const CartesianChartProvider: import('react').FC<{
3
+ children: import('react').ReactNode;
4
+ value: CartesianChartContextValue;
5
+ }>;
6
+ export declare const useCartesianChartContext: () => CartesianChartContextValue;
7
+ export { CartesianChartProvider };
8
+ //# sourceMappingURL=cartesianChartContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cartesianChartContext.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/CartesianChart/context/cartesianChartContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAEvE,QAAA,MAAO,sBAAsB;;;EACoC,CAAC;AAElE,eAAO,MAAM,wBAAwB,kCAIjC,CAAC;AAEL,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { createSafeContext as t } from "../../../../libs/utils-shared/dist/index.js";
2
+ const [r, e] = t("CartesianChart"), C = () => e({
3
+ consumerName: "useCartesianChartContext",
4
+ contextRequired: !0
5
+ });
6
+ export {
7
+ r as CartesianChartProvider,
8
+ C as useCartesianChartContext
9
+ };
@@ -0,0 +1,3 @@
1
+ export { CartesianChartProvider, useCartesianChartContext, } from './cartesianChartContext';
2
+ export { buildScale, computeAxisRange, computeDrawingArea, useBuildChartContext, } from './useBuildChartContext';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/CartesianChart/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { AxisBounds, AxisConfigProps, CartesianChartContextValue, ChartInset, ChartScaleFunction, DrawingArea, Series } from '../../../utils/types';
2
+ type UseBuildChartContextParams = {
3
+ series: Series[];
4
+ xAxis?: Partial<AxisConfigProps>;
5
+ yAxis?: Partial<AxisConfigProps>;
6
+ width: number;
7
+ height: number;
8
+ inset: ChartInset;
9
+ axisPadding: ChartInset;
10
+ };
11
+ type AxisRange = {
12
+ min: number;
13
+ max: number;
14
+ };
15
+ export declare const computeAxisRange: (drawingArea: DrawingArea) => {
16
+ xRange: AxisRange;
17
+ yRange: AxisRange;
18
+ };
19
+ export declare const buildScale: (domain: AxisBounds, range: AxisRange, scaleType?: AxisConfigProps["scaleType"]) => ChartScaleFunction;
20
+ export declare const computeDrawingArea: (width: number, height: number, inset: ChartInset, axisPadding: ChartInset) => DrawingArea;
21
+ export declare const useBuildChartContext: ({ series, xAxis, yAxis, width, height, inset, axisPadding, }: UseBuildChartContextParams) => CartesianChartContextValue;
22
+ export {};
23
+ //# sourceMappingURL=useBuildChartContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBuildChartContext.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/CartesianChart/context/useBuildChartContext.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,0BAA0B,EAC1B,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,MAAM,EACP,MAAM,sBAAsB,CAAC;AAE9B,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACjC,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,eAAe,CAAC,WAAW,CAAY,KACjD,kBAGgD,CAAC;AAEpD,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"}
@@ -0,0 +1,61 @@
1
+ import { useMemo as u } from "react";
2
+ import { computeXDomain as b, computeYDomain as C, computeDataLength as M } from "../../../utils/domain/domain.js";
3
+ import { getCategoricalScale as R, getNumericScale as _, isBandScaleType as X } from "../../../utils/scales/scales.js";
4
+ const Y = (t) => ({
5
+ xRange: { min: t.x, max: t.x + t.width },
6
+ yRange: {
7
+ min: t.y + t.height,
8
+ max: t.y
9
+ }
10
+ }), f = (t, e, o = "linear") => X(o) ? R({ domain: t, range: e }) : _({ scaleType: o, domain: t, range: e }), B = (t, e, o, a) => {
11
+ const c = {
12
+ top: o.top + a.top,
13
+ right: o.right + a.right,
14
+ bottom: o.bottom + a.bottom,
15
+ left: o.left + a.left
16
+ };
17
+ return {
18
+ x: c.left,
19
+ y: c.top,
20
+ width: Math.max(0, t - c.left - c.right),
21
+ height: Math.max(0, e - c.top - c.bottom)
22
+ };
23
+ }, I = ({
24
+ series: t,
25
+ xAxis: e,
26
+ yAxis: o,
27
+ width: a,
28
+ height: c,
29
+ inset: n,
30
+ axisPadding: p
31
+ }) => {
32
+ const l = u(
33
+ () => B(a, c, n, p),
34
+ [a, c, n, p]
35
+ );
36
+ return u(() => {
37
+ const { xRange: r, yRange: S } = Y(l);
38
+ let h, g;
39
+ if (l.width > 0 && l.height > 0) {
40
+ const m = b(t, e), D = C(t, o);
41
+ h = f(m, r, e?.scaleType), g = f(D, S, o?.scaleType);
42
+ }
43
+ const i = M(t, e), y = new Map(t.map((m) => [m.id, m]));
44
+ return {
45
+ series: t,
46
+ seriesMap: y,
47
+ getXScale: (m) => h,
48
+ getYScale: (m) => g,
49
+ getXAxisConfig: (m) => e,
50
+ getYAxisConfig: (m) => o,
51
+ drawingArea: l,
52
+ dataLength: i
53
+ };
54
+ }, [t, e, o, l]);
55
+ };
56
+ export {
57
+ f as buildScale,
58
+ Y as computeAxisRange,
59
+ B as computeDrawingArea,
60
+ I as useBuildChartContext
61
+ };
@@ -0,0 +1,4 @@
1
+ export { CartesianChart } from './CartesianChart';
2
+ export { useCartesianChartContext } from './context';
3
+ export type { CartesianChartProps } from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/CartesianChart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { ReactNode } from 'react';
2
+ import { AxisConfigProps, ChartInset, Series } from '../../utils/types';
3
+ export type CartesianChartProps = {
4
+ /**
5
+ * Data series provided to child components via context.
6
+ */
7
+ series: Series[];
8
+ /**
9
+ * Scale and domain configuration for the x-axis.
10
+ */
11
+ xAxis?: Partial<AxisConfigProps>;
12
+ /**
13
+ * Scale and domain configuration for the y-axis.
14
+ */
15
+ yAxis?: Partial<AxisConfigProps>;
16
+ /**
17
+ * Width of the chart.
18
+ * A number is treated as pixels; a string (e.g. `'100%'`) fills the container
19
+ * and enables auto-measurement via `ResizeObserver`.
20
+ * @default '100%'
21
+ */
22
+ width?: number | string;
23
+ /**
24
+ * Height of the chart in pixels.
25
+ * @default 160
26
+ */
27
+ height?: number;
28
+ /**
29
+ * Padding between the SVG edge and the drawing area.
30
+ * A number applies uniformly; a partial object overrides individual sides.
31
+ */
32
+ inset?: number | Partial<ChartInset>;
33
+ /**
34
+ * Space reserved for axes around the drawing area.
35
+ * Shrinks the drawing area by the specified amount on each side.
36
+ */
37
+ axisPadding?: Partial<ChartInset>;
38
+ /**
39
+ * Accessible label for the chart SVG.
40
+ * @default 'Chart'
41
+ */
42
+ ariaLabel?: string;
43
+ /**
44
+ * SVG content rendered inside the chart's context provider.
45
+ */
46
+ children?: ReactNode;
47
+ };
48
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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;;;OAGG;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,3 @@
1
+ import { LineProps } from './types';
2
+ export declare function Line({ seriesId, stroke, showArea, areaType: _areaType, }: LineProps): import("react/jsx-runtime").JSX.Element | null;
3
+ //# sourceMappingURL=Line.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Line/Line.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAMzC,wBAAgB,IAAI,CAAC,EACnB,QAAQ,EACR,MAAM,EACN,QAAgB,EAChB,QAAQ,EAAE,SAAsB,GACjC,EAAE,SAAS,kDAgEX"}
@@ -0,0 +1,53 @@
1
+ import { jsxs as l, Fragment as m, jsx as e } from "react/jsx-runtime";
2
+ import { useId as y, useMemo as c } from "react";
3
+ import { isNumericScale as A } from "../../utils/scales/scales.js";
4
+ import { toScaledPoints as P, buildLinePath as T, buildAreaPath as I } from "./utils.js";
5
+ import { useCartesianChartContext as L } from "../CartesianChart/context/cartesianChartContext.js";
6
+ const O = 2, _ = 0.2;
7
+ function M({
8
+ seriesId: g,
9
+ stroke: h,
10
+ showArea: s = !1,
11
+ areaType: j = "gradient"
12
+ }) {
13
+ const { getXScale: x, getYScale: C, getXAxisConfig: S, drawingArea: i, seriesMap: k } = L(), a = x(), o = C(), d = S(), p = y(), n = k.get(g), r = h ?? n?.stroke, t = c(
14
+ () => n?.data && a && o && A(o) ? P(n.data, a, o, d?.data) : null,
15
+ [n, a, o, d]
16
+ ), f = c(
17
+ () => t ? T(t) : null,
18
+ [t]
19
+ ), u = c(
20
+ () => s && t && i ? I(t, i) : null,
21
+ [s, t, i]
22
+ );
23
+ return f ? /* @__PURE__ */ l(m, { children: [
24
+ s && u && r && /* @__PURE__ */ l(m, { children: [
25
+ /* @__PURE__ */ e("defs", { children: /* @__PURE__ */ l("linearGradient", { id: p, x1: "0", y1: "0", x2: "0", y2: "1", children: [
26
+ /* @__PURE__ */ e(
27
+ "stop",
28
+ {
29
+ offset: "0%",
30
+ stopColor: r,
31
+ stopOpacity: _
32
+ }
33
+ ),
34
+ /* @__PURE__ */ e("stop", { offset: "100%", stopColor: r, stopOpacity: 0 })
35
+ ] }) }),
36
+ /* @__PURE__ */ e("path", { d: u, fill: `url(#${p})`, stroke: "none" })
37
+ ] }),
38
+ /* @__PURE__ */ e(
39
+ "path",
40
+ {
41
+ d: f,
42
+ fill: "none",
43
+ stroke: r,
44
+ strokeWidth: O,
45
+ strokeLinecap: "round",
46
+ strokeLinejoin: "round"
47
+ }
48
+ )
49
+ ] }) : null;
50
+ }
51
+ export {
52
+ M as Line
53
+ };
@@ -0,0 +1,3 @@
1
+ export { Line } from './Line';
2
+ export type { LineProps } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Line/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,24 @@
1
+ export type LineProps = {
2
+ /**
3
+ * The ID of the series to render.
4
+ * Must match a `Series.id` provided to the parent chart.
5
+ */
6
+ seriesId: string;
7
+ /**
8
+ * Override color for the line stroke.
9
+ * When omitted, falls back to the `stroke` defined on the series.
10
+ */
11
+ stroke?: string;
12
+ /**
13
+ * Whether to show a filled area under the line.
14
+ * @default false
15
+ */
16
+ showArea?: boolean;
17
+ /**
18
+ * Area fill style.
19
+ * When `'gradient'`, renders a vertical gradient from the stroke color to transparent.
20
+ * @default 'gradient'
21
+ */
22
+ areaType?: 'gradient';
23
+ };
24
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Line/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { ChartScaleFunction, DrawingArea, NumericScale } from '../../utils/types';
2
+ type Point = [x: number, y: number];
3
+ /**
4
+ * Project series data into scaled [x, y] pixel coordinates, skipping nulls.
5
+ *
6
+ * When `xData` contains numeric values, those values are fed into the scale
7
+ * instead of the array index so the points honour a numeric X domain.
8
+ */
9
+ export declare const toScaledPoints: (data: Array<number | null>, xScale: ChartScaleFunction, yScale: NumericScale, xData?: ReadonlyArray<string | number>) => Point[] | null;
10
+ /**
11
+ * Build the SVG `d` attribute for the line stroke.
12
+ */
13
+ export declare const buildLinePath: (points: Point[]) => string | null;
14
+ /**
15
+ * Build the SVG `d` attribute for the filled area beneath the line.
16
+ */
17
+ export declare const buildAreaPath: (points: Point[], drawingArea: DrawingArea) => string | null;
18
+ export {};
19
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +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,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,EAC1B,QAAQ,kBAAkB,EAC1B,QAAQ,YAAY,EACpB,QAAQ,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,KACrC,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"}
@@ -0,0 +1,22 @@
1
+ import { isCategoricalScale as p } from "../../utils/scales/scales.js";
2
+ import h from "../../../node_modules/d3-shape/src/line.js";
3
+ import { bumpX as s } from "../../../node_modules/d3-shape/src/curve/bump.js";
4
+ import f from "../../../node_modules/d3-shape/src/area.js";
5
+ const v = (n, t, e, o) => {
6
+ const u = [];
7
+ for (let r = 0; r < n.length; r++) {
8
+ const i = n[r];
9
+ if (i === null) continue;
10
+ const l = o && typeof o[r] == "number" ? o[r] : r, c = p(t) ? (t(l) ?? 0) + t.bandwidth() / 2 : t(l), m = e(i);
11
+ u.push([c, m]);
12
+ }
13
+ return u.length >= 2 ? u : null;
14
+ }, P = (n) => h().x((t) => t[0]).y((t) => t[1]).curve(s)(n) ?? null, B = (n, t) => {
15
+ const e = t.y + t.height;
16
+ return f().x((o) => o[0]).y0(e).y1((o) => o[1]).curve(s)(n) ?? null;
17
+ };
18
+ export {
19
+ B as buildAreaPath,
20
+ P as buildLinePath,
21
+ v as toScaledPoints
22
+ };
@@ -1,9 +1,3 @@
1
- import { Series } from '../../utils';
2
- type LineChartProps = {
3
- series: Series[];
4
- width?: number;
5
- height?: number;
6
- };
7
- export declare function LineChart({ series, width, height, }: LineChartProps): import("react/jsx-runtime").JSX.Element;
8
- export {};
1
+ import { LineChartProps } from './types';
2
+ export declare function LineChart({ series, showArea, areaType, showXAxis, showYAxis, xAxis, yAxis, width, height, inset, children, }: LineChartProps): import("react/jsx-runtime").JSX.Element;
9
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":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,KAAK,cAAc,GAAG;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,SAAS,CAAC,EACxB,MAAM,EACN,KAAW,EACX,MAAY,GACb,EAAE,cAAc,2CAkBhB"}
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,2CAqEhB"}
@@ -1,27 +1,82 @@
1
- import { jsxs as l, jsx as n } from "react/jsx-runtime";
2
- function a({
3
- series: i,
4
- width: e = 400,
5
- height: r = 300
1
+ import { jsxs as b, jsx as e } from "react/jsx-runtime";
2
+ import { useMemo as E } from "react";
3
+ import { DEFAULT_AXIS_WIDTH as p, YAxis as H } from "../YAxis/YAxis.js";
4
+ import { DEFAULT_AXIS_HEIGHT as m, XAxis as j } from "../XAxis/XAxis.js";
5
+ import { CartesianChart as F } from "../CartesianChart/CartesianChart.js";
6
+ import { Line as U } from "../Line/Line.js";
7
+ function q({
8
+ series: r,
9
+ showArea: d = !1,
10
+ areaType: f = "gradient",
11
+ showXAxis: t = !1,
12
+ showYAxis: o = !1,
13
+ xAxis: c,
14
+ yAxis: l,
15
+ width: x = "100%",
16
+ height: y = 160,
17
+ inset: T,
18
+ children: g
6
19
  }) {
7
- return /* @__PURE__ */ l("svg", { width: e, height: r, role: "img", "aria-label": "Line chart", children: [
8
- /* @__PURE__ */ n("title", { children: `Line chart with ${i.length} series` }),
9
- /* @__PURE__ */ n("rect", { width: e, height: r, rx: 8, fill: "#F3F0FA" }),
10
- /* @__PURE__ */ n(
11
- "text",
12
- {
13
- x: e / 2,
14
- y: r / 2,
15
- textAnchor: "middle",
16
- dominantBaseline: "central",
17
- fill: "#7e4ea5",
18
- fontSize: 14,
19
- fontFamily: "Inter, sans-serif",
20
- children: "LineChart placeholder"
21
- }
22
- )
23
- ] });
20
+ const {
21
+ scaleType: u,
22
+ data: D,
23
+ domain: A,
24
+ ...a
25
+ } = c ?? {}, {
26
+ scaleType: C,
27
+ data: I,
28
+ domain: P,
29
+ ...n
30
+ } = l ?? {}, L = {
31
+ scaleType: u,
32
+ data: D,
33
+ domain: A
34
+ }, S = {
35
+ scaleType: C,
36
+ data: I,
37
+ domain: P
38
+ }, _ = E(() => {
39
+ if (!t && !o) return;
40
+ const i = a.position === "top" ? "top" : "bottom", s = n.position === "end" ? "right" : "left";
41
+ return {
42
+ top: t && i === "top" ? m : 0,
43
+ bottom: t && i === "bottom" ? m : 0,
44
+ left: o && s === "left" ? p : 0,
45
+ right: o && s === "right" ? p : 0
46
+ };
47
+ }, [
48
+ t,
49
+ o,
50
+ a.position,
51
+ n.position
52
+ ]);
53
+ return /* @__PURE__ */ b(
54
+ F,
55
+ {
56
+ series: r ?? [],
57
+ xAxis: L,
58
+ yAxis: S,
59
+ width: x,
60
+ height: y,
61
+ inset: T,
62
+ axisPadding: _,
63
+ children: [
64
+ t && /* @__PURE__ */ e(j, { ...a }),
65
+ o && /* @__PURE__ */ e(H, { ...n }),
66
+ r?.map((i) => /* @__PURE__ */ e(
67
+ U,
68
+ {
69
+ seriesId: i.id,
70
+ showArea: d,
71
+ areaType: f
72
+ },
73
+ i.id
74
+ )),
75
+ g
76
+ ]
77
+ }
78
+ );
24
79
  }
25
80
  export {
26
- a as LineChart
81
+ q as LineChart
27
82
  };
@@ -1,2 +1,3 @@
1
1
  export { LineChart } from './LineChart';
2
+ export type { LineChartProps } from './types';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/LineChart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/LineChart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { ReactNode } from 'react';
2
+ import { AxisConfigProps, ChartInset, Series, XAxisVisualProps, YAxisVisualProps } from '../../utils/types';
3
+ export type LineChartProps = {
4
+ /**
5
+ * Data series to render as lines.
6
+ * Each series produces one `<Line>` element.
7
+ */
8
+ series?: Series[];
9
+ /**
10
+ * Whether to show area fill under all lines.
11
+ * @default false
12
+ */
13
+ showArea?: boolean;
14
+ /**
15
+ * Area fill style applied to all lines.
16
+ * When `'gradient'`, renders a vertical gradient from the stroke color to transparent.
17
+ * @default 'gradient'
18
+ */
19
+ areaType?: 'gradient';
20
+ /**
21
+ * Whether to render an x-axis.
22
+ * @default false
23
+ */
24
+ showXAxis?: boolean;
25
+ /**
26
+ * Whether to render a y-axis.
27
+ * @default false
28
+ */
29
+ showYAxis?: boolean;
30
+ /**
31
+ * Combined axis configuration and visual props for the x-axis.
32
+ * Includes scale/domain settings as well as visual options like `showGrid` and `showLine`.
33
+ */
34
+ xAxis?: Partial<AxisConfigProps> & XAxisVisualProps;
35
+ /**
36
+ * Combined axis configuration and visual props for the y-axis.
37
+ * Includes scale/domain settings as well as visual options like `showGrid` and `showLine`.
38
+ */
39
+ yAxis?: Partial<AxisConfigProps> & YAxisVisualProps;
40
+ /**
41
+ * Width of the chart.
42
+ * A number is treated as pixels; a string (e.g. `'100%'`) fills the container.
43
+ * @default '100%'
44
+ */
45
+ width?: number | string;
46
+ /**
47
+ * Height of the chart in pixels.
48
+ * @default 160
49
+ */
50
+ height?: number;
51
+ /**
52
+ * Padding between the SVG edge and the drawing area.
53
+ * A number applies uniformly; a partial object overrides individual sides.
54
+ */
55
+ inset?: number | Partial<ChartInset>;
56
+ /**
57
+ * Additional SVG content rendered inside the chart after lines and axes.
58
+ */
59
+ children?: ReactNode;
60
+ };
61
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,EACV,eAAe,EACf,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,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,OAAO,CAAC,eAAe,CAAC,GAAG,gBAAgB,CAAC;IACpD;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,gBAAgB,CAAC;IACpD;;;;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;CACtB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { XAxisProps } from './types';
2
+ export declare const DEFAULT_AXIS_HEIGHT = 28;
3
+ export declare function XAxis({ 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/XAxis/XAxis.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,wBAAgB,KAAK,CAAC,EACpB,QAAmB,EACnB,QAAgB,EAChB,QAAgB,EAChB,YAAoB,EACpB,KAAK,EAAE,SAAS,EAChB,kBAAkB,GACnB,EAAE,UAAU,kDAkFZ"}