@coinbase/cds-web-visualization 3.4.0-beta.9 → 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 (156) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/dts/chart/CartesianChart.d.ts +40 -4
  3. package/dts/chart/CartesianChart.d.ts.map +1 -1
  4. package/dts/chart/ChartProvider.d.ts +3 -0
  5. package/dts/chart/ChartProvider.d.ts.map +1 -1
  6. package/dts/chart/Path.d.ts +51 -12
  7. package/dts/chart/Path.d.ts.map +1 -1
  8. package/dts/chart/PeriodSelector.d.ts +25 -4
  9. package/dts/chart/PeriodSelector.d.ts.map +1 -1
  10. package/dts/chart/area/Area.d.ts +13 -11
  11. package/dts/chart/area/Area.d.ts.map +1 -1
  12. package/dts/chart/area/AreaChart.d.ts +18 -5
  13. package/dts/chart/area/AreaChart.d.ts.map +1 -1
  14. package/dts/chart/area/DottedArea.d.ts.map +1 -1
  15. package/dts/chart/area/GradientArea.d.ts.map +1 -1
  16. package/dts/chart/area/SolidArea.d.ts.map +1 -1
  17. package/dts/chart/axis/Axis.d.ts +29 -29
  18. package/dts/chart/axis/Axis.d.ts.map +1 -1
  19. package/dts/chart/axis/XAxis.d.ts +6 -0
  20. package/dts/chart/axis/XAxis.d.ts.map +1 -1
  21. package/dts/chart/axis/YAxis.d.ts +2 -1
  22. package/dts/chart/axis/YAxis.d.ts.map +1 -1
  23. package/dts/chart/bar/Bar.d.ts +51 -51
  24. package/dts/chart/bar/Bar.d.ts.map +1 -1
  25. package/dts/chart/bar/BarChart.d.ts +29 -6
  26. package/dts/chart/bar/BarChart.d.ts.map +1 -1
  27. package/dts/chart/bar/BarPlot.d.ts +2 -1
  28. package/dts/chart/bar/BarPlot.d.ts.map +1 -1
  29. package/dts/chart/bar/BarStack.d.ts +58 -20
  30. package/dts/chart/bar/BarStack.d.ts.map +1 -1
  31. package/dts/chart/bar/BarStackGroup.d.ts +2 -1
  32. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
  33. package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
  34. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
  35. package/dts/chart/gradient/Gradient.d.ts +7 -0
  36. package/dts/chart/gradient/Gradient.d.ts.map +1 -1
  37. package/dts/chart/index.d.ts +1 -0
  38. package/dts/chart/index.d.ts.map +1 -1
  39. package/dts/chart/legend/DefaultLegendEntry.d.ts +21 -0
  40. package/dts/chart/legend/DefaultLegendEntry.d.ts.map +1 -0
  41. package/dts/chart/legend/DefaultLegendShape.d.ts +7 -0
  42. package/dts/chart/legend/DefaultLegendShape.d.ts.map +1 -0
  43. package/dts/chart/legend/Legend.d.ts +169 -0
  44. package/dts/chart/legend/Legend.d.ts.map +1 -0
  45. package/dts/chart/legend/index.d.ts +4 -0
  46. package/dts/chart/legend/index.d.ts.map +1 -0
  47. package/dts/chart/line/DottedLine.d.ts.map +1 -1
  48. package/dts/chart/line/Line.d.ts +45 -24
  49. package/dts/chart/line/Line.d.ts.map +1 -1
  50. package/dts/chart/line/LineChart.d.ts +5 -3
  51. package/dts/chart/line/LineChart.d.ts.map +1 -1
  52. package/dts/chart/line/ReferenceLine.d.ts +9 -0
  53. package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
  54. package/dts/chart/line/SolidLine.d.ts.map +1 -1
  55. package/dts/chart/point/Point.d.ts +26 -2
  56. package/dts/chart/point/Point.d.ts.map +1 -1
  57. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +34 -17
  58. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -1
  59. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.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 +148 -46
  63. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
  64. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +10 -0
  65. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -1
  66. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +25 -1
  67. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -1
  68. package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -1
  69. package/dts/chart/text/ChartText.d.ts.map +1 -1
  70. package/dts/chart/utils/axis.d.ts +48 -9
  71. package/dts/chart/utils/axis.d.ts.map +1 -1
  72. package/dts/chart/utils/bar.d.ts +188 -0
  73. package/dts/chart/utils/bar.d.ts.map +1 -1
  74. package/dts/chart/utils/chart.d.ts +32 -0
  75. package/dts/chart/utils/chart.d.ts.map +1 -1
  76. package/dts/chart/utils/context.d.ts +20 -4
  77. package/dts/chart/utils/context.d.ts.map +1 -1
  78. package/dts/chart/utils/gradient.d.ts +3 -1
  79. package/dts/chart/utils/gradient.d.ts.map +1 -1
  80. package/dts/chart/utils/path.d.ts +26 -0
  81. package/dts/chart/utils/path.d.ts.map +1 -1
  82. package/dts/chart/utils/point.d.ts +18 -7
  83. package/dts/chart/utils/point.d.ts.map +1 -1
  84. package/dts/chart/utils/scale.d.ts +11 -0
  85. package/dts/chart/utils/scale.d.ts.map +1 -1
  86. package/dts/chart/utils/scrubber.d.ts +2 -1
  87. package/dts/chart/utils/scrubber.d.ts.map +1 -1
  88. package/dts/chart/utils/transition.d.ts +50 -14
  89. package/dts/chart/utils/transition.d.ts.map +1 -1
  90. package/dts/sparkline/Sparkline.d.ts +2 -1
  91. package/dts/sparkline/Sparkline.d.ts.map +1 -1
  92. package/dts/sparkline/SparklineArea.d.ts +2 -1
  93. package/dts/sparkline/SparklineArea.d.ts.map +1 -1
  94. package/dts/sparkline/SparklineGradient.d.ts +2 -1
  95. package/dts/sparkline/SparklineGradient.d.ts.map +1 -1
  96. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +2 -1
  97. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -1
  98. package/esm/chart/CartesianChart.js +154 -90
  99. package/esm/chart/ChartProvider.js +2 -2
  100. package/esm/chart/Path.js +35 -19
  101. package/esm/chart/PeriodSelector.js +33 -15
  102. package/esm/chart/area/Area.js +21 -9
  103. package/esm/chart/area/AreaChart.js +28 -25
  104. package/esm/chart/area/DottedArea.js +18 -9
  105. package/esm/chart/area/GradientArea.js +16 -8
  106. package/esm/chart/area/SolidArea.js +8 -3
  107. package/esm/chart/axis/Axis.js +3 -17
  108. package/esm/chart/axis/XAxis.js +153 -50
  109. package/esm/chart/axis/YAxis.js +146 -36
  110. package/esm/chart/bar/Bar.js +16 -8
  111. package/esm/chart/bar/BarChart.js +38 -33
  112. package/esm/chart/bar/BarPlot.js +20 -25
  113. package/esm/chart/bar/BarStack.js +109 -505
  114. package/esm/chart/bar/BarStackGroup.js +36 -27
  115. package/esm/chart/bar/DefaultBar.js +34 -26
  116. package/esm/chart/bar/DefaultBarStack.js +31 -18
  117. package/esm/chart/gradient/Gradient.js +3 -2
  118. package/esm/chart/index.js +1 -0
  119. package/esm/chart/legend/DefaultLegendEntry.css +1 -0
  120. package/esm/chart/legend/DefaultLegendEntry.js +50 -0
  121. package/esm/chart/legend/DefaultLegendShape.css +5 -0
  122. package/esm/chart/legend/DefaultLegendShape.js +47 -0
  123. package/esm/chart/legend/Legend.js +76 -0
  124. package/esm/chart/legend/index.js +3 -0
  125. package/esm/chart/line/DottedLine.js +7 -2
  126. package/esm/chart/line/Line.js +41 -42
  127. package/esm/chart/line/LineChart.js +18 -13
  128. package/esm/chart/line/ReferenceLine.js +6 -2
  129. package/esm/chart/line/SolidLine.js +8 -3
  130. package/esm/chart/point/Point.js +41 -24
  131. package/esm/chart/scrubber/DefaultScrubberBeacon.js +64 -65
  132. package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +25 -14
  133. package/esm/chart/scrubber/DefaultScrubberLabel.js +26 -8
  134. package/esm/chart/scrubber/Scrubber.js +54 -43
  135. package/esm/chart/scrubber/ScrubberBeaconGroup.js +60 -35
  136. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +31 -8
  137. package/esm/chart/scrubber/ScrubberProvider.js +44 -39
  138. package/esm/chart/text/ChartText.js +3 -2
  139. package/esm/chart/utils/axis.js +90 -43
  140. package/esm/chart/utils/bar.js +863 -0
  141. package/esm/chart/utils/chart.js +34 -7
  142. package/esm/chart/utils/context.js +7 -0
  143. package/esm/chart/utils/gradient.js +6 -4
  144. package/esm/chart/utils/path.js +88 -61
  145. package/esm/chart/utils/point.js +57 -30
  146. package/esm/chart/utils/scale.js +13 -2
  147. package/esm/chart/utils/scrubber.js +9 -4
  148. package/esm/chart/utils/transition.js +68 -41
  149. package/esm/sparkline/Sparkline.js +2 -1
  150. package/esm/sparkline/SparklineArea.js +2 -1
  151. package/esm/sparkline/SparklineGradient.js +2 -1
  152. package/esm/sparkline/__figma__/Sparkline.figma.js +1 -1
  153. package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +2 -1
  154. package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +1 -1
  155. package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +1 -1
  156. package/package.json +8 -7
@@ -1,4 +1,4 @@
1
- const _excluded = ["seriesId", "curve", "type", "areaType", "areaBaseline", "stroke", "strokeOpacity", "onPointClick", "showArea", "LineComponent", "AreaComponent", "opacity", "points", "connectNulls", "transition", "gradient"];
1
+ const _excluded = ["seriesId", "curve", "type", "areaType", "areaBaseline", "stroke", "strokeOpacity", "onPointClick", "showArea", "LineComponent", "AreaComponent", "opacity", "points", "connectNulls", "transitions", "transition", "gradient"];
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -7,11 +7,10 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
7
7
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
8
8
  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; }
9
9
  import React, { memo, useMemo } from 'react';
10
- import { m as motion } from 'framer-motion';
11
10
  import { Area } from '../area/Area';
12
11
  import { useCartesianChartContext } from '../ChartProvider';
13
12
  import { Point } from '../point';
14
- import { accessoryFadeTransitionDelay, accessoryFadeTransitionDuration, evaluateGradientAtValue, getGradientConfig, getLineData, getLinePath } from '../utils';
13
+ import { evaluateGradientAtValue, getGradientConfig, getLineData, getLinePath } from '../utils';
15
14
  import { DottedLine } from './DottedLine';
16
15
  import { SolidLine } from './SolidLine';
17
16
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
@@ -32,11 +31,13 @@ export const Line = /*#__PURE__*/memo(_ref => {
32
31
  opacity = 1,
33
32
  points,
34
33
  connectNulls,
34
+ transitions,
35
35
  transition,
36
36
  gradient: gradientProp
37
37
  } = _ref,
38
38
  props = _objectWithoutProperties(_ref, _excluded);
39
39
  const {
40
+ layout,
40
41
  animate,
41
42
  getSeries,
42
43
  getSeriesData,
@@ -48,26 +49,36 @@ export const Line = /*#__PURE__*/memo(_ref => {
48
49
  const matchedSeries = useMemo(() => getSeries(seriesId), [getSeries, seriesId]);
49
50
  const gradient = useMemo(() => gradientProp !== null && gradientProp !== void 0 ? gradientProp : matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.gradient, [gradientProp, matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.gradient]);
50
51
  const sourceData = useMemo(() => getSeriesData(seriesId), [getSeriesData, seriesId]);
51
- const xAxis = useMemo(() => getXAxis(), [getXAxis]);
52
- const xScale = useMemo(() => getXScale(), [getXScale]);
52
+ const xAxis = useMemo(() => getXAxis(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.xAxisId), [getXAxis, matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.xAxisId]);
53
+ const xScale = useMemo(() => getXScale(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.xAxisId), [getXScale, matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.xAxisId]);
53
54
  const yScale = useMemo(() => getYScale(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId), [getYScale, matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId]);
55
+ const yAxis = useMemo(() => getYAxis(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId), [getYAxis, matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId]);
54
56
 
55
57
  // Convert sourceData to number array (line only supports numbers, not tuples)
56
58
  const chartData = useMemo(() => getLineData(sourceData), [sourceData]);
59
+ const categoryAxisIsX = useMemo(() => {
60
+ return layout !== 'horizontal';
61
+ }, [layout]);
62
+ const categoryAxis = useMemo(() => {
63
+ return categoryAxisIsX ? xAxis : yAxis;
64
+ }, [categoryAxisIsX, xAxis, yAxis]);
57
65
  const path = useMemo(() => {
58
66
  if (!xScale || !yScale || chartData.length === 0) return '';
59
67
 
60
- // Get numeric x-axis data if available
61
- const xData = xAxis !== null && xAxis !== void 0 && xAxis.data && Array.isArray(xAxis.data) && typeof xAxis.data[0] === 'number' ? xAxis.data : undefined;
68
+ // Get numeric category-axis data if available
69
+ const indexAxis = categoryAxis;
70
+ const indexData = indexAxis !== null && indexAxis !== void 0 && indexAxis.data && Array.isArray(indexAxis.data) && typeof indexAxis.data[0] === 'number' ? indexAxis.data : undefined;
62
71
  return getLinePath({
63
72
  data: chartData,
64
73
  xScale,
65
74
  yScale,
66
75
  curve,
67
- xData,
68
- connectNulls
76
+ xData: categoryAxisIsX ? indexData : undefined,
77
+ yData: !categoryAxisIsX ? indexData : undefined,
78
+ connectNulls,
79
+ layout
69
80
  });
70
- }, [chartData, xScale, yScale, curve, xAxis === null || xAxis === void 0 ? void 0 : xAxis.data, connectNulls]);
81
+ }, [xScale, yScale, chartData, categoryAxis, curve, categoryAxisIsX, connectNulls, layout]);
71
82
  const LineComponent = useMemo(() => {
72
83
  if (SelectedLineComponent) {
73
84
  return SelectedLineComponent;
@@ -82,10 +93,10 @@ export const Line = /*#__PURE__*/memo(_ref => {
82
93
 
83
94
  // Get series color for stroke
84
95
  const stroke = (_ref2 = strokeProp !== null && strokeProp !== void 0 ? strokeProp : matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.color) !== null && _ref2 !== void 0 ? _ref2 : 'var(--color-fgPrimary)';
85
- const xData = useMemo(() => {
86
- const data = xAxis === null || xAxis === void 0 ? void 0 : xAxis.data;
96
+ const categoryData = useMemo(() => {
97
+ const data = categoryAxis === null || categoryAxis === void 0 ? void 0 : categoryAxis.data;
87
98
  return data && Array.isArray(data) && data.length > 0 && typeof data[0] === 'number' ? data : null;
88
- }, [xAxis === null || xAxis === void 0 ? void 0 : xAxis.data]);
99
+ }, [categoryAxis]);
89
100
  const gradientConfig = useMemo(() => {
90
101
  if (!gradient || !xScale || !yScale) return;
91
102
  const gradientScale = gradient.axis === 'x' ? xScale : yScale;
@@ -108,6 +119,7 @@ export const Line = /*#__PURE__*/memo(_ref => {
108
119
  gradient: gradient,
109
120
  seriesId: seriesId,
110
121
  transition: transition,
122
+ transitions: transitions,
111
123
  type: areaType
112
124
  }), /*#__PURE__*/_jsx(LineComponent, _objectSpread({
113
125
  d: path,
@@ -115,37 +127,21 @@ export const Line = /*#__PURE__*/memo(_ref => {
115
127
  stroke: stroke,
116
128
  strokeOpacity: strokeOpacity !== null && strokeOpacity !== void 0 ? strokeOpacity : opacity,
117
129
  transition: transition,
130
+ transitions: transitions,
131
+ xAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.xAxisId,
118
132
  yAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId
119
- }, props)), points && /*#__PURE__*/_jsx(motion.g, _objectSpread(_objectSpread({
120
- "data-component": "line-points-group"
121
- }, animate ? {
122
- animate: {
123
- opacity: 1,
124
- transition: {
125
- duration: accessoryFadeTransitionDuration,
126
- delay: accessoryFadeTransitionDelay
127
- }
128
- },
129
- exit: {
130
- opacity: 0,
131
- transition: {
132
- duration: accessoryFadeTransitionDuration
133
- }
134
- },
135
- initial: {
136
- opacity: 0
137
- }
138
- } : {}), {}, {
133
+ }, props)), points && /*#__PURE__*/_jsx("g", {
134
+ "data-component": "line-points-group",
139
135
  children: chartData.map((value, index) => {
140
136
  var _pointConfig$onClick;
141
137
  if (value === null) return;
142
- const xValue = xData && xData[index] !== undefined ? xData[index] : index;
138
+ const indexValue = categoryData && categoryData[index] !== undefined ? categoryData[index] : index;
143
139
  let pointFill = stroke;
144
140
  if (gradientConfig && gradient) {
145
141
  var _gradient$axis;
146
- // Use the appropriate data value based on gradient axis
147
- const axis = (_gradient$axis = gradient.axis) !== null && _gradient$axis !== void 0 ? _gradient$axis : 'y';
148
- const dataValue = axis === 'x' ? xValue : value;
142
+ // Match gradient sampling to the chart axis roles for each layout.
143
+ const gradientAxis = (_gradient$axis = gradient.axis) !== null && _gradient$axis !== void 0 ? _gradient$axis : 'y';
144
+ const dataValue = gradientAxis === 'x' ? categoryAxisIsX ? indexValue : value : categoryAxisIsX ? value : indexValue;
149
145
  const evaluatedColor = evaluateGradientAtValue(gradientConfig.stops, dataValue, gradientConfig.scale);
150
146
  if (evaluatedColor) {
151
147
  // Apply gradient color to fill if not explicitly set
@@ -155,9 +151,10 @@ export const Line = /*#__PURE__*/memo(_ref => {
155
151
 
156
152
  // Build defaults that would be passed to Point
157
153
  const defaults = {
158
- dataX: xValue,
159
- dataY: value,
154
+ dataX: categoryAxisIsX ? indexValue : value,
155
+ dataY: categoryAxisIsX ? value : indexValue,
160
156
  fill: pointFill,
157
+ xAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.xAxisId,
161
158
  yAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId,
162
159
  opacity,
163
160
  testID: undefined
@@ -167,7 +164,8 @@ export const Line = /*#__PURE__*/memo(_ref => {
167
164
  if (points === true) {
168
165
  return /*#__PURE__*/_jsx(Point, _objectSpread({
169
166
  onClick: onPointClick,
170
- transition: transition
167
+ transition: transition,
168
+ transitions: transitions
171
169
  }, defaults), "".concat(seriesId, "-").concat(index));
172
170
  }
173
171
 
@@ -177,9 +175,10 @@ export const Line = /*#__PURE__*/memo(_ref => {
177
175
  const pointConfig = result === true ? {} : result;
178
176
  return /*#__PURE__*/_jsx(Point, _objectSpread(_objectSpread({
179
177
  onClick: (_pointConfig$onClick = pointConfig.onClick) !== null && _pointConfig$onClick !== void 0 ? _pointConfig$onClick : onPointClick,
180
- transition: transition
178
+ transition: transition,
179
+ transitions: transitions
181
180
  }, defaults), pointConfig), "".concat(seriesId, "-").concat(index));
182
181
  })
183
- }))]
182
+ })]
184
183
  });
185
184
  });
@@ -1,7 +1,7 @@
1
- const _excluded = ["series", "showArea", "areaType", "type", "onPointClick", "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", "onPointClick", "LineComponent", "AreaComponent", "curve", "points", "strokeWidth", "strokeOpacity", "connectNulls", "transitions", "transition", "opacity", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "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", "legendShape"];
5
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -13,7 +13,6 @@ import { forwardRef, memo, useMemo } from 'react';
13
13
  import { XAxis } from '../axis/XAxis';
14
14
  import { YAxis } from '../axis/YAxis';
15
15
  import { CartesianChart } from '../CartesianChart';
16
- import { defaultChartInset, getChartInset } from '../utils';
17
16
  import { Line } from './Line';
18
17
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
18
  export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
@@ -30,6 +29,7 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
30
29
  strokeWidth,
31
30
  strokeOpacity,
32
31
  connectNulls,
32
+ transitions,
33
33
  transition,
34
34
  opacity,
35
35
  showXAxis,
@@ -40,8 +40,6 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
40
40
  children
41
41
  } = _ref,
42
42
  chartProps = _objectWithoutProperties(_ref, _excluded);
43
- const calculatedInset = useMemo(() => getChartInset(inset, defaultChartInset), [inset]);
44
-
45
43
  // Convert LineSeries to Series for Chart context
46
44
  const chartSeries = useMemo(() => {
47
45
  return series === null || series === void 0 ? void 0 : series.map(s => ({
@@ -49,9 +47,11 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
49
47
  data: s.data,
50
48
  label: s.label,
51
49
  color: s.color,
50
+ xAxisId: s.xAxisId,
52
51
  yAxisId: s.yAxisId,
53
52
  stackId: s.stackId,
54
- gradient: s.gradient
53
+ gradient: s.gradient,
54
+ legendShape: s.legendShape
55
55
  }));
56
56
  }, [series]);
57
57
 
@@ -63,7 +63,8 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
63
63
  categoryPadding: xCategoryPadding,
64
64
  domain: xDomain,
65
65
  domainLimit: xDomainLimit,
66
- range: xRange
66
+ range: xRange,
67
+ id: xAxisId
67
68
  } = _ref2,
68
69
  xAxisVisualProps = _objectWithoutProperties(_ref2, _excluded2);
69
70
  const _ref3 = yAxis || {},
@@ -95,20 +96,23 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
95
96
  };
96
97
  return /*#__PURE__*/_jsxs(CartesianChart, _objectSpread(_objectSpread({}, chartProps), {}, {
97
98
  ref: ref,
98
- inset: calculatedInset,
99
+ inset: inset,
99
100
  series: chartSeries,
100
101
  xAxis: xAxisConfig,
101
102
  yAxis: yAxisConfig,
102
- children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _objectSpread({}, xAxisVisualProps)), showYAxis && /*#__PURE__*/_jsx(YAxis, _objectSpread({
103
+ children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _objectSpread({
104
+ axisId: xAxisId
105
+ }, xAxisVisualProps)), showYAxis && /*#__PURE__*/_jsx(YAxis, _objectSpread({
103
106
  axisId: yAxisId
104
107
  }, yAxisVisualProps)), series === null || series === void 0 ? void 0 : series.map(_ref4 => {
105
- var _linePropsFromSeries$;
106
108
  let {
107
109
  id,
108
110
  data,
109
111
  label,
110
112
  color,
111
- yAxisId
113
+ xAxisId,
114
+ yAxisId,
115
+ legendShape
112
116
  } = _ref4,
113
117
  linePropsFromSeries = _objectWithoutProperties(_ref4, _excluded4);
114
118
  return /*#__PURE__*/_jsx(Line, _objectSpread({
@@ -124,7 +128,8 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
124
128
  showArea: showArea,
125
129
  strokeOpacity: strokeOpacity,
126
130
  strokeWidth: strokeWidth,
127
- transition: (_linePropsFromSeries$ = linePropsFromSeries.transition) !== null && _linePropsFromSeries$ !== void 0 ? _linePropsFromSeries$ : transition,
131
+ transition: transition,
132
+ transitions: transitions,
128
133
  type: type
129
134
  }, linePropsFromSeries), id);
130
135
  }), children]
@@ -69,9 +69,11 @@ export const ReferenceLine = /*#__PURE__*/memo(_ref => {
69
69
  style: rootStyle,
70
70
  children: [/*#__PURE__*/_jsx(LineComponent, {
71
71
  animate: false,
72
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.line,
72
73
  d: "M".concat(drawingArea.x, ",").concat(yPixel, " L").concat(drawingArea.x + drawingArea.width, ",").concat(yPixel),
73
74
  stroke: stroke,
74
- strokeOpacity: opacity
75
+ strokeOpacity: opacity,
76
+ style: styles === null || styles === void 0 ? void 0 : styles.line
75
77
  }), label && /*#__PURE__*/_jsx(LabelComponent, {
76
78
  boundsInset: labelBoundsInset,
77
79
  className: classNames === null || classNames === void 0 ? void 0 : classNames.label,
@@ -115,9 +117,11 @@ export const ReferenceLine = /*#__PURE__*/memo(_ref => {
115
117
  style: rootStyle,
116
118
  children: [/*#__PURE__*/_jsx(LineComponent, {
117
119
  animate: false,
120
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.line,
118
121
  d: "M".concat(xPixel, ",").concat(drawingArea.y, " L").concat(xPixel, ",").concat(drawingArea.y + drawingArea.height),
119
122
  stroke: stroke,
120
- strokeOpacity: opacity
123
+ strokeOpacity: opacity,
124
+ style: styles === null || styles === void 0 ? void 0 : styles.line
121
125
  }), label && /*#__PURE__*/_jsx(LabelComponent, {
122
126
  boundsInset: labelBoundsInset,
123
127
  className: classNames === null || classNames === void 0 ? void 0 : classNames.label,
@@ -1,4 +1,4 @@
1
- const _excluded = ["fill", "stroke", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "gradient", "yAxisId", "animate", "transition", "d"];
1
+ const _excluded = ["fill", "stroke", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "gradient", "xAxisId", "yAxisId", "animate", "transitions", "transition", "d"];
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -15,6 +15,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
15
15
  * Supports gradient for gradient effects and smooth data transitions.
16
16
  */
17
17
  export const SolidLine = /*#__PURE__*/memo(_ref => {
18
+ var _transitions$update;
18
19
  let {
19
20
  fill = 'none',
20
21
  stroke = 'var(--color-fgPrimary)',
@@ -23,8 +24,10 @@ export const SolidLine = /*#__PURE__*/memo(_ref => {
23
24
  strokeOpacity = 1,
24
25
  strokeWidth = 2,
25
26
  gradient,
27
+ xAxisId,
26
28
  yAxisId,
27
29
  animate,
30
+ transitions,
28
31
  transition,
29
32
  d
30
33
  } = _ref,
@@ -36,7 +39,8 @@ export const SolidLine = /*#__PURE__*/memo(_ref => {
36
39
  animate: animate,
37
40
  gradient: gradient,
38
41
  id: gradientId,
39
- transition: transition,
42
+ transition: (_transitions$update = transitions === null || transitions === void 0 ? void 0 : transitions.update) !== null && _transitions$update !== void 0 ? _transitions$update : transition,
43
+ xAxisId: xAxisId,
40
44
  yAxisId: yAxisId
41
45
  })
42
46
  }), /*#__PURE__*/_jsx(Path, _objectSpread({
@@ -49,7 +53,8 @@ export const SolidLine = /*#__PURE__*/memo(_ref => {
49
53
  strokeLinejoin: strokeLinejoin,
50
54
  strokeOpacity: strokeOpacity,
51
55
  strokeWidth: strokeWidth,
52
- transition: transition
56
+ transition: transition,
57
+ transitions: transitions
53
58
  }, props))]
54
59
  });
55
60
  });
@@ -1,4 +1,4 @@
1
- const _excluded = ["dataX", "dataY", "yAxisId", "fill", "radius", "opacity", "onClick", "className", "style", "classNames", "styles", "stroke", "strokeWidth", "accessibilityLabel", "label", "LabelComponent", "labelPosition", "labelOffset", "labelFont", "testID", "animate", "transition"];
1
+ const _excluded = ["dataX", "dataY", "xAxisId", "yAxisId", "fill", "radius", "opacity", "onClick", "className", "style", "classNames", "styles", "stroke", "strokeWidth", "accessibilityLabel", "label", "LabelComponent", "labelPosition", "labelOffset", "labelFont", "testID", "animate", "transitions", "transition"];
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -10,7 +10,7 @@ import React, { memo, useMemo } from 'react';
10
10
  import { cx } from '@coinbase/cds-web';
11
11
  import { m as motion } from 'framer-motion';
12
12
  import { useCartesianChartContext } from '../ChartProvider';
13
- import { projectPoint } from '../utils';
13
+ import { defaultAccessoryEnterTransition, defaultTransition, getTransition, projectPoint } from '../utils';
14
14
  import { DefaultPointLabel } from './DefaultPointLabel';
15
15
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
16
  const containerCss = "cds-containerCss-ckemp0e";
@@ -24,6 +24,7 @@ export const Point = /*#__PURE__*/memo(_ref => {
24
24
  let {
25
25
  dataX,
26
26
  dataY,
27
+ xAxisId,
27
28
  yAxisId,
28
29
  fill = 'var(--color-fgPrimary)',
29
30
  radius = 5,
@@ -43,6 +44,7 @@ export const Point = /*#__PURE__*/memo(_ref => {
43
44
  labelFont,
44
45
  testID,
45
46
  animate: animateProp,
47
+ transitions,
46
48
  transition
47
49
  } = _ref,
48
50
  svgProps = _objectWithoutProperties(_ref, _excluded);
@@ -53,7 +55,9 @@ export const Point = /*#__PURE__*/memo(_ref => {
53
55
  drawingArea
54
56
  } = useCartesianChartContext();
55
57
  const animate = animateProp !== null && animateProp !== void 0 ? animateProp : animationEnabled;
56
- const xScale = getXScale();
58
+ const enterTransition = useMemo(() => getTransition(transitions === null || transitions === void 0 ? void 0 : transitions.enter, animate, defaultAccessoryEnterTransition), [animate, transitions === null || transitions === void 0 ? void 0 : transitions.enter]);
59
+ const updateTransition = useMemo(() => getTransition((transitions === null || transitions === void 0 ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), [animate, transitions === null || transitions === void 0 ? void 0 : transitions.update, transition]);
60
+ const xScale = getXScale(xAxisId);
57
61
  const yScale = getYScale(yAxisId);
58
62
  const pixelCoordinate = useMemo(() => {
59
63
  if (!xScale || !yScale) {
@@ -133,7 +137,6 @@ export const Point = /*#__PURE__*/memo(_ref => {
133
137
  cx: pixelCoordinate.x,
134
138
  cy: pixelCoordinate.y,
135
139
  fill: fill,
136
- initial: false,
137
140
  onClick: onClick ? event => onClick(event, {
138
141
  dataX,
139
142
  dataY,
@@ -147,34 +150,48 @@ export const Point = /*#__PURE__*/memo(_ref => {
147
150
  strokeWidth: strokeWidth,
148
151
  style: mergedStyles,
149
152
  tabIndex: onClick ? 0 : -1,
150
- transition: transition,
153
+ transition: {
154
+ cx: updateTransition,
155
+ cy: updateTransition
156
+ },
151
157
  variants: variants,
152
158
  whileHover: onClick ? 'hovered' : 'default',
153
159
  whileTap: onClick ? 'pressed' : 'default'
154
160
  }, svgProps));
155
- }, [style, styles === null || styles === void 0 ? void 0 : styles.point, classNames === null || classNames === void 0 ? void 0 : classNames.point, fill, animate, radius, className, onClick, stroke, strokeWidth, svgProps, dataX, dataY, pixelCoordinate.x, pixelCoordinate.y, accessibilityLabel, transition]);
161
+ }, [style, styles === null || styles === void 0 ? void 0 : styles.point, classNames === null || classNames === void 0 ? void 0 : classNames.point, fill, animate, radius, className, onClick, stroke, strokeWidth, svgProps, dataX, dataY, pixelCoordinate.x, pixelCoordinate.y, accessibilityLabel, updateTransition]);
156
162
  if (!xScale || !yScale) {
157
163
  return;
158
164
  }
159
- return /*#__PURE__*/_jsxs("g", {
165
+ return /*#__PURE__*/_jsx("g", {
160
166
  opacity: isWithinDrawingArea ? 1 : 0,
161
- children: [/*#__PURE__*/_jsx("g", {
162
- className: cx(containerCss, classNames === null || classNames === void 0 ? void 0 : classNames.root),
163
- "data-testid": testID,
164
- opacity: opacity,
165
- style: styles === null || styles === void 0 ? void 0 : styles.root,
166
- children: innerPoint
167
- }), label && /*#__PURE__*/_jsx(LabelComponent, {
168
- dataX: dataX,
169
- dataY: dataY,
170
- fill: fill,
171
- font: labelFont,
172
- offset: labelOffset,
173
- position: labelPosition,
174
- x: pixelCoordinate.x,
175
- y: pixelCoordinate.y,
176
- children: label
177
- })]
167
+ children: /*#__PURE__*/_jsxs(motion.g, {
168
+ animate: {
169
+ opacity: 1
170
+ },
171
+ initial: animate ? {
172
+ opacity: 0
173
+ } : false,
174
+ transition: {
175
+ opacity: enterTransition
176
+ },
177
+ children: [/*#__PURE__*/_jsx("g", {
178
+ className: cx(containerCss, classNames === null || classNames === void 0 ? void 0 : classNames.root),
179
+ "data-testid": testID,
180
+ opacity: opacity,
181
+ style: styles === null || styles === void 0 ? void 0 : styles.root,
182
+ children: innerPoint
183
+ }), label && /*#__PURE__*/_jsx(LabelComponent, {
184
+ dataX: dataX,
185
+ dataY: dataY,
186
+ fill: fill,
187
+ font: labelFont,
188
+ offset: labelOffset,
189
+ position: labelPosition,
190
+ x: pixelCoordinate.x,
191
+ y: pixelCoordinate.y,
192
+ children: label
193
+ })]
194
+ })
178
195
  });
179
196
  });
180
197
  import "./Point.css";