@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.
Files changed (83) hide show
  1. package/dist/lib/Components/Axis/Axis.constants.d.ts +9 -0
  2. package/dist/lib/Components/Axis/Axis.constants.d.ts.map +1 -0
  3. package/dist/lib/Components/Axis/Axis.constants.js +24 -0
  4. package/dist/lib/Components/Axis/Axis.types.d.ts +37 -0
  5. package/dist/lib/Components/Axis/Axis.types.d.ts.map +1 -1
  6. package/dist/lib/Components/Axis/XAxis/XAxis.d.ts +0 -1
  7. package/dist/lib/Components/Axis/XAxis/XAxis.d.ts.map +1 -1
  8. package/dist/lib/Components/Axis/XAxis/XAxis.js +21 -22
  9. package/dist/lib/Components/Axis/XAxis/index.d.ts +1 -1
  10. package/dist/lib/Components/Axis/XAxis/index.d.ts.map +1 -1
  11. package/dist/lib/Components/Axis/YAxis/YAxis.d.ts +0 -1
  12. package/dist/lib/Components/Axis/YAxis/YAxis.d.ts.map +1 -1
  13. package/dist/lib/Components/Axis/YAxis/YAxis.js +16 -17
  14. package/dist/lib/Components/Axis/YAxis/index.d.ts +1 -1
  15. package/dist/lib/Components/Axis/YAxis/index.d.ts.map +1 -1
  16. package/dist/lib/Components/Axis/index.d.ts +3 -0
  17. package/dist/lib/Components/Axis/index.d.ts.map +1 -0
  18. package/dist/lib/Components/CartesianChart/CartesianChart.d.ts +1 -1
  19. package/dist/lib/Components/CartesianChart/CartesianChart.d.ts.map +1 -1
  20. package/dist/lib/Components/CartesianChart/CartesianChart.js +62 -58
  21. package/dist/lib/Components/CartesianChart/context/useBuildChartContext.d.ts +7 -4
  22. package/dist/lib/Components/CartesianChart/context/useBuildChartContext.d.ts.map +1 -1
  23. package/dist/lib/Components/CartesianChart/context/useBuildChartContext.js +31 -31
  24. package/dist/lib/Components/CartesianChart/types.d.ts +11 -3
  25. package/dist/lib/Components/CartesianChart/types.d.ts.map +1 -1
  26. package/dist/lib/Components/CartesianChart/utils.d.ts +19 -8
  27. package/dist/lib/Components/CartesianChart/utils.d.ts.map +1 -1
  28. package/dist/lib/Components/CartesianChart/utils.js +10 -11
  29. package/dist/lib/Components/Line/utils.d.ts +4 -0
  30. package/dist/lib/Components/Line/utils.d.ts.map +1 -1
  31. package/dist/lib/Components/Line/utils.js +15 -15
  32. package/dist/lib/Components/LineChart/LineChart.d.ts +1 -1
  33. package/dist/lib/Components/LineChart/LineChart.d.ts.map +1 -1
  34. package/dist/lib/Components/LineChart/LineChart.js +64 -74
  35. package/dist/lib/Components/LineChart/__stories__/cryptoChartData.d.ts +85 -0
  36. package/dist/lib/Components/LineChart/__stories__/cryptoChartData.d.ts.map +1 -0
  37. package/dist/lib/Components/LineChart/types.d.ts +10 -3
  38. package/dist/lib/Components/LineChart/types.d.ts.map +1 -1
  39. package/dist/lib/Components/Point/Point.d.ts +1 -1
  40. package/dist/lib/Components/Point/Point.d.ts.map +1 -1
  41. package/dist/lib/Components/Point/Point.js +35 -30
  42. package/dist/lib/Components/Point/constants.d.ts +7 -0
  43. package/dist/lib/Components/Point/constants.d.ts.map +1 -0
  44. package/dist/lib/Components/Point/constants.js +9 -0
  45. package/dist/lib/Components/Point/pointContext/MagneticPointsProvider.d.ts +7 -0
  46. package/dist/lib/Components/Point/pointContext/MagneticPointsProvider.d.ts.map +1 -0
  47. package/dist/lib/Components/Point/pointContext/MagneticPointsProvider.js +19 -0
  48. package/dist/lib/Components/Point/pointContext/index.d.ts +3 -0
  49. package/dist/lib/Components/Point/pointContext/index.d.ts.map +1 -0
  50. package/dist/lib/Components/Point/pointContext/magneticPointsContext.d.ts +13 -0
  51. package/dist/lib/Components/Point/pointContext/magneticPointsContext.d.ts.map +1 -0
  52. package/dist/lib/Components/Point/pointContext/magneticPointsContext.js +9 -0
  53. package/dist/lib/Components/Point/types.d.ts +7 -0
  54. package/dist/lib/Components/Point/types.d.ts.map +1 -1
  55. package/dist/lib/Components/Point/utils.d.ts +8 -6
  56. package/dist/lib/Components/Point/utils.d.ts.map +1 -1
  57. package/dist/lib/Components/Point/utils.js +32 -20
  58. package/dist/lib/Components/ReferenceLine/constants.d.ts +1 -1
  59. package/dist/lib/Components/ReferenceLine/constants.d.ts.map +1 -1
  60. package/dist/lib/Components/ReferenceLine/utils.d.ts +3 -2
  61. package/dist/lib/Components/ReferenceLine/utils.d.ts.map +1 -1
  62. package/dist/lib/Components/Scrubber/ScrubberProvider.d.ts +1 -1
  63. package/dist/lib/Components/Scrubber/ScrubberProvider.d.ts.map +1 -1
  64. package/dist/lib/Components/Scrubber/ScrubberProvider.js +97 -72
  65. package/dist/lib/Components/Scrubber/types.d.ts +6 -0
  66. package/dist/lib/Components/Scrubber/types.d.ts.map +1 -1
  67. package/dist/lib/Components/Scrubber/utils.d.ts +33 -3
  68. package/dist/lib/Components/Scrubber/utils.d.ts.map +1 -1
  69. package/dist/lib/Components/Scrubber/utils.js +71 -37
  70. package/dist/lib/utils/domain/domain.d.ts +5 -4
  71. package/dist/lib/utils/domain/domain.d.ts.map +1 -1
  72. package/dist/lib/utils/index.d.ts +1 -1
  73. package/dist/lib/utils/index.d.ts.map +1 -1
  74. package/dist/lib/utils/scales/scales.d.ts +11 -5
  75. package/dist/lib/utils/scales/scales.d.ts.map +1 -1
  76. package/dist/lib/utils/scales/scales.js +19 -15
  77. package/dist/lib/utils/ticks/ticks.d.ts +13 -5
  78. package/dist/lib/utils/ticks/ticks.d.ts.map +1 -1
  79. package/dist/lib/utils/ticks/ticks.js +20 -20
  80. package/dist/lib/utils/types.d.ts +3 -28
  81. package/dist/lib/utils/types.d.ts.map +1 -1
  82. package/dist/package.json +4 -4
  83. 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;CACzD,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":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI1C,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,wBAAgB,KAAK,CAAC,EACpB,aAAuB,EACvB,QAAmB,EACnB,QAAgB,EAChB,QAAgB,EAChB,YAAoB,EACpB,KAAK,EAAE,SAAS,EAChB,kBAAkB,GACnB,EAAE,UAAU,kDAuFZ"}
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 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";
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
- const c = 4, S = 6, F = 28;
7
- function K({
8
- gridLineStyle: p = "solid",
7
+ function W({
8
+ gridLineStyle: h = "solid",
9
9
  position: l = "bottom",
10
- showGrid: h = !1,
11
- showLine: u = !1,
10
+ showGrid: u = !1,
11
+ showLine: c = !1,
12
12
  showTickMark: g = !1,
13
13
  ticks: d,
14
- tickLabelFormatter: x
14
+ tickLabelFormatter: m
15
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]
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, y = f ? -1 : 1, b = s + y * (c + S);
23
- return /* @__PURE__ */ k("g", { "data-testid": "x-axis", children: [
24
- h && n.filter((t) => E(t, e)).map((t, i) => /* @__PURE__ */ a(
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: p === "dashed" ? "3 3" : void 0
35
+ strokeDasharray: h === "dashed" ? "3 3" : void 0
36
36
  },
37
37
  `grid-${t.value}-${i}`
38
38
  )),
39
- u && /* @__PURE__ */ a(
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 + y * c,
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: b,
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
- F as DEFAULT_AXIS_HEIGHT,
84
- K as XAxis
83
+ W as XAxis
85
84
  };
@@ -1,3 +1,3 @@
1
- export { XAxis, DEFAULT_AXIS_HEIGHT } from './XAxis';
1
+ export { XAxis } from './XAxis';
2
2
  export type { XAxisProps } from './types';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -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,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACrD,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
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":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI1C,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,wBAAgB,KAAK,CAAC,EACpB,aAAuB,EACvB,QAAkB,EAClB,QAAgB,EAChB,QAAgB,EAChB,YAAoB,EACpB,KAAK,EAAE,SAAS,EAChB,kBAAkB,GACnB,EAAE,UAAU,kDAuFZ"}
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 b, jsx as a } from "react/jsx-runtime";
1
+ import { jsxs as A, jsx as a } from "react/jsx-runtime";
2
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";
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
- const f = 4, E = 6, w = 40;
7
- function F({
8
- gridLineStyle: h = "solid",
7
+ function W({
8
+ gridLineStyle: p = "solid",
9
9
  position: l = "start",
10
- showGrid: p = !1,
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: A, drawingArea: e } = T(), i = g(), m = A(), n = C(
17
- () => i ? D(i, m, d, x) : [],
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 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
- p && n.filter((t) => S(t, e)).map((t, o) => /* @__PURE__ */ a(
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: h === "dashed" ? "3 3" : void 0
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 + c * f,
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: k,
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
- w as DEFAULT_AXIS_WIDTH,
84
- F as YAxis
83
+ W as YAxis
85
84
  };
@@ -1,3 +1,3 @@
1
- export { YAxis, DEFAULT_AXIS_WIDTH } from './YAxis';
1
+ export { YAxis } from './YAxis';
2
2
  export type { YAxisProps } from './types';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -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,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACpD,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
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,3 @@
1
+ export * from './Axis.types';
2
+ export * from './Axis.constants';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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":"AAKA,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,eAAuB,EACvB,wBAAwB,EACxB,OAAc,EACd,QAAQ,GACT,EAAE,mBAAmB,2CA6FrB"}
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 r } from "react/jsx-runtime";
2
- import { useRef as p, useState as O, useCallback as P, useEffect as W, useMemo as h } from "react";
3
- import { ScrubberProvider as w } from "../Scrubber/ScrubberProvider.js";
4
- import { resolveInset as z, resolveAxisPadding as G, OVERFLOW_NEGATIVE_MARGIN as T, DEFAULT_HEIGHT as V } from "./utils.js";
5
- import { useBuildChartContext as _ } from "./context/useBuildChartContext.js";
6
- import { CartesianChartProvider as k } from "./context/cartesianChartContext.js";
7
- import { RevealClipDefs as D } from "./RevealClip/RevealClipDefs.js";
8
- function q({
9
- series: d,
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: R,
12
+ yAxis: y,
12
13
  width: e = "100%",
13
- height: s = V,
14
- inset: l,
15
- axisPadding: c,
16
- ariaLabel: b = "Chart",
14
+ height: l = _,
15
+ inset: c,
16
+ axisPadding: f,
17
+ ariaLabel: x = "Chart",
17
18
  enableScrubbing: i = !1,
18
- onScrubberPositionChange: y,
19
- animate: x = !0,
20
- children: A
19
+ onScrubberPositionChange: E,
20
+ animate: F = !0,
21
+ magnetRadius: O,
22
+ children: P
21
23
  }) {
22
- const a = p(null), f = p(null), [E, I] = O(
24
+ const d = R(null), v = R(null), [W, A] = M(
23
25
  typeof e == "number" ? e : void 0
24
- ), t = typeof e != "number", u = P((n) => {
25
- const [m] = n;
26
- m && I(m.contentRect.width);
26
+ ), r = typeof e != "number", u = z((n) => {
27
+ const [g] = n;
28
+ g && A(g.contentRect.width);
27
29
  }, []);
28
- W(() => {
29
- if (!t || !a.current || typeof ResizeObserver > "u")
30
+ H(() => {
31
+ if (!r || !d.current || typeof ResizeObserver > "u")
30
32
  return;
31
33
  const n = new ResizeObserver(u);
32
- return n.observe(a.current), () => n.disconnect();
33
- }, [t, u]);
34
- const o = typeof e == "number" ? e : E ?? 0, g = h(() => z(l), [l]), M = h(
35
- () => G(c),
36
- [c]
37
- ), v = _({
38
- series: d,
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: R,
41
- width: o,
42
- height: s,
43
- inset: g,
44
- axisPadding: M
42
+ yAxis: y,
43
+ width: m,
44
+ height: h,
45
+ inset: w,
46
+ axisPadding: I
45
47
  });
46
- return /* @__PURE__ */ r(
48
+ return /* @__PURE__ */ t(
47
49
  "div",
48
50
  {
49
- ref: t ? a : void 0,
51
+ ref: r ? d : void 0,
50
52
  "data-testid": "chart-container",
51
53
  style: {
52
- width: t ? e : o,
53
- height: s,
54
- ...T
54
+ width: r ? e : o,
55
+ height: l,
56
+ overflow: "visible"
55
57
  },
56
- children: o > 0 && /* @__PURE__ */ r(
58
+ children: o > 0 && /* @__PURE__ */ t(
57
59
  "svg",
58
60
  {
59
- ref: f,
61
+ ref: v,
60
62
  "data-testid": "chart-svg",
61
- width: o,
62
- height: s,
63
+ width: m,
64
+ height: h,
63
65
  role: "img",
64
- "aria-label": b || "Chart",
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__ */ r(k, { value: v, children: /* @__PURE__ */ r(
72
- w,
74
+ children: /* @__PURE__ */ t(D, { value: p, children: /* @__PURE__ */ t(U, { children: /* @__PURE__ */ t(
75
+ L,
73
76
  {
74
- svgRef: f,
77
+ svgRef: v,
75
78
  enableScrubbing: i,
76
- onScrubberPositionChange: y,
77
- children: /* @__PURE__ */ r(
78
- D,
79
+ onScrubberPositionChange: E,
80
+ magnetRadius: O,
81
+ children: /* @__PURE__ */ t(
82
+ j,
79
83
  {
80
- drawingArea: v.drawingArea,
81
- series: d,
82
- animate: x,
83
- children: A
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
- q as CartesianChart
98
+ Y as CartesianChart
95
99
  };
@@ -1,8 +1,11 @@
1
- import { AxisBounds, AxisConfigProps, CartesianChartContextValue, ChartInset, ChartScaleFunction, DrawingArea, Series } from '../../../utils/types';
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?: Partial<AxisConfigProps>;
5
- yAxis?: Partial<AxisConfigProps>;
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?: AxisConfigProps["scaleType"]) => ChartScaleFunction;
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,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"}
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 b, computeYDomain as C, computeDataLength as M } from "../../../utils/domain/domain.js";
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, 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
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: 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)
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
- }, I = ({
23
+ }, N = ({
24
24
  series: t,
25
25
  xAxis: e,
26
26
  yAxis: o,
27
- width: a,
28
- height: c,
29
- inset: n,
27
+ width: c,
28
+ height: m,
29
+ inset: l,
30
30
  axisPadding: p
31
31
  }) => {
32
- const l = u(
33
- () => B(a, c, n, p),
34
- [a, c, n, p]
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(l);
37
+ const { xRange: r, yRange: S } = Y(a);
38
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);
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), y = new Map(t.map((m) => [m.id, m]));
43
+ const i = M(t, e), D = new Map(t.map((n) => [n.id, n]));
44
44
  return {
45
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,
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, l]);
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
- I as useBuildChartContext
60
+ N as useBuildChartContext
61
61
  };
@@ -1,5 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
- import { AxisConfigProps, ChartInset, Series } from '../../utils/types';
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<AxisConfigProps>;
12
+ xAxis?: Partial<BaseAxisProps>;
12
13
  /**
13
14
  * Scale and domain configuration for the y-axis.
14
15
  */
15
- yAxis?: Partial<AxisConfigProps>;
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