@coinbase/cds-mobile-visualization 3.4.0-beta.8 → 3.4.0

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 (170) hide show
  1. package/CHANGELOG.md +142 -0
  2. package/dts/chart/CartesianChart.d.ts +92 -7
  3. package/dts/chart/CartesianChart.d.ts.map +1 -1
  4. package/dts/chart/ChartContextBridge.d.ts.map +1 -1
  5. package/dts/chart/ChartProvider.d.ts +3 -0
  6. package/dts/chart/ChartProvider.d.ts.map +1 -1
  7. package/dts/chart/Path.d.ts +36 -13
  8. package/dts/chart/Path.d.ts.map +1 -1
  9. package/dts/chart/PeriodSelector.d.ts +21 -6
  10. package/dts/chart/PeriodSelector.d.ts.map +1 -1
  11. package/dts/chart/area/Area.d.ts +14 -11
  12. package/dts/chart/area/Area.d.ts.map +1 -1
  13. package/dts/chart/area/AreaChart.d.ts +33 -9
  14. package/dts/chart/area/AreaChart.d.ts.map +1 -1
  15. package/dts/chart/area/DottedArea.d.ts.map +1 -1
  16. package/dts/chart/area/GradientArea.d.ts.map +1 -1
  17. package/dts/chart/area/SolidArea.d.ts.map +1 -1
  18. package/dts/chart/axis/Axis.d.ts +22 -42
  19. package/dts/chart/axis/Axis.d.ts.map +1 -1
  20. package/dts/chart/axis/XAxis.d.ts +6 -0
  21. package/dts/chart/axis/XAxis.d.ts.map +1 -1
  22. package/dts/chart/axis/YAxis.d.ts +1 -0
  23. package/dts/chart/axis/YAxis.d.ts.map +1 -1
  24. package/dts/chart/bar/Bar.d.ts +51 -51
  25. package/dts/chart/bar/Bar.d.ts.map +1 -1
  26. package/dts/chart/bar/BarChart.d.ts +56 -11
  27. package/dts/chart/bar/BarChart.d.ts.map +1 -1
  28. package/dts/chart/bar/BarPlot.d.ts +2 -1
  29. package/dts/chart/bar/BarPlot.d.ts.map +1 -1
  30. package/dts/chart/bar/BarStack.d.ts +45 -20
  31. package/dts/chart/bar/BarStack.d.ts.map +1 -1
  32. package/dts/chart/bar/BarStackGroup.d.ts +2 -1
  33. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
  34. package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
  35. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
  36. package/dts/chart/gradient/Gradient.d.ts +5 -0
  37. package/dts/chart/gradient/Gradient.d.ts.map +1 -1
  38. package/dts/chart/index.d.ts +1 -0
  39. package/dts/chart/index.d.ts.map +1 -1
  40. package/dts/chart/legend/DefaultLegendEntry.d.ts +5 -0
  41. package/dts/chart/legend/DefaultLegendEntry.d.ts.map +1 -0
  42. package/dts/chart/legend/DefaultLegendShape.d.ts +5 -0
  43. package/dts/chart/legend/DefaultLegendShape.d.ts.map +1 -0
  44. package/dts/chart/legend/Legend.d.ts +168 -0
  45. package/dts/chart/legend/Legend.d.ts.map +1 -0
  46. package/dts/chart/legend/index.d.ts +4 -0
  47. package/dts/chart/legend/index.d.ts.map +1 -0
  48. package/dts/chart/line/DottedLine.d.ts.map +1 -1
  49. package/dts/chart/line/Line.d.ts +23 -19
  50. package/dts/chart/line/Line.d.ts.map +1 -1
  51. package/dts/chart/line/LineChart.d.ts +26 -9
  52. package/dts/chart/line/LineChart.d.ts.map +1 -1
  53. package/dts/chart/line/ReferenceLine.d.ts +1 -0
  54. package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
  55. package/dts/chart/line/SolidLine.d.ts.map +1 -1
  56. package/dts/chart/point/Point.d.ts +26 -2
  57. package/dts/chart/point/Point.d.ts.map +1 -1
  58. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +32 -2
  59. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -1
  60. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +2 -1
  61. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -1
  62. package/dts/chart/scrubber/Scrubber.d.ts +86 -17
  63. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
  64. package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts +12 -0
  65. package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts.map +1 -0
  66. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +10 -0
  67. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -1
  68. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +16 -1
  69. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -1
  70. package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -1
  71. package/dts/chart/utils/axis.d.ts +45 -10
  72. package/dts/chart/utils/axis.d.ts.map +1 -1
  73. package/dts/chart/utils/bar.d.ts +190 -0
  74. package/dts/chart/utils/bar.d.ts.map +1 -1
  75. package/dts/chart/utils/chart.d.ts +32 -0
  76. package/dts/chart/utils/chart.d.ts.map +1 -1
  77. package/dts/chart/utils/context.d.ts +21 -6
  78. package/dts/chart/utils/context.d.ts.map +1 -1
  79. package/dts/chart/utils/gradient.d.ts +3 -1
  80. package/dts/chart/utils/gradient.d.ts.map +1 -1
  81. package/dts/chart/utils/path.d.ts +26 -0
  82. package/dts/chart/utils/path.d.ts.map +1 -1
  83. package/dts/chart/utils/point.d.ts +24 -12
  84. package/dts/chart/utils/point.d.ts.map +1 -1
  85. package/dts/chart/utils/scale.d.ts +11 -0
  86. package/dts/chart/utils/scale.d.ts.map +1 -1
  87. package/dts/chart/utils/scrubber.d.ts +2 -1
  88. package/dts/chart/utils/scrubber.d.ts.map +1 -1
  89. package/dts/chart/utils/transition.d.ts +63 -22
  90. package/dts/chart/utils/transition.d.ts.map +1 -1
  91. package/dts/sparkline/Sparkline.d.ts +2 -1
  92. package/dts/sparkline/Sparkline.d.ts.map +1 -1
  93. package/dts/sparkline/SparklineArea.d.ts +2 -1
  94. package/dts/sparkline/SparklineArea.d.ts.map +1 -1
  95. package/dts/sparkline/SparklineGradient.d.ts +2 -1
  96. package/dts/sparkline/SparklineGradient.d.ts.map +1 -1
  97. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +2 -1
  98. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -1
  99. package/esm/chart/CartesianChart.js +176 -82
  100. package/esm/chart/ChartContextBridge.js +14 -3
  101. package/esm/chart/ChartProvider.js +2 -2
  102. package/esm/chart/Path.js +34 -29
  103. package/esm/chart/PeriodSelector.js +6 -2
  104. package/esm/chart/__stories__/CartesianChart.stories.js +27 -86
  105. package/esm/chart/__stories__/ChartAccessibility.stories.js +721 -0
  106. package/esm/chart/__stories__/ChartTransitions.stories.js +625 -0
  107. package/esm/chart/__stories__/PeriodSelector.stories.js +102 -4
  108. package/esm/chart/area/Area.js +21 -9
  109. package/esm/chart/area/AreaChart.js +18 -13
  110. package/esm/chart/area/DottedArea.js +28 -18
  111. package/esm/chart/area/GradientArea.js +14 -7
  112. package/esm/chart/area/SolidArea.js +6 -2
  113. package/esm/chart/area/__stories__/AreaChart.stories.js +47 -5
  114. package/esm/chart/axis/Axis.js +5 -41
  115. package/esm/chart/axis/XAxis.js +116 -47
  116. package/esm/chart/axis/YAxis.js +105 -26
  117. package/esm/chart/axis/__stories__/Axis.stories.js +324 -48
  118. package/esm/chart/bar/Bar.js +17 -15
  119. package/esm/chart/bar/BarChart.js +38 -33
  120. package/esm/chart/bar/BarPlot.js +40 -45
  121. package/esm/chart/bar/BarStack.js +92 -475
  122. package/esm/chart/bar/BarStackGroup.js +37 -27
  123. package/esm/chart/bar/DefaultBar.js +27 -18
  124. package/esm/chart/bar/DefaultBarStack.js +25 -9
  125. package/esm/chart/bar/__stories__/BarChart.stories.js +728 -54
  126. package/esm/chart/gradient/Gradient.js +2 -1
  127. package/esm/chart/index.js +1 -0
  128. package/esm/chart/legend/DefaultLegendEntry.js +42 -0
  129. package/esm/chart/legend/DefaultLegendShape.js +64 -0
  130. package/esm/chart/legend/Legend.js +59 -0
  131. package/esm/chart/legend/__stories__/Legend.stories.js +574 -0
  132. package/esm/chart/legend/index.js +3 -0
  133. package/esm/chart/line/DottedLine.js +6 -2
  134. package/esm/chart/line/Line.js +42 -38
  135. package/esm/chart/line/LineChart.js +36 -12
  136. package/esm/chart/line/SolidLine.js +6 -2
  137. package/esm/chart/line/__stories__/LineChart.stories.js +241 -594
  138. package/esm/chart/line/__stories__/ReferenceLine.stories.js +95 -1
  139. package/esm/chart/point/Point.js +35 -36
  140. package/esm/chart/scrubber/DefaultScrubberBeacon.js +41 -38
  141. package/esm/chart/scrubber/DefaultScrubberLabel.js +26 -10
  142. package/esm/chart/scrubber/Scrubber.js +67 -35
  143. package/esm/chart/scrubber/ScrubberAccessibilityView.js +177 -0
  144. package/esm/chart/scrubber/ScrubberBeaconGroup.js +30 -22
  145. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +35 -8
  146. package/esm/chart/scrubber/ScrubberProvider.js +29 -24
  147. package/esm/chart/scrubber/__stories__/Scrubber.stories.js +946 -0
  148. package/esm/chart/utils/axis.js +88 -44
  149. package/esm/chart/utils/bar.js +820 -0
  150. package/esm/chart/utils/chart.js +34 -7
  151. package/esm/chart/utils/context.js +7 -0
  152. package/esm/chart/utils/gradient.js +8 -4
  153. package/esm/chart/utils/path.js +91 -61
  154. package/esm/chart/utils/point.js +92 -39
  155. package/esm/chart/utils/scale.js +13 -2
  156. package/esm/chart/utils/scrubber.js +12 -5
  157. package/esm/chart/utils/transition.js +108 -60
  158. package/esm/sparkline/Sparkline.js +2 -1
  159. package/esm/sparkline/SparklineArea.js +2 -1
  160. package/esm/sparkline/SparklineGradient.js +2 -1
  161. package/esm/sparkline/__figma__/Sparkline.figma.js +1 -1
  162. package/esm/sparkline/__stories__/Sparkline.stories.js +11 -7
  163. package/esm/sparkline/__stories__/SparklineGradient.stories.js +7 -4
  164. package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +2 -1
  165. package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +1 -1
  166. package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +51 -26
  167. package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +1 -1
  168. package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +19 -9
  169. package/package.json +13 -10
  170. package/esm/chart/__stories__/Chart.stories.js +0 -77
@@ -1,14 +1,13 @@
1
- const _excluded = ["seriesId", "curve", "type", "areaType", "areaBaseline", "stroke", "strokeOpacity", "showArea", "LineComponent", "AreaComponent", "opacity", "points", "connectNulls", "transition", "gradient"];
1
+ const _excluded = ["seriesId", "curve", "type", "areaType", "areaBaseline", "stroke", "strokeOpacity", "showArea", "LineComponent", "AreaComponent", "opacity", "points", "connectNulls", "transitions", "transition", "gradient"];
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
- import React, { memo, useEffect, useMemo } from 'react';
5
- import { useSharedValue, withDelay, withTiming } from 'react-native-reanimated';
4
+ import React, { memo, useMemo } from 'react';
6
5
  import { useTheme } from '@coinbase/cds-mobile';
7
6
  import { Group } from '@shopify/react-native-skia';
8
7
  import { Area } from '../area/Area';
9
8
  import { useCartesianChartContext } from '../ChartProvider';
10
9
  import { Point } from '../point';
11
- import { accessoryFadeTransitionDelay, accessoryFadeTransitionDuration, getLineData, getLinePath } from '../utils';
10
+ import { getLineData, getLinePath } from '../utils';
12
11
  import { evaluateGradientAtValue, getGradientStops } from '../utils/gradient';
13
12
  import { convertToSerializableScale } from '../utils/scale';
14
13
  import { DottedLine } from './DottedLine';
@@ -30,54 +29,54 @@ export const Line = /*#__PURE__*/memo(_ref => {
30
29
  opacity = 1,
31
30
  points,
32
31
  connectNulls,
32
+ transitions,
33
33
  transition,
34
34
  gradient: gradientProp
35
35
  } = _ref,
36
36
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
37
37
  const theme = useTheme();
38
38
  const {
39
+ layout,
39
40
  animate,
40
41
  getSeries,
41
42
  getSeriesData,
42
43
  getXScale,
43
44
  getYScale,
44
- getXAxis
45
+ getXAxis,
46
+ getYAxis
45
47
  } = useCartesianChartContext();
46
-
47
- // Animation state for delayed point rendering (matches web timing)
48
- const pointsOpacity = useSharedValue(animate ? 0 : 1);
49
-
50
- // Delay point appearance until after path enter animation completes
51
- useEffect(() => {
52
- if (animate) {
53
- pointsOpacity.value = withDelay(accessoryFadeTransitionDelay, withTiming(1, {
54
- duration: accessoryFadeTransitionDuration
55
- }));
56
- }
57
- }, [animate, pointsOpacity]);
58
48
  const matchedSeries = useMemo(() => getSeries(seriesId), [getSeries, seriesId]);
59
49
  const gradient = useMemo(() => gradientProp != null ? gradientProp : matchedSeries == null ? void 0 : matchedSeries.gradient, [gradientProp, matchedSeries == null ? void 0 : matchedSeries.gradient]);
60
50
  const sourceData = useMemo(() => getSeriesData(seriesId), [getSeriesData, seriesId]);
61
- const xAxis = useMemo(() => getXAxis(), [getXAxis]);
62
- const xScale = useMemo(() => getXScale(), [getXScale]);
51
+ const xAxis = useMemo(() => getXAxis(matchedSeries == null ? void 0 : matchedSeries.xAxisId), [getXAxis, matchedSeries == null ? void 0 : matchedSeries.xAxisId]);
52
+ const xScale = useMemo(() => getXScale(matchedSeries == null ? void 0 : matchedSeries.xAxisId), [getXScale, matchedSeries == null ? void 0 : matchedSeries.xAxisId]);
63
53
  const yScale = useMemo(() => getYScale(matchedSeries == null ? void 0 : matchedSeries.yAxisId), [getYScale, matchedSeries == null ? void 0 : matchedSeries.yAxisId]);
54
+ const yAxis = useMemo(() => getYAxis(matchedSeries == null ? void 0 : matchedSeries.yAxisId), [getYAxis, matchedSeries == null ? void 0 : matchedSeries.yAxisId]);
64
55
 
65
56
  // Convert sourceData to number array (line only supports numbers, not tuples)
66
57
  const chartData = useMemo(() => getLineData(sourceData), [sourceData]);
58
+ const categoryAxisIsX = useMemo(() => {
59
+ return layout !== 'horizontal';
60
+ }, [layout]);
61
+ const categoryAxis = useMemo(() => {
62
+ return categoryAxisIsX ? xAxis : yAxis;
63
+ }, [categoryAxisIsX, xAxis, yAxis]);
67
64
  const path = useMemo(() => {
68
65
  if (!xScale || !yScale || chartData.length === 0) return '';
69
66
 
70
- // Get numeric x-axis data if available
71
- const xData = xAxis != null && xAxis.data && Array.isArray(xAxis.data) && typeof xAxis.data[0] === 'number' ? xAxis.data : undefined;
67
+ // Get numeric category-axis data if available.
68
+ const indexData = categoryAxis != null && categoryAxis.data && Array.isArray(categoryAxis.data) && typeof categoryAxis.data[0] === 'number' ? categoryAxis.data : undefined;
72
69
  return getLinePath({
73
70
  data: chartData,
74
71
  xScale,
75
72
  yScale,
76
73
  curve,
77
- xData,
78
- connectNulls
74
+ xData: categoryAxisIsX ? indexData : undefined,
75
+ yData: !categoryAxisIsX ? indexData : undefined,
76
+ connectNulls,
77
+ layout
79
78
  });
80
- }, [chartData, xScale, yScale, curve, xAxis == null ? void 0 : xAxis.data, connectNulls]);
79
+ }, [xScale, yScale, chartData, categoryAxis, curve, categoryAxisIsX, connectNulls, layout]);
81
80
  const LineComponent = useMemo(() => {
82
81
  if (SelectedLineComponent) {
83
82
  return SelectedLineComponent;
@@ -92,10 +91,10 @@ export const Line = /*#__PURE__*/memo(_ref => {
92
91
 
93
92
  // Get series color for stroke
94
93
  const stroke = (_ref2 = strokeProp != null ? strokeProp : matchedSeries == null ? void 0 : matchedSeries.color) != null ? _ref2 : theme.color.fgPrimary;
95
- const xData = useMemo(() => {
96
- const data = xAxis == null ? void 0 : xAxis.data;
94
+ const categoryData = useMemo(() => {
95
+ const data = categoryAxis == null ? void 0 : categoryAxis.data;
97
96
  return data && Array.isArray(data) && data.length > 0 && typeof data[0] === 'number' ? data : null;
98
- }, [xAxis == null ? void 0 : xAxis.data]);
97
+ }, [categoryAxis]);
99
98
  const gradientConfig = useMemo(() => {
100
99
  if (!gradient || !xScale || !yScale) return;
101
100
  const gradientScale = gradient.axis === 'x' ? xScale : yScale;
@@ -123,6 +122,7 @@ export const Line = /*#__PURE__*/memo(_ref => {
123
122
  gradient: gradient,
124
123
  seriesId: seriesId,
125
124
  transition: transition,
125
+ transitions: transitions,
126
126
  type: areaType
127
127
  }), /*#__PURE__*/_jsx(LineComponent, _extends({
128
128
  d: path,
@@ -130,18 +130,19 @@ export const Line = /*#__PURE__*/memo(_ref => {
130
130
  stroke: stroke,
131
131
  strokeOpacity: strokeOpacity != null ? strokeOpacity : opacity,
132
132
  transition: transition,
133
+ transitions: transitions,
134
+ xAxisId: matchedSeries == null ? void 0 : matchedSeries.xAxisId,
133
135
  yAxisId: matchedSeries == null ? void 0 : matchedSeries.yAxisId
134
136
  }, props)), points && /*#__PURE__*/_jsx(Group, {
135
- opacity: pointsOpacity,
136
137
  children: chartData.map((value, index) => {
137
138
  if (value === null) return;
138
- const xValue = xData && xData[index] !== undefined ? xData[index] : index;
139
+ const indexValue = categoryData && categoryData[index] !== undefined ? categoryData[index] : index;
139
140
  let pointFill = stroke;
140
141
  if (gradientConfig && gradient) {
141
142
  var _gradient$axis;
142
- // Use the appropriate data value based on gradient axis
143
- const axis = (_gradient$axis = gradient.axis) != null ? _gradient$axis : 'y';
144
- const dataValue = axis === 'x' ? xValue : value;
143
+ // Match gradient sampling to the chart axis roles for each layout.
144
+ const gradientAxis = (_gradient$axis = gradient.axis) != null ? _gradient$axis : 'y';
145
+ const dataValue = gradientAxis === 'x' ? categoryAxisIsX ? indexValue : value : categoryAxisIsX ? value : indexValue;
145
146
  const evaluatedColor = evaluateGradientAtValue(gradientConfig.stops, dataValue, gradientConfig.scale);
146
147
  if (evaluatedColor) {
147
148
  // Apply gradient color to fill if not explicitly set
@@ -151,9 +152,10 @@ export const Line = /*#__PURE__*/memo(_ref => {
151
152
 
152
153
  // Build defaults that would be passed to Point
153
154
  const defaults = {
154
- dataX: xValue,
155
- dataY: value,
155
+ dataX: categoryAxisIsX ? indexValue : value,
156
+ dataY: categoryAxisIsX ? value : indexValue,
156
157
  fill: pointFill,
158
+ xAxisId: matchedSeries == null ? void 0 : matchedSeries.xAxisId,
157
159
  yAxisId: matchedSeries == null ? void 0 : matchedSeries.yAxisId,
158
160
  opacity
159
161
  };
@@ -161,8 +163,9 @@ export const Line = /*#__PURE__*/memo(_ref => {
161
163
  // If points is true, render with defaults
162
164
  if (points === true) {
163
165
  return /*#__PURE__*/_jsx(Point, _extends({
164
- transition: transition
165
- }, defaults), seriesId + "-" + xValue);
166
+ transition: transition,
167
+ transitions: transitions
168
+ }, defaults), seriesId + "-" + index);
166
169
  }
167
170
 
168
171
  // Call the function with defaults
@@ -170,8 +173,9 @@ export const Line = /*#__PURE__*/memo(_ref => {
170
173
  if (!result) return;
171
174
  const pointConfig = result === true ? {} : result;
172
175
  return /*#__PURE__*/_jsx(Point, _extends({
173
- transition: transition
174
- }, defaults, pointConfig), seriesId + "-" + xValue);
176
+ transition: transition,
177
+ transitions: transitions
178
+ }, defaults, pointConfig), seriesId + "-" + index);
175
179
  })
176
180
  })]
177
181
  });
@@ -1,16 +1,22 @@
1
- const _excluded = ["series", "showArea", "areaType", "type", "LineComponent", "AreaComponent", "curve", "points", "strokeWidth", "strokeOpacity", "connectNulls", "transition", "opacity", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children"],
2
- _excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range"],
1
+ const _excluded = ["series", "showArea", "areaType", "type", "LineComponent", "AreaComponent", "curve", "points", "strokeWidth", "strokeOpacity", "connectNulls", "transition", "transitions", "opacity", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "scrubberAccessibilityLabelStep", "layout", "children"],
2
+ _excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"],
3
3
  _excluded3 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"],
4
- _excluded4 = ["id", "data", "label", "color", "yAxisId"];
4
+ _excluded4 = ["id", "data", "label", "color", "xAxisId", "yAxisId"];
5
5
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
6
6
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
7
7
  import { forwardRef, memo, useMemo } from 'react';
8
8
  import { XAxis } from '../axis/XAxis';
9
9
  import { YAxis } from '../axis/YAxis';
10
10
  import { CartesianChart } from '../CartesianChart';
11
- import { defaultChartInset, getChartInset } from '../utils';
12
11
  import { Line } from './Line';
13
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ const getDefaultScrubberAccessibilityStep = function (dataLength, sampleCount) {
14
+ if (sampleCount === void 0) {
15
+ sampleCount = 10;
16
+ }
17
+ if (dataLength <= 0) return 1;
18
+ return Math.max(1, Math.ceil(dataLength / sampleCount));
19
+ };
14
20
  export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
15
21
  let {
16
22
  series,
@@ -25,17 +31,18 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
25
31
  strokeOpacity,
26
32
  connectNulls,
27
33
  transition,
34
+ transitions,
28
35
  opacity,
29
36
  showXAxis,
30
37
  showYAxis,
31
38
  xAxis,
32
39
  yAxis,
33
40
  inset,
41
+ scrubberAccessibilityLabelStep,
42
+ layout = 'vertical',
34
43
  children
35
44
  } = _ref,
36
45
  chartProps = _objectWithoutPropertiesLoose(_ref, _excluded);
37
- const calculatedInset = useMemo(() => getChartInset(inset, defaultChartInset), [inset]);
38
-
39
46
  // Convert LineSeries to Series for Chart context
40
47
  const chartSeries = useMemo(() => {
41
48
  return series == null ? void 0 : series.map(s => ({
@@ -43,9 +50,11 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
43
50
  data: s.data,
44
51
  label: s.label,
45
52
  color: s.color,
53
+ xAxisId: s.xAxisId,
46
54
  yAxisId: s.yAxisId,
47
55
  stackId: s.stackId,
48
- gradient: s.gradient
56
+ gradient: s.gradient,
57
+ legendShape: s.legendShape
49
58
  }));
50
59
  }, [series]);
51
60
 
@@ -57,7 +66,8 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
57
66
  categoryPadding: xCategoryPadding,
58
67
  domain: xDomain,
59
68
  domainLimit: xDomainLimit,
60
- range: xRange
69
+ range: xRange,
70
+ id: xAxisId
61
71
  } = _ref2,
62
72
  xAxisVisualProps = _objectWithoutPropertiesLoose(_ref2, _excluded2);
63
73
  const _ref3 = yAxis || {},
@@ -87,16 +97,29 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
87
97
  domainLimit: yDomainLimit,
88
98
  range: yRange
89
99
  };
100
+ const categoryAxisData = layout === 'horizontal' ? yData : xData;
101
+ const lineChartDataLength = useMemo(() => {
102
+ if (categoryAxisData && categoryAxisData.length > 0) return categoryAxisData.length;
103
+ if (!series || series.length === 0) return 0;
104
+ return series.reduce((max, s) => {
105
+ var _s$data$length, _s$data;
106
+ return Math.max(max, (_s$data$length = (_s$data = s.data) == null ? void 0 : _s$data.length) != null ? _s$data$length : 0);
107
+ }, 0);
108
+ }, [categoryAxisData, series]);
109
+ const resolvedScrubberAccessibilityLabelStep = useMemo(() => scrubberAccessibilityLabelStep != null ? scrubberAccessibilityLabelStep : getDefaultScrubberAccessibilityStep(lineChartDataLength), [scrubberAccessibilityLabelStep, lineChartDataLength]);
90
110
  return /*#__PURE__*/_jsxs(CartesianChart, _extends({}, chartProps, {
91
111
  ref: ref,
92
- inset: calculatedInset,
112
+ inset: inset,
113
+ layout: layout,
114
+ scrubberAccessibilityLabelStep: resolvedScrubberAccessibilityLabelStep,
93
115
  series: chartSeries,
94
116
  xAxis: xAxisConfig,
95
117
  yAxis: yAxisConfig,
96
- children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _extends({}, xAxisVisualProps)), showYAxis && /*#__PURE__*/_jsx(YAxis, _extends({
118
+ children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _extends({
119
+ axisId: xAxisId
120
+ }, xAxisVisualProps)), showYAxis && /*#__PURE__*/_jsx(YAxis, _extends({
97
121
  axisId: yAxisId
98
122
  }, yAxisVisualProps)), series == null ? void 0 : series.map(_ref4 => {
99
- var _linePropsFromSeries$;
100
123
  let {
101
124
  id
102
125
  } = _ref4,
@@ -113,7 +136,8 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
113
136
  showArea: showArea,
114
137
  strokeOpacity: strokeOpacity,
115
138
  strokeWidth: strokeWidth,
116
- transition: (_linePropsFromSeries$ = linePropsFromSeries.transition) != null ? _linePropsFromSeries$ : transition,
139
+ transition: transition,
140
+ transitions: transitions,
117
141
  type: type
118
142
  }, linePropsFromSeries), id);
119
143
  }), children]
@@ -1,4 +1,4 @@
1
- const _excluded = ["fill", "stroke", "strokeCap", "strokeJoin", "strokeOpacity", "strokeWidth", "gradient", "yAxisId", "d", "animate", "transition"];
1
+ const _excluded = ["fill", "stroke", "strokeCap", "strokeJoin", "strokeOpacity", "strokeWidth", "gradient", "xAxisId", "yAxisId", "d", "animate", "transitions", "transition"];
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
4
  import { memo } from 'react';
@@ -19,9 +19,11 @@ export const SolidLine = /*#__PURE__*/memo(_ref => {
19
19
  strokeOpacity = 1,
20
20
  strokeWidth = 2,
21
21
  gradient,
22
+ xAxisId,
22
23
  yAxisId,
23
24
  d,
24
25
  animate,
26
+ transitions,
25
27
  transition
26
28
  } = _ref,
27
29
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
@@ -36,10 +38,12 @@ export const SolidLine = /*#__PURE__*/memo(_ref => {
36
38
  strokeJoin: strokeJoin,
37
39
  strokeOpacity: strokeOpacity,
38
40
  strokeWidth: strokeWidth,
39
- transition: transition
41
+ transition: transition,
42
+ transitions: transitions
40
43
  }, props, {
41
44
  children: gradient && /*#__PURE__*/_jsx(Gradient, {
42
45
  gradient: gradient,
46
+ xAxisId: xAxisId,
43
47
  yAxisId: yAxisId
44
48
  })
45
49
  }));