@coinbase/cds-web-visualization 3.4.0-beta.1 → 3.4.0-beta.11

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 (175) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dts/chart/CartesianChart.d.ts +38 -2
  3. package/dts/chart/CartesianChart.d.ts.map +1 -1
  4. package/dts/chart/Path.d.ts +27 -7
  5. package/dts/chart/Path.d.ts.map +1 -1
  6. package/dts/chart/PeriodSelector.d.ts +0 -4
  7. package/dts/chart/PeriodSelector.d.ts.map +1 -1
  8. package/dts/chart/area/Area.d.ts +54 -24
  9. package/dts/chart/area/Area.d.ts.map +1 -1
  10. package/dts/chart/area/AreaChart.d.ts +33 -6
  11. package/dts/chart/area/AreaChart.d.ts.map +1 -1
  12. package/dts/chart/area/DottedArea.d.ts +21 -44
  13. package/dts/chart/area/DottedArea.d.ts.map +1 -1
  14. package/dts/chart/area/GradientArea.d.ts +21 -12
  15. package/dts/chart/area/GradientArea.d.ts.map +1 -1
  16. package/dts/chart/area/SolidArea.d.ts +16 -1
  17. package/dts/chart/area/SolidArea.d.ts.map +1 -1
  18. package/dts/chart/axis/Axis.d.ts +109 -63
  19. package/dts/chart/axis/Axis.d.ts.map +1 -1
  20. package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
  21. package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
  22. package/dts/chart/axis/XAxis.d.ts +1 -1
  23. package/dts/chart/axis/XAxis.d.ts.map +1 -1
  24. package/dts/chart/axis/YAxis.d.ts +2 -2
  25. package/dts/chart/axis/YAxis.d.ts.map +1 -1
  26. package/dts/chart/axis/index.d.ts +1 -0
  27. package/dts/chart/axis/index.d.ts.map +1 -1
  28. package/dts/chart/bar/Bar.d.ts +16 -13
  29. package/dts/chart/bar/Bar.d.ts.map +1 -1
  30. package/dts/chart/bar/BarChart.d.ts +17 -8
  31. package/dts/chart/bar/BarChart.d.ts.map +1 -1
  32. package/dts/chart/bar/BarPlot.d.ts +2 -1
  33. package/dts/chart/bar/BarPlot.d.ts.map +1 -1
  34. package/dts/chart/bar/BarStack.d.ts +40 -48
  35. package/dts/chart/bar/BarStack.d.ts.map +1 -1
  36. package/dts/chart/bar/BarStackGroup.d.ts +1 -0
  37. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
  38. package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
  39. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
  40. package/dts/chart/gradient/Gradient.d.ts +35 -0
  41. package/dts/chart/gradient/Gradient.d.ts.map +1 -0
  42. package/dts/chart/gradient/index.d.ts +2 -0
  43. package/dts/chart/gradient/index.d.ts.map +1 -0
  44. package/dts/chart/index.d.ts +2 -1
  45. package/dts/chart/index.d.ts.map +1 -1
  46. package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
  47. package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
  48. package/dts/chart/line/DottedLine.d.ts +15 -3
  49. package/dts/chart/line/DottedLine.d.ts.map +1 -1
  50. package/dts/chart/line/Line.d.ts +87 -28
  51. package/dts/chart/line/Line.d.ts.map +1 -1
  52. package/dts/chart/line/LineChart.d.ts +26 -8
  53. package/dts/chart/line/LineChart.d.ts.map +1 -1
  54. package/dts/chart/line/ReferenceLine.d.ts +91 -44
  55. package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
  56. package/dts/chart/line/SolidLine.d.ts +14 -3
  57. package/dts/chart/line/SolidLine.d.ts.map +1 -1
  58. package/dts/chart/line/index.d.ts +1 -1
  59. package/dts/chart/line/index.d.ts.map +1 -1
  60. package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
  61. package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
  62. package/dts/chart/point/Point.d.ts +201 -0
  63. package/dts/chart/point/Point.d.ts.map +1 -0
  64. package/dts/chart/point/index.d.ts +3 -0
  65. package/dts/chart/point/index.d.ts.map +1 -0
  66. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +24 -0
  67. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
  68. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
  69. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
  70. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +10 -0
  71. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
  72. package/dts/chart/scrubber/Scrubber.d.ts +207 -66
  73. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
  74. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +70 -0
  75. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
  76. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +32 -0
  77. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
  78. package/dts/chart/scrubber/index.d.ts +3 -0
  79. package/dts/chart/scrubber/index.d.ts.map +1 -1
  80. package/dts/chart/text/ChartText.d.ts +46 -43
  81. package/dts/chart/text/ChartText.d.ts.map +1 -1
  82. package/dts/chart/text/{SmartChartTextGroup.d.ts → ChartTextGroup.d.ts} +9 -3
  83. package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
  84. package/dts/chart/text/index.d.ts +1 -1
  85. package/dts/chart/text/index.d.ts.map +1 -1
  86. package/dts/chart/utils/axis.d.ts +25 -1
  87. package/dts/chart/utils/axis.d.ts.map +1 -1
  88. package/dts/chart/utils/chart.d.ts +27 -7
  89. package/dts/chart/utils/chart.d.ts.map +1 -1
  90. package/dts/chart/utils/context.d.ts +6 -0
  91. package/dts/chart/utils/context.d.ts.map +1 -1
  92. package/dts/chart/utils/gradient.d.ts +104 -0
  93. package/dts/chart/utils/gradient.d.ts.map +1 -0
  94. package/dts/chart/utils/index.d.ts +4 -0
  95. package/dts/chart/utils/index.d.ts.map +1 -1
  96. package/dts/chart/utils/interpolate.d.ts +112 -0
  97. package/dts/chart/utils/interpolate.d.ts.map +1 -0
  98. package/dts/chart/utils/path.d.ts +24 -1
  99. package/dts/chart/utils/path.d.ts.map +1 -1
  100. package/dts/chart/utils/point.d.ts +40 -7
  101. package/dts/chart/utils/point.d.ts.map +1 -1
  102. package/dts/chart/utils/scale.d.ts +11 -0
  103. package/dts/chart/utils/scale.d.ts.map +1 -1
  104. package/dts/chart/utils/scrubber.d.ts +39 -0
  105. package/dts/chart/utils/scrubber.d.ts.map +1 -0
  106. package/dts/chart/utils/transition.d.ts +65 -0
  107. package/dts/chart/utils/transition.d.ts.map +1 -0
  108. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts.map +1 -1
  109. package/esm/chart/CartesianChart.js +140 -85
  110. package/esm/chart/Path.js +53 -47
  111. package/esm/chart/PeriodSelector.js +4 -18
  112. package/esm/chart/area/Area.js +24 -34
  113. package/esm/chart/area/AreaChart.js +24 -15
  114. package/esm/chart/area/DottedArea.js +35 -89
  115. package/esm/chart/area/GradientArea.js +34 -80
  116. package/esm/chart/area/SolidArea.js +29 -11
  117. package/esm/chart/axis/Axis.js +4 -39
  118. package/esm/chart/axis/DefaultAxisTickLabel.js +15 -0
  119. package/esm/chart/axis/XAxis.js +184 -63
  120. package/esm/chart/axis/YAxis.js +190 -57
  121. package/esm/chart/axis/index.js +1 -0
  122. package/esm/chart/bar/Bar.js +3 -1
  123. package/esm/chart/bar/BarChart.js +15 -32
  124. package/esm/chart/bar/BarPlot.js +3 -2
  125. package/esm/chart/bar/BarStack.js +65 -23
  126. package/esm/chart/bar/BarStackGroup.js +7 -17
  127. package/esm/chart/bar/DefaultBar.js +4 -7
  128. package/esm/chart/bar/DefaultBarStack.js +5 -7
  129. package/esm/chart/gradient/Gradient.js +104 -0
  130. package/esm/chart/gradient/index.js +1 -0
  131. package/esm/chart/index.js +2 -1
  132. package/esm/chart/line/DefaultReferenceLineLabel.js +81 -0
  133. package/esm/chart/line/DottedLine.js +38 -17
  134. package/esm/chart/line/Line.js +96 -70
  135. package/esm/chart/line/LineChart.js +18 -6
  136. package/esm/chart/line/ReferenceLine.js +41 -43
  137. package/esm/chart/line/SolidLine.js +36 -15
  138. package/esm/chart/line/index.js +1 -1
  139. package/esm/chart/{line/GradientLine.js → point/DefaultPointLabel.js} +31 -45
  140. package/esm/chart/point/Point.css +2 -0
  141. package/esm/chart/{Point.js → point/Point.js} +66 -57
  142. package/esm/chart/point/index.js +2 -0
  143. package/esm/chart/scrubber/DefaultScrubberBeacon.js +155 -0
  144. package/esm/chart/scrubber/{ScrubberBeaconLabel.js → DefaultScrubberBeaconLabel.js} +23 -10
  145. package/esm/chart/scrubber/DefaultScrubberLabel.js +30 -0
  146. package/esm/chart/scrubber/Scrubber.js +98 -392
  147. package/esm/chart/scrubber/ScrubberBeaconGroup.js +166 -0
  148. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +186 -0
  149. package/esm/chart/scrubber/index.js +3 -1
  150. package/esm/chart/text/ChartText.js +15 -20
  151. package/esm/chart/text/{SmartChartTextGroup.js → ChartTextGroup.js} +4 -3
  152. package/esm/chart/text/index.js +1 -1
  153. package/esm/chart/utils/axis.js +45 -29
  154. package/esm/chart/utils/chart.js +29 -3
  155. package/esm/chart/utils/gradient.js +257 -0
  156. package/esm/chart/utils/index.js +4 -0
  157. package/esm/chart/utils/interpolate.js +644 -0
  158. package/esm/chart/utils/path.js +32 -9
  159. package/esm/chart/utils/point.js +99 -12
  160. package/esm/chart/utils/scale.js +13 -2
  161. package/esm/chart/utils/scrubber.js +132 -0
  162. package/esm/chart/utils/transition.js +111 -0
  163. package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +8 -4
  164. package/package.json +9 -9
  165. package/dts/chart/Point.d.ts +0 -153
  166. package/dts/chart/Point.d.ts.map +0 -1
  167. package/dts/chart/line/GradientLine.d.ts +0 -42
  168. package/dts/chart/line/GradientLine.d.ts.map +0 -1
  169. package/dts/chart/scrubber/ScrubberBeacon.d.ts +0 -93
  170. package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +0 -1
  171. package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts +0 -7
  172. package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts.map +0 -1
  173. package/dts/chart/text/SmartChartTextGroup.d.ts.map +0 -1
  174. package/esm/chart/Point.css +0 -2
  175. package/esm/chart/scrubber/ScrubberBeacon.js +0 -195
@@ -1,4 +1,4 @@
1
- const _excluded = ["fill", "stroke", "strokeDasharray", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "vectorEffect"];
1
+ const _excluded = ["fill", "stroke", "strokeDasharray", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "vectorEffect", "gradient", "yAxisId", "animate", "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; }
@@ -6,33 +6,54 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
6
6
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
- import { memo } from 'react';
9
+ import { memo, useId } from 'react';
10
+ import { Gradient } from '../gradient';
10
11
  import { Path } from '../Path';
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
12
13
  /**
13
- * A customizable dotted line component which uses path element.
14
+ * A customizable dotted line component.
15
+ * Supports gradient for gradient effects on the dots.
14
16
  */
15
17
  export const DottedLine = /*#__PURE__*/memo(_ref => {
16
18
  let {
17
19
  fill = 'none',
18
- stroke = 'var(--color-bgLine)',
20
+ stroke = 'var(--color-fgPrimary)',
19
21
  strokeDasharray = '0 4',
20
22
  strokeLinecap = 'round',
21
23
  strokeLinejoin = 'round',
22
24
  strokeOpacity = 1,
23
25
  strokeWidth = 2,
24
- vectorEffect = 'non-scaling-stroke'
26
+ vectorEffect = 'non-scaling-stroke',
27
+ gradient,
28
+ yAxisId,
29
+ animate,
30
+ transition,
31
+ d
25
32
  } = _ref,
26
33
  props = _objectWithoutProperties(_ref, _excluded);
27
- return /*#__PURE__*/_jsx(Path, _objectSpread({
28
- clipOffset: strokeWidth,
29
- fill: fill,
30
- stroke: stroke,
31
- strokeDasharray: strokeDasharray,
32
- strokeLinecap: strokeLinecap,
33
- strokeLinejoin: strokeLinejoin,
34
- strokeOpacity: strokeOpacity,
35
- strokeWidth: strokeWidth,
36
- vectorEffect: vectorEffect
37
- }, props));
34
+ const gradientId = useId();
35
+ return /*#__PURE__*/_jsxs(_Fragment, {
36
+ children: [gradient && /*#__PURE__*/_jsx("defs", {
37
+ children: /*#__PURE__*/_jsx(Gradient, {
38
+ animate: animate,
39
+ gradient: gradient,
40
+ id: gradientId,
41
+ transition: transition,
42
+ yAxisId: yAxisId
43
+ })
44
+ }), /*#__PURE__*/_jsx(Path, _objectSpread({
45
+ animate: animate,
46
+ clipOffset: strokeWidth,
47
+ d: d,
48
+ fill: fill,
49
+ stroke: gradient ? "url(#".concat(gradientId, ")") : stroke,
50
+ strokeDasharray: strokeDasharray,
51
+ strokeLinecap: strokeLinecap,
52
+ strokeLinejoin: strokeLinejoin,
53
+ strokeOpacity: strokeOpacity,
54
+ strokeWidth: strokeWidth,
55
+ transition: transition,
56
+ vectorEffect: vectorEffect
57
+ }, props))]
58
+ });
38
59
  });
@@ -1,4 +1,4 @@
1
- const _excluded = ["seriesId", "curve", "type", "areaType", "areaBaseline", "stroke", "onPointClick", "showArea", "LineComponent", "AreaComponent", "opacity", "renderPoints"];
1
+ const _excluded = ["seriesId", "curve", "type", "areaType", "areaBaseline", "stroke", "strokeOpacity", "onPointClick", "showArea", "LineComponent", "AreaComponent", "opacity", "points", "connectNulls", "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; }
@@ -9,29 +9,31 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
9
9
  import React, { memo, useMemo } from 'react';
10
10
  import { m as motion } from 'framer-motion';
11
11
  import { Area } from '../area/Area';
12
- import { axisTickLabelsInitialAnimationVariants } from '../axis';
13
12
  import { useCartesianChartContext } from '../ChartProvider';
14
- import { Point } from '../Point';
15
- import { getLinePath } from '../utils';
13
+ import { Point } from '../point';
14
+ import { accessoryFadeTransitionDelay, accessoryFadeTransitionDuration, evaluateGradientAtValue, getGradientConfig, getLineData, getLinePath } from '../utils';
16
15
  import { DottedLine } from './DottedLine';
17
- import { GradientLine } from './GradientLine';
18
16
  import { SolidLine } from './SolidLine';
19
17
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
20
18
  export const Line = /*#__PURE__*/memo(_ref => {
21
19
  var _ref2;
22
20
  let {
23
21
  seriesId,
24
- curve = 'linear',
22
+ curve = 'bump',
25
23
  type = 'solid',
26
24
  areaType = 'gradient',
27
25
  areaBaseline,
28
- stroke: specifiedStroke,
26
+ stroke: strokeProp,
27
+ strokeOpacity,
29
28
  onPointClick,
30
29
  showArea = false,
31
30
  LineComponent: SelectedLineComponent,
32
31
  AreaComponent,
33
32
  opacity = 1,
34
- renderPoints
33
+ points,
34
+ connectNulls,
35
+ transition,
36
+ gradient: gradientProp
35
37
  } = _ref,
36
38
  props = _objectWithoutProperties(_ref, _excluded);
37
39
  const {
@@ -40,42 +42,18 @@ export const Line = /*#__PURE__*/memo(_ref => {
40
42
  getSeriesData,
41
43
  getXScale,
42
44
  getYScale,
43
- getXAxis
45
+ getXAxis,
46
+ getYAxis
44
47
  } = useCartesianChartContext();
45
- const matchedSeries = getSeries(seriesId);
46
- const sourceData = useMemo(() => {
47
- const stackedData = getSeriesData(seriesId);
48
- if (stackedData) {
49
- return stackedData;
50
- }
51
- return getSeriesData(seriesId) || null;
52
- }, [seriesId, getSeriesData]);
53
- const xAxis = getXAxis();
54
- const xScale = getXScale();
55
- const yScale = getYScale(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId);
48
+ const matchedSeries = useMemo(() => getSeries(seriesId), [getSeries, seriesId]);
49
+ 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
+ const sourceData = useMemo(() => getSeriesData(seriesId), [getSeriesData, seriesId]);
51
+ const xAxis = useMemo(() => getXAxis(), [getXAxis]);
52
+ const xScale = useMemo(() => getXScale(), [getXScale]);
53
+ const yScale = useMemo(() => getYScale(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId), [getYScale, matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId]);
56
54
 
57
55
  // Convert sourceData to number array (line only supports numbers, not tuples)
58
- // If data is stacked (tuples), extract the actual values from [baseline, actualValue] format
59
- const chartData = useMemo(() => {
60
- if (!sourceData) return [];
61
-
62
- // Check if this is stacked data (array of tuples)
63
- const firstNonNull = sourceData.find(d => d !== null);
64
- if (Array.isArray(firstNonNull)) {
65
- // Extract actual values from [baseline, value] tuples
66
- return sourceData.map(d => {
67
- if (d === null) return null;
68
- if (Array.isArray(d)) return d[1];
69
- return d;
70
- });
71
- }
72
-
73
- // Regular number array
74
- if (sourceData.every(d => typeof d === 'number' || d === null)) {
75
- return sourceData;
76
- }
77
- return [];
78
- }, [sourceData]);
56
+ const chartData = useMemo(() => getLineData(sourceData), [sourceData]);
79
57
  const path = useMemo(() => {
80
58
  if (!xScale || !yScale || chartData.length === 0) return '';
81
59
 
@@ -86,9 +64,10 @@ export const Line = /*#__PURE__*/memo(_ref => {
86
64
  xScale,
87
65
  yScale,
88
66
  curve,
89
- xData
67
+ xData,
68
+ connectNulls
90
69
  });
91
- }, [chartData, xScale, yScale, curve, xAxis === null || xAxis === void 0 ? void 0 : xAxis.data]);
70
+ }, [chartData, xScale, yScale, curve, xAxis === null || xAxis === void 0 ? void 0 : xAxis.data, connectNulls]);
92
71
  const LineComponent = useMemo(() => {
93
72
  if (SelectedLineComponent) {
94
73
  return SelectedLineComponent;
@@ -96,63 +75,110 @@ export const Line = /*#__PURE__*/memo(_ref => {
96
75
  switch (type) {
97
76
  case 'dotted':
98
77
  return DottedLine;
99
- case 'gradient':
100
- return GradientLine;
101
- case 'solid':
102
78
  default:
103
79
  return SolidLine;
104
80
  }
105
81
  }, [SelectedLineComponent, type]);
106
82
 
107
83
  // Get series color for stroke
108
- const stroke = (_ref2 = specifiedStroke !== null && specifiedStroke !== void 0 ? specifiedStroke : matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.color) !== null && _ref2 !== void 0 ? _ref2 : 'var(--color-fgPrimary)';
84
+ 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)';
109
85
  const xData = useMemo(() => {
110
86
  const data = xAxis === null || xAxis === void 0 ? void 0 : xAxis.data;
111
87
  return data && Array.isArray(data) && data.length > 0 && typeof data[0] === 'number' ? data : null;
112
88
  }, [xAxis === null || xAxis === void 0 ? void 0 : xAxis.data]);
89
+ const gradientConfig = useMemo(() => {
90
+ if (!gradient || !xScale || !yScale) return;
91
+ const gradientScale = gradient.axis === 'x' ? xScale : yScale;
92
+ const stops = getGradientConfig(gradient, xScale, yScale);
93
+ if (!stops) return;
94
+ return {
95
+ scale: gradientScale,
96
+ stops
97
+ };
98
+ }, [gradient, xScale, yScale]);
99
+ if (!xScale || !yScale || !path) return;
113
100
  return /*#__PURE__*/_jsxs(_Fragment, {
114
101
  children: [showArea && /*#__PURE__*/_jsx(Area, {
115
102
  AreaComponent: AreaComponent,
116
103
  baseline: areaBaseline,
104
+ connectNulls: connectNulls,
117
105
  curve: curve,
118
106
  fill: stroke,
119
107
  fillOpacity: opacity,
108
+ gradient: gradient,
120
109
  seriesId: seriesId,
110
+ transition: transition,
121
111
  type: areaType
122
112
  }), /*#__PURE__*/_jsx(LineComponent, _objectSpread({
123
113
  d: path,
114
+ gradient: gradient,
124
115
  stroke: stroke,
125
- strokeOpacity: opacity
126
- }, props)), renderPoints && /*#__PURE__*/_jsx(motion.g, _objectSpread(_objectSpread({
116
+ strokeOpacity: strokeOpacity !== null && strokeOpacity !== void 0 ? strokeOpacity : opacity,
117
+ transition: transition,
118
+ yAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId
119
+ }, props)), points && /*#__PURE__*/_jsx(motion.g, _objectSpread(_objectSpread({
127
120
  "data-component": "line-points-group"
128
121
  }, animate ? {
129
- animate: 'animate',
130
- exit: 'exit',
131
- initial: 'initial',
132
- variants: axisTickLabelsInitialAnimationVariants
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
+ }
133
138
  } : {}), {}, {
134
139
  children: chartData.map((value, index) => {
135
- var _xScale, _yScale, _pointConfig$fill, _pointConfig$onClick, _pointConfig$opacity;
136
- if (value === null) {
137
- return null;
138
- }
140
+ var _pointConfig$onClick;
141
+ if (value === null) return;
139
142
  const xValue = xData && xData[index] !== undefined ? xData[index] : index;
140
- const point = renderPoints({
141
- dataY: value,
143
+ let pointFill = stroke;
144
+ if (gradientConfig && gradient) {
145
+ 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;
149
+ const evaluatedColor = evaluateGradientAtValue(gradientConfig.stops, dataValue, gradientConfig.scale);
150
+ if (evaluatedColor) {
151
+ // Apply gradient color to fill if not explicitly set
152
+ pointFill = evaluatedColor;
153
+ }
154
+ }
155
+
156
+ // Build defaults that would be passed to Point
157
+ const defaults = {
142
158
  dataX: xValue,
143
- x: (_xScale = xScale === null || xScale === void 0 ? void 0 : xScale(xValue)) !== null && _xScale !== void 0 ? _xScale : 0,
144
- y: (_yScale = yScale === null || yScale === void 0 ? void 0 : yScale(value)) !== null && _yScale !== void 0 ? _yScale : 0
145
- });
146
- if (!point) return;
147
- const pointConfig = typeof point === 'object' ? point : {};
159
+ dataY: value,
160
+ fill: pointFill,
161
+ yAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId,
162
+ opacity,
163
+ testID: undefined
164
+ };
165
+
166
+ // If points is true, render with defaults
167
+ if (points === true) {
168
+ return /*#__PURE__*/_jsx(Point, _objectSpread({
169
+ onClick: onPointClick,
170
+ transition: transition
171
+ }, defaults), "".concat(seriesId, "-").concat(index));
172
+ }
173
+
174
+ // Call the function with defaults
175
+ const result = points(defaults);
176
+ if (!result) return;
177
+ const pointConfig = result === true ? {} : result;
148
178
  return /*#__PURE__*/_jsx(Point, _objectSpread(_objectSpread({
149
- dataX: xValue,
150
- dataY: value
151
- }, pointConfig), {}, {
152
- fill: (_pointConfig$fill = pointConfig.fill) !== null && _pointConfig$fill !== void 0 ? _pointConfig$fill : stroke,
153
179
  onClick: (_pointConfig$onClick = pointConfig.onClick) !== null && _pointConfig$onClick !== void 0 ? _pointConfig$onClick : onPointClick,
154
- opacity: (_pointConfig$opacity = pointConfig.opacity) !== null && _pointConfig$opacity !== void 0 ? _pointConfig$opacity : opacity
155
- }), "".concat(seriesId, "-renderpoint-").concat(index));
180
+ transition: transition
181
+ }, defaults), pointConfig), "".concat(seriesId, "-").concat(index));
156
182
  })
157
183
  }))]
158
184
  });
@@ -1,4 +1,4 @@
1
- const _excluded = ["series", "showArea", "areaType", "type", "onPointClick", "LineComponent", "AreaComponent", "curve", "renderPoints", "strokeWidth", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children"],
1
+ const _excluded = ["series", "showArea", "areaType", "type", "onPointClick", "LineComponent", "AreaComponent", "curve", "points", "strokeWidth", "strokeOpacity", "connectNulls", "transition", "opacity", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children"],
2
2
  _excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range"],
3
3
  _excluded3 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"],
4
4
  _excluded4 = ["id", "data", "label", "color", "yAxisId"];
@@ -26,17 +26,21 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
26
26
  LineComponent,
27
27
  AreaComponent,
28
28
  curve,
29
- renderPoints,
29
+ points,
30
30
  strokeWidth,
31
+ strokeOpacity,
32
+ connectNulls,
33
+ transition,
34
+ opacity,
31
35
  showXAxis,
32
36
  showYAxis,
33
37
  xAxis,
34
38
  yAxis,
35
- inset: userInset,
39
+ inset,
36
40
  children
37
41
  } = _ref,
38
42
  chartProps = _objectWithoutProperties(_ref, _excluded);
39
- const calculatedInset = useMemo(() => getChartInset(userInset, defaultChartInset), [userInset]);
43
+ const calculatedInset = useMemo(() => getChartInset(inset, defaultChartInset), [inset]);
40
44
 
41
45
  // Convert LineSeries to Series for Chart context
42
46
  const chartSeries = useMemo(() => {
@@ -44,7 +48,10 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
44
48
  id: s.id,
45
49
  data: s.data,
46
50
  label: s.label,
47
- color: s.color
51
+ color: s.color,
52
+ yAxisId: s.yAxisId,
53
+ stackId: s.stackId,
54
+ gradient: s.gradient
48
55
  }));
49
56
  }, [series]);
50
57
 
@@ -95,6 +102,7 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
95
102
  children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _objectSpread({}, xAxisVisualProps)), showYAxis && /*#__PURE__*/_jsx(YAxis, _objectSpread({
96
103
  axisId: yAxisId
97
104
  }, yAxisVisualProps)), series === null || series === void 0 ? void 0 : series.map(_ref4 => {
105
+ var _linePropsFromSeries$;
98
106
  let {
99
107
  id,
100
108
  data,
@@ -107,12 +115,16 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
107
115
  AreaComponent: AreaComponent,
108
116
  LineComponent: LineComponent,
109
117
  areaType: areaType,
118
+ connectNulls: connectNulls,
110
119
  curve: curve,
111
120
  onPointClick: onPointClick,
112
- renderPoints: renderPoints,
121
+ opacity: opacity,
122
+ points: points,
113
123
  seriesId: id,
114
124
  showArea: showArea,
125
+ strokeOpacity: strokeOpacity,
115
126
  strokeWidth: strokeWidth,
127
+ transition: (_linePropsFromSeries$ = linePropsFromSeries.transition) !== null && _linePropsFromSeries$ !== void 0 ? _linePropsFromSeries$ : transition,
116
128
  type: type
117
129
  }, linePropsFromSeries), id);
118
130
  }), children]
@@ -3,16 +3,12 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
3
3
  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; }
4
4
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
5
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
- import React, { memo, useMemo } from 'react';
6
+ import React, { memo } from 'react';
7
7
  import { cx } from '@coinbase/cds-web';
8
8
  import { useCartesianChartContext } from '../ChartProvider';
9
- import { ChartText } from '../text';
10
9
  import { getPointOnScale } from '../utils';
10
+ import { DefaultReferenceLineLabel } from './DefaultReferenceLineLabel';
11
11
  import { DottedLine } from './DottedLine';
12
-
13
- /**
14
- * Configuration for ReferenceLine label rendering using ChartText.
15
- */
16
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
13
  export const ReferenceLine = /*#__PURE__*/memo(_ref => {
18
14
  let {
@@ -23,8 +19,16 @@ export const ReferenceLine = /*#__PURE__*/memo(_ref => {
23
19
  labelPosition = dataY !== undefined ? 'right' : 'top',
24
20
  testID,
25
21
  LineComponent = DottedLine,
22
+ LabelComponent = DefaultReferenceLineLabel,
23
+ labelElevated,
24
+ labelFont,
25
+ labelDx,
26
+ labelDy,
27
+ labelHorizontalAlignment,
28
+ labelVerticalAlignment,
29
+ labelBoundsInset,
26
30
  stroke = 'var(--color-bgLine)',
27
- labelProps,
31
+ opacity,
28
32
  className,
29
33
  style,
30
34
  classNames,
@@ -36,36 +40,6 @@ export const ReferenceLine = /*#__PURE__*/memo(_ref => {
36
40
  drawingArea
37
41
  } = useCartesianChartContext();
38
42
 
39
- // For horizontal lines (dataY defined): default to verticalAlignment: 'middle'
40
- // For vertical lines (dataX defined): default to horizontalAlignment: 'center'
41
- const isHorizontal = dataY !== undefined;
42
-
43
- // Merge default props with user provided props, including text-specific styles and classNames
44
- const finalLabelProps = useMemo(() => _objectSpread(_objectSpread(_objectSpread({
45
- borderRadius: 4,
46
- color: 'var(--color-fgMuted)',
47
- elevation: 0,
48
- inset: {
49
- top: 8,
50
- bottom: 8,
51
- left: 12,
52
- right: 12
53
- }
54
- }, isHorizontal ? {
55
- verticalAlignment: 'middle'
56
- } : {
57
- horizontalAlignment: 'center'
58
- }), labelProps), {}, {
59
- // Merge classNames for text
60
- classNames: _objectSpread(_objectSpread({}, labelProps === null || labelProps === void 0 ? void 0 : labelProps.classNames), (classNames === null || classNames === void 0 ? void 0 : classNames.label) && {
61
- text: classNames.label
62
- }),
63
- // Merge styles for text
64
- styles: _objectSpread(_objectSpread({}, labelProps === null || labelProps === void 0 ? void 0 : labelProps.styles), (styles === null || styles === void 0 ? void 0 : styles.label) && {
65
- text: styles.label
66
- })
67
- }), [isHorizontal, labelProps, classNames === null || classNames === void 0 ? void 0 : classNames.label, styles === null || styles === void 0 ? void 0 : styles.label]);
68
-
69
43
  // Combine root classNames
70
44
  const rootClassName = cx(className, classNames === null || classNames === void 0 ? void 0 : classNames.root);
71
45
  // Combine root styles
@@ -96,12 +70,24 @@ export const ReferenceLine = /*#__PURE__*/memo(_ref => {
96
70
  children: [/*#__PURE__*/_jsx(LineComponent, {
97
71
  animate: false,
98
72
  d: "M".concat(drawingArea.x, ",").concat(yPixel, " L").concat(drawingArea.x + drawingArea.width, ",").concat(yPixel),
99
- stroke: stroke
100
- }), label && /*#__PURE__*/_jsx(ChartText, _objectSpread(_objectSpread({}, finalLabelProps), {}, {
73
+ stroke: stroke,
74
+ strokeOpacity: opacity
75
+ }), label && /*#__PURE__*/_jsx(LabelComponent, {
76
+ boundsInset: labelBoundsInset,
77
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.label,
78
+ dx: labelDx,
79
+ dy: labelDy,
80
+ elevated: labelElevated,
81
+ font: labelFont,
82
+ horizontalAlignment: labelHorizontalAlignment,
83
+ opacity: opacity,
84
+ style: styles === null || styles === void 0 ? void 0 : styles.label,
85
+ testID: testID,
86
+ verticalAlignment: labelVerticalAlignment !== null && labelVerticalAlignment !== void 0 ? labelVerticalAlignment : 'middle',
101
87
  x: labelX,
102
88
  y: yPixel,
103
89
  children: label
104
- }))]
90
+ })]
105
91
  });
106
92
  }
107
93
 
@@ -130,12 +116,24 @@ export const ReferenceLine = /*#__PURE__*/memo(_ref => {
130
116
  children: [/*#__PURE__*/_jsx(LineComponent, {
131
117
  animate: false,
132
118
  d: "M".concat(xPixel, ",").concat(drawingArea.y, " L").concat(xPixel, ",").concat(drawingArea.y + drawingArea.height),
133
- stroke: stroke
134
- }), label && /*#__PURE__*/_jsx(ChartText, _objectSpread(_objectSpread({}, finalLabelProps), {}, {
119
+ stroke: stroke,
120
+ strokeOpacity: opacity
121
+ }), label && /*#__PURE__*/_jsx(LabelComponent, {
122
+ boundsInset: labelBoundsInset,
123
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.label,
124
+ dx: labelDx,
125
+ dy: labelDy,
126
+ elevated: labelElevated,
127
+ font: labelFont,
128
+ horizontalAlignment: labelHorizontalAlignment !== null && labelHorizontalAlignment !== void 0 ? labelHorizontalAlignment : 'center',
129
+ opacity: opacity,
130
+ style: styles === null || styles === void 0 ? void 0 : styles.label,
131
+ testID: testID,
132
+ verticalAlignment: labelVerticalAlignment,
135
133
  x: xPixel,
136
134
  y: labelY,
137
135
  children: label
138
- }))]
136
+ })]
139
137
  });
140
138
  }
141
139
  return;
@@ -1,4 +1,4 @@
1
- const _excluded = ["fill", "stroke", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth"];
1
+ const _excluded = ["fill", "stroke", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "gradient", "yAxisId", "animate", "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; }
@@ -6,29 +6,50 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
6
6
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
- import { memo } from 'react';
9
+ import { memo, useId } from 'react';
10
+ import { Gradient } from '../gradient';
10
11
  import { Path } from '../Path';
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
12
13
  /**
13
- * A customizable solid line component which uses path element.
14
+ * A customizable solid line component.
15
+ * Supports gradient for gradient effects and smooth data transitions.
14
16
  */
15
17
  export const SolidLine = /*#__PURE__*/memo(_ref => {
16
18
  let {
17
19
  fill = 'none',
18
- stroke = 'var(--color-bgLine)',
20
+ stroke = 'var(--color-fgPrimary)',
19
21
  strokeLinecap = 'round',
20
22
  strokeLinejoin = 'round',
21
23
  strokeOpacity = 1,
22
- strokeWidth = 2
24
+ strokeWidth = 2,
25
+ gradient,
26
+ yAxisId,
27
+ animate,
28
+ transition,
29
+ d
23
30
  } = _ref,
24
31
  props = _objectWithoutProperties(_ref, _excluded);
25
- return /*#__PURE__*/_jsx(Path, _objectSpread({
26
- clipOffset: strokeWidth,
27
- fill: fill,
28
- stroke: stroke,
29
- strokeLinecap: strokeLinecap,
30
- strokeLinejoin: strokeLinejoin,
31
- strokeOpacity: strokeOpacity,
32
- strokeWidth: strokeWidth
33
- }, props));
32
+ const gradientId = useId();
33
+ return /*#__PURE__*/_jsxs(_Fragment, {
34
+ children: [gradient && /*#__PURE__*/_jsx("defs", {
35
+ children: /*#__PURE__*/_jsx(Gradient, {
36
+ animate: animate,
37
+ gradient: gradient,
38
+ id: gradientId,
39
+ transition: transition,
40
+ yAxisId: yAxisId
41
+ })
42
+ }), /*#__PURE__*/_jsx(Path, _objectSpread({
43
+ animate: animate,
44
+ clipOffset: strokeWidth,
45
+ d: d,
46
+ fill: fill,
47
+ stroke: gradient ? "url(#".concat(gradientId, ")") : stroke,
48
+ strokeLinecap: strokeLinecap,
49
+ strokeLinejoin: strokeLinejoin,
50
+ strokeOpacity: strokeOpacity,
51
+ strokeWidth: strokeWidth,
52
+ transition: transition
53
+ }, props))]
54
+ });
34
55
  });
@@ -1,6 +1,6 @@
1
1
  // codegen:start {preset: barrel, include: ./*.tsx, exclude: ./__stories__/*.tsx}
2
+ export * from './DefaultReferenceLineLabel';
2
3
  export * from './DottedLine';
3
- export * from './GradientLine';
4
4
  export * from './Line';
5
5
  export * from './LineChart';
6
6
  export * from './ReferenceLine';