@coinbase/cds-mobile-visualization 3.3.0 → 3.4.0-beta.10

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 (265) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/dts/chart/CartesianChart.d.ts +125 -0
  3. package/dts/chart/CartesianChart.d.ts.map +1 -0
  4. package/dts/chart/ChartContextBridge.d.ts +28 -0
  5. package/dts/chart/ChartContextBridge.d.ts.map +1 -0
  6. package/dts/chart/ChartProvider.d.ts +6 -0
  7. package/dts/chart/ChartProvider.d.ts.map +1 -0
  8. package/dts/chart/Path.d.ts +91 -0
  9. package/dts/chart/Path.d.ts.map +1 -0
  10. package/dts/chart/PeriodSelector.d.ts +85 -0
  11. package/dts/chart/PeriodSelector.d.ts.map +1 -0
  12. package/dts/chart/area/Area.d.ts +77 -0
  13. package/dts/chart/area/Area.d.ts.map +1 -0
  14. package/dts/chart/area/AreaChart.d.ts +131 -0
  15. package/dts/chart/area/AreaChart.d.ts.map +1 -0
  16. package/dts/chart/area/DottedArea.d.ts +46 -0
  17. package/dts/chart/area/DottedArea.d.ts.map +1 -0
  18. package/dts/chart/area/GradientArea.d.ts +36 -0
  19. package/dts/chart/area/GradientArea.d.ts.map +1 -0
  20. package/dts/chart/area/SolidArea.d.ts +23 -0
  21. package/dts/chart/area/SolidArea.d.ts.map +1 -0
  22. package/dts/chart/area/index.d.ts +6 -0
  23. package/dts/chart/area/index.d.ts.map +1 -0
  24. package/dts/chart/axis/Axis.d.ts +194 -0
  25. package/dts/chart/axis/Axis.d.ts.map +1 -0
  26. package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
  27. package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
  28. package/dts/chart/axis/XAxis.d.ts +16 -0
  29. package/dts/chart/axis/XAxis.d.ts.map +1 -0
  30. package/dts/chart/axis/YAxis.d.ts +21 -0
  31. package/dts/chart/axis/YAxis.d.ts.map +1 -0
  32. package/dts/chart/axis/index.d.ts +5 -0
  33. package/dts/chart/axis/index.d.ts.map +1 -0
  34. package/dts/chart/bar/Bar.d.ts +92 -0
  35. package/dts/chart/bar/Bar.d.ts.map +1 -0
  36. package/dts/chart/bar/BarChart.d.ts +113 -0
  37. package/dts/chart/bar/BarChart.d.ts.map +1 -0
  38. package/dts/chart/bar/BarPlot.d.ts +30 -0
  39. package/dts/chart/bar/BarPlot.d.ts.map +1 -0
  40. package/dts/chart/bar/BarStack.d.ts +102 -0
  41. package/dts/chart/bar/BarStack.d.ts.map +1 -0
  42. package/dts/chart/bar/BarStackGroup.d.ts +36 -0
  43. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -0
  44. package/dts/chart/bar/DefaultBar.d.ts +7 -0
  45. package/dts/chart/bar/DefaultBar.d.ts.map +1 -0
  46. package/dts/chart/bar/DefaultBarStack.d.ts +7 -0
  47. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -0
  48. package/dts/chart/bar/index.d.ts +8 -0
  49. package/dts/chart/bar/index.d.ts.map +1 -0
  50. package/dts/chart/gradient/Gradient.d.ts +25 -0
  51. package/dts/chart/gradient/Gradient.d.ts.map +1 -0
  52. package/dts/chart/gradient/index.d.ts +2 -0
  53. package/dts/chart/gradient/index.d.ts.map +1 -0
  54. package/dts/chart/index.d.ts +15 -0
  55. package/dts/chart/index.d.ts.map +1 -0
  56. package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
  57. package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
  58. package/dts/chart/line/DottedLine.d.ts +20 -0
  59. package/dts/chart/line/DottedLine.d.ts.map +1 -0
  60. package/dts/chart/line/Line.d.ts +115 -0
  61. package/dts/chart/line/Line.d.ts.map +1 -0
  62. package/dts/chart/line/LineChart.d.ts +118 -0
  63. package/dts/chart/line/LineChart.d.ts.map +1 -0
  64. package/dts/chart/line/ReferenceLine.d.ts +139 -0
  65. package/dts/chart/line/ReferenceLine.d.ts.map +1 -0
  66. package/dts/chart/line/SolidLine.d.ts +15 -0
  67. package/dts/chart/line/SolidLine.d.ts.map +1 -0
  68. package/dts/chart/line/index.d.ts +7 -0
  69. package/dts/chart/line/index.d.ts.map +1 -0
  70. package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
  71. package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
  72. package/dts/chart/point/Point.d.ts +120 -0
  73. package/dts/chart/point/Point.d.ts.map +1 -0
  74. package/dts/chart/point/index.d.ts +3 -0
  75. package/dts/chart/point/index.d.ts.map +1 -0
  76. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +8 -0
  77. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
  78. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
  79. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
  80. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +11 -0
  81. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
  82. package/dts/chart/scrubber/Scrubber.d.ts +233 -0
  83. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -0
  84. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +44 -0
  85. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
  86. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +31 -0
  87. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
  88. package/dts/chart/scrubber/ScrubberProvider.d.ts +20 -0
  89. package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -0
  90. package/dts/chart/scrubber/index.d.ts +5 -0
  91. package/dts/chart/scrubber/index.d.ts.map +1 -0
  92. package/dts/chart/text/ChartText.d.ts +164 -0
  93. package/dts/chart/text/ChartText.d.ts.map +1 -0
  94. package/dts/chart/text/ChartTextGroup.d.ts +61 -0
  95. package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
  96. package/dts/chart/text/index.d.ts +3 -0
  97. package/dts/chart/text/index.d.ts.map +1 -0
  98. package/dts/chart/utils/axis.d.ts +342 -0
  99. package/dts/chart/utils/axis.d.ts.map +1 -0
  100. package/dts/chart/utils/bar.d.ts +20 -0
  101. package/dts/chart/utils/bar.d.ts.map +1 -0
  102. package/dts/chart/utils/chart.d.ts +124 -0
  103. package/dts/chart/utils/chart.d.ts.map +1 -0
  104. package/dts/chart/utils/context.d.ts +116 -0
  105. package/dts/chart/utils/context.d.ts.map +1 -0
  106. package/dts/chart/utils/gradient.d.ts +117 -0
  107. package/dts/chart/utils/gradient.d.ts.map +1 -0
  108. package/dts/chart/utils/index.d.ts +11 -0
  109. package/dts/chart/utils/index.d.ts.map +1 -0
  110. package/dts/chart/utils/path.d.ts +160 -0
  111. package/dts/chart/utils/path.d.ts.map +1 -0
  112. package/dts/chart/utils/point.d.ts +134 -0
  113. package/dts/chart/utils/point.d.ts.map +1 -0
  114. package/dts/chart/utils/scale.d.ts +134 -0
  115. package/dts/chart/utils/scale.d.ts.map +1 -0
  116. package/dts/chart/utils/scrubber.d.ts +39 -0
  117. package/dts/chart/utils/scrubber.d.ts.map +1 -0
  118. package/dts/chart/utils/transition.d.ts +140 -0
  119. package/dts/chart/utils/transition.d.ts.map +1 -0
  120. package/dts/index.d.ts +2 -1
  121. package/dts/index.d.ts.map +1 -1
  122. package/dts/sparkline/Counter.d.ts +7 -2
  123. package/dts/sparkline/Sparkline.d.ts +67 -16
  124. package/dts/sparkline/Sparkline.d.ts.map +1 -1
  125. package/dts/sparkline/SparklineArea.d.ts +10 -4
  126. package/dts/sparkline/SparklineArea.d.ts.map +1 -1
  127. package/dts/sparkline/SparklineAreaPattern.d.ts +12 -4
  128. package/dts/sparkline/SparklineAreaPattern.d.ts.map +1 -1
  129. package/dts/sparkline/SparklineGradient.d.ts +21 -10
  130. package/dts/sparkline/SparklineGradient.d.ts.map +1 -1
  131. package/dts/sparkline/__figma__/Sparkline.figma.d.ts +1 -1
  132. package/dts/sparkline/generateSparklineWithId.d.ts +8 -2
  133. package/dts/sparkline/generateSparklineWithId.d.ts.map +1 -1
  134. package/dts/sparkline/index.d.ts +1 -1
  135. package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts +8 -3
  136. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +132 -110
  137. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -1
  138. package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +22 -9
  139. package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +1 -1
  140. package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +18 -7
  141. package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +9 -4
  142. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +11 -6
  143. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts +7 -5
  144. package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts +22 -10
  145. package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +21 -7
  146. package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +1 -1
  147. package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +21 -16
  148. package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +29 -23
  149. package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +22 -14
  150. package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +1 -1
  151. package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts +9 -5
  152. package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts +11 -6
  153. package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts +5 -2
  154. package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +17 -17
  155. package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts +16 -13
  156. package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +106 -98
  157. package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +1 -1
  158. package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts +22 -19
  159. package/esm/chart/CartesianChart.js +335 -0
  160. package/esm/chart/ChartContextBridge.js +148 -0
  161. package/esm/chart/ChartProvider.js +10 -0
  162. package/esm/chart/Path.js +218 -0
  163. package/esm/chart/PeriodSelector.js +136 -0
  164. package/esm/chart/__stories__/CartesianChart.stories.js +723 -0
  165. package/esm/chart/__stories__/Chart.stories.js +77 -0
  166. package/esm/chart/__stories__/PeriodSelector.stories.js +322 -0
  167. package/esm/chart/area/Area.js +75 -0
  168. package/esm/chart/area/AreaChart.js +151 -0
  169. package/esm/chart/area/DottedArea.js +80 -0
  170. package/esm/chart/area/GradientArea.js +54 -0
  171. package/esm/chart/area/SolidArea.js +38 -0
  172. package/esm/chart/area/__stories__/AreaChart.stories.js +100 -0
  173. package/esm/chart/area/index.js +7 -0
  174. package/esm/chart/axis/Axis.js +45 -0
  175. package/esm/chart/axis/DefaultAxisTickLabel.js +11 -0
  176. package/esm/chart/axis/XAxis.js +188 -0
  177. package/esm/chart/axis/YAxis.js +177 -0
  178. package/esm/chart/axis/__stories__/Axis.stories.js +276 -0
  179. package/esm/chart/axis/index.js +6 -0
  180. package/esm/chart/bar/Bar.js +69 -0
  181. package/esm/chart/bar/BarChart.js +125 -0
  182. package/esm/chart/bar/BarPlot.js +102 -0
  183. package/esm/chart/bar/BarStack.js +551 -0
  184. package/esm/chart/bar/BarStackGroup.js +79 -0
  185. package/esm/chart/bar/DefaultBar.js +56 -0
  186. package/esm/chart/bar/DefaultBarStack.js +47 -0
  187. package/esm/chart/bar/__stories__/BarChart.stories.js +668 -0
  188. package/esm/chart/bar/index.js +9 -0
  189. package/esm/chart/gradient/Gradient.js +53 -0
  190. package/esm/chart/gradient/index.js +1 -0
  191. package/esm/chart/index.js +16 -0
  192. package/esm/chart/line/DefaultReferenceLineLabel.js +66 -0
  193. package/esm/chart/line/DottedLine.js +50 -0
  194. package/esm/chart/line/Line.js +178 -0
  195. package/esm/chart/line/LineChart.js +121 -0
  196. package/esm/chart/line/ReferenceLine.js +132 -0
  197. package/esm/chart/line/SolidLine.js +46 -0
  198. package/esm/chart/line/__stories__/LineChart.stories.js +2372 -0
  199. package/esm/chart/line/__stories__/ReferenceLine.stories.js +132 -0
  200. package/esm/chart/line/index.js +8 -0
  201. package/esm/chart/point/DefaultPointLabel.js +39 -0
  202. package/esm/chart/point/Point.js +188 -0
  203. package/esm/chart/point/index.js +2 -0
  204. package/esm/chart/scrubber/DefaultScrubberBeacon.js +179 -0
  205. package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +43 -0
  206. package/esm/chart/scrubber/DefaultScrubberLabel.js +28 -0
  207. package/esm/chart/scrubber/Scrubber.js +166 -0
  208. package/esm/chart/scrubber/ScrubberBeaconGroup.js +161 -0
  209. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +185 -0
  210. package/esm/chart/scrubber/ScrubberProvider.js +135 -0
  211. package/esm/chart/scrubber/index.js +4 -0
  212. package/esm/chart/text/ChartText.js +305 -0
  213. package/esm/chart/text/ChartTextGroup.js +211 -0
  214. package/esm/chart/text/index.js +4 -0
  215. package/esm/chart/utils/axis.js +592 -0
  216. package/esm/chart/utils/bar.js +24 -0
  217. package/esm/chart/utils/chart.js +270 -0
  218. package/esm/chart/utils/context.js +15 -0
  219. package/esm/chart/utils/gradient.js +305 -0
  220. package/esm/chart/utils/index.js +12 -0
  221. package/esm/chart/utils/path.js +274 -0
  222. package/esm/chart/utils/point.js +229 -0
  223. package/esm/chart/utils/scale.js +277 -0
  224. package/esm/chart/utils/scrubber.js +139 -0
  225. package/esm/chart/utils/transition.js +185 -0
  226. package/esm/index.js +4 -1
  227. package/esm/sparkline/Sparkline.js +129 -16
  228. package/esm/sparkline/SparklineArea.js +7 -2
  229. package/esm/sparkline/SparklineAreaPattern.js +4 -2
  230. package/esm/sparkline/SparklineGradient.js +4 -0
  231. package/esm/sparkline/__stories__/Sparkline.stories.js +11 -7
  232. package/esm/sparkline/__stories__/SparklineGradient.stories.js +7 -4
  233. package/esm/sparkline/generateSparklineWithId.js +3 -2
  234. package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +5 -1
  235. package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +5 -2
  236. package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +4 -0
  237. package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +76 -24
  238. package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +17 -9
  239. package/package.json +17 -11
  240. package/dts/sparkline/__stories__/Sparkline.stories.d.ts +0 -3
  241. package/dts/sparkline/__stories__/Sparkline.stories.d.ts.map +0 -1
  242. package/dts/sparkline/__stories__/SparklineGradient.stories.d.ts +0 -3
  243. package/dts/sparkline/__stories__/SparklineGradient.stories.d.ts.map +0 -1
  244. package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts +0 -3
  245. package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts.map +0 -1
  246. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts +0 -2
  247. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts.map +0 -1
  248. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveHoverDate.test.d.ts +0 -2
  249. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveHoverDate.test.d.ts.map +0 -1
  250. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePanGestureHandler.test.d.ts +0 -2
  251. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePanGestureHandler.test.d.ts.map +0 -1
  252. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts +0 -2
  253. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts.map +0 -1
  254. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveTimeseriesPaths.test.d.ts +0 -2
  255. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveTimeseriesPaths.test.d.ts.map +0 -1
  256. package/dts/sparkline/sparkline-interactive/__tests__/useMinMaxTransform.test.d.ts +0 -2
  257. package/dts/sparkline/sparkline-interactive/__tests__/useMinMaxTransform.test.d.ts.map +0 -1
  258. package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.d.ts +0 -2
  259. package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.d.ts.map +0 -1
  260. package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts +0 -4
  261. package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts.map +0 -1
  262. package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts +0 -2
  263. package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts.map +0 -1
  264. package/dts/sparkline/sparkline-interactive-header/__tests__/useSparklineInteractiveHeaderStyles.test.d.ts +0 -2
  265. package/dts/sparkline/sparkline-interactive-header/__tests__/useSparklineInteractiveHeaderStyles.test.d.ts.map +0 -1
@@ -0,0 +1,80 @@
1
+ const _excluded = ["d", "fill", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "animate", "transition"];
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
+ 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, useMemo } from 'react';
5
+ import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
6
+ import { Group, Skia } from '@shopify/react-native-skia';
7
+ import { useCartesianChartContext } from '../ChartProvider';
8
+ import { Gradient } from '../gradient';
9
+ import { Path } from '../Path';
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
+ */
19
+ export const DottedArea = /*#__PURE__*/memo(_ref => {
20
+ let {
21
+ d,
22
+ fill: fillProp,
23
+ patternSize = 4,
24
+ dotSize = 1,
25
+ peakOpacity = 1,
26
+ baselineOpacity = 0,
27
+ baseline,
28
+ yAxisId,
29
+ gradient: gradientProp,
30
+ animate: animateProp,
31
+ transition
32
+ } = _ref,
33
+ pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
34
+ const theme = useTheme();
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
+ }))
79
+ });
80
+ });
@@ -0,0 +1,54 @@
1
+ const _excluded = ["d", "fill", "fillOpacity", "gradient", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "animate", "transition"];
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
+ 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, useMemo } from 'react';
5
+ import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
6
+ import { useCartesianChartContext } from '../ChartProvider';
7
+ import { Gradient } from '../gradient';
8
+ import { Path } from '../Path';
9
+ import { createGradient, getBaseline } from '../utils';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ /**
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.
15
+ */
16
+ export const GradientArea = /*#__PURE__*/memo(_ref => {
17
+ let {
18
+ d,
19
+ fill: fillProp,
20
+ fillOpacity = 1,
21
+ gradient: gradientProp,
22
+ peakOpacity = 0.3,
23
+ baselineOpacity = 0,
24
+ baseline,
25
+ yAxisId,
26
+ animate,
27
+ transition
28
+ } = _ref,
29
+ pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
30
+ const {
31
+ getYAxis
32
+ } = useCartesianChartContext();
33
+ const theme = useTheme();
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
+ }));
54
+ });
@@ -0,0 +1,38 @@
1
+ const _excluded = ["d", "fill", "fillOpacity", "yAxisId", "animate", "transition", "gradient"];
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
+ 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 } from 'react';
5
+ import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
6
+ import { Gradient } from '../gradient';
7
+ import { Path } from '../Path';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ /**
10
+ * A customizable solid area component.
11
+ * When a gradient is provided, renders with gradient fill.
12
+ * Otherwise, renders with solid fill.
13
+ */
14
+ export const SolidArea = /*#__PURE__*/memo(_ref => {
15
+ let {
16
+ d,
17
+ fill,
18
+ fillOpacity = 1,
19
+ yAxisId,
20
+ animate,
21
+ transition,
22
+ gradient
23
+ } = _ref,
24
+ pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
25
+ const theme = useTheme();
26
+ return /*#__PURE__*/_jsx(Path, _extends({
27
+ animate: animate,
28
+ d: d,
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
+ }));
38
+ });
@@ -0,0 +1,100 @@
1
+ import { Example, ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
2
+ import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
3
+ import { DottedLine } from '../../line';
4
+ import { Scrubber } from '../../scrubber/Scrubber';
5
+ import { AreaChart } from '..';
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ const BasicExample = () => {
8
+ return /*#__PURE__*/_jsx(AreaChart, {
9
+ enableScrubbing: true,
10
+ showYAxis: true,
11
+ height: 400,
12
+ series: [{
13
+ id: 'pageViews',
14
+ data: [24, 13, 98, 39, 48, 38, 43]
15
+ }],
16
+ yAxis: {
17
+ showGrid: true,
18
+ domain: {
19
+ min: 0
20
+ }
21
+ },
22
+ children: /*#__PURE__*/_jsx(Scrubber, {})
23
+ });
24
+ };
25
+ const StackedExample = () => {
26
+ const theme = useTheme();
27
+ return /*#__PURE__*/_jsx(AreaChart, {
28
+ enableScrubbing: true,
29
+ showLines: true,
30
+ stacked: true,
31
+ curve: "natural",
32
+ height: 256,
33
+ series: [{
34
+ id: 'currentRewards',
35
+ data: [100, 150, 200, 280, 380, 500, 650, 820, 1020, 1250, 1510, 1800, 2120, 2470, 2850, 3260, 3700, 4170],
36
+ color: theme.color.fg
37
+ }, {
38
+ id: 'potentialRewards',
39
+ data: [150, 220, 300, 400, 520, 660, 820, 1000, 1200, 1420, 1660, 1920, 2200, 2500, 2820, 3160, 3520, 3900],
40
+ color: theme.color.fgPositive,
41
+ type: 'dotted',
42
+ LineComponent: DottedLine
43
+ }],
44
+ type: "dotted",
45
+ children: /*#__PURE__*/_jsx(Scrubber, {})
46
+ });
47
+ };
48
+ const AreaChartStories = () => {
49
+ return /*#__PURE__*/_jsxs(ExampleScreen, {
50
+ children: [/*#__PURE__*/_jsx(Example, {
51
+ title: "Basic",
52
+ children: /*#__PURE__*/_jsx(BasicExample, {})
53
+ }), /*#__PURE__*/_jsx(Example, {
54
+ title: "Stacked",
55
+ children: /*#__PURE__*/_jsx(StackedExample, {})
56
+ }), /*#__PURE__*/_jsx(Example, {
57
+ title: "Negative Values",
58
+ children: /*#__PURE__*/_jsx(AreaChart, {
59
+ enableScrubbing: true,
60
+ showLines: true,
61
+ showYAxis: true,
62
+ height: 400,
63
+ series: [{
64
+ id: 'pageViews',
65
+ data: [24, 13, -98, 39, 48, 38, 43]
66
+ }],
67
+ type: "solid",
68
+ yAxis: {
69
+ showGrid: true
70
+ },
71
+ children: /*#__PURE__*/_jsx(Scrubber, {})
72
+ })
73
+ }), /*#__PURE__*/_jsx(Example, {
74
+ title: "Styles",
75
+ children: /*#__PURE__*/_jsx(AreaChart, {
76
+ enableScrubbing: false,
77
+ height: 350,
78
+ series: [{
79
+ id: 'visitors',
80
+ data: [450, 520, 480, 600, 750, 680, 590],
81
+ label: 'Weekly Visitors',
82
+ color: '#fb4d3d',
83
+ type: 'dotted'
84
+ }, {
85
+ id: 'repeatVisitors',
86
+ data: [250, 200, 150, 140, 100, 80, 50],
87
+ label: 'Weekly Repeat Visitors',
88
+ color: '#16a34a'
89
+ }, {
90
+ id: 'signups',
91
+ data: [45, 62, 55, 250, 380, 400, 450],
92
+ label: 'Weekly Signups',
93
+ color: '#2563eb',
94
+ type: 'gradient'
95
+ }]
96
+ })
97
+ })]
98
+ });
99
+ };
100
+ export default AreaChartStories;
@@ -0,0 +1,7 @@
1
+ // codegen:start {preset: barrel, include: ./*.tsx, exclude: ./__stories__/*.tsx}
2
+ export * from './Area';
3
+ export * from './AreaChart';
4
+ export * from './DottedArea';
5
+ export * from './GradientArea';
6
+ export * from './SolidArea';
7
+ // codegen:end
@@ -0,0 +1,45 @@
1
+ /**
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.
5
+ */
6
+ export const axisTickLabelsInitialAnimationVariants = {
7
+ initial: {
8
+ opacity: 0
9
+ },
10
+ animate: {
11
+ opacity: 1,
12
+ transition: {
13
+ duration: 0,
14
+ delay: 0
15
+ }
16
+ },
17
+ exit: {
18
+ opacity: 0,
19
+ transition: {
20
+ duration: 0.15
21
+ }
22
+ }
23
+ };
24
+
25
+ /**
26
+ * Animation variants for axis elements - updates (used for both grid lines and tick labels)
27
+ */
28
+ export const axisUpdateAnimationVariants = {
29
+ initial: {
30
+ opacity: 0
31
+ },
32
+ animate: {
33
+ opacity: 1,
34
+ transition: {
35
+ duration: 0.15,
36
+ delay: 0.15 // For updates: fade out 150ms, then fade in 150ms
37
+ }
38
+ },
39
+ exit: {
40
+ opacity: 0,
41
+ transition: {
42
+ duration: 0.15
43
+ }
44
+ }
45
+ };
@@ -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
+ });
@@ -0,0 +1,188 @@
1
+ const _excluded = ["position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "tickMinStep", "tickMaxStep", "label", "labelGap", "height"];
2
+ 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; }
3
+ import { memo, useCallback, useEffect, useId, useMemo } from 'react';
4
+ import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
5
+ import { Group } from '@shopify/react-native-skia';
6
+ import { useCartesianChartContext } from '../ChartProvider';
7
+ import { DottedLine } from '../line/DottedLine';
8
+ import { ReferenceLine } from '../line/ReferenceLine';
9
+ import { SolidLine } from '../line/SolidLine';
10
+ import { ChartText } from '../text/ChartText';
11
+ import { ChartTextGroup } from '../text/ChartTextGroup';
12
+ import { getAxisTicksData, isCategoricalScale, lineToPath } from '../utils';
13
+ import { DefaultAxisTickLabel } from './DefaultAxisTickLabel';
14
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
+ const AXIS_HEIGHT = 32;
16
+ const LABEL_SIZE = 20;
17
+ export const XAxis = /*#__PURE__*/memo(_ref => {
18
+ let {
19
+ position = 'bottom',
20
+ showGrid,
21
+ requestedTickCount,
22
+ ticks,
23
+ tickLabelFormatter,
24
+ TickLabelComponent = DefaultAxisTickLabel,
25
+ GridLineComponent = DottedLine,
26
+ LineComponent = SolidLine,
27
+ TickMarkLineComponent = SolidLine,
28
+ tickMarkLabelGap = 2,
29
+ minTickLabelGap = 4,
30
+ showTickMarks,
31
+ showLine,
32
+ tickMarkSize = 4,
33
+ tickInterval = 32,
34
+ tickMinStep = 1,
35
+ tickMaxStep,
36
+ label,
37
+ labelGap = 4,
38
+ height = label ? AXIS_HEIGHT + LABEL_SIZE : AXIS_HEIGHT
39
+ } = _ref,
40
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
41
+ const theme = useTheme();
42
+ const registrationId = useId();
43
+ const {
44
+ animate,
45
+ getXScale,
46
+ getXAxis,
47
+ registerAxis,
48
+ unregisterAxis,
49
+ getAxisBounds
50
+ } = useCartesianChartContext();
51
+ const xScale = getXScale();
52
+ const xAxis = getXAxis();
53
+ const axisBounds = getAxisBounds(registrationId);
54
+
55
+ // Note: gridOpacity not currently used in Skia version
56
+ // const gridOpacity = useSharedValue(1);
57
+
58
+ useEffect(() => {
59
+ registerAxis(registrationId, position, height);
60
+ return () => unregisterAxis(registrationId);
61
+ }, [registrationId, registerAxis, unregisterAxis, position, height]);
62
+ const formatTick = useCallback(value => {
63
+ var _tickLabelFormatter;
64
+ // If we have string labels and no custom formatter, use the labels
65
+ const axisData = xAxis == null ? void 0 : xAxis.data;
66
+ const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
67
+ let finalValue = value;
68
+
69
+ // For band scales with string data, value is an index
70
+ if (hasStringLabels && typeof value === 'number' && axisData[value] !== undefined) {
71
+ finalValue = axisData[value];
72
+ }
73
+
74
+ // Use the formatter (if provided) or the value itself
75
+ return (_tickLabelFormatter = tickLabelFormatter == null ? void 0 : tickLabelFormatter(finalValue)) != null ? _tickLabelFormatter : finalValue;
76
+ }, [xAxis == null ? void 0 : xAxis.data, tickLabelFormatter]);
77
+ const ticksData = useMemo(() => {
78
+ if (!xScale) return [];
79
+
80
+ // Check if we have string labels
81
+ const axisData = xAxis == null ? void 0 : xAxis.data;
82
+ const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
83
+
84
+ // For band scales, we need categories
85
+ let categories;
86
+ if (hasStringLabels) {
87
+ categories = axisData;
88
+ } else if (isCategoricalScale(xScale)) {
89
+ // For band scales without explicit string data, generate numeric categories
90
+ // based on the domain of the scale
91
+ const domain = xScale.domain();
92
+ categories = domain.map(String);
93
+ }
94
+ let possibleTickValues;
95
+
96
+ // If we have discrete data, we can use the indices as possible tick values
97
+ if (axisData && Array.isArray(axisData) && (typeof axisData[0] === 'string' || typeof axisData[0] === 'number' && isCategoricalScale(xScale))) {
98
+ possibleTickValues = Array.from({
99
+ length: axisData.length
100
+ }, (_, i) => i);
101
+ }
102
+ return getAxisTicksData({
103
+ scaleFunction: xScale,
104
+ ticks,
105
+ requestedTickCount,
106
+ categories,
107
+ possibleTickValues,
108
+ tickInterval: tickInterval,
109
+ options: {
110
+ minStep: tickMinStep,
111
+ maxStep: tickMaxStep
112
+ }
113
+ });
114
+ }, [ticks, xScale, requestedTickCount, tickInterval, tickMinStep, tickMaxStep, xAxis == null ? void 0 : xAxis.data]);
115
+ const chartTextData = useMemo(() => {
116
+ if (!axisBounds) return null;
117
+ return ticksData.map(tick => {
118
+ const tickOffset = tickMarkLabelGap + (showTickMarks ? tickMarkSize : 0);
119
+
120
+ // Use AXIS_HEIGHT for centering, not full axisBounds.height
121
+ // This ensures tick labels are centered in the axis area, not including label space
122
+ const availableSpace = AXIS_HEIGHT - tickOffset;
123
+ const labelOffset = availableSpace / 2;
124
+
125
+ // For bottom position: start at axisBounds.y
126
+ // For top position with label: start at axisBounds.y + LABEL_SIZE
127
+ const baseY = position === 'top' && label ? axisBounds.y + LABEL_SIZE : axisBounds.y;
128
+ const labelY = position === 'top' ? baseY + labelOffset - tickOffset : baseY + labelOffset + tickOffset;
129
+ return {
130
+ x: tick.position,
131
+ y: labelY,
132
+ label: String(formatTick(tick.tick)),
133
+ chartTextProps: {
134
+ color: theme.color.fgMuted,
135
+ verticalAlignment: 'middle',
136
+ horizontalAlignment: 'center'
137
+ }
138
+ };
139
+ });
140
+ }, [axisBounds, ticksData, theme.color.fgMuted, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick, label]);
141
+ if (!xScale || !axisBounds) return;
142
+ const labelX = axisBounds.x + axisBounds.width / 2;
143
+ const labelY = position === 'bottom' ? axisBounds.y + axisBounds.height - LABEL_SIZE / 2 : axisBounds.y + LABEL_SIZE / 2;
144
+ return /*#__PURE__*/_jsxs(Group, {
145
+ children: [showGrid && /*#__PURE__*/_jsx(Group, {
146
+ children: ticksData.map((tick, index) => {
147
+ const verticalLine = /*#__PURE__*/_jsx(ReferenceLine, {
148
+ LineComponent: GridLineComponent,
149
+ dataX: tick.tick
150
+ });
151
+ return /*#__PURE__*/_jsx(Group, {
152
+ children: verticalLine
153
+ }, "grid-" + tick.tick + "-" + index);
154
+ })
155
+ }), chartTextData && /*#__PURE__*/_jsx(ChartTextGroup, {
156
+ prioritizeEndLabels: true,
157
+ LabelComponent: TickLabelComponent,
158
+ labels: chartTextData,
159
+ minGap: minTickLabelGap
160
+ }), axisBounds && showTickMarks && /*#__PURE__*/_jsx(Group, {
161
+ children: ticksData.map((tick, index) => {
162
+ const tickY = position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height;
163
+ const tickY2 = position === 'bottom' ? axisBounds.y + tickMarkSize : axisBounds.y + axisBounds.height - tickMarkSize;
164
+ return /*#__PURE__*/_jsx(TickMarkLineComponent, {
165
+ animate: false,
166
+ clipPath: null,
167
+ d: lineToPath(tick.position, tickY, tick.position, tickY2),
168
+ stroke: theme.color.fg,
169
+ strokeCap: "square",
170
+ strokeWidth: 1
171
+ }, "tick-mark-" + tick.tick + "-" + index);
172
+ })
173
+ }), showLine && /*#__PURE__*/_jsx(LineComponent, {
174
+ animate: false,
175
+ clipPath: null,
176
+ d: lineToPath(axisBounds.x, position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height, axisBounds.x + axisBounds.width, position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height),
177
+ stroke: theme.color.fg,
178
+ strokeCap: "square",
179
+ strokeWidth: 1
180
+ }), label && /*#__PURE__*/_jsx(ChartText, {
181
+ horizontalAlignment: "center",
182
+ verticalAlignment: "middle",
183
+ x: labelX,
184
+ y: labelY,
185
+ children: label
186
+ })]
187
+ });
188
+ });