@coinbase/cds-mobile-visualization 3.4.0-beta.5 → 3.4.0-beta.6

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 (179) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dts/chart/CartesianChart.d.ts +57 -33
  3. package/dts/chart/CartesianChart.d.ts.map +1 -1
  4. package/dts/chart/ChartContextBridge.d.ts +28 -0
  5. package/dts/chart/ChartContextBridge.d.ts.map +1 -0
  6. package/dts/chart/Path.d.ts +77 -34
  7. package/dts/chart/Path.d.ts.map +1 -1
  8. package/dts/chart/PeriodSelector.d.ts +1 -1
  9. package/dts/chart/PeriodSelector.d.ts.map +1 -1
  10. package/dts/chart/area/Area.d.ts +42 -27
  11. package/dts/chart/area/Area.d.ts.map +1 -1
  12. package/dts/chart/area/AreaChart.d.ts +51 -10
  13. package/dts/chart/area/AreaChart.d.ts.map +1 -1
  14. package/dts/chart/area/DottedArea.d.ts +21 -2
  15. package/dts/chart/area/DottedArea.d.ts.map +1 -1
  16. package/dts/chart/area/GradientArea.d.ts +19 -13
  17. package/dts/chart/area/GradientArea.d.ts.map +1 -1
  18. package/dts/chart/area/SolidArea.d.ts +17 -2
  19. package/dts/chart/area/SolidArea.d.ts.map +1 -1
  20. package/dts/chart/axis/Axis.d.ts +68 -78
  21. package/dts/chart/axis/Axis.d.ts.map +1 -1
  22. package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
  23. package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
  24. package/dts/chart/axis/XAxis.d.ts +1 -1
  25. package/dts/chart/axis/XAxis.d.ts.map +1 -1
  26. package/dts/chart/axis/YAxis.d.ts +2 -2
  27. package/dts/chart/axis/YAxis.d.ts.map +1 -1
  28. package/dts/chart/axis/index.d.ts +1 -0
  29. package/dts/chart/axis/index.d.ts.map +1 -1
  30. package/dts/chart/bar/Bar.d.ts +16 -13
  31. package/dts/chart/bar/Bar.d.ts.map +1 -1
  32. package/dts/chart/bar/BarChart.d.ts +36 -20
  33. package/dts/chart/bar/BarChart.d.ts.map +1 -1
  34. package/dts/chart/bar/BarPlot.d.ts +2 -1
  35. package/dts/chart/bar/BarPlot.d.ts.map +1 -1
  36. package/dts/chart/bar/BarStack.d.ts +39 -48
  37. package/dts/chart/bar/BarStack.d.ts.map +1 -1
  38. package/dts/chart/bar/BarStackGroup.d.ts +1 -0
  39. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
  40. package/dts/chart/bar/DefaultBar.d.ts +1 -1
  41. package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
  42. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
  43. package/dts/chart/gradient/Gradient.d.ts +25 -0
  44. package/dts/chart/gradient/Gradient.d.ts.map +1 -0
  45. package/dts/chart/gradient/index.d.ts +2 -0
  46. package/dts/chart/gradient/index.d.ts.map +1 -0
  47. package/dts/chart/index.d.ts +3 -1
  48. package/dts/chart/index.d.ts.map +1 -1
  49. package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
  50. package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
  51. package/dts/chart/line/DottedLine.d.ts +13 -5
  52. package/dts/chart/line/DottedLine.d.ts.map +1 -1
  53. package/dts/chart/line/Line.d.ts +62 -25
  54. package/dts/chart/line/Line.d.ts.map +1 -1
  55. package/dts/chart/line/LineChart.d.ts +43 -9
  56. package/dts/chart/line/LineChart.d.ts.map +1 -1
  57. package/dts/chart/line/ReferenceLine.d.ts +65 -22
  58. package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
  59. package/dts/chart/line/SolidLine.d.ts +8 -5
  60. package/dts/chart/line/SolidLine.d.ts.map +1 -1
  61. package/dts/chart/line/index.d.ts +1 -1
  62. package/dts/chart/line/index.d.ts.map +1 -1
  63. package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
  64. package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
  65. package/dts/chart/point/Point.d.ts +120 -0
  66. package/dts/chart/point/Point.d.ts.map +1 -0
  67. package/dts/chart/point/index.d.ts +3 -0
  68. package/dts/chart/point/index.d.ts.map +1 -0
  69. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +8 -0
  70. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
  71. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
  72. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
  73. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +11 -0
  74. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
  75. package/dts/chart/scrubber/Scrubber.d.ts +168 -41
  76. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
  77. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +44 -0
  78. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
  79. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +31 -0
  80. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
  81. package/dts/chart/scrubber/ScrubberProvider.d.ts +6 -3
  82. package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -1
  83. package/dts/chart/scrubber/index.d.ts +3 -0
  84. package/dts/chart/scrubber/index.d.ts.map +1 -1
  85. package/dts/chart/text/ChartText.d.ts +151 -77
  86. package/dts/chart/text/ChartText.d.ts.map +1 -1
  87. package/dts/chart/text/{SmartChartTextGroup.d.ts → ChartTextGroup.d.ts} +9 -3
  88. package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
  89. package/dts/chart/text/index.d.ts +1 -1
  90. package/dts/chart/text/index.d.ts.map +1 -1
  91. package/dts/chart/utils/chart.d.ts +34 -7
  92. package/dts/chart/utils/chart.d.ts.map +1 -1
  93. package/dts/chart/utils/context.d.ts +28 -7
  94. package/dts/chart/utils/context.d.ts.map +1 -1
  95. package/dts/chart/utils/gradient.d.ts +117 -0
  96. package/dts/chart/utils/gradient.d.ts.map +1 -0
  97. package/dts/chart/utils/index.d.ts +3 -0
  98. package/dts/chart/utils/index.d.ts.map +1 -1
  99. package/dts/chart/utils/path.d.ts +53 -0
  100. package/dts/chart/utils/path.d.ts.map +1 -1
  101. package/dts/chart/utils/point.d.ts +60 -1
  102. package/dts/chart/utils/point.d.ts.map +1 -1
  103. package/dts/chart/utils/scale.d.ts +91 -0
  104. package/dts/chart/utils/scale.d.ts.map +1 -1
  105. package/dts/chart/utils/scrubber.d.ts +39 -0
  106. package/dts/chart/utils/scrubber.d.ts.map +1 -0
  107. package/dts/chart/utils/transition.d.ts +140 -0
  108. package/dts/chart/utils/transition.d.ts.map +1 -0
  109. package/esm/chart/CartesianChart.js +164 -70
  110. package/esm/chart/ChartContextBridge.js +148 -0
  111. package/esm/chart/Path.js +196 -113
  112. package/esm/chart/PeriodSelector.js +1 -1
  113. package/esm/chart/__stories__/CartesianChart.stories.js +371 -129
  114. package/esm/chart/__stories__/Chart.stories.js +2 -4
  115. package/esm/chart/area/Area.js +25 -35
  116. package/esm/chart/area/AreaChart.js +17 -12
  117. package/esm/chart/area/DottedArea.js +61 -109
  118. package/esm/chart/area/GradientArea.js +35 -91
  119. package/esm/chart/area/SolidArea.js +22 -8
  120. package/esm/chart/area/__stories__/AreaChart.stories.js +1 -1
  121. package/esm/chart/axis/Axis.js +2 -0
  122. package/esm/chart/axis/DefaultAxisTickLabel.js +11 -0
  123. package/esm/chart/axis/XAxis.js +62 -56
  124. package/esm/chart/axis/YAxis.js +58 -52
  125. package/esm/chart/axis/__stories__/Axis.stories.js +0 -1
  126. package/esm/chart/axis/index.js +1 -0
  127. package/esm/chart/bar/Bar.js +3 -1
  128. package/esm/chart/bar/BarChart.js +15 -37
  129. package/esm/chart/bar/BarPlot.js +41 -35
  130. package/esm/chart/bar/BarStack.js +75 -38
  131. package/esm/chart/bar/BarStackGroup.js +6 -16
  132. package/esm/chart/bar/DefaultBar.js +26 -48
  133. package/esm/chart/bar/DefaultBarStack.js +23 -58
  134. package/esm/chart/bar/__stories__/BarChart.stories.js +463 -77
  135. package/esm/chart/gradient/Gradient.js +53 -0
  136. package/esm/chart/gradient/index.js +1 -0
  137. package/esm/chart/index.js +3 -1
  138. package/esm/chart/line/DefaultReferenceLineLabel.js +66 -0
  139. package/esm/chart/line/DottedLine.js +29 -14
  140. package/esm/chart/line/Line.js +106 -67
  141. package/esm/chart/line/LineChart.js +20 -14
  142. package/esm/chart/line/ReferenceLine.js +73 -62
  143. package/esm/chart/line/SolidLine.js +25 -10
  144. package/esm/chart/line/__stories__/LineChart.stories.js +2098 -1975
  145. package/esm/chart/line/__stories__/ReferenceLine.stories.js +83 -28
  146. package/esm/chart/line/index.js +1 -1
  147. package/esm/chart/point/DefaultPointLabel.js +39 -0
  148. package/esm/chart/point/Point.js +188 -0
  149. package/esm/chart/point/index.js +2 -0
  150. package/esm/chart/scrubber/DefaultScrubberBeacon.js +179 -0
  151. package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +43 -0
  152. package/esm/chart/scrubber/DefaultScrubberLabel.js +28 -0
  153. package/esm/chart/scrubber/Scrubber.js +130 -148
  154. package/esm/chart/scrubber/ScrubberBeaconGroup.js +161 -0
  155. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +185 -0
  156. package/esm/chart/scrubber/ScrubberProvider.js +46 -54
  157. package/esm/chart/scrubber/index.js +3 -1
  158. package/esm/chart/text/ChartText.js +242 -174
  159. package/esm/chart/text/{SmartChartTextGroup.js → ChartTextGroup.js} +6 -5
  160. package/esm/chart/text/index.js +1 -1
  161. package/esm/chart/utils/chart.js +44 -3
  162. package/esm/chart/utils/gradient.js +305 -0
  163. package/esm/chart/utils/index.js +3 -0
  164. package/esm/chart/utils/path.js +76 -8
  165. package/esm/chart/utils/point.js +116 -5
  166. package/esm/chart/utils/scale.js +230 -1
  167. package/esm/chart/utils/scrubber.js +139 -0
  168. package/esm/chart/utils/transition.js +221 -0
  169. package/package.json +7 -5
  170. package/dts/chart/Point.d.ts +0 -103
  171. package/dts/chart/Point.d.ts.map +0 -1
  172. package/dts/chart/line/GradientLine.d.ts +0 -45
  173. package/dts/chart/line/GradientLine.d.ts.map +0 -1
  174. package/dts/chart/scrubber/ScrubberBeacon.d.ts +0 -75
  175. package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +0 -1
  176. package/dts/chart/text/SmartChartTextGroup.d.ts.map +0 -1
  177. package/esm/chart/Point.js +0 -111
  178. package/esm/chart/line/GradientLine.js +0 -62
  179. package/esm/chart/scrubber/ScrubberBeacon.js +0 -199
@@ -1,5 +1,4 @@
1
1
  import React, { memo, useMemo } from 'react';
2
- import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
3
2
  import { useCartesianChartContext } from '../ChartProvider';
4
3
  import { getAreaPath } from '../utils';
5
4
  import { DottedArea } from './DottedArea';
@@ -7,37 +6,30 @@ import { GradientArea } from './GradientArea';
7
6
  import { SolidArea } from './SolidArea';
8
7
  import { jsx as _jsx } from "react/jsx-runtime";
9
8
  export const Area = /*#__PURE__*/memo(_ref => {
10
- var _ref2;
11
9
  let {
12
10
  seriesId,
13
- curve = 'linear',
11
+ curve = 'bump',
14
12
  type = 'solid',
15
- AreaComponent: SelectedAreaComponent,
16
- fill: specifiedFill,
13
+ AreaComponent: AreaComponentProp,
14
+ fill: fillProp,
17
15
  fillOpacity = 1,
18
- stroke,
19
- strokeWidth,
20
- baseline
16
+ baseline,
17
+ connectNulls,
18
+ gradient: gradientProp,
19
+ transition,
20
+ animate
21
21
  } = _ref;
22
- const theme = useTheme();
23
22
  const {
24
23
  getSeries,
25
24
  getSeriesData,
26
25
  getXScale,
27
26
  getYScale,
28
- getXAxis,
29
- drawingArea
27
+ getXAxis
30
28
  } = useCartesianChartContext();
31
-
32
- // Get sourceData from series (using stacked data if available)
33
29
  const matchedSeries = useMemo(() => getSeries(seriesId), [seriesId, getSeries]);
34
-
35
- // Check for stacked data first, then fall back to raw data
36
- const sourceData = useMemo(() => {
37
- return getSeriesData(seriesId) || null;
38
- }, [seriesId, getSeriesData]);
39
-
40
- // Get scales and axes for this series
30
+ const gradient = useMemo(() => gradientProp != null ? gradientProp : matchedSeries == null ? void 0 : matchedSeries.gradient, [gradientProp, matchedSeries == null ? void 0 : matchedSeries.gradient]);
31
+ const fill = useMemo(() => fillProp != null ? fillProp : matchedSeries == null ? void 0 : matchedSeries.color, [fillProp, matchedSeries == null ? void 0 : matchedSeries.color]);
32
+ const sourceData = useMemo(() => getSeriesData(seriesId), [seriesId, getSeriesData]);
41
33
  const xAxis = getXAxis();
42
34
  const xScale = getXScale();
43
35
  const yScale = getYScale(matchedSeries == null ? void 0 : matchedSeries.yAxisId);
@@ -51,35 +43,33 @@ export const Area = /*#__PURE__*/memo(_ref => {
51
43
  xScale,
52
44
  yScale,
53
45
  curve,
54
- xData
46
+ xData,
47
+ connectNulls
55
48
  });
56
- }, [sourceData, xScale, yScale, curve, xAxis == null ? void 0 : xAxis.data]);
49
+ }, [sourceData, xScale, yScale, curve, xAxis == null ? void 0 : xAxis.data, connectNulls]);
57
50
  const AreaComponent = useMemo(() => {
58
- if (SelectedAreaComponent) {
59
- return SelectedAreaComponent;
51
+ if (AreaComponentProp) {
52
+ return AreaComponentProp;
60
53
  }
61
54
  switch (type) {
62
- case 'solid':
63
- return SolidArea;
64
55
  case 'dotted':
65
56
  return DottedArea;
66
57
  case 'gradient':
67
- default:
68
58
  return GradientArea;
59
+ case 'solid':
60
+ default:
61
+ return SolidArea;
69
62
  }
70
- }, [SelectedAreaComponent, type]);
71
- if (!xScale || !yScale || !sourceData || !area) {
72
- return null;
73
- }
74
- const fill = (_ref2 = specifiedFill != null ? specifiedFill : matchedSeries == null ? void 0 : matchedSeries.color) != null ? _ref2 : theme.color.fgPrimary;
63
+ }, [AreaComponentProp, type]);
64
+ if (!xScale || !yScale || !sourceData || !area) return;
75
65
  return /*#__PURE__*/_jsx(AreaComponent, {
66
+ animate: animate,
76
67
  baseline: baseline,
77
- clipRect: drawingArea,
78
68
  d: area,
79
69
  fill: fill,
80
70
  fillOpacity: fillOpacity,
81
- stroke: stroke,
82
- strokeWidth: strokeWidth,
71
+ gradient: gradient,
72
+ transition: transition,
83
73
  yAxisId: matchedSeries == null ? void 0 : matchedSeries.yAxisId
84
74
  });
85
75
  });
@@ -1,8 +1,8 @@
1
- const _excluded = ["series", "stacked", "AreaComponent", "curve", "fillOpacity", "type", "LineComponent", "strokeWidth", "showXAxis", "showYAxis", "showLines", "lineType", "xAxis", "yAxis", "inset", "children"],
1
+ const _excluded = ["series", "stacked", "AreaComponent", "curve", "fillOpacity", "type", "connectNulls", "transition", "LineComponent", "strokeWidth", "showXAxis", "showYAxis", "showLines", "lineType", "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", "opacity", "LineComponent", "stackId"],
5
- _excluded5 = ["id", "data", "label", "color", "yAxisId", "fill", "fillOpacity", "stackId"];
5
+ _excluded5 = ["id", "data", "label", "color", "yAxisId", "fill", "fillOpacity", "stackId", "type", "lineType"];
6
6
  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); }
7
7
  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; }
8
8
  import { forwardRef, memo, useMemo } from 'react';
@@ -20,6 +20,8 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
20
20
  curve,
21
21
  fillOpacity,
22
22
  type,
23
+ connectNulls,
24
+ transition,
23
25
  LineComponent,
24
26
  strokeWidth,
25
27
  showXAxis,
@@ -28,11 +30,11 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
28
30
  lineType = 'solid',
29
31
  xAxis,
30
32
  yAxis,
31
- inset: userInset,
33
+ inset,
32
34
  children
33
35
  } = _ref,
34
36
  chartProps = _objectWithoutPropertiesLoose(_ref, _excluded);
35
- const calculatedInset = useMemo(() => getChartInset(userInset, defaultChartInset), [userInset]);
37
+ const calculatedInset = useMemo(() => getChartInset(inset, defaultChartInset), [inset]);
36
38
 
37
39
  // Convert AreaSeries to Series for Chart context
38
40
  const chartSeries = useMemo(() => {
@@ -41,6 +43,7 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
41
43
  data: s.data,
42
44
  label: s.label,
43
45
  color: s.color,
46
+ gradient: s.gradient,
44
47
  yAxisId: s.yAxisId,
45
48
  stackId: s.stackId
46
49
  }));
@@ -120,27 +123,29 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
120
123
  areaPropsFromSeries = _objectWithoutPropertiesLoose(_ref4, _excluded4);
121
124
  return /*#__PURE__*/_jsx(Area, _extends({
122
125
  AreaComponent: AreaComponent,
126
+ connectNulls: connectNulls,
123
127
  curve: curve,
124
128
  fillOpacity: fillOpacity,
125
129
  seriesId: id,
130
+ transition: transition,
126
131
  type: type
127
132
  }, areaPropsFromSeries), id);
128
133
  }), showLines && (series == null ? void 0 : series.map(_ref5 => {
129
134
  let {
130
135
  id,
131
- color
136
+ // Area type (don't pass to Line)
137
+ lineType: seriesLineType
132
138
  } = _ref5,
133
- linePropsFromSeries = _objectWithoutPropertiesLoose(_ref5, _excluded5);
139
+ otherPropsFromSeries = _objectWithoutPropertiesLoose(_ref5, _excluded5);
134
140
  return /*#__PURE__*/_jsx(Line, _extends({
135
141
  LineComponent: LineComponent,
142
+ connectNulls: connectNulls,
136
143
  curve: curve,
137
- seriesId: id // Line component now handles stacked data automatically
138
- ,
139
- stroke: color // Default to series color
140
- ,
144
+ seriesId: id,
141
145
  strokeWidth: strokeWidth,
142
- type: lineType
143
- }, linePropsFromSeries), id + "-line");
146
+ transition: transition,
147
+ type: seriesLineType != null ? seriesLineType : lineType
148
+ }, otherPropsFromSeries), id);
144
149
  })), children]
145
150
  }));
146
151
  }));
@@ -1,128 +1,80 @@
1
- const _excluded = ["d", "fill", "fillOpacity", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "clipRect"];
1
+ const _excluded = ["d", "fill", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "animate", "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
- import { memo, useId } from 'react';
5
- import { Circle, Defs, G, LinearGradient, Mask, Pattern, Stop } from 'react-native-svg';
4
+ import { memo, useMemo } from 'react';
6
5
  import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
6
+ import { Group, Skia } from '@shopify/react-native-skia';
7
7
  import { useCartesianChartContext } from '../ChartProvider';
8
+ import { Gradient } from '../gradient';
8
9
  import { Path } from '../Path';
9
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
+ import { createGradient, getBaseline } from '../utils';
11
+ import { getDottedAreaPath } from '../utils/path';
12
+ import { usePathTransition } from '../utils/transition';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ /**
15
+ * A customizable dotted area gradient component.
16
+ * When no gradient is provided, renders a default gradient based
17
+ * on the fill color and peak/baseline opacities.
18
+ */
10
19
  export const DottedArea = /*#__PURE__*/memo(_ref => {
11
20
  let {
12
21
  d,
13
- fill,
14
- fillOpacity = 1,
22
+ fill: fillProp,
15
23
  patternSize = 4,
16
24
  dotSize = 1,
17
25
  peakOpacity = 1,
18
26
  baselineOpacity = 0,
19
27
  baseline,
20
28
  yAxisId,
21
- clipRect
29
+ gradient: gradientProp,
30
+ animate: animateProp,
31
+ transition
22
32
  } = _ref,
23
33
  pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
24
34
  const theme = useTheme();
25
- const context = useCartesianChartContext();
26
- const patternId = useId();
27
- const gradientId = useId();
28
- const maskId = useId();
29
- const dotCenterPosition = patternSize / 2;
30
-
31
- // Get the y-scale for the specified axis (or default)
32
- const yScale = context.getYScale(yAxisId);
33
- const yRange = yScale == null ? void 0 : yScale.range();
34
- const yDomain = yScale == null ? void 0 : yScale.domain();
35
-
36
- // Use chart range if available, otherwise fall back to percentage
37
- const useUserSpaceUnits = yRange !== undefined;
38
-
39
- // Auto-calculate baseline position based on domain
40
- let baselinePosition;
41
- let baselinePercentage;
42
- if (yScale && yDomain) {
43
- const [minValue, maxValue] = yDomain;
44
- let dataBaseline;
45
- if (minValue >= 0) {
46
- // All positive: baseline at min
47
- dataBaseline = minValue;
48
- } else if (maxValue <= 0) {
49
- // All negative: baseline at max
50
- dataBaseline = maxValue;
51
- } else {
52
- // Crosses zero: baseline at 0
53
- dataBaseline = 0;
54
- }
55
- if (useUserSpaceUnits && yRange) {
56
- // Get the actual y coordinate for the baseline
57
- const scaledValue = yScale(baseline != null ? baseline : dataBaseline);
58
- if (typeof scaledValue === 'number') {
59
- baselinePosition = scaledValue;
60
- }
61
- } else {
62
- // Calculate percentage position
63
- baselinePercentage = (maxValue - (baseline != null ? baseline : dataBaseline)) / (maxValue - minValue) * 100 + "%";
64
- }
65
- }
66
- const gradientY1 = useUserSpaceUnits && yRange ? String(yRange[1]) : '0%';
67
- const gradientY2 = useUserSpaceUnits && yRange ? String(yRange[0]) : '100%';
68
- const effectiveFill = fill != null ? fill : theme.color.fgPrimary;
69
- return /*#__PURE__*/_jsxs(G, {
70
- children: [/*#__PURE__*/_jsxs(Defs, {
71
- children: [/*#__PURE__*/_jsx(Pattern, {
72
- height: patternSize,
73
- id: patternId,
74
- patternUnits: "userSpaceOnUse",
75
- width: patternSize,
76
- x: "0",
77
- y: "0",
78
- children: /*#__PURE__*/_jsx(Circle, {
79
- cx: dotCenterPosition,
80
- cy: dotCenterPosition,
81
- fill: effectiveFill,
82
- r: dotSize
83
- })
84
- }), /*#__PURE__*/_jsx(LinearGradient, {
85
- gradientUnits: useUserSpaceUnits ? 'userSpaceOnUse' : 'objectBoundingBox',
86
- id: gradientId,
87
- x1: useUserSpaceUnits ? '0' : '0%',
88
- x2: useUserSpaceUnits ? '0' : '0%',
89
- y1: gradientY1,
90
- y2: gradientY2,
91
- children: baselinePosition !== undefined || baselinePercentage !== undefined ? /* Diverging gradient: high opacity at extremes, low at baseline */
92
- [/*#__PURE__*/_jsx(Stop, {
93
- offset: "0%",
94
- stopColor: "white",
95
- stopOpacity: peakOpacity
96
- }, "0"), /*#__PURE__*/_jsx(Stop, {
97
- offset: baselinePercentage != null ? baselinePercentage : (baselinePosition - yRange[1]) / (yRange[0] - yRange[1]) * 100 + "%",
98
- stopColor: "white",
99
- stopOpacity: baselineOpacity
100
- }, "1"), /*#__PURE__*/_jsx(Stop, {
101
- offset: "100%",
102
- stopColor: "white",
103
- stopOpacity: peakOpacity
104
- }, "2")] : /* Simple gradient from top to bottom */
105
- [/*#__PURE__*/_jsx(Stop, {
106
- offset: "0%",
107
- stopColor: "white",
108
- stopOpacity: peakOpacity
109
- }, "0"), /*#__PURE__*/_jsx(Stop, {
110
- offset: "100%",
111
- stopColor: "white",
112
- stopOpacity: baselineOpacity
113
- }, "1")]
114
- }), /*#__PURE__*/_jsx(Mask, {
115
- id: maskId,
116
- children: /*#__PURE__*/_jsx(Path, {
117
- d: d,
118
- fill: "url(#" + gradientId + ")"
119
- })
120
- })]
121
- }), /*#__PURE__*/_jsx(Path, _extends({
122
- clipRect: clipRect,
123
- d: d,
124
- fill: "url(#" + patternId + ")",
125
- mask: "url(#" + maskId + ")"
126
- }, pathProps))]
35
+ const {
36
+ drawingArea,
37
+ animate,
38
+ getYAxis
39
+ } = useCartesianChartContext();
40
+ const yAxisConfig = getYAxis(yAxisId);
41
+ const fill = useMemo(() => fillProp != null ? fillProp : theme.color.fgPrimary, [fillProp, theme.color.fgPrimary]);
42
+ const dottedPath = useMemo(() => {
43
+ if (!drawingArea) return '';
44
+ return getDottedAreaPath({
45
+ x: drawingArea.x,
46
+ y: drawingArea.y,
47
+ width: drawingArea.width,
48
+ height: drawingArea.height
49
+ }, patternSize, dotSize);
50
+ }, [drawingArea, patternSize, dotSize]);
51
+ const animatedClipPath = usePathTransition({
52
+ currentPath: d,
53
+ transition
54
+ });
55
+ const staticClipPath = useMemo(() => {
56
+ var _Skia$Path$MakeFromSV;
57
+ if (!d) return;
58
+ return (_Skia$Path$MakeFromSV = Skia.Path.MakeFromSVGString(d)) != null ? _Skia$Path$MakeFromSV : undefined;
59
+ }, [d]);
60
+ const gradient = useMemo(() => {
61
+ if (gradientProp) return gradientProp;
62
+ if (!yAxisConfig) return;
63
+ const baselineValue = getBaseline(yAxisConfig.domain, baseline);
64
+ return createGradient(yAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity);
65
+ }, [gradientProp, yAxisConfig, fill, baseline, peakOpacity, baselineOpacity]);
66
+ return /*#__PURE__*/_jsx(Group, {
67
+ clip: animate ? animatedClipPath : staticClipPath,
68
+ children: /*#__PURE__*/_jsx(Path, _extends({
69
+ animate: animateProp != null ? animateProp : animate,
70
+ d: dottedPath,
71
+ fill: fill,
72
+ transition: transition
73
+ }, pathProps, {
74
+ children: gradient && /*#__PURE__*/_jsx(Gradient, {
75
+ gradient: gradient,
76
+ yAxisId: yAxisId
77
+ })
78
+ }))
127
79
  });
128
80
  });
@@ -1,110 +1,54 @@
1
- const _excluded = ["d", "fill", "fillOpacity", "peakColor", "baselineColor", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "clipRect"];
1
+ const _excluded = ["d", "fill", "fillOpacity", "gradient", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "animate", "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
- import { memo, useId } from 'react';
5
- import { Defs, LinearGradient, Stop } from 'react-native-svg';
4
+ import { memo, useMemo } from 'react';
6
5
  import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
7
6
  import { useCartesianChartContext } from '../ChartProvider';
7
+ import { Gradient } from '../gradient';
8
8
  import { Path } from '../Path';
9
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
9
+ import { createGradient, getBaseline } from '../utils';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
10
11
  /**
11
- * A customizable gradient area component which uses Path.
12
+ * A customizable gradient area component.
13
+ * When no gradient is provided, renders a default gradient based
14
+ * on the fill color and peak/baseline opacities.
12
15
  */
13
16
  export const GradientArea = /*#__PURE__*/memo(_ref => {
14
17
  let {
15
18
  d,
16
- fill,
19
+ fill: fillProp,
17
20
  fillOpacity = 1,
18
- peakColor,
19
- baselineColor,
21
+ gradient: gradientProp,
20
22
  peakOpacity = 0.3,
21
23
  baselineOpacity = 0,
22
24
  baseline,
23
25
  yAxisId,
24
- clipRect
26
+ animate,
27
+ transition
25
28
  } = _ref,
26
29
  pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
27
- const context = useCartesianChartContext();
30
+ const {
31
+ getYAxis
32
+ } = useCartesianChartContext();
28
33
  const theme = useTheme();
29
- const patternId = useId();
30
-
31
- // Get the y-scale for the specified axis (or default)
32
- const yScale = context.getYScale(yAxisId);
33
- const yRange = yScale == null ? void 0 : yScale.range();
34
- const yDomain = yScale == null ? void 0 : yScale.domain();
35
-
36
- // Use chart range if available, otherwise fall back to percentage
37
- const useUserSpaceUnits = yRange !== undefined;
38
- const gradientY1 = useUserSpaceUnits && yRange ? String(yRange[1]) : '0%';
39
- const gradientY2 = useUserSpaceUnits && yRange ? String(yRange[0]) : '100%';
40
-
41
- // Auto-calculate baseline position based on domain
42
- let baselinePosition;
43
- let baselinePercentage;
44
- if (yScale && yDomain) {
45
- const [minValue, maxValue] = yDomain;
46
- let dataBaseline;
47
- if (minValue >= 0) {
48
- // All positive: baseline at min
49
- dataBaseline = minValue;
50
- } else if (maxValue <= 0) {
51
- // All negative: baseline at max
52
- dataBaseline = maxValue;
53
- } else {
54
- // Crosses zero: baseline at 0
55
- dataBaseline = 0;
56
- }
57
- if (useUserSpaceUnits && yRange) {
58
- // Get the actual y coordinate for the baseline
59
- const scaledValue = yScale(baseline != null ? baseline : dataBaseline);
60
- if (typeof scaledValue === 'number') {
61
- baselinePosition = scaledValue;
62
- }
63
- } else {
64
- // Calculate percentage position
65
- baselinePercentage = (maxValue - (baseline != null ? baseline : dataBaseline)) / (maxValue - minValue) * 100 + "%";
66
- }
67
- }
68
- const effectiveFill = fill != null ? fill : theme.color.fgPrimary;
69
- const effectivePeakColor = peakColor != null ? peakColor : effectiveFill;
70
- const effectiveBaselineColor = baselineColor != null ? baselineColor : effectiveFill;
71
- return /*#__PURE__*/_jsxs(_Fragment, {
72
- children: [/*#__PURE__*/_jsx(Defs, {
73
- children: /*#__PURE__*/_jsx(LinearGradient, {
74
- gradientUnits: useUserSpaceUnits ? 'userSpaceOnUse' : 'objectBoundingBox',
75
- id: patternId,
76
- x1: useUserSpaceUnits ? '0' : '0%',
77
- x2: useUserSpaceUnits ? '0' : '0%',
78
- y1: gradientY1,
79
- y2: gradientY2,
80
- children: baselinePosition !== undefined || baselinePercentage !== undefined ? /* Diverging gradient: peak opacity at extremes, baseline opacity at baseline */
81
- [/*#__PURE__*/_jsx(Stop, {
82
- offset: "0%",
83
- stopColor: effectivePeakColor,
84
- stopOpacity: peakOpacity
85
- }, "0"), /*#__PURE__*/_jsx(Stop, {
86
- offset: baselinePercentage != null ? baselinePercentage : (baselinePosition - yRange[1]) / (yRange[0] - yRange[1]) * 100 + "%",
87
- stopColor: effectiveBaselineColor,
88
- stopOpacity: baselineOpacity
89
- }, "1"), /*#__PURE__*/_jsx(Stop, {
90
- offset: "100%",
91
- stopColor: effectivePeakColor,
92
- stopOpacity: peakOpacity
93
- }, "2")] : /* Simple gradient from peak to baseline */
94
- [/*#__PURE__*/_jsx(Stop, {
95
- offset: "0%",
96
- stopColor: effectivePeakColor,
97
- stopOpacity: peakOpacity
98
- }, "0"), /*#__PURE__*/_jsx(Stop, {
99
- offset: "100%",
100
- stopColor: effectiveBaselineColor,
101
- stopOpacity: baselineOpacity
102
- }, "1")]
103
- })
104
- }), /*#__PURE__*/_jsx(Path, _extends({
105
- clipRect: clipRect,
106
- d: d,
107
- fill: "url(#" + patternId + ")"
108
- }, pathProps))]
109
- });
34
+ const yAxisConfig = getYAxis(yAxisId);
35
+ const fill = useMemo(() => fillProp != null ? fillProp : theme.color.fgPrimary, [fillProp, theme.color.fgPrimary]);
36
+ const gradient = useMemo(() => {
37
+ if (gradientProp) return gradientProp;
38
+ if (!yAxisConfig) return;
39
+ const baselineValue = getBaseline(yAxisConfig.domain, baseline);
40
+ return createGradient(yAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity);
41
+ }, [gradientProp, yAxisConfig, fill, baseline, peakOpacity, baselineOpacity]);
42
+ return /*#__PURE__*/_jsx(Path, _extends({
43
+ animate: animate,
44
+ d: d,
45
+ fill: fill,
46
+ fillOpacity: fillOpacity,
47
+ transition: transition
48
+ }, pathProps, {
49
+ children: gradient && /*#__PURE__*/_jsx(Gradient, {
50
+ gradient: gradient,
51
+ yAxisId: yAxisId
52
+ })
53
+ }));
110
54
  });
@@ -1,24 +1,38 @@
1
- const _excluded = ["d", "fill", "fillOpacity", "clipRect"];
1
+ const _excluded = ["d", "fill", "fillOpacity", "yAxisId", "animate", "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
4
  import { memo } from 'react';
5
+ import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
6
+ import { Gradient } from '../gradient';
5
7
  import { Path } from '../Path';
6
8
  import { jsx as _jsx } from "react/jsx-runtime";
7
9
  /**
8
- * A customizable solid area component which uses Path.
10
+ * A customizable solid area component.
11
+ * When a gradient is provided, renders with gradient fill.
12
+ * Otherwise, renders with solid fill.
9
13
  */
10
14
  export const SolidArea = /*#__PURE__*/memo(_ref => {
11
15
  let {
12
16
  d,
13
17
  fill,
14
18
  fillOpacity = 1,
15
- clipRect
19
+ yAxisId,
20
+ animate,
21
+ transition,
22
+ gradient
16
23
  } = _ref,
17
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
24
+ pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
25
+ const theme = useTheme();
18
26
  return /*#__PURE__*/_jsx(Path, _extends({
19
- clipRect: clipRect,
27
+ animate: animate,
20
28
  d: d,
21
- fill: fill,
22
- fillOpacity: fillOpacity
23
- }, props));
29
+ fill: fill != null ? fill : theme.color.fgPrimary,
30
+ fillOpacity: fillOpacity,
31
+ transition: transition
32
+ }, pathProps, {
33
+ children: gradient && /*#__PURE__*/_jsx(Gradient, {
34
+ gradient: gradient,
35
+ yAxisId: yAxisId
36
+ })
37
+ }));
24
38
  });
@@ -64,7 +64,7 @@ const AreaChartStories = () => {
64
64
  id: 'pageViews',
65
65
  data: [24, 13, -98, 39, 48, 38, 43]
66
66
  }],
67
- type: "gradient",
67
+ type: "solid",
68
68
  yAxis: {
69
69
  showGrid: true
70
70
  },
@@ -1,5 +1,7 @@
1
1
  /**
2
2
  * Animation variants for grouped axis tick labels - initial mount
3
+ * Note: Mobile currently doesn't use these variants. Axes render immediately without animation.
4
+ * Web uses similar variants with delay to match path enter animation timing.
3
5
  */
4
6
  export const axisTickLabelsInitialAnimationVariants = {
5
7
  initial: {
@@ -0,0 +1,11 @@
1
+ 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); }
2
+ import { memo } from 'react';
3
+ import { ChartText } from '../text';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ /**
6
+ * DefaultAxisTickLabel is the default label component for axis tick labels.
7
+ * Provides standard styling for both X and Y axis tick labels.
8
+ */
9
+ export const DefaultAxisTickLabel = /*#__PURE__*/memo(props => {
10
+ return /*#__PURE__*/_jsx(ChartText, _extends({}, props));
11
+ });