@coinbase/cds-mobile-visualization 3.8.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dts/chart/index.d.ts +1 -15
  3. package/dts/chart/index.d.ts.map +1 -1
  4. package/dts/index.d.ts.map +1 -1
  5. package/dts/sparkline/index.d.ts +1 -5
  6. package/dts/sparkline/index.d.ts.map +1 -1
  7. package/esm/chart/index.js +1 -17
  8. package/esm/index.js +1 -3
  9. package/esm/sparkline/index.js +1 -5
  10. package/package.json +26 -20
  11. package/dts/chart/CartesianChart.d.ts +0 -206
  12. package/dts/chart/CartesianChart.d.ts.map +0 -1
  13. package/dts/chart/ChartContextBridge.d.ts +0 -28
  14. package/dts/chart/ChartContextBridge.d.ts.map +0 -1
  15. package/dts/chart/ChartProvider.d.ts +0 -9
  16. package/dts/chart/ChartProvider.d.ts.map +0 -1
  17. package/dts/chart/Path.d.ts +0 -121
  18. package/dts/chart/Path.d.ts.map +0 -1
  19. package/dts/chart/PeriodSelector.d.ts +0 -100
  20. package/dts/chart/PeriodSelector.d.ts.map +0 -1
  21. package/dts/chart/area/Area.d.ts +0 -83
  22. package/dts/chart/area/Area.d.ts.map +0 -1
  23. package/dts/chart/area/AreaChart.d.ts +0 -155
  24. package/dts/chart/area/AreaChart.d.ts.map +0 -1
  25. package/dts/chart/area/DottedArea.d.ts +0 -46
  26. package/dts/chart/area/DottedArea.d.ts.map +0 -1
  27. package/dts/chart/area/GradientArea.d.ts +0 -36
  28. package/dts/chart/area/GradientArea.d.ts.map +0 -1
  29. package/dts/chart/area/SolidArea.d.ts +0 -23
  30. package/dts/chart/area/SolidArea.d.ts.map +0 -1
  31. package/dts/chart/area/index.d.ts +0 -6
  32. package/dts/chart/area/index.d.ts.map +0 -1
  33. package/dts/chart/axis/Axis.d.ts +0 -174
  34. package/dts/chart/axis/Axis.d.ts.map +0 -1
  35. package/dts/chart/axis/DefaultAxisTickLabel.d.ts +0 -8
  36. package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +0 -1
  37. package/dts/chart/axis/XAxis.d.ts +0 -22
  38. package/dts/chart/axis/XAxis.d.ts.map +0 -1
  39. package/dts/chart/axis/YAxis.d.ts +0 -22
  40. package/dts/chart/axis/YAxis.d.ts.map +0 -1
  41. package/dts/chart/axis/index.d.ts +0 -5
  42. package/dts/chart/axis/index.d.ts.map +0 -1
  43. package/dts/chart/bar/Bar.d.ts +0 -100
  44. package/dts/chart/bar/Bar.d.ts.map +0 -1
  45. package/dts/chart/bar/BarChart.d.ts +0 -158
  46. package/dts/chart/bar/BarChart.d.ts.map +0 -1
  47. package/dts/chart/bar/BarPlot.d.ts +0 -31
  48. package/dts/chart/bar/BarPlot.d.ts.map +0 -1
  49. package/dts/chart/bar/BarStack.d.ts +0 -127
  50. package/dts/chart/bar/BarStack.d.ts.map +0 -1
  51. package/dts/chart/bar/BarStackGroup.d.ts +0 -37
  52. package/dts/chart/bar/BarStackGroup.d.ts.map +0 -1
  53. package/dts/chart/bar/DefaultBar.d.ts +0 -7
  54. package/dts/chart/bar/DefaultBar.d.ts.map +0 -1
  55. package/dts/chart/bar/DefaultBarStack.d.ts +0 -7
  56. package/dts/chart/bar/DefaultBarStack.d.ts.map +0 -1
  57. package/dts/chart/bar/PercentageBarChart.d.ts +0 -106
  58. package/dts/chart/bar/PercentageBarChart.d.ts.map +0 -1
  59. package/dts/chart/bar/index.d.ts +0 -9
  60. package/dts/chart/bar/index.d.ts.map +0 -1
  61. package/dts/chart/gradient/Gradient.d.ts +0 -41
  62. package/dts/chart/gradient/Gradient.d.ts.map +0 -1
  63. package/dts/chart/gradient/index.d.ts +0 -2
  64. package/dts/chart/gradient/index.d.ts.map +0 -1
  65. package/dts/chart/legend/DefaultLegendEntry.d.ts +0 -5
  66. package/dts/chart/legend/DefaultLegendEntry.d.ts.map +0 -1
  67. package/dts/chart/legend/DefaultLegendShape.d.ts +0 -5
  68. package/dts/chart/legend/DefaultLegendShape.d.ts.map +0 -1
  69. package/dts/chart/legend/Legend.d.ts +0 -168
  70. package/dts/chart/legend/Legend.d.ts.map +0 -1
  71. package/dts/chart/legend/index.d.ts +0 -4
  72. package/dts/chart/legend/index.d.ts.map +0 -1
  73. package/dts/chart/line/DefaultReferenceLineLabel.d.ts +0 -9
  74. package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +0 -1
  75. package/dts/chart/line/DottedLine.d.ts +0 -20
  76. package/dts/chart/line/DottedLine.d.ts.map +0 -1
  77. package/dts/chart/line/Line.d.ts +0 -122
  78. package/dts/chart/line/Line.d.ts.map +0 -1
  79. package/dts/chart/line/LineChart.d.ts +0 -135
  80. package/dts/chart/line/LineChart.d.ts.map +0 -1
  81. package/dts/chart/line/ReferenceLine.d.ts +0 -140
  82. package/dts/chart/line/ReferenceLine.d.ts.map +0 -1
  83. package/dts/chart/line/SolidLine.d.ts +0 -15
  84. package/dts/chart/line/SolidLine.d.ts.map +0 -1
  85. package/dts/chart/line/index.d.ts +0 -7
  86. package/dts/chart/line/index.d.ts.map +0 -1
  87. package/dts/chart/point/DefaultPointLabel.d.ts +0 -10
  88. package/dts/chart/point/DefaultPointLabel.d.ts.map +0 -1
  89. package/dts/chart/point/Point.d.ts +0 -144
  90. package/dts/chart/point/Point.d.ts.map +0 -1
  91. package/dts/chart/point/index.d.ts +0 -3
  92. package/dts/chart/point/index.d.ts.map +0 -1
  93. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +0 -38
  94. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +0 -1
  95. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +0 -12
  96. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +0 -1
  97. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +0 -12
  98. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +0 -1
  99. package/dts/chart/scrubber/Scrubber.d.ts +0 -302
  100. package/dts/chart/scrubber/Scrubber.d.ts.map +0 -1
  101. package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts +0 -12
  102. package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts.map +0 -1
  103. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +0 -54
  104. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +0 -1
  105. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +0 -46
  106. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +0 -1
  107. package/dts/chart/scrubber/ScrubberProvider.d.ts +0 -20
  108. package/dts/chart/scrubber/ScrubberProvider.d.ts.map +0 -1
  109. package/dts/chart/scrubber/index.d.ts +0 -5
  110. package/dts/chart/scrubber/index.d.ts.map +0 -1
  111. package/dts/chart/text/ChartText.d.ts +0 -164
  112. package/dts/chart/text/ChartText.d.ts.map +0 -1
  113. package/dts/chart/text/ChartTextGroup.d.ts +0 -61
  114. package/dts/chart/text/ChartTextGroup.d.ts.map +0 -1
  115. package/dts/chart/text/index.d.ts +0 -3
  116. package/dts/chart/text/index.d.ts.map +0 -1
  117. package/dts/chart/utils/axis.d.ts +0 -387
  118. package/dts/chart/utils/axis.d.ts.map +0 -1
  119. package/dts/chart/utils/bar.d.ts +0 -225
  120. package/dts/chart/utils/bar.d.ts.map +0 -1
  121. package/dts/chart/utils/chart.d.ts +0 -165
  122. package/dts/chart/utils/chart.d.ts.map +0 -1
  123. package/dts/chart/utils/context.d.ts +0 -131
  124. package/dts/chart/utils/context.d.ts.map +0 -1
  125. package/dts/chart/utils/gradient.d.ts +0 -129
  126. package/dts/chart/utils/gradient.d.ts.map +0 -1
  127. package/dts/chart/utils/index.d.ts +0 -11
  128. package/dts/chart/utils/index.d.ts.map +0 -1
  129. package/dts/chart/utils/path.d.ts +0 -186
  130. package/dts/chart/utils/path.d.ts.map +0 -1
  131. package/dts/chart/utils/point.d.ts +0 -146
  132. package/dts/chart/utils/point.d.ts.map +0 -1
  133. package/dts/chart/utils/scale.d.ts +0 -145
  134. package/dts/chart/utils/scale.d.ts.map +0 -1
  135. package/dts/chart/utils/scrubber.d.ts +0 -40
  136. package/dts/chart/utils/scrubber.d.ts.map +0 -1
  137. package/dts/chart/utils/transition.d.ts +0 -181
  138. package/dts/chart/utils/transition.d.ts.map +0 -1
  139. package/dts/sparkline/Counter.d.ts +0 -8
  140. package/dts/sparkline/Counter.d.ts.map +0 -1
  141. package/dts/sparkline/Sparkline.d.ts +0 -74
  142. package/dts/sparkline/Sparkline.d.ts.map +0 -1
  143. package/dts/sparkline/SparklineArea.d.ts +0 -15
  144. package/dts/sparkline/SparklineArea.d.ts.map +0 -1
  145. package/dts/sparkline/SparklineAreaPattern.d.ts +0 -14
  146. package/dts/sparkline/SparklineAreaPattern.d.ts.map +0 -1
  147. package/dts/sparkline/SparklineGradient.d.ts +0 -24
  148. package/dts/sparkline/SparklineGradient.d.ts.map +0 -1
  149. package/dts/sparkline/__figma__/Sparkline.figma.d.ts +0 -2
  150. package/dts/sparkline/__figma__/Sparkline.figma.d.ts.map +0 -1
  151. package/dts/sparkline/generateSparklineWithId.d.ts +0 -11
  152. package/dts/sparkline/generateSparklineWithId.d.ts.map +0 -1
  153. package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts +0 -23
  154. package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts.map +0 -1
  155. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +0 -185
  156. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +0 -1
  157. package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +0 -25
  158. package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +0 -1
  159. package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +0 -28
  160. package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts.map +0 -1
  161. package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +0 -13
  162. package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts.map +0 -1
  163. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +0 -17
  164. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts.map +0 -1
  165. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts +0 -11
  166. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts.map +0 -1
  167. package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts +0 -26
  168. package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts.map +0 -1
  169. package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +0 -25
  170. package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +0 -1
  171. package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +0 -25
  172. package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts.map +0 -1
  173. package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +0 -39
  174. package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts.map +0 -1
  175. package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +0 -31
  176. package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts.map +0 -1
  177. package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +0 -2
  178. package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts.map +0 -1
  179. package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts +0 -13
  180. package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts.map +0 -1
  181. package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts +0 -16
  182. package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts.map +0 -1
  183. package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts +0 -6
  184. package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts.map +0 -1
  185. package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +0 -22
  186. package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts.map +0 -1
  187. package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts +0 -34
  188. package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts.map +0 -1
  189. package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +0 -118
  190. package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts.map +0 -1
  191. package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +0 -2
  192. package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts.map +0 -1
  193. package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts +0 -29
  194. package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts.map +0 -1
  195. package/esm/chart/CartesianChart.js +0 -431
  196. package/esm/chart/ChartContextBridge.js +0 -159
  197. package/esm/chart/ChartProvider.js +0 -10
  198. package/esm/chart/Path.js +0 -255
  199. package/esm/chart/PeriodSelector.js +0 -139
  200. package/esm/chart/__stories__/CartesianChart.stories.js +0 -659
  201. package/esm/chart/__stories__/ChartAccessibility.stories.js +0 -721
  202. package/esm/chart/__stories__/ChartTransitions.stories.js +0 -693
  203. package/esm/chart/__stories__/PeriodSelector.stories.js +0 -420
  204. package/esm/chart/area/Area.js +0 -85
  205. package/esm/chart/area/AreaChart.js +0 -152
  206. package/esm/chart/area/DottedArea.js +0 -92
  207. package/esm/chart/area/GradientArea.js +0 -63
  208. package/esm/chart/area/SolidArea.js +0 -45
  209. package/esm/chart/area/__stories__/AreaChart.stories.js +0 -370
  210. package/esm/chart/area/index.js +0 -7
  211. package/esm/chart/axis/Axis.js +0 -9
  212. package/esm/chart/axis/DefaultAxisTickLabel.js +0 -11
  213. package/esm/chart/axis/XAxis.js +0 -256
  214. package/esm/chart/axis/YAxis.js +0 -255
  215. package/esm/chart/axis/__stories__/Axis.stories.js +0 -552
  216. package/esm/chart/axis/index.js +0 -6
  217. package/esm/chart/bar/Bar.js +0 -71
  218. package/esm/chart/bar/BarChart.js +0 -122
  219. package/esm/chart/bar/BarPlot.js +0 -106
  220. package/esm/chart/bar/BarStack.js +0 -173
  221. package/esm/chart/bar/BarStackGroup.js +0 -89
  222. package/esm/chart/bar/DefaultBar.js +0 -79
  223. package/esm/chart/bar/DefaultBarStack.js +0 -68
  224. package/esm/chart/bar/PercentageBarChart.js +0 -99
  225. package/esm/chart/bar/__stories__/BarChart.stories.js +0 -1417
  226. package/esm/chart/bar/__stories__/PercentageBarChart.stories.js +0 -833
  227. package/esm/chart/bar/index.js +0 -10
  228. package/esm/chart/gradient/Gradient.js +0 -156
  229. package/esm/chart/gradient/index.js +0 -1
  230. package/esm/chart/legend/DefaultLegendEntry.js +0 -42
  231. package/esm/chart/legend/DefaultLegendShape.js +0 -64
  232. package/esm/chart/legend/Legend.js +0 -59
  233. package/esm/chart/legend/__stories__/Legend.stories.js +0 -574
  234. package/esm/chart/legend/index.js +0 -3
  235. package/esm/chart/line/DefaultReferenceLineLabel.js +0 -66
  236. package/esm/chart/line/DottedLine.js +0 -57
  237. package/esm/chart/line/Line.js +0 -180
  238. package/esm/chart/line/LineChart.js +0 -149
  239. package/esm/chart/line/ReferenceLine.js +0 -132
  240. package/esm/chart/line/SolidLine.js +0 -53
  241. package/esm/chart/line/__stories__/LineChart.stories.js +0 -2018
  242. package/esm/chart/line/__stories__/ReferenceLine.stories.js +0 -226
  243. package/esm/chart/line/index.js +0 -8
  244. package/esm/chart/point/DefaultPointLabel.js +0 -39
  245. package/esm/chart/point/Point.js +0 -187
  246. package/esm/chart/point/index.js +0 -2
  247. package/esm/chart/scrubber/DefaultScrubberBeacon.js +0 -182
  248. package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +0 -43
  249. package/esm/chart/scrubber/DefaultScrubberLabel.js +0 -44
  250. package/esm/chart/scrubber/Scrubber.js +0 -198
  251. package/esm/chart/scrubber/ScrubberAccessibilityView.js +0 -177
  252. package/esm/chart/scrubber/ScrubberBeaconGroup.js +0 -169
  253. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +0 -212
  254. package/esm/chart/scrubber/ScrubberProvider.js +0 -140
  255. package/esm/chart/scrubber/__stories__/Scrubber.stories.js +0 -946
  256. package/esm/chart/scrubber/index.js +0 -4
  257. package/esm/chart/text/ChartText.js +0 -305
  258. package/esm/chart/text/ChartTextGroup.js +0 -211
  259. package/esm/chart/text/index.js +0 -4
  260. package/esm/chart/utils/axis.js +0 -664
  261. package/esm/chart/utils/bar.js +0 -906
  262. package/esm/chart/utils/chart.js +0 -329
  263. package/esm/chart/utils/context.js +0 -22
  264. package/esm/chart/utils/gradient.js +0 -319
  265. package/esm/chart/utils/index.js +0 -12
  266. package/esm/chart/utils/path.js +0 -304
  267. package/esm/chart/utils/point.js +0 -282
  268. package/esm/chart/utils/scale.js +0 -288
  269. package/esm/chart/utils/scrubber.js +0 -146
  270. package/esm/chart/utils/transition.js +0 -241
  271. package/esm/sparkline/Counter.js +0 -45
  272. package/esm/sparkline/Sparkline.js +0 -165
  273. package/esm/sparkline/SparklineArea.js +0 -20
  274. package/esm/sparkline/SparklineAreaPattern.js +0 -38
  275. package/esm/sparkline/SparklineGradient.js +0 -77
  276. package/esm/sparkline/__figma__/Sparkline.figma.js +0 -22
  277. package/esm/sparkline/__stories__/Sparkline.stories.js +0 -124
  278. package/esm/sparkline/__stories__/SparklineGradient.stories.js +0 -126
  279. package/esm/sparkline/generateSparklineWithId.js +0 -7
  280. package/esm/sparkline/sparkline-interactive/SparklineAccessibleView.js +0 -75
  281. package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +0 -308
  282. package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +0 -116
  283. package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.js +0 -131
  284. package/esm/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.js +0 -99
  285. package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +0 -82
  286. package/esm/sparkline/sparkline-interactive/SparklineInteractiveMinMax.js +0 -103
  287. package/esm/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.js +0 -104
  288. package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +0 -57
  289. package/esm/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.js +0 -124
  290. package/esm/sparkline/sparkline-interactive/SparklineInteractiveProvider.js +0 -80
  291. package/esm/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.js +0 -109
  292. package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +0 -85
  293. package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +0 -526
  294. package/esm/sparkline/sparkline-interactive/useInterruptiblePathAnimation.js +0 -58
  295. package/esm/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.js +0 -37
  296. package/esm/sparkline/sparkline-interactive/useMinMaxTransform.js +0 -56
  297. package/esm/sparkline/sparkline-interactive/useOpacityAnimation.js +0 -23
  298. package/esm/sparkline/sparkline-interactive/useSparklineInteractiveConstants.js +0 -47
  299. package/esm/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.js +0 -34
  300. package/esm/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.js +0 -233
  301. package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +0 -104
  302. package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +0 -565
  303. package/esm/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.js +0 -117
@@ -1,659 +0,0 @@
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, useCallback, useMemo, useState } from 'react';
3
- import { Image, ScrollView, StyleSheet } from 'react-native';
4
- import { assets } from '@coinbase/cds-common/internal/data/assets';
5
- import { candles as btcCandles } from '@coinbase/cds-common/internal/data/candles';
6
- import { Example, ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
7
- import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
8
- import { Box, HStack, VStack } from '@coinbase/cds-mobile/layout';
9
- import { Text } from '@coinbase/cds-mobile/typography';
10
- import { Circle, Group } from '@shopify/react-native-skia';
11
- import { Area } from '../area/Area';
12
- import { XAxis, YAxis } from '../axis';
13
- import { BarPlot } from '../bar/BarPlot';
14
- import { useCartesianChartContext } from '../ChartProvider';
15
- import { Line } from '../line/Line';
16
- import { Point } from '../point/Point';
17
- import { Scrubber } from '../scrubber/Scrubber';
18
- import { ChartText } from '../text';
19
- import { isCategoricalScale } from '../utils';
20
- import { CartesianChart, DottedArea, ReferenceLine, SolidLine } from '../';
21
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
- const defaultChartHeight = 250;
23
- const LineStyles = () => {
24
- const topChartData = [15, 28, 32, 44, 46, 36, 40, 45, 48, 38];
25
- const upperMiddleChartData = [12, 23, 21, 29, 34, 28, 31, 38, 42, 35];
26
- const lowerMiddleChartData = [8, 15, 14, 25, 20, 18, 22, 28, 24, 30];
27
- const bottomChartData = [4, 8, 11, 15, 16, 14, 16, 10, 12, 14];
28
- return /*#__PURE__*/_jsxs(CartesianChart, {
29
- height: defaultChartHeight,
30
- series: [{
31
- id: 'top',
32
- data: topChartData
33
- }, {
34
- id: 'upperMiddle',
35
- data: upperMiddleChartData,
36
- color: '#ef4444'
37
- }, {
38
- id: 'lowerMiddle',
39
- data: lowerMiddleChartData,
40
- color: '#f59e0b'
41
- }, {
42
- id: 'bottom',
43
- data: bottomChartData,
44
- color: '#800080'
45
- }],
46
- children: [/*#__PURE__*/_jsx(Line, {
47
- seriesId: "top"
48
- }), /*#__PURE__*/_jsx(Line, {
49
- seriesId: "upperMiddle",
50
- type: "dotted"
51
- }), /*#__PURE__*/_jsx(Line, {
52
- LineComponent: lineProps => /*#__PURE__*/_jsx(SolidLine, _extends({}, lineProps, {
53
- strokeWidth: 4
54
- })),
55
- curve: "natural",
56
- seriesId: "lowerMiddle"
57
- }), /*#__PURE__*/_jsx(Line, {
58
- showArea: true,
59
- AreaComponent: DottedArea,
60
- curve: "step",
61
- seriesId: "bottom"
62
- })]
63
- });
64
- };
65
- const MultipleChart = () => {
66
- const barData = [1, 2, 3, 2, 1];
67
- const lineData = [4, 3, 1, 3, 4];
68
- return /*#__PURE__*/_jsxs(CartesianChart, {
69
- height: defaultChartHeight,
70
- series: [{
71
- id: 'bar',
72
- data: barData
73
- }, {
74
- id: 'line',
75
- data: lineData
76
- }],
77
- children: [/*#__PURE__*/_jsx(Area, {
78
- seriesId: "bar",
79
- type: "dotted"
80
- }), /*#__PURE__*/_jsx(Line, {
81
- curve: "natural",
82
- seriesId: "line"
83
- })]
84
- });
85
- };
86
- const EarningsHistory = () => {
87
- const theme = useTheme();
88
- const CirclePlot = /*#__PURE__*/memo(_ref => {
89
- let {
90
- seriesId,
91
- opacity = 1
92
- } = _ref;
93
- const {
94
- getSeries,
95
- getSeriesData,
96
- getXScale,
97
- getYScale
98
- } = useCartesianChartContext();
99
- const series = getSeries(seriesId);
100
- const data = getSeriesData(seriesId);
101
- const xScale = getXScale();
102
- const yScale = getYScale(series == null ? void 0 : series.yAxisId);
103
- if (!xScale || !yScale || !data || !isCategoricalScale(xScale)) return null;
104
- const yScaleSize = Math.abs(yScale.range()[1] - yScale.range()[0]);
105
-
106
- // Have circle diameter be the smaller of the x scale bandwidth or 10% of the y space available
107
- const diameter = Math.min(xScale.bandwidth(), yScaleSize / 10);
108
- return /*#__PURE__*/_jsx(Group, {
109
- children: data.map((value, index) => {
110
- if (value === null || value === undefined) return null;
111
-
112
- // Get x position from band scale - center of the band
113
- const xPos = xScale(index);
114
- if (xPos === undefined) return null;
115
- const centerX = xPos + xScale.bandwidth() / 2;
116
-
117
- // Get y position from value
118
- const yValue = Array.isArray(value) ? value[1] : value;
119
- const centerY = yScale(yValue);
120
- if (centerY === undefined) return null;
121
- return /*#__PURE__*/_jsx(Circle, {
122
- color: (series == null ? void 0 : series.color) || theme.color.fgPrimary,
123
- cx: centerX,
124
- cy: centerY,
125
- opacity: opacity,
126
- r: diameter / 2
127
- }, seriesId + "-" + index);
128
- })
129
- });
130
- });
131
- const quarters = useMemo(() => ['Q1', 'Q2', 'Q3', 'Q4'], []);
132
- const estimatedEPS = useMemo(() => [1.71, 1.82, 1.93, 2.34], []);
133
- const actualEPS = useMemo(() => [1.68, 1.83, 2.01, 2.24], []);
134
- const formatEarningAmount = useCallback(value => {
135
- return "$" + value.toLocaleString('en-US', {
136
- minimumFractionDigits: 2,
137
- maximumFractionDigits: 2
138
- });
139
- }, []);
140
- const surprisePercentage = useCallback(index => {
141
- const percentage = (actualEPS[index] - estimatedEPS[index]) / estimatedEPS[index];
142
- const percentageString = percentage.toLocaleString('en-US', {
143
- style: 'percent',
144
- minimumFractionDigits: 2,
145
- maximumFractionDigits: 2
146
- });
147
- const prefix = percentage > 0 ? '+' : '';
148
- return "" + prefix + percentageString;
149
- }, [actualEPS, estimatedEPS]);
150
- const styles = StyleSheet.create({
151
- legendDot: {
152
- width: 10,
153
- height: 10,
154
- borderRadius: 1000,
155
- backgroundColor: theme.color.bgPositive
156
- }
157
- });
158
- const LegendEntry = /*#__PURE__*/memo(_ref2 => {
159
- let {
160
- opacity = 1,
161
- label
162
- } = _ref2;
163
- return /*#__PURE__*/_jsxs(Box, {
164
- alignItems: "center",
165
- flexDirection: "row",
166
- gap: 0.5,
167
- children: [/*#__PURE__*/_jsx(Box, {
168
- style: [styles.legendDot, {
169
- opacity
170
- }]
171
- }), /*#__PURE__*/_jsx(Text, {
172
- font: "label2",
173
- children: label
174
- })]
175
- });
176
- });
177
- return /*#__PURE__*/_jsxs(VStack, {
178
- gap: 0.5,
179
- children: [/*#__PURE__*/_jsxs(CartesianChart, {
180
- height: defaultChartHeight,
181
- inset: {
182
- top: 32,
183
- bottom: 0,
184
- left: 0,
185
- right: 0
186
- },
187
- series: [{
188
- id: 'estimatedEPS',
189
- data: estimatedEPS,
190
- color: theme.color.bgPositive
191
- }, {
192
- id: 'actualEPS',
193
- data: actualEPS,
194
- color: theme.color.bgPositive
195
- }],
196
- xAxis: {
197
- scaleType: 'band',
198
- categoryPadding: 0.25
199
- },
200
- children: [/*#__PURE__*/_jsx(YAxis, {
201
- showGrid: true,
202
- position: "left",
203
- requestedTickCount: 3,
204
- tickLabelFormatter: formatEarningAmount
205
- }), /*#__PURE__*/_jsx(XAxis, {
206
- height: 20,
207
- tickLabelFormatter: index => quarters[index]
208
- }), /*#__PURE__*/_jsx(XAxis, {
209
- height: 20,
210
- tickLabelFormatter: surprisePercentage
211
- }), /*#__PURE__*/_jsx(CirclePlot, {
212
- opacity: 0.5,
213
- seriesId: "estimatedEPS"
214
- }), /*#__PURE__*/_jsx(CirclePlot, {
215
- seriesId: "actualEPS"
216
- })]
217
- }), /*#__PURE__*/_jsxs(HStack, {
218
- gap: 2,
219
- justifyContent: "flex-end",
220
- children: [/*#__PURE__*/_jsx(LegendEntry, {
221
- label: "Estimated EPS",
222
- opacity: 0.5
223
- }), /*#__PURE__*/_jsx(LegendEntry, {
224
- label: "Actual EPS"
225
- })]
226
- })]
227
- });
228
- };
229
- const btcData = btcCandles.slice(0, 180).reverse();
230
- const btcPrices = btcData.map(candle => parseFloat(candle.close));
231
- const btcVolumes = btcData.map(candle => parseFloat(candle.volume));
232
- const btcDates = btcData.map(candle => new Date(parseInt(candle.start) * 1000));
233
- const displayIndex = btcPrices.length - 1;
234
- const currentPrice = btcPrices[displayIndex];
235
- const currentDate = btcDates[displayIndex];
236
- const PriceWithVolumeChart = /*#__PURE__*/memo(_ref3 => {
237
- let {
238
- onScrubberPositionChange
239
- } = _ref3;
240
- const theme = useTheme();
241
- const formatPriceInThousands = useCallback(price => {
242
- return "$" + (price / 1000).toLocaleString('en-US', {
243
- minimumFractionDigits: 0,
244
- maximumFractionDigits: 2
245
- }) + "k";
246
- }, []);
247
- const formatDate = useCallback(date => {
248
- return date.toLocaleDateString('en-US', {
249
- month: 'short',
250
- day: 'numeric'
251
- });
252
- }, []);
253
- const formatVolume = useCallback(volume => {
254
- return (volume / 1000).toFixed(2) + "K";
255
- }, []);
256
- const scrubberLabel = useCallback(dataIndex => {
257
- return formatDate(btcDates[dataIndex]);
258
- }, [formatDate]);
259
- const chartAccessibilityLabel = useMemo(() => {
260
- const lastIndex = btcPrices.length - 1;
261
- return "Bitcoin chart. Current date " + formatDate(btcDates[lastIndex]) + ". Current price " + formatPriceInThousands(btcPrices[lastIndex]) + ". Current volume " + formatVolume(btcVolumes[lastIndex]) + ".";
262
- }, [formatDate, formatPriceInThousands, formatVolume]);
263
- const getScrubberAccessibilityLabel = useCallback(dataIndex => "Bitcoin on " + formatDate(btcDates[dataIndex]) + ". Price " + formatPriceInThousands(btcPrices[dataIndex]) + ". Volume " + formatVolume(btcVolumes[dataIndex]) + ".", [formatDate, formatPriceInThousands, formatVolume]);
264
- return /*#__PURE__*/_jsxs(CartesianChart, {
265
- enableScrubbing: true,
266
- accessibilityLabel: chartAccessibilityLabel,
267
- getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
268
- height: defaultChartHeight,
269
- onScrubberPositionChange: onScrubberPositionChange,
270
- series: [{
271
- id: 'prices',
272
- data: btcPrices,
273
- color: assets.btc.color,
274
- yAxisId: 'price'
275
- }, {
276
- id: 'volume',
277
- data: btcVolumes,
278
- color: theme.color.fgMuted,
279
- yAxisId: 'volume'
280
- }],
281
- xAxis: {
282
- scaleType: 'band',
283
- range: _ref4 => {
284
- let {
285
- min,
286
- max
287
- } = _ref4;
288
- return {
289
- min,
290
- max: max - 8
291
- };
292
- }
293
- },
294
- yAxis: [{
295
- id: 'price',
296
- domain: _ref5 => {
297
- let {
298
- min,
299
- max
300
- } = _ref5;
301
- return {
302
- min: min * 0.9,
303
- max
304
- };
305
- }
306
- }, {
307
- id: 'volume',
308
- range: _ref6 => {
309
- let {
310
- min,
311
- max
312
- } = _ref6;
313
- return {
314
- min: max - 32,
315
- max
316
- };
317
- }
318
- }],
319
- children: [/*#__PURE__*/_jsx(YAxis, {
320
- showGrid: true,
321
- axisId: "price",
322
- tickLabelFormatter: formatPriceInThousands,
323
- width: 20
324
- }), /*#__PURE__*/_jsx(BarPlot, {
325
- seriesIds: ['volume']
326
- }), /*#__PURE__*/_jsx(Line, {
327
- showArea: true,
328
- seriesId: "prices"
329
- }), /*#__PURE__*/_jsx(Scrubber, {
330
- label: scrubberLabel,
331
- seriesIds: ['prices']
332
- })]
333
- });
334
- });
335
- const PriceWithVolumeHeader = /*#__PURE__*/memo(_ref7 => {
336
- let {
337
- currentIndex
338
- } = _ref7;
339
- const theme = useTheme();
340
- const formatPrice = useCallback(price => {
341
- return "$" + price.toLocaleString('en-US', {
342
- minimumFractionDigits: 2,
343
- maximumFractionDigits: 2
344
- });
345
- }, []);
346
- const formatDate = useCallback(date => {
347
- return date.toLocaleDateString('en-US', {
348
- month: 'short',
349
- day: 'numeric'
350
- });
351
- }, []);
352
- const formatVolume = useCallback(volume => {
353
- return (volume / 1000).toFixed(2) + "K";
354
- }, []);
355
- const volumeText = useMemo(() => {
356
- return formatVolume(currentIndex !== undefined ? btcVolumes[currentIndex] : btcVolumes[displayIndex]);
357
- }, [currentIndex, formatVolume]);
358
- return /*#__PURE__*/_jsxs(HStack, {
359
- gap: 2,
360
- justifyContent: "space-between",
361
- paddingX: 0,
362
- children: [/*#__PURE__*/_jsxs(VStack, {
363
- gap: 0,
364
- children: [/*#__PURE__*/_jsx(Text, {
365
- font: "title1",
366
- children: "Bitcoin"
367
- }), /*#__PURE__*/_jsx(Text, {
368
- font: "title2",
369
- children: formatPrice(currentPrice)
370
- })]
371
- }), /*#__PURE__*/_jsxs(HStack, {
372
- gap: 2,
373
- children: [/*#__PURE__*/_jsxs(VStack, {
374
- alignItems: "flex-end",
375
- justifyContent: "center",
376
- children: [/*#__PURE__*/_jsx(Text, {
377
- font: "label1",
378
- children: formatDate(currentDate)
379
- }), /*#__PURE__*/_jsx(Text, {
380
- font: "label2",
381
- children: volumeText
382
- })]
383
- }), /*#__PURE__*/_jsx(VStack, {
384
- justifyContent: "center",
385
- children: /*#__PURE__*/_jsx(Image, {
386
- source: {
387
- uri: assets.btc.imageUrl
388
- },
389
- style: {
390
- width: theme.iconSize.l,
391
- height: theme.iconSize.l,
392
- borderRadius: 1000
393
- }
394
- })
395
- })]
396
- })]
397
- });
398
- });
399
- const PriceWithVolume = /*#__PURE__*/memo(() => {
400
- const [currentIndex, setCurrentIndex] = useState();
401
- return /*#__PURE__*/_jsxs(VStack, {
402
- gap: 2,
403
- children: [/*#__PURE__*/_jsx(PriceWithVolumeHeader, {
404
- currentIndex: currentIndex
405
- }), /*#__PURE__*/_jsx(PriceWithVolumeChart, {
406
- onScrubberPositionChange: setCurrentIndex
407
- })]
408
- });
409
- });
410
- function TradingTrends() {
411
- const theme = useTheme();
412
- const profitData = [34, 24, 28, -4, 8, -16, -3, 12, 24, 18, 20, 28];
413
- const gains = profitData.map(value => value > 0 ? value : 0);
414
- const losses = profitData.map(value => value < 0 ? value : 0);
415
- const renderProfit = useCallback(value => {
416
- return "$" + value + "M";
417
- }, []);
418
- const ThinSolidLine = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(SolidLine, _extends({}, props, {
419
- strokeWidth: 1
420
- })));
421
- const ThickSolidLine = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(SolidLine, _extends({}, props, {
422
- strokeWidth: 2
423
- })));
424
- return /*#__PURE__*/_jsxs(CartesianChart, {
425
- height: 250,
426
- series: [{
427
- id: 'gains',
428
- data: gains,
429
- yAxisId: 'profit',
430
- color: theme.color.bgPositive,
431
- stackId: 'bars'
432
- }, {
433
- id: 'losses',
434
- data: losses,
435
- yAxisId: 'profit',
436
- color: theme.color.bgNegative,
437
- stackId: 'bars'
438
- }, {
439
- id: 'revenue',
440
- data: [128, 118, 122, 116, 120, 114, 118, 122, 126, 130, 134, 138],
441
- yAxisId: 'revenue',
442
- color: theme.color.fgMuted
443
- }],
444
- xAxis: {
445
- scaleType: 'band',
446
- data: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
447
- },
448
- yAxis: [{
449
- id: 'profit',
450
- range: _ref8 => {
451
- let {
452
- min,
453
- max
454
- } = _ref8;
455
- return {
456
- min: min,
457
- max: max - 64
458
- };
459
- },
460
- domain: {
461
- min: -40,
462
- max: 40
463
- }
464
- }, {
465
- id: 'revenue',
466
- range: _ref9 => {
467
- let {
468
- min,
469
- max
470
- } = _ref9;
471
- return {
472
- min: max - 64,
473
- max
474
- };
475
- },
476
- domain: {
477
- min: 100
478
- }
479
- }],
480
- children: [/*#__PURE__*/_jsx(YAxis, {
481
- showGrid: true,
482
- GridLineComponent: ThinSolidLine,
483
- axisId: "profit",
484
- position: "left",
485
- tickLabelFormatter: renderProfit
486
- }), /*#__PURE__*/_jsx(XAxis, {}), /*#__PURE__*/_jsx(ReferenceLine, {
487
- LineComponent: ThickSolidLine,
488
- dataY: 0,
489
- yAxisId: "profit"
490
- }), /*#__PURE__*/_jsx(BarPlot, {
491
- seriesIds: ['gains', 'losses']
492
- }), /*#__PURE__*/_jsx(Line, {
493
- showArea: true,
494
- seriesId: "revenue"
495
- })]
496
- });
497
- }
498
- const ScatterplotWithCustomLabels = /*#__PURE__*/memo(() => {
499
- const theme = useTheme();
500
- const dataPoints = useMemo(() => [{
501
- x: 12,
502
- y: 34,
503
- label: 'A',
504
- color: theme.color.accentBoldBlue
505
- }, {
506
- x: 28,
507
- y: 67,
508
- label: 'B',
509
- color: theme.color.accentBoldBlue
510
- }, {
511
- x: 45,
512
- y: 23,
513
- label: 'C',
514
- color: theme.color.accentBoldBlue
515
- }, {
516
- x: 67,
517
- y: 89,
518
- label: 'D',
519
- color: theme.color.bgPositive
520
- }, {
521
- x: 82,
522
- y: 76,
523
- label: 'E',
524
- color: theme.color.bgPositive
525
- }, {
526
- x: 34,
527
- y: 91,
528
- label: 'F',
529
- color: theme.color.bgPositive
530
- }, {
531
- x: 56,
532
- y: 45,
533
- label: 'G',
534
- color: theme.color.bgPositive
535
- }, {
536
- x: 19,
537
- y: 12,
538
- label: 'H',
539
- color: theme.color.fgWarning
540
- }, {
541
- x: 73,
542
- y: 28,
543
- label: 'I',
544
- color: theme.color.fgWarning
545
- }, {
546
- x: 91,
547
- y: 54,
548
- label: 'J',
549
- color: theme.color.fgWarning
550
- }, {
551
- x: 15,
552
- y: 58,
553
- label: 'K',
554
- color: theme.color.fgPrimary
555
- }, {
556
- x: 39,
557
- y: 72,
558
- label: 'L',
559
- color: theme.color.fgPrimary
560
- }, {
561
- x: 88,
562
- y: 15,
563
- label: 'M',
564
- color: theme.color.fgPrimary
565
- }, {
566
- x: 52,
567
- y: 82,
568
- label: 'N',
569
- color: theme.color.fgPrimary
570
- }], [theme]);
571
-
572
- // Calculate domain based on data
573
- const xValues = useMemo(() => dataPoints.map(p => p.x), [dataPoints]);
574
- const yValues = useMemo(() => dataPoints.map(p => p.y), [dataPoints]);
575
- const xMin = Math.min(...xValues);
576
- const xMax = Math.max(...xValues);
577
- const yMin = Math.min(...yValues);
578
- const yMax = Math.max(...yValues);
579
-
580
- // Custom label component that places labels to the top-right
581
- const TopRightPointLabel = useCallback(_ref0 => {
582
- let {
583
- x,
584
- y,
585
- offset = 0,
586
- children
587
- } = _ref0;
588
- return /*#__PURE__*/_jsx(ChartText, {
589
- font: "label1",
590
- fontWeight: 600,
591
- horizontalAlignment: "left",
592
- verticalAlignment: "bottom",
593
- x: x + offset,
594
- y: y - offset,
595
- children: children
596
- });
597
- }, []);
598
- return /*#__PURE__*/_jsxs(CartesianChart, {
599
- height: 300,
600
- xAxis: {
601
- domain: {
602
- min: xMin,
603
- max: xMax
604
- },
605
- domainLimit: 'nice'
606
- },
607
- yAxis: {
608
- domain: {
609
- min: yMin,
610
- max: yMax
611
- },
612
- domainLimit: 'nice'
613
- },
614
- children: [/*#__PURE__*/_jsx(XAxis, {
615
- showGrid: true,
616
- showLine: true,
617
- showTickMarks: true
618
- }), /*#__PURE__*/_jsx(YAxis, {
619
- showGrid: true,
620
- showLine: true,
621
- showTickMarks: true,
622
- position: "left"
623
- }), dataPoints.map((point, index) => /*#__PURE__*/_jsx(Point, {
624
- LabelComponent: TopRightPointLabel,
625
- dataX: point.x,
626
- dataY: point.y,
627
- fill: point.color,
628
- label: point.label,
629
- labelOffset: 8,
630
- radius: 5
631
- }, index))]
632
- });
633
- });
634
- const ChartStories = () => {
635
- return /*#__PURE__*/_jsx(ScrollView, {
636
- children: /*#__PURE__*/_jsxs(ExampleScreen, {
637
- children: [/*#__PURE__*/_jsx(Example, {
638
- title: "Line Styles",
639
- children: /*#__PURE__*/_jsx(LineStyles, {})
640
- }), /*#__PURE__*/_jsx(Example, {
641
- title: "Multiple Types",
642
- children: /*#__PURE__*/_jsx(MultipleChart, {})
643
- }), /*#__PURE__*/_jsx(Example, {
644
- title: "Earnings History",
645
- children: /*#__PURE__*/_jsx(EarningsHistory, {})
646
- }), /*#__PURE__*/_jsx(Example, {
647
- title: "Price With Volume",
648
- children: /*#__PURE__*/_jsx(PriceWithVolume, {})
649
- }), /*#__PURE__*/_jsx(Example, {
650
- title: "Trading Trends",
651
- children: /*#__PURE__*/_jsx(TradingTrends, {})
652
- }), /*#__PURE__*/_jsx(Example, {
653
- title: "Scatterplot with Custom Labels",
654
- children: /*#__PURE__*/_jsx(ScatterplotWithCustomLabels, {})
655
- })]
656
- })
657
- });
658
- };
659
- export default ChartStories;