@ledgerhq/lumen-ui-react-visualization 0.1.14 → 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 (99) hide show
  1. package/dist/index.js +8 -12
  2. package/dist/lib/Components/Axis/Axis.constants.d.ts +9 -0
  3. package/dist/lib/Components/Axis/Axis.constants.d.ts.map +1 -0
  4. package/dist/lib/Components/Axis/Axis.constants.js +24 -0
  5. package/dist/lib/Components/Axis/Axis.types.d.ts +37 -0
  6. package/dist/lib/Components/Axis/Axis.types.d.ts.map +1 -1
  7. package/dist/lib/Components/Axis/XAxis/XAxis.d.ts +0 -1
  8. package/dist/lib/Components/Axis/XAxis/XAxis.d.ts.map +1 -1
  9. package/dist/lib/Components/Axis/XAxis/XAxis.js +21 -22
  10. package/dist/lib/Components/Axis/XAxis/index.d.ts +1 -1
  11. package/dist/lib/Components/Axis/XAxis/index.d.ts.map +1 -1
  12. package/dist/lib/Components/Axis/YAxis/YAxis.d.ts +0 -1
  13. package/dist/lib/Components/Axis/YAxis/YAxis.d.ts.map +1 -1
  14. package/dist/lib/Components/Axis/YAxis/YAxis.js +16 -17
  15. package/dist/lib/Components/Axis/YAxis/index.d.ts +1 -1
  16. package/dist/lib/Components/Axis/YAxis/index.d.ts.map +1 -1
  17. package/dist/lib/Components/Axis/index.d.ts +3 -0
  18. package/dist/lib/Components/Axis/index.d.ts.map +1 -0
  19. package/dist/lib/Components/CartesianChart/CartesianChart.d.ts +1 -1
  20. package/dist/lib/Components/CartesianChart/CartesianChart.d.ts.map +1 -1
  21. package/dist/lib/Components/CartesianChart/CartesianChart.js +62 -58
  22. package/dist/lib/Components/CartesianChart/context/useBuildChartContext.d.ts +7 -4
  23. package/dist/lib/Components/CartesianChart/context/useBuildChartContext.d.ts.map +1 -1
  24. package/dist/lib/Components/CartesianChart/context/useBuildChartContext.js +31 -31
  25. package/dist/lib/Components/CartesianChart/types.d.ts +11 -3
  26. package/dist/lib/Components/CartesianChart/types.d.ts.map +1 -1
  27. package/dist/lib/Components/CartesianChart/utils.d.ts +19 -8
  28. package/dist/lib/Components/CartesianChart/utils.d.ts.map +1 -1
  29. package/dist/lib/Components/CartesianChart/utils.js +10 -11
  30. package/dist/lib/Components/Line/utils.d.ts +4 -0
  31. package/dist/lib/Components/Line/utils.d.ts.map +1 -1
  32. package/dist/lib/Components/Line/utils.js +15 -15
  33. package/dist/lib/Components/LineChart/LineChart.d.ts +1 -1
  34. package/dist/lib/Components/LineChart/LineChart.d.ts.map +1 -1
  35. package/dist/lib/Components/LineChart/LineChart.js +64 -74
  36. package/dist/lib/Components/LineChart/__stories__/cryptoChartData.d.ts +85 -0
  37. package/dist/lib/Components/LineChart/__stories__/cryptoChartData.d.ts.map +1 -0
  38. package/dist/lib/Components/LineChart/types.d.ts +10 -3
  39. package/dist/lib/Components/LineChart/types.d.ts.map +1 -1
  40. package/dist/lib/Components/Point/Point.d.ts +1 -1
  41. package/dist/lib/Components/Point/Point.d.ts.map +1 -1
  42. package/dist/lib/Components/Point/Point.js +35 -30
  43. package/dist/lib/Components/Point/constants.d.ts +7 -0
  44. package/dist/lib/Components/Point/constants.d.ts.map +1 -0
  45. package/dist/lib/Components/Point/constants.js +9 -0
  46. package/dist/lib/Components/Point/pointContext/MagneticPointsProvider.d.ts +7 -0
  47. package/dist/lib/Components/Point/pointContext/MagneticPointsProvider.d.ts.map +1 -0
  48. package/dist/lib/Components/Point/pointContext/MagneticPointsProvider.js +19 -0
  49. package/dist/lib/Components/Point/pointContext/index.d.ts +3 -0
  50. package/dist/lib/Components/Point/pointContext/index.d.ts.map +1 -0
  51. package/dist/lib/Components/Point/pointContext/magneticPointsContext.d.ts +13 -0
  52. package/dist/lib/Components/Point/pointContext/magneticPointsContext.d.ts.map +1 -0
  53. package/dist/lib/Components/Point/pointContext/magneticPointsContext.js +9 -0
  54. package/dist/lib/Components/Point/types.d.ts +7 -0
  55. package/dist/lib/Components/Point/types.d.ts.map +1 -1
  56. package/dist/lib/Components/Point/utils.d.ts +8 -6
  57. package/dist/lib/Components/Point/utils.d.ts.map +1 -1
  58. package/dist/lib/Components/Point/utils.js +32 -20
  59. package/dist/lib/Components/ReferenceLine/constants.d.ts +1 -1
  60. package/dist/lib/Components/ReferenceLine/constants.d.ts.map +1 -1
  61. package/dist/lib/Components/ReferenceLine/utils.d.ts +3 -2
  62. package/dist/lib/Components/ReferenceLine/utils.d.ts.map +1 -1
  63. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/ChartTooltipItem.d.ts +7 -1
  64. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/ChartTooltipItem.d.ts.map +1 -1
  65. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/ChartTooltipItem.js +23 -22
  66. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/DefaultScrubberTooltip.d.ts.map +1 -1
  67. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/DefaultScrubberTooltip.js +43 -47
  68. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/utils.d.ts +19 -4
  69. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/utils.d.ts.map +1 -1
  70. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/utils.js +62 -41
  71. package/dist/lib/Components/Scrubber/Scrubber.d.ts +1 -1
  72. package/dist/lib/Components/Scrubber/Scrubber.d.ts.map +1 -1
  73. package/dist/lib/Components/Scrubber/Scrubber.js +78 -99
  74. package/dist/lib/Components/Scrubber/ScrubberProvider.d.ts +1 -1
  75. package/dist/lib/Components/Scrubber/ScrubberProvider.d.ts.map +1 -1
  76. package/dist/lib/Components/Scrubber/ScrubberProvider.js +97 -72
  77. package/dist/lib/Components/Scrubber/index.d.ts +0 -1
  78. package/dist/lib/Components/Scrubber/index.d.ts.map +1 -1
  79. package/dist/lib/Components/Scrubber/types.d.ts +17 -17
  80. package/dist/lib/Components/Scrubber/types.d.ts.map +1 -1
  81. package/dist/lib/Components/Scrubber/utils.d.ts +33 -3
  82. package/dist/lib/Components/Scrubber/utils.d.ts.map +1 -1
  83. package/dist/lib/Components/Scrubber/utils.js +70 -37
  84. package/dist/lib/utils/domain/domain.d.ts +5 -4
  85. package/dist/lib/utils/domain/domain.d.ts.map +1 -1
  86. package/dist/lib/utils/index.d.ts +1 -1
  87. package/dist/lib/utils/index.d.ts.map +1 -1
  88. package/dist/lib/utils/scales/scales.d.ts +11 -5
  89. package/dist/lib/utils/scales/scales.d.ts.map +1 -1
  90. package/dist/lib/utils/scales/scales.js +19 -15
  91. package/dist/lib/utils/ticks/ticks.d.ts +13 -5
  92. package/dist/lib/utils/ticks/ticks.d.ts.map +1 -1
  93. package/dist/lib/utils/ticks/ticks.js +20 -20
  94. package/dist/lib/utils/types.d.ts +3 -28
  95. package/dist/lib/utils/types.d.ts.map +1 -1
  96. package/dist/package.json +4 -4
  97. package/package.json +4 -4
  98. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/index.d.ts +0 -3
  99. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/index.d.ts.map +0 -1
@@ -1,5 +1,4 @@
1
1
  export { Scrubber } from './Scrubber';
2
2
  export { useScrubberContext } from './context';
3
- export { ChartTooltipItem, DefaultScrubberTooltip, } from './DefaultScrubberTooltip';
4
3
  export type { ChartTooltipItemData, ChartTooltipItemProps, ScrubberContextValue, ScrubberProps, ScrubberTooltipContent, ScrubberTooltipProps, SvgTextContent, } from './types';
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,GACf,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,GACf,MAAM,SAAS,CAAC"}
@@ -28,6 +28,12 @@ export type ScrubberProviderProps = {
28
28
  * Optional external callback fired whenever the scrubber position changes.
29
29
  */
30
30
  onScrubberPositionChange?: (index: number | undefined) => void;
31
+ /**
32
+ * Pixel radius within which the scrubber magnetically snaps to registered
33
+ * magnetic points. Set to `0` to disable magnetization.
34
+ * @default 8
35
+ */
36
+ magnetRadius?: number;
31
37
  };
32
38
  /**
33
39
  * Valid content for an SVG `<text>` element: a plain string,
@@ -35,9 +41,13 @@ export type ScrubberProviderProps = {
35
41
  */
36
42
  export type SvgTextContent = string | number | ReactElement<SVGProps<SVGTSpanElement>, 'tspan'>;
37
43
  export type ChartTooltipItemData = {
38
- /** Label displayed on the left side of the row. */
44
+ /**
45
+ * Label displayed on the left side of the row.
46
+ */
39
47
  label: SvgTextContent;
40
- /** Value displayed on the right side of the row. */
48
+ /**
49
+ * Value displayed on the right side of the row.
50
+ */
41
51
  value: SvgTextContent;
42
52
  };
43
53
  export type ChartTooltipItemProps = ChartTooltipItemData & {
@@ -92,15 +102,10 @@ export type ScrubberTooltipProps = ScrubberTooltipLayoutProps & {
92
102
  */
93
103
  drawingArea: DrawingArea;
94
104
  /**
95
- * Zero-based index of the data point currently under the scrubber. Maps
96
- * directly to the series data arrays so consumers can look up values.
97
- */
98
- dataIndex: number;
99
- /**
100
- * Optional title displayed at the top of the tooltip. Pass `null` or omit
101
- * to render the tooltip without a title row.
105
+ * Optional title displayed at the top of the tooltip. Omit to render
106
+ * the tooltip without a title row.
102
107
  */
103
- title?: SvgTextContent | null;
108
+ title?: SvgTextContent;
104
109
  /**
105
110
  * List of label/value pairs rendered as rows inside the tooltip body.
106
111
  */
@@ -112,20 +117,15 @@ export type ScrubberTooltipProps = ScrubberTooltipLayoutProps & {
112
117
  export type ScrubberTooltipContent = ScrubberTooltipLayoutProps & {
113
118
  /**
114
119
  * Optional header. Static value or callback per data index.
115
- * A callback may return `null` or `undefined` to suppress the title.
120
+ * A callback may return `undefined` to suppress the title.
116
121
  */
117
- title?: SvgTextContent | ((index: number) => SvgTextContent | null | undefined);
122
+ title?: SvgTextContent | ((index: number) => SvgTextContent | undefined);
118
123
  /**
119
124
  * Tooltip rows for this index. Return an empty array to hide the tooltip.
120
125
  */
121
126
  items: ChartTooltipItemData[];
122
127
  };
123
128
  export type ScrubberProps = {
124
- /**
125
- * Formats a label string shown above the reference line for a given data index.
126
- * When omitted, no label is rendered.
127
- */
128
- label?: (dataIndex: number) => string;
129
129
  /**
130
130
  * Hides the vertical reference line.
131
131
  * @default false
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC;;OAEG;IACH,wBAAwB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,Q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EG;AACH,MAAM,MAAM,sBAAsB,GAAG,0BAA0B,GAAG;IAChE;;;OAGG;IACH,KAAK,CAAC,EAAE,cAAc,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,cAAc,GAAG,SAAS,CAAC,CAAC;IACzE;;OAEG;IACH,KAAK,EAAE,oBAAoB,EAAE,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,sBAAsB,CAAC;CACzD,CAAC"}
@@ -1,4 +1,5 @@
1
- import { AxisConfigProps, ChartScaleFunction } from '../../utils/types';
1
+ import { ChartScaleFunction } from '../../utils/types';
2
+ import { BaseAxisProps } from '../Axis';
2
3
  import { useCartesianChartContext } from '../CartesianChart/context';
3
4
  export declare const BEACON_RADIUS = 5;
4
5
  export declare const BEACON_STROKE_WIDTH = 2;
@@ -7,6 +8,19 @@ export declare const OVERLAY_OFFSET = 2;
7
8
  export declare const OVERLAY_LINE_INSET = 0.5;
8
9
  export declare const OVERLAY_OPACITY = 0.8;
9
10
  export declare const LINE_GRADIENT_EDGE_OPACITY = 0.1;
11
+ export type MagnetEntry = {
12
+ index: number;
13
+ pixelX: number;
14
+ };
15
+ /**
16
+ * Resolves each magnetic index to its pixel position and returns them sorted
17
+ * by `pixelX` ascending. Indices that cannot be projected are filtered out.
18
+ * The sorted output enables early-exit in {@link applyMagnetization}.
19
+ */
20
+ export declare const buildSortedMagnets: ({ magneticIndices, getPixelForIndex, }: {
21
+ magneticIndices: ReadonlySet<number>;
22
+ getPixelForIndex: (index: number) => number | undefined;
23
+ }) => MagnetEntry[];
10
24
  /**
11
25
  * Converts a pixel position along the x-axis into the nearest data index.
12
26
  *
@@ -14,7 +28,7 @@ export declare const LINE_GRADIENT_EDGE_OPACITY = 0.1;
14
28
  * `pixelX`. For numeric scales, uses `scale.invert()` and rounds to the
15
29
  * nearest integer, clamped to the valid index range.
16
30
  */
17
- export declare const getDataIndexFromPosition: (pixelX: number, scale: ChartScaleFunction, axisConfig: Partial<AxisConfigProps> | undefined, dataLength: number) => number;
31
+ export declare const getDataIndexFromPosition: (pixelX: number, scale: ChartScaleFunction, axisConfig: Partial<BaseAxisProps> | undefined, dataLength: number) => number;
18
32
  /**
19
33
  * Resolves the pixel y-coordinate for a given series data point at a data index.
20
34
  * Returns undefined when the value is null/missing or the scale is unavailable.
@@ -26,5 +40,21 @@ export declare const resolvePixelY: (dataIndex: number, seriesData: (number | nu
26
40
  * otherwise the data index is used as the x input.
27
41
  * Returns undefined when the scale is unavailable or the value cannot be mapped.
28
42
  */
29
- export declare const resolvePixelX: (dataIndex: number, getXScale: ReturnType<typeof useCartesianChartContext>["getXScale"], axisConfig?: AxisConfigProps) => number | undefined;
43
+ export declare const resolvePixelX: (dataIndex: number, getXScale: ReturnType<typeof useCartesianChartContext>["getXScale"], axisConfig?: BaseAxisProps) => number | undefined;
44
+ /**
45
+ * Binary search for the magnet whose `pixelX` is closest to `pixelX`.
46
+ * Returns -1 when the array is empty. Favors the left neighbor on ties.
47
+ */
48
+ export declare const nearestIndex: (sortedMagnets: readonly MagnetEntry[], pixelX: number) => number;
49
+ /**
50
+ * Given a resolved data index and the raw pixel position, checks whether any
51
+ * magnetic point is within `magnetRadius` pixels of `pixelX`. If so, returns
52
+ * the closest magnetic index; otherwise returns the original `resolvedIndex`.
53
+ */
54
+ export declare const applyMagnetization: ({ resolvedIndex, pixelX, sortedMagnets, magnetRadius, }: {
55
+ resolvedIndex: number;
56
+ pixelX: number;
57
+ sortedMagnets: readonly MagnetEntry[];
58
+ magnetRadius: number;
59
+ }) => number;
30
60
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAE1E,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAgC9C;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GACnC,QAAQ,MAAM,EACd,OAAO,kBAAkB,EACzB,YAAY,OAAO,CAAC,eAAe,CAAC,GAAG,SAAS,EAChD,YAAY,MAAM,KACjB,MA2BF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,GACxB,WAAW,MAAM,EACjB,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,SAAS,EACzC,WAAW,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,WAAW,CAAC,KAClE,MAAM,GAAG,SASX,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,WAAW,MAAM,EACjB,WAAW,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,WAAW,CAAC,EACnE,aAAa,eAAe,KAC3B,MAAM,GAAG,SAMX,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,K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C,QAAQ,MAAM,KACb,MAsBF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,yDAKhC;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,SAAS,WAAW,EAAE,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC;CACtB,KAAG,MAWH,CAAC"}
@@ -1,57 +1,90 @@
1
- import { getPointOnScale as d, isNumericScale as u, isCategoricalScale as l } from "../../utils/scales/scales.js";
2
- const v = 5, _ = 2, m = 12, A = 2, I = 0.5, O = 0.8, h = 0.1, f = (o) => typeof o[0] == "number", a = (o, n, r) => {
1
+ import { getPointOnScale as f, isNumericScale as l, isCategoricalScale as a } from "../../utils/scales/scales.js";
2
+ const v = 5, E = 2, m = 2, p = 0.5, A = 0.8, I = 0.1, O = ({
3
+ magneticIndices: o,
4
+ getPixelForIndex: i
5
+ }) => {
6
+ if (o.size === 0) return [];
7
+ const n = [];
8
+ for (const e of o) {
9
+ const t = i(e);
10
+ t !== void 0 && n.push({ index: e, pixelX: t });
11
+ }
12
+ return n.sort((e, t) => e.pixelX - t.pixelX), n;
13
+ }, d = (o) => typeof o[0] == "number", u = (o, i, n) => {
3
14
  let e = 0, t = 1 / 0;
4
- for (let i = 0; i < o; i++) {
5
- const s = r(i);
6
- if (s === void 0) continue;
7
- const c = Math.abs(n - s);
8
- c < t && (t = c, e = i);
15
+ for (let r = 0; r < o; r++) {
16
+ const c = n(r);
17
+ if (c === void 0) continue;
18
+ const s = Math.abs(i - c);
19
+ s < t && (t = s, e = r);
9
20
  }
10
21
  return e;
11
- }, S = (o, n, r, e) => {
12
- if (l(n)) {
13
- const t = n.domain(), i = n.bandwidth();
14
- return a(t.length, o, (s) => {
15
- const c = n(t[s]);
16
- return c === void 0 ? void 0 : c + i / 2;
22
+ }, _ = (o, i, n, e) => {
23
+ if (a(i)) {
24
+ const t = i.domain(), r = i.bandwidth();
25
+ return u(t.length, o, (c) => {
26
+ const s = i(t[c]);
27
+ return s === void 0 ? void 0 : s + r / 2;
17
28
  });
18
29
  }
19
- if (u(n)) {
20
- const t = r?.data;
21
- if (t && t.length > 0 && f(t))
22
- return a(
30
+ if (l(i)) {
31
+ const t = n?.data;
32
+ if (t && t.length > 0 && d(t))
33
+ return u(
23
34
  t.length,
24
35
  o,
25
- (s) => n(t[s])
36
+ (c) => i(t[c])
26
37
  );
27
- const i = n.invert(o);
38
+ const r = i.invert(o);
28
39
  return Math.max(
29
40
  0,
30
- Math.min(Math.round(i), e - 1)
41
+ Math.min(Math.round(r), e - 1)
31
42
  );
32
43
  }
33
44
  return 0;
34
- }, x = (o, n, r) => {
35
- const e = r();
36
- if (!e || !u(e) || !n) return;
37
- const t = n[o];
45
+ }, S = (o, i, n) => {
46
+ const e = n();
47
+ if (!e || !l(e) || !i) return;
48
+ const t = i[o];
38
49
  if (t != null)
39
50
  return e(t);
40
- }, N = (o, n, r) => {
41
- const e = n();
51
+ }, b = (o, i, n) => {
52
+ const e = i();
42
53
  if (!e) return;
43
- const t = r?.data?.[o];
44
- return d(typeof t == "number" ? t : o, e);
54
+ const t = n?.data?.[o];
55
+ return f(typeof t == "number" ? t : o, e);
56
+ }, h = (o, i) => {
57
+ if (o.length === 0) return -1;
58
+ let n = 0, e = o.length;
59
+ for (; n < e; ) {
60
+ const c = Math.floor((n + e) / 2);
61
+ o[c].pixelX < i ? n = c + 1 : e = c;
62
+ }
63
+ if (n === 0) return 0;
64
+ if (n === o.length) return n - 1;
65
+ const t = i - o[n - 1].pixelX, r = o[n].pixelX - i;
66
+ return t <= r ? n - 1 : n;
67
+ }, N = ({
68
+ resolvedIndex: o,
69
+ pixelX: i,
70
+ sortedMagnets: n,
71
+ magnetRadius: e
72
+ }) => {
73
+ if (e <= 0 || n.length === 0) return o;
74
+ const t = h(n, i);
75
+ return t >= 0 && Math.abs(n[t].pixelX - i) <= e ? n[t].index : o;
45
76
  };
46
77
  export {
47
78
  v as BEACON_RADIUS,
48
- _ as BEACON_STROKE_WIDTH,
49
- m as LABEL_OFFSET_Y,
50
- h as LINE_GRADIENT_EDGE_OPACITY,
51
- I as OVERLAY_LINE_INSET,
52
- A as OVERLAY_OFFSET,
53
- O as OVERLAY_OPACITY,
54
- S as getDataIndexFromPosition,
55
- N as resolvePixelX,
56
- x as resolvePixelY
79
+ E as BEACON_STROKE_WIDTH,
80
+ I as LINE_GRADIENT_EDGE_OPACITY,
81
+ p as OVERLAY_LINE_INSET,
82
+ m as OVERLAY_OFFSET,
83
+ A as OVERLAY_OPACITY,
84
+ N as applyMagnetization,
85
+ O as buildSortedMagnets,
86
+ _ as getDataIndexFromPosition,
87
+ h as nearestIndex,
88
+ b as resolvePixelX,
89
+ S as resolvePixelY
57
90
  };
@@ -1,17 +1,18 @@
1
- import { AxisBounds, AxisConfigProps, Series } from '../types';
1
+ import { AxisBounds, BaseAxisProps } from '../../Components/Axis';
2
+ import { Series } from '../types';
2
3
  /**
3
4
  * Compute the X domain (index-based) from series data and axis config.
4
5
  * For the X axis the domain is typically 0..N-1 where N = longest series length,
5
6
  * unless explicit `data` is provided on the axis config.
6
7
  */
7
- export declare const computeXDomain: (series: Series[], axisConfig?: Partial<AxisConfigProps>) => AxisBounds;
8
+ export declare const computeXDomain: (series: Series[], axisConfig?: Partial<BaseAxisProps>) => AxisBounds;
8
9
  /**
9
10
  * Compute the Y domain (value-based) from series data and axis config.
10
11
  * Scans all non-null values across all series to find min/max.
11
12
  */
12
- export declare const computeYDomain: (series: Series[], axisConfig?: Partial<AxisConfigProps>) => AxisBounds;
13
+ export declare const computeYDomain: (series: Series[], axisConfig?: Partial<BaseAxisProps>) => AxisBounds;
13
14
  /**
14
15
  * Compute the data length (number of discrete positions on the index axis).
15
16
  */
16
- export declare const computeDataLength: (series: Series[], axisConfig?: Partial<AxisConfigProps>) => number;
17
+ export declare const computeDataLength: (series: Series[], axisConfig?: Partial<BaseAxisProps>) => number;
17
18
  //# sourceMappingURL=domain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/domain/domain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEpE;;;;GAIG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EAAE,EAChB,aAAa,OAAO,CAAC,eAAe,CAAC,KACpC,UA4BF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EAAE,EAChB,aAAa,OAAO,CAAC,eAAe,CAAC,KACpC,UAwBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,EAAE,EAChB,aAAa,OAAO,CAAC,eAAe,CAAC,KACpC,MAKF,CAAC"}
1
+ {"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/domain/domain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;GAIG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EAAE,EAChB,aAAa,OAAO,CAAC,aAAa,CAAC,KAClC,UA4BF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EAAE,EAChB,aAAa,OAAO,CAAC,aAAa,CAAC,KAClC,UAwBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,EAAE,EAChB,aAAa,OAAO,CAAC,aAAa,CAAC,KAClC,MAKF,CAAC"}
@@ -1,2 +1,2 @@
1
- export type { AxisBounds, AxisConfigProps, CartesianChartContextValue, CategoricalScale, ChartInset, ChartScaleFunction, DrawingArea, NumericScale, Series, } from './types';
1
+ export type { CartesianChartContextValue, CategoricalScale, ChartInset, ChartScaleFunction, DrawingArea, NumericScale, Series, } from './types';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,eAAe,EACf,0BAA0B,EAC1B,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,MAAM,GACP,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,0BAA0B,EAC1B,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,MAAM,GACP,MAAM,SAAS,CAAC"}
@@ -1,12 +1,18 @@
1
- import { AxisBounds, AxisConfigProps, CategoricalScale, ChartScaleFunction, NumericScale } from '../types';
1
+ import { AxisBounds, BaseAxisProps } from '../../Components/Axis';
2
+ import { CategoricalScale, ChartScaleFunction, NumericScale } from '../types';
2
3
  /**
3
- * Creates a numeric scale with `.nice()` applied so the domain
4
- * extends to clean rounded boundaries (e.g. `[4, 98]` → `[0, 100]`).
4
+ * Creates a numeric scale.
5
+ *
6
+ * When `nice` is `true` (default), the domain is rounded outward to clean
7
+ * boundaries via d3's `.nice()` (e.g. `[4, 98]` → `[0, 100]`). Set `nice` to
8
+ * `false` to keep the domain exactly as provided so data fills the range
9
+ * boundary-to-boundary.
5
10
  */
6
- export declare const getNumericScale: ({ scaleType, domain, range, }: {
11
+ export declare const getNumericScale: ({ scaleType, domain, range, nice, }: {
7
12
  scaleType: "linear" | "log";
8
13
  domain: AxisBounds;
9
14
  range: AxisBounds;
15
+ nice?: boolean;
10
16
  }) => NumericScale;
11
17
  export declare const getCategoricalScale: ({ domain, range, padding, }: {
12
18
  domain: AxisBounds;
@@ -16,7 +22,7 @@ export declare const getCategoricalScale: ({ domain, range, padding, }: {
16
22
  /**
17
23
  * Checks if a scale type config value refers to a band (categorical) scale.
18
24
  */
19
- export declare const isBandScaleType: (scaleType: AxisConfigProps["scaleType"]) => scaleType is "band";
25
+ export declare const isBandScaleType: (scaleType: BaseAxisProps["scaleType"]) => scaleType is "band";
20
26
  /**
21
27
  * Checks if a scale is a categorical scale.
22
28
  */
@@ -1 +1 @@
1
- {"version":3,"file":"scales.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/scales/scales.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACb,MAAM,UAAU,CAAC;AAElB;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,+BAI7B;IACD,SAAS,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC5B,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;CACnB,KAAG,YAMH,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,6BAIjC;IACD,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,KAAG,gBAUH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAC1B,WAAW,eAAe,CAAC,WAAW,CAAC,KACtC,SAAS,IAAI,MAA8B,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,kBAAkB,KACxB,KAAK,IAAI,gBAEX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,kBAAkB,KACxB,KAAK,IAAI,YAEX,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,MAAM,EACb,OAAO,kBAAkB,KACxB,MAKF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,MAAM,EACb,OAAO,MAAM,EACb,QAAQ,kBAAkB,EA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MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAGvB,CAAC"}
@@ -1,30 +1,34 @@
1
- import c from "../../../node_modules/d3-scale/src/band.js";
2
- import m from "../../../node_modules/d3-scale/src/log.js";
3
- import d from "../../../node_modules/d3-scale/src/linear.js";
4
- const p = ({
1
+ import m from "../../../node_modules/d3-scale/src/band.js";
2
+ import d from "../../../node_modules/d3-scale/src/log.js";
3
+ import u from "../../../node_modules/d3-scale/src/linear.js";
4
+ const l = ({
5
5
  scaleType: n,
6
6
  domain: t,
7
- range: r
8
- }) => (n === "log" ? m() : d()).domain([t.min, t.max]).nice().range([r.min, r.max]), f = ({
7
+ range: r,
8
+ nice: i = !0
9
+ }) => {
10
+ const o = n === "log" ? d() : u();
11
+ return o.domain([t.min, t.max]), i && o.nice(), o.range([r.min, r.max]);
12
+ }, p = ({
9
13
  domain: n,
10
14
  range: t,
11
15
  padding: r = 0.1
12
16
  }) => {
13
17
  const i = Array.from(
14
18
  { length: n.max - n.min + 1 },
15
- (s, a) => n.min + a
19
+ (o, c) => n.min + c
16
20
  );
17
- return c().domain(i).range([t.min, t.max]).paddingInner(r).paddingOuter(r / 2);
18
- }, x = (n) => n === "band", e = (n) => "bandwidth" in n && typeof n.bandwidth == "function", S = (n) => !e(n), o = (n, t) => e(t) ? (t(n) ?? 0) + t.bandwidth() / 2 : t(n), b = (n, t, r, i) => ({
19
- x: o(n, r),
20
- y: o(t, i)
21
+ return m().domain(i).range([t.min, t.max]).paddingInner(r).paddingOuter(r / 2);
22
+ }, x = (n) => n === "band", a = (n) => "bandwidth" in n && typeof n.bandwidth == "function", S = (n) => !a(n), e = (n, t) => a(t) ? (t(n) ?? 0) + t.bandwidth() / 2 : t(n), b = (n, t, r, i) => ({
23
+ x: e(n, r),
24
+ y: e(t, i)
21
25
  });
22
26
  export {
23
- f as getCategoricalScale,
24
- p as getNumericScale,
25
- o as getPointOnScale,
27
+ p as getCategoricalScale,
28
+ l as getNumericScale,
29
+ e as getPointOnScale,
26
30
  x as isBandScaleType,
27
- e as isCategoricalScale,
31
+ a as isCategoricalScale,
28
32
  S as isNumericScale,
29
33
  b as projectPoint
30
34
  };
@@ -1,4 +1,5 @@
1
- import { AxisConfigProps, ChartScaleFunction, DrawingArea } from '../types';
1
+ import { BaseAxisProps } from '../../Components/Axis';
2
+ import { ChartScaleFunction, DrawingArea } from '../types';
2
3
  export declare const APPROXIMATE_TICK_COUNT = 5;
3
4
  export type TickData = {
4
5
  position: number;
@@ -7,9 +8,16 @@ export type TickData = {
7
8
  };
8
9
  /**
9
10
  * Resolves which numeric tick values should appear on the axis.
10
- * Explicit ticks take priority, then scale-specific defaults.
11
+ *
12
+ * Priority:
13
+ * 1. Explicit `ticks` provided by the consumer.
14
+ * 2. Axis `data` — when provided, ticks come from the data itself (numeric
15
+ * values for numeric data, indices for string data) so the rendered ticks
16
+ * mirror exactly what the consumer asked for, with no d3-invented
17
+ * intermediate values.
18
+ * 3. Scale-specific defaults (band domain, or `scale.ticks()` for numeric).
11
19
  */
12
- export declare const getTickValues: (scale: ChartScaleFunction, explicitTicks?: number[]) => number[];
20
+ export declare const getTickValues: (scale: ChartScaleFunction, explicitTicks?: number[], axisData?: BaseAxisProps["data"]) => number[];
13
21
  /**
14
22
  * Converts a tick value to its pixel position on the axis.
15
23
  * Band scales are centered within the band.
@@ -19,11 +27,11 @@ export declare const getTickPosition: (scale: ChartScaleFunction, tick: number)
19
27
  * Resolves the display label for a tick value.
20
28
  * Priority: formatter > string label lookup > raw value.
21
29
  */
22
- export declare const getTickLabel: (tick: number, axisData: AxisConfigProps["data"], formatter?: (value: number | string) => string) => string;
30
+ export declare const getTickLabel: (tick: number, axisData: BaseAxisProps["data"], formatter?: (value: number | string) => string) => string;
23
31
  /**
24
32
  * Builds the complete tick data array from a scale and axis configuration.
25
33
  */
26
- export declare const buildTicksData: (scale: ChartScaleFunction, axisConfig?: AxisConfigProps, explicitTicks?: number[], formatter?: (value: number | string) => string) => TickData[];
34
+ export declare const buildTicksData: (scale: ChartScaleFunction, axisConfig?: BaseAxisProps, explicitTicks?: number[], formatter?: (value: number | string) => string) => TickData[];
27
35
  /**
28
36
  * Excludes the X grid line at the Y-axis origin (left edge)
29
37
  * to prevent overlap with the Y-axis solid line.
@@ -1 +1 @@
1
- {"version":3,"file":"ticks.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/ticks/ticks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,WAAW,EACZ,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,kBAAkB,EACzB,gBAAgB,MAAM,EAAE,KACvB,MAAM,EAKR,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,kBAAkB,EACzB,MAAM,MAAM,KACX,MAKF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,EACZ,UAAU,eAAe,CAAC,MAAM,CAAC,EACjC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,KAC7C,MAeF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,kBAAkB,EACzB,aAAa,eAAe,EAC5B,gBAAgB,MAAM,EAAE,EACxB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,KAC7C,QAAQ,EASV,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,MAAM,QAAQ,EACd,aAAa,WAAW,KACvB,OAEF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,MAAM,QAAQ,EACd,aAAa,WA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{ isCategoricalScale as u, isNumericScale as g } from "../scales/scales.js";
2
- const d = 5, T = (n, r) => r || (u(n) ? n.domain() : g(n) ? n.ticks(d) : []), f = (n, r) => u(n) ? (n(r) ?? 0) + n.bandwidth() / 2 : n(r), c = (n, r, t) => {
3
- const i = r && Array.isArray(r) && typeof r[0] == "string";
4
- if (t) {
5
- const o = i && r[n] !== void 0 ? r[n] : n;
6
- return String(t(o));
2
+ const s = 5, f = (n, r, o) => r && r.length > 0 ? r : o && o.length > 0 ? typeof o[0] == "number" ? o : o.map((e, t) => t) : u(n) ? n.domain() : g(n) ? n.ticks(s) : [], d = (n, r) => u(n) ? (n(r) ?? 0) + n.bandwidth() / 2 : n(r), m = (n, r, o) => {
3
+ const e = r && Array.isArray(r) && typeof r[0] == "string";
4
+ if (o) {
5
+ const t = e && r[n] !== void 0 ? r[n] : n;
6
+ return String(o(t));
7
7
  }
8
- return i && r[n] !== void 0 ? String(r[n]) : String(n);
9
- }, p = (n, r, t, i) => {
10
- const o = T(n, t), s = r?.data;
11
- return o.map((e) => ({
12
- position: f(n, e),
13
- value: e,
14
- label: c(e, s, i)
8
+ return e && r[n] !== void 0 ? String(r[n]) : String(n);
9
+ }, b = (n, r, o, e) => {
10
+ const t = r?.data;
11
+ return f(n, o, t).map((i) => ({
12
+ position: d(n, i),
13
+ value: i,
14
+ label: m(i, t, e)
15
15
  }));
16
- }, S = (n, r) => n.position !== r.x, b = (n, r) => n.position !== r.y + r.height;
16
+ }, h = (n, r) => n.position !== r.x, l = (n, r) => n.position !== r.y + r.height;
17
17
  export {
18
- d as APPROXIMATE_TICK_COUNT,
19
- p as buildTicksData,
20
- c as getTickLabel,
21
- f as getTickPosition,
22
- T as getTickValues,
23
- S as isTickOnXAxisDomainEdge,
24
- b as isTickOnYAxisDomainEdge
18
+ s as APPROXIMATE_TICK_COUNT,
19
+ b as buildTicksData,
20
+ m as getTickLabel,
21
+ d as getTickPosition,
22
+ f as getTickValues,
23
+ h as isTickOnXAxisDomainEdge,
24
+ l as isTickOnYAxisDomainEdge
25
25
  };
@@ -1,8 +1,5 @@
1
1
  import { ScaleBand, ScaleLinear, ScaleLogarithmic } from 'd3-scale';
2
- export type AxisBounds = {
3
- min: number;
4
- max: number;
5
- };
2
+ import { BaseAxisProps } from '../Components/Axis';
6
3
  export type ChartInset = {
7
4
  top: number;
8
5
  right: number;
@@ -36,28 +33,6 @@ export type Series = {
36
33
  */
37
34
  stroke: string;
38
35
  };
39
- export type AxisConfigProps = {
40
- /**
41
- * Scale algorithm used by this axis.
42
- * @default 'linear'
43
- */
44
- scaleType?: 'linear' | 'log' | 'band';
45
- /**
46
- * Explicit data values for band scales or category labels.
47
- * For band scales, provides the discrete domain. For numeric scales, string values
48
- * are used as tick labels at corresponding indices.
49
- */
50
- data?: string[] | number[];
51
- /**
52
- * Fixed domain bounds or a function that adjusts the computed bounds.
53
- * A partial object overrides only the specified bound(s).
54
- * A function receives the auto-computed bounds and returns adjusted ones.
55
- *
56
- * The final domain is always rounded to nice boundaries via d3's `.nice()`,
57
- * ensuring tick marks land on clean values (e.g. `[4, 98]` becomes `[0, 100]`).
58
- */
59
- domain?: Partial<AxisBounds> | ((bounds: AxisBounds) => AxisBounds);
60
- };
61
36
  export type NumericScale = ScaleLinear<number, number> | ScaleLogarithmic<number, number>;
62
37
  export type CategoricalScale = ScaleBand<number>;
63
38
  export type ChartScaleFunction = NumericScale | CategoricalScale;
@@ -81,11 +56,11 @@ export type CartesianChartContextValue = {
81
56
  /**
82
57
  * Returns the x-axis config. Accepts an optional axis ID for future multi-axis support.
83
58
  */
84
- getXAxisConfig: (id?: string) => AxisConfigProps | undefined;
59
+ getXAxisConfig: (id?: string) => BaseAxisProps | undefined;
85
60
  /**
86
61
  * Returns the y-axis config. Accepts an optional axis ID for future multi-axis support.
87
62
  */
88
- getYAxisConfig: (id?: string) => AxisConfigProps | undefined;
63
+ getYAxisConfig: (id?: string) => BaseAxisProps | undefined;
89
64
  /**
90
65
  * Pixel bounds of the drawable region.
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AAC"}
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/lumen-ui-react-visualization",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "keywords": [
@@ -33,8 +33,8 @@
33
33
  ]
34
34
  },
35
35
  "peerDependencies": {
36
- "@ledgerhq/lumen-design-core": "0.1.14",
37
- "@ledgerhq/lumen-ui-react": "0.1.34",
36
+ "@ledgerhq/lumen-design-core": "0.1.15",
37
+ "@ledgerhq/lumen-ui-react": "0.1.36",
38
38
  "class-variance-authority": "^0.7.1",
39
39
  "clsx": "^2.1.1",
40
40
  "react": "^18.0.0 || ^19.0.0",
@@ -42,7 +42,7 @@
42
42
  "tailwind-merge": "^2.6.0"
43
43
  },
44
44
  "dependencies": {
45
- "@ledgerhq/lumen-utils-shared": "0.1.3",
45
+ "@ledgerhq/lumen-utils-shared": "0.1.4",
46
46
  "d3-array": "^3.2.4",
47
47
  "d3-scale": "^4.0.2",
48
48
  "d3-shape": "^3.2.0"