react-native-wagmi-charts 2.3.0 → 2.3.2

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 (351) hide show
  1. package/README.md +23 -22
  2. package/lib/commonjs/charts/candle/Candle.js +6 -19
  3. package/lib/commonjs/charts/candle/Candle.js.map +1 -1
  4. package/lib/commonjs/charts/candle/Candles.js +6 -13
  5. package/lib/commonjs/charts/candle/Candles.js.map +1 -1
  6. package/lib/commonjs/charts/candle/Chart.js +3 -12
  7. package/lib/commonjs/charts/candle/Chart.js.map +1 -1
  8. package/lib/commonjs/charts/candle/Context.js +4 -12
  9. package/lib/commonjs/charts/candle/Context.js.map +1 -1
  10. package/lib/commonjs/charts/candle/Crosshair.js +3 -18
  11. package/lib/commonjs/charts/candle/Crosshair.js.map +1 -1
  12. package/lib/commonjs/charts/candle/CrosshairTooltip.js +6 -21
  13. package/lib/commonjs/charts/candle/CrosshairTooltip.js.map +1 -1
  14. package/lib/commonjs/charts/candle/DatetimeText.js +2 -8
  15. package/lib/commonjs/charts/candle/DatetimeText.js.map +1 -1
  16. package/lib/commonjs/charts/candle/HoverTrap/index.web.js +12 -24
  17. package/lib/commonjs/charts/candle/HoverTrap/index.web.js.map +1 -1
  18. package/lib/commonjs/charts/candle/Line.js +3 -12
  19. package/lib/commonjs/charts/candle/Line.js.map +1 -1
  20. package/lib/commonjs/charts/candle/PriceText.js +2 -8
  21. package/lib/commonjs/charts/candle/PriceText.js.map +1 -1
  22. package/lib/commonjs/charts/candle/index.js +1 -32
  23. package/lib/commonjs/charts/candle/index.js.map +1 -1
  24. package/lib/commonjs/charts/candle/types.js.map +1 -1
  25. package/lib/commonjs/charts/candle/useCandleData.js +0 -4
  26. package/lib/commonjs/charts/candle/useCandleData.js.map +1 -1
  27. package/lib/commonjs/charts/candle/useCandlestickChart.js +2 -7
  28. package/lib/commonjs/charts/candle/useCandlestickChart.js.map +1 -1
  29. package/lib/commonjs/charts/candle/useDatetime.js +0 -4
  30. package/lib/commonjs/charts/candle/useDatetime.js.map +1 -1
  31. package/lib/commonjs/charts/candle/usePrice.js +0 -8
  32. package/lib/commonjs/charts/candle/usePrice.js.map +1 -1
  33. package/lib/commonjs/charts/candle/utils/getDomain.js +0 -1
  34. package/lib/commonjs/charts/candle/utils/getDomain.js.map +1 -1
  35. package/lib/commonjs/charts/candle/utils/getHeight.js +0 -2
  36. package/lib/commonjs/charts/candle/utils/getHeight.js.map +1 -1
  37. package/lib/commonjs/charts/candle/utils/getPrice.js +0 -2
  38. package/lib/commonjs/charts/candle/utils/getPrice.js.map +1 -1
  39. package/lib/commonjs/charts/candle/utils/getY.js +0 -2
  40. package/lib/commonjs/charts/candle/utils/getY.js.map +1 -1
  41. package/lib/commonjs/charts/candle/utils/index.js +0 -8
  42. package/lib/commonjs/charts/candle/utils/index.js.map +1 -1
  43. package/lib/commonjs/charts/candle/utils.js +1 -6
  44. package/lib/commonjs/charts/candle/utils.js.map +1 -1
  45. package/lib/commonjs/charts/line/Chart.js +9 -28
  46. package/lib/commonjs/charts/line/Chart.js.map +1 -1
  47. package/lib/commonjs/charts/line/ChartPath.js +23 -46
  48. package/lib/commonjs/charts/line/ChartPath.js.map +1 -1
  49. package/lib/commonjs/charts/line/Context.js +8 -19
  50. package/lib/commonjs/charts/line/Context.js.map +1 -1
  51. package/lib/commonjs/charts/line/Cursor.js +41 -66
  52. package/lib/commonjs/charts/line/Cursor.js.map +1 -1
  53. package/lib/commonjs/charts/line/CursorCrosshair.js +5 -14
  54. package/lib/commonjs/charts/line/CursorCrosshair.js.map +1 -1
  55. package/lib/commonjs/charts/line/CursorLine.js +5 -19
  56. package/lib/commonjs/charts/line/CursorLine.js.map +1 -1
  57. package/lib/commonjs/charts/line/Data.js +5 -17
  58. package/lib/commonjs/charts/line/Data.js.map +1 -1
  59. package/lib/commonjs/charts/line/DatetimeText.js +2 -9
  60. package/lib/commonjs/charts/line/DatetimeText.js.map +1 -1
  61. package/lib/commonjs/charts/line/Dot.js +27 -33
  62. package/lib/commonjs/charts/line/Dot.js.map +1 -1
  63. package/lib/commonjs/charts/line/Gradient.js +12 -19
  64. package/lib/commonjs/charts/line/Gradient.js.map +1 -1
  65. package/lib/commonjs/charts/line/Group.js +2 -14
  66. package/lib/commonjs/charts/line/Group.js.map +1 -1
  67. package/lib/commonjs/charts/line/Highlight.js +9 -21
  68. package/lib/commonjs/charts/line/Highlight.js.map +1 -1
  69. package/lib/commonjs/charts/line/HorizontalLine.js +8 -23
  70. package/lib/commonjs/charts/line/HorizontalLine.js.map +1 -1
  71. package/lib/commonjs/charts/line/HoverTrap/index.js +0 -4
  72. package/lib/commonjs/charts/line/HoverTrap/index.js.map +1 -1
  73. package/lib/commonjs/charts/line/HoverTrap/index.web.js +12 -23
  74. package/lib/commonjs/charts/line/HoverTrap/index.web.js.map +1 -1
  75. package/lib/commonjs/charts/line/LineChartPathContext.js +1 -6
  76. package/lib/commonjs/charts/line/LineChartPathContext.js.map +1 -1
  77. package/lib/commonjs/charts/line/Path.js +9 -18
  78. package/lib/commonjs/charts/line/Path.js.map +1 -1
  79. package/lib/commonjs/charts/line/PriceText.js +2 -9
  80. package/lib/commonjs/charts/line/PriceText.js.map +1 -1
  81. package/lib/commonjs/charts/line/Tooltip.js +25 -47
  82. package/lib/commonjs/charts/line/Tooltip.js.map +1 -1
  83. package/lib/commonjs/charts/line/index.js +1 -39
  84. package/lib/commonjs/charts/line/index.js.map +1 -1
  85. package/lib/commonjs/charts/line/types.js.map +1 -1
  86. package/lib/commonjs/charts/line/useAnimatedPath.js +6 -12
  87. package/lib/commonjs/charts/line/useAnimatedPath.js.map +1 -1
  88. package/lib/commonjs/charts/line/useCurrentY.js +0 -7
  89. package/lib/commonjs/charts/line/useCurrentY.js.map +1 -1
  90. package/lib/commonjs/charts/line/useDatetime.js +0 -4
  91. package/lib/commonjs/charts/line/useDatetime.js.map +1 -1
  92. package/lib/commonjs/charts/line/useLineChart.js +4 -10
  93. package/lib/commonjs/charts/line/useLineChart.js.map +1 -1
  94. package/lib/commonjs/charts/line/usePrice.js +1 -5
  95. package/lib/commonjs/charts/line/usePrice.js.map +1 -1
  96. package/lib/commonjs/charts/line/utils/getArea.js +11 -11
  97. package/lib/commonjs/charts/line/utils/getArea.js.map +1 -1
  98. package/lib/commonjs/charts/line/utils/getDomain.js +0 -1
  99. package/lib/commonjs/charts/line/utils/getDomain.js.map +1 -1
  100. package/lib/commonjs/charts/line/utils/getPath.js +5 -8
  101. package/lib/commonjs/charts/line/utils/getPath.js.map +1 -1
  102. package/lib/commonjs/charts/line/utils/getXPositionForCurve.js +15 -0
  103. package/lib/commonjs/charts/line/utils/getXPositionForCurve.js.map +1 -0
  104. package/lib/commonjs/charts/line/utils/index.js +0 -10
  105. package/lib/commonjs/charts/line/utils/index.js.map +1 -1
  106. package/lib/commonjs/charts/line/utils/interpolatePath.js +119 -124
  107. package/lib/commonjs/charts/line/utils/interpolatePath.js.map +1 -1
  108. package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js +0 -3
  109. package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js.map +1 -1
  110. package/lib/commonjs/components/AnimatedText.js +6 -17
  111. package/lib/commonjs/components/AnimatedText.js.map +1 -1
  112. package/lib/commonjs/index.js +0 -8
  113. package/lib/commonjs/index.js.map +1 -1
  114. package/lib/commonjs/utils/formatDatetime.js +0 -1
  115. package/lib/commonjs/utils/formatDatetime.js.map +1 -1
  116. package/lib/commonjs/utils/formatPrice.js +2 -12
  117. package/lib/commonjs/utils/formatPrice.js.map +1 -1
  118. package/lib/commonjs/utils/index.js +0 -6
  119. package/lib/commonjs/utils/index.js.map +1 -1
  120. package/lib/commonjs/utils/usePrevious.js +4 -9
  121. package/lib/commonjs/utils/usePrevious.js.map +1 -1
  122. package/lib/module/charts/candle/Candle.js +4 -2
  123. package/lib/module/charts/candle/Candle.js.map +1 -1
  124. package/lib/module/charts/candle/Candles.js +4 -3
  125. package/lib/module/charts/candle/Candles.js.map +1 -1
  126. package/lib/module/charts/candle/Chart.js.map +1 -1
  127. package/lib/module/charts/candle/Context.js.map +1 -1
  128. package/lib/module/charts/candle/Crosshair.js +1 -4
  129. package/lib/module/charts/candle/Crosshair.js.map +1 -1
  130. package/lib/module/charts/candle/CrosshairTooltip.js +3 -6
  131. package/lib/module/charts/candle/CrosshairTooltip.js.map +1 -1
  132. package/lib/module/charts/candle/DatetimeText.js.map +1 -1
  133. package/lib/module/charts/candle/HoverTrap/index.web.js +12 -14
  134. package/lib/module/charts/candle/HoverTrap/index.web.js.map +1 -1
  135. package/lib/module/charts/candle/Line.js +1 -2
  136. package/lib/module/charts/candle/Line.js.map +1 -1
  137. package/lib/module/charts/candle/PriceText.js.map +1 -1
  138. package/lib/module/charts/candle/index.js.map +1 -1
  139. package/lib/module/charts/candle/types.js.map +1 -1
  140. package/lib/module/charts/candle/useCandleData.js +0 -1
  141. package/lib/module/charts/candle/useCandleData.js.map +1 -1
  142. package/lib/module/charts/candle/useCandlestickChart.js.map +1 -1
  143. package/lib/module/charts/candle/useDatetime.js.map +1 -1
  144. package/lib/module/charts/candle/usePrice.js +0 -2
  145. package/lib/module/charts/candle/usePrice.js.map +1 -1
  146. package/lib/module/charts/candle/utils/getDomain.js.map +1 -1
  147. package/lib/module/charts/candle/utils/getHeight.js.map +1 -1
  148. package/lib/module/charts/candle/utils/getPrice.js.map +1 -1
  149. package/lib/module/charts/candle/utils/getY.js.map +1 -1
  150. package/lib/module/charts/candle/utils/index.js.map +1 -1
  151. package/lib/module/charts/candle/utils.js.map +1 -1
  152. package/lib/module/charts/line/Chart.js +8 -12
  153. package/lib/module/charts/line/Chart.js.map +1 -1
  154. package/lib/module/charts/line/ChartPath.js +21 -28
  155. package/lib/module/charts/line/ChartPath.js.map +1 -1
  156. package/lib/module/charts/line/Context.js +4 -6
  157. package/lib/module/charts/line/Context.js.map +1 -1
  158. package/lib/module/charts/line/Cursor.js +37 -50
  159. package/lib/module/charts/line/Cursor.js.map +1 -1
  160. package/lib/module/charts/line/CursorCrosshair.js +3 -3
  161. package/lib/module/charts/line/CursorCrosshair.js.map +1 -1
  162. package/lib/module/charts/line/CursorLine.js +3 -3
  163. package/lib/module/charts/line/CursorLine.js.map +1 -1
  164. package/lib/module/charts/line/Data.js +0 -2
  165. package/lib/module/charts/line/Data.js.map +1 -1
  166. package/lib/module/charts/line/DatetimeText.js.map +1 -1
  167. package/lib/module/charts/line/Dot.js +25 -18
  168. package/lib/module/charts/line/Dot.js.map +1 -1
  169. package/lib/module/charts/line/Gradient.js +10 -5
  170. package/lib/module/charts/line/Gradient.js.map +1 -1
  171. package/lib/module/charts/line/Group.js +0 -2
  172. package/lib/module/charts/line/Group.js.map +1 -1
  173. package/lib/module/charts/line/Highlight.js +7 -5
  174. package/lib/module/charts/line/Highlight.js.map +1 -1
  175. package/lib/module/charts/line/HorizontalLine.js +6 -8
  176. package/lib/module/charts/line/HorizontalLine.js.map +1 -1
  177. package/lib/module/charts/line/HoverTrap/index.js.map +1 -1
  178. package/lib/module/charts/line/HoverTrap/index.web.js +12 -14
  179. package/lib/module/charts/line/HoverTrap/index.web.js.map +1 -1
  180. package/lib/module/charts/line/LineChartPathContext.js.map +1 -1
  181. package/lib/module/charts/line/Path.js +7 -4
  182. package/lib/module/charts/line/Path.js.map +1 -1
  183. package/lib/module/charts/line/PriceText.js.map +1 -1
  184. package/lib/module/charts/line/Tooltip.js +21 -33
  185. package/lib/module/charts/line/Tooltip.js.map +1 -1
  186. package/lib/module/charts/line/index.js.map +1 -1
  187. package/lib/module/charts/line/types.js.map +1 -1
  188. package/lib/module/charts/line/useAnimatedPath.js +3 -5
  189. package/lib/module/charts/line/useAnimatedPath.js.map +1 -1
  190. package/lib/module/charts/line/useCurrentY.js +0 -1
  191. package/lib/module/charts/line/useCurrentY.js.map +1 -1
  192. package/lib/module/charts/line/useDatetime.js.map +1 -1
  193. package/lib/module/charts/line/useLineChart.js +2 -1
  194. package/lib/module/charts/line/useLineChart.js.map +1 -1
  195. package/lib/module/charts/line/usePrice.js +1 -1
  196. package/lib/module/charts/line/usePrice.js.map +1 -1
  197. package/lib/module/charts/line/utils/getArea.js +9 -6
  198. package/lib/module/charts/line/utils/getArea.js.map +1 -1
  199. package/lib/module/charts/line/utils/getDomain.js.map +1 -1
  200. package/lib/module/charts/line/utils/getPath.js +3 -3
  201. package/lib/module/charts/line/utils/getPath.js.map +1 -1
  202. package/lib/module/charts/line/utils/getXPositionForCurve.js +9 -0
  203. package/lib/module/charts/line/utils/getXPositionForCurve.js.map +1 -0
  204. package/lib/module/charts/line/utils/index.js.map +1 -1
  205. package/lib/module/charts/line/utils/interpolatePath.js +116 -117
  206. package/lib/module/charts/line/utils/interpolatePath.js.map +1 -1
  207. package/lib/module/charts/line/utils/lineChartDataPropToArray.js +0 -2
  208. package/lib/module/charts/line/utils/lineChartDataPropToArray.js.map +1 -1
  209. package/lib/module/components/AnimatedText.js +4 -3
  210. package/lib/module/components/AnimatedText.js.map +1 -1
  211. package/lib/module/index.js.map +1 -1
  212. package/lib/module/utils/formatDatetime.js.map +1 -1
  213. package/lib/module/utils/formatPrice.js +2 -11
  214. package/lib/module/utils/formatPrice.js.map +1 -1
  215. package/lib/module/utils/index.js.map +1 -1
  216. package/lib/module/utils/usePrevious.js +2 -3
  217. package/lib/module/utils/usePrevious.js.map +1 -1
  218. package/lib/typescript/src/charts/candle/Candle.d.ts +7 -5
  219. package/lib/typescript/src/charts/candle/Candle.d.ts.map +1 -0
  220. package/lib/typescript/src/charts/candle/Candles.d.ts +4 -3
  221. package/lib/typescript/src/charts/candle/Candles.d.ts.map +1 -0
  222. package/lib/typescript/src/charts/candle/Chart.d.ts +3 -2
  223. package/lib/typescript/src/charts/candle/Chart.d.ts.map +1 -0
  224. package/lib/typescript/src/charts/candle/Context.d.ts +3 -2
  225. package/lib/typescript/src/charts/candle/Context.d.ts.map +1 -0
  226. package/lib/typescript/src/charts/candle/Crosshair.d.ts +3 -2
  227. package/lib/typescript/src/charts/candle/Crosshair.d.ts.map +1 -0
  228. package/lib/typescript/src/charts/candle/CrosshairTooltip.d.ts +4 -3
  229. package/lib/typescript/src/charts/candle/CrosshairTooltip.d.ts.map +1 -0
  230. package/lib/typescript/src/charts/candle/DatetimeText.d.ts +4 -3
  231. package/lib/typescript/src/charts/candle/DatetimeText.d.ts.map +1 -0
  232. package/lib/typescript/src/charts/candle/HoverTrap/index.web.d.ts +3 -2
  233. package/lib/typescript/src/charts/candle/HoverTrap/index.web.d.ts.map +1 -0
  234. package/lib/typescript/src/charts/candle/Line.d.ts +4 -3
  235. package/lib/typescript/src/charts/candle/Line.d.ts.map +1 -0
  236. package/lib/typescript/src/charts/candle/PriceText.d.ts +4 -3
  237. package/lib/typescript/src/charts/candle/PriceText.d.ts.map +1 -0
  238. package/lib/typescript/src/charts/candle/index.d.ts +3 -2
  239. package/lib/typescript/src/charts/candle/index.d.ts.map +1 -0
  240. package/lib/typescript/src/charts/candle/types.d.ts +7 -6
  241. package/lib/typescript/src/charts/candle/types.d.ts.map +1 -0
  242. package/lib/typescript/src/charts/candle/useCandleData.d.ts +1 -0
  243. package/lib/typescript/src/charts/candle/useCandleData.d.ts.map +1 -0
  244. package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts +1 -0
  245. package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts.map +1 -0
  246. package/lib/typescript/src/charts/candle/useDatetime.d.ts +1 -0
  247. package/lib/typescript/src/charts/candle/useDatetime.d.ts.map +1 -0
  248. package/lib/typescript/src/charts/candle/usePrice.d.ts +1 -0
  249. package/lib/typescript/src/charts/candle/usePrice.d.ts.map +1 -0
  250. package/lib/typescript/src/charts/candle/utils/getDomain.d.ts +1 -0
  251. package/lib/typescript/src/charts/candle/utils/getDomain.d.ts.map +1 -0
  252. package/lib/typescript/src/charts/candle/utils/getHeight.d.ts +1 -0
  253. package/lib/typescript/src/charts/candle/utils/getHeight.d.ts.map +1 -0
  254. package/lib/typescript/src/charts/candle/utils/getPrice.d.ts +1 -0
  255. package/lib/typescript/src/charts/candle/utils/getPrice.d.ts.map +1 -0
  256. package/lib/typescript/src/charts/candle/utils/getY.d.ts +1 -0
  257. package/lib/typescript/src/charts/candle/utils/getY.d.ts.map +1 -0
  258. package/lib/typescript/src/charts/candle/utils/index.d.ts +1 -0
  259. package/lib/typescript/src/charts/candle/utils/index.d.ts.map +1 -0
  260. package/lib/typescript/src/charts/candle/utils.d.ts +1 -0
  261. package/lib/typescript/src/charts/candle/utils.d.ts.map +1 -0
  262. package/lib/typescript/src/charts/line/Chart.d.ts +3 -2
  263. package/lib/typescript/src/charts/line/Chart.d.ts.map +1 -0
  264. package/lib/typescript/src/charts/line/ChartPath.d.ts +3 -2
  265. package/lib/typescript/src/charts/line/ChartPath.d.ts.map +1 -0
  266. package/lib/typescript/src/charts/line/Context.d.ts +3 -2
  267. package/lib/typescript/src/charts/line/Context.d.ts.map +1 -0
  268. package/lib/typescript/src/charts/line/Cursor.d.ts +3 -2
  269. package/lib/typescript/src/charts/line/Cursor.d.ts.map +1 -0
  270. package/lib/typescript/src/charts/line/CursorCrosshair.d.ts +3 -2
  271. package/lib/typescript/src/charts/line/CursorCrosshair.d.ts.map +1 -0
  272. package/lib/typescript/src/charts/line/CursorLine.d.ts +3 -2
  273. package/lib/typescript/src/charts/line/CursorLine.d.ts.map +1 -0
  274. package/lib/typescript/src/charts/line/Data.d.ts +6 -4
  275. package/lib/typescript/src/charts/line/Data.d.ts.map +1 -0
  276. package/lib/typescript/src/charts/line/DatetimeText.d.ts +4 -3
  277. package/lib/typescript/src/charts/line/DatetimeText.d.ts.map +1 -0
  278. package/lib/typescript/src/charts/line/Dot.d.ts +4 -3
  279. package/lib/typescript/src/charts/line/Dot.d.ts.map +1 -0
  280. package/lib/typescript/src/charts/line/Gradient.d.ts +3 -2
  281. package/lib/typescript/src/charts/line/Gradient.d.ts.map +1 -0
  282. package/lib/typescript/src/charts/line/Group.d.ts +4 -2
  283. package/lib/typescript/src/charts/line/Group.d.ts.map +1 -0
  284. package/lib/typescript/src/charts/line/Highlight.d.ts +4 -3
  285. package/lib/typescript/src/charts/line/Highlight.d.ts.map +1 -0
  286. package/lib/typescript/src/charts/line/HorizontalLine.d.ts +4 -3
  287. package/lib/typescript/src/charts/line/HorizontalLine.d.ts.map +1 -0
  288. package/lib/typescript/src/charts/line/HoverTrap/index.d.ts +3 -2
  289. package/lib/typescript/src/charts/line/HoverTrap/index.d.ts.map +1 -0
  290. package/lib/typescript/src/charts/line/HoverTrap/index.web.d.ts +3 -2
  291. package/lib/typescript/src/charts/line/HoverTrap/index.web.d.ts.map +1 -0
  292. package/lib/typescript/src/charts/line/LineChartPathContext.d.ts +1 -0
  293. package/lib/typescript/src/charts/line/LineChartPathContext.d.ts.map +1 -0
  294. package/lib/typescript/src/charts/line/Path.d.ts +4 -3
  295. package/lib/typescript/src/charts/line/Path.d.ts.map +1 -0
  296. package/lib/typescript/src/charts/line/PriceText.d.ts +4 -3
  297. package/lib/typescript/src/charts/line/PriceText.d.ts.map +1 -0
  298. package/lib/typescript/src/charts/line/Tooltip.d.ts +4 -3
  299. package/lib/typescript/src/charts/line/Tooltip.d.ts.map +1 -0
  300. package/lib/typescript/src/charts/line/index.d.ts +2 -1
  301. package/lib/typescript/src/charts/line/index.d.ts.map +1 -0
  302. package/lib/typescript/src/charts/line/types.d.ts +8 -7
  303. package/lib/typescript/src/charts/line/types.d.ts.map +1 -0
  304. package/lib/typescript/src/charts/line/useAnimatedPath.d.ts +1 -0
  305. package/lib/typescript/src/charts/line/useAnimatedPath.d.ts.map +1 -0
  306. package/lib/typescript/src/charts/line/useCurrentY.d.ts +1 -0
  307. package/lib/typescript/src/charts/line/useCurrentY.d.ts.map +1 -0
  308. package/lib/typescript/src/charts/line/useDatetime.d.ts +1 -0
  309. package/lib/typescript/src/charts/line/useDatetime.d.ts.map +1 -0
  310. package/lib/typescript/src/charts/line/useLineChart.d.ts +1 -0
  311. package/lib/typescript/src/charts/line/useLineChart.d.ts.map +1 -0
  312. package/lib/typescript/src/charts/line/usePrice.d.ts +1 -0
  313. package/lib/typescript/src/charts/line/usePrice.d.ts.map +1 -0
  314. package/lib/typescript/src/charts/line/utils/getArea.d.ts +3 -1
  315. package/lib/typescript/src/charts/line/utils/getArea.d.ts.map +1 -0
  316. package/lib/typescript/src/charts/line/utils/getDomain.d.ts +1 -0
  317. package/lib/typescript/src/charts/line/utils/getDomain.d.ts.map +1 -0
  318. package/lib/typescript/src/charts/line/utils/getPath.d.ts +1 -0
  319. package/lib/typescript/src/charts/line/utils/getPath.d.ts.map +1 -0
  320. package/lib/typescript/src/charts/line/utils/getXPositionForCurve.d.ts +3 -0
  321. package/lib/typescript/src/charts/line/utils/getXPositionForCurve.d.ts.map +1 -0
  322. package/lib/typescript/src/charts/line/utils/index.d.ts +1 -0
  323. package/lib/typescript/src/charts/line/utils/index.d.ts.map +1 -0
  324. package/lib/typescript/src/charts/line/utils/interpolatePath.d.ts +1 -0
  325. package/lib/typescript/src/charts/line/utils/interpolatePath.d.ts.map +1 -0
  326. package/lib/typescript/src/charts/line/utils/lineChartDataPropToArray.d.ts +1 -0
  327. package/lib/typescript/src/charts/line/utils/lineChartDataPropToArray.d.ts.map +1 -0
  328. package/lib/typescript/src/components/AnimatedText.d.ts +3 -2
  329. package/lib/typescript/src/components/AnimatedText.d.ts.map +1 -0
  330. package/lib/typescript/src/index.d.ts +1 -0
  331. package/lib/typescript/src/index.d.ts.map +1 -0
  332. package/lib/typescript/src/utils/formatDatetime.d.ts +1 -0
  333. package/lib/typescript/src/utils/formatDatetime.d.ts.map +1 -0
  334. package/lib/typescript/src/utils/formatPrice.d.ts +1 -0
  335. package/lib/typescript/src/utils/formatPrice.d.ts.map +1 -0
  336. package/lib/typescript/src/utils/index.d.ts +1 -0
  337. package/lib/typescript/src/utils/index.d.ts.map +1 -0
  338. package/lib/typescript/src/utils/usePrevious.d.ts +1 -0
  339. package/lib/typescript/src/utils/usePrevious.d.ts.map +1 -0
  340. package/package.json +10 -9
  341. package/src/charts/candle/Candle.tsx +3 -3
  342. package/src/charts/candle/CrosshairTooltip.tsx +2 -2
  343. package/src/charts/line/Chart.tsx +6 -4
  344. package/src/charts/line/Cursor.tsx +52 -67
  345. package/src/charts/line/Dot.tsx +8 -8
  346. package/src/charts/line/Gradient.tsx +1 -0
  347. package/src/charts/line/HorizontalLine.tsx +8 -15
  348. package/src/charts/line/Tooltip.tsx +21 -13
  349. package/src/charts/line/useAnimatedPath.ts +3 -3
  350. package/src/charts/line/utils/getArea.ts +8 -5
  351. package/src/charts/line/utils/getXPositionForCurve.ts +9 -0
@@ -1,3 +1,4 @@
1
1
  export declare function useCurrentY(): Readonly<{
2
2
  value: number;
3
3
  }>;
4
+ //# sourceMappingURL=useCurrentY.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCurrentY.d.ts","sourceRoot":"","sources":["../../../../../src/charts/line/useCurrentY.ts"],"names":[],"mappings":"AAMA,wBAAgB,WAAW;;GAc1B"}
@@ -11,3 +11,4 @@ export declare function useLineChartDatetime({ format, locale, options, }?: {
11
11
  value: string;
12
12
  }>;
13
13
  };
14
+ //# sourceMappingURL=useDatetime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDatetime.d.ts","sourceRoot":"","sources":["../../../../../src/charts/line/useDatetime.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,MAAM,EACN,OAAO,GACR,GAAE;IACD,MAAM,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;CACjC;;;;;;;EA4BL"}
@@ -17,3 +17,4 @@ export declare function useLineChart(): {
17
17
  xLength: number;
18
18
  xDomain?: [number, number] | undefined;
19
19
  };
20
+ //# sourceMappingURL=useLineChart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLineChart.d.ts","sourceRoot":"","sources":["../../../../../src/charts/line/useLineChart.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY;;;;;;;;;;;;;;;;;;EAY3B"}
@@ -11,3 +11,4 @@ export declare function useLineChartPrice({ format, precision, index, }?: {
11
11
  value: string;
12
12
  }>;
13
13
  };
14
+ //# sourceMappingURL=usePrice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePrice.d.ts","sourceRoot":"","sources":["../../../../../src/charts/line/usePrice.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,SAAa,EACb,KAAK,GACN,GAAE;IAAE,MAAM,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO;;;;;;;EAuB5E"}
@@ -1,9 +1,11 @@
1
1
  import type { TLineChartData, YDomain } from '../types';
2
- export declare function getArea({ data, width, height, gutter, shape: _shape, yDomain, }: {
2
+ export declare function getArea({ data, width, height, gutter, shape: _shape, yDomain, xDomain, }: {
3
3
  data: TLineChartData;
4
4
  width: number;
5
5
  height: number;
6
6
  gutter: number;
7
7
  shape?: unknown;
8
8
  yDomain: YDomain;
9
+ xDomain?: [number, number];
9
10
  }): string;
11
+ //# sourceMappingURL=getArea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getArea.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/line/utils/getArea.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAKxD,wBAAgB,OAAO,CAAC,EACtB,IAAI,EACJ,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,EAAE,MAAM,EACb,OAAO,EACP,OAAO,GACR,EAAE;IACD,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B,GAAG,MAAM,CAgBT"}
@@ -1,2 +1,3 @@
1
1
  import type { TLineChartPoint } from '../types';
2
2
  export declare function getDomain(rows: TLineChartPoint[]): [number, number];
3
+ //# sourceMappingURL=getDomain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDomain.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/line/utils/getDomain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,wBAAgB,SAAS,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAInE"}
@@ -10,3 +10,4 @@ export declare function getPath({ data, from, to, width, height, gutter, shape:
10
10
  yDomain: YDomain;
11
11
  xDomain?: [number, number];
12
12
  }): string;
13
+ //# sourceMappingURL=getPath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPath.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/line/utils/getPath.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExD,wBAAgB,OAAO,CAAC,EACtB,IAAI,EACJ,IAAI,EACJ,EAAE,EACF,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,EAAE,MAAM,EACb,OAAO,EACP,OAAO,GACR,EAAE;IACD,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B,GAAG,MAAM,CAsBT"}
@@ -0,0 +1,3 @@
1
+ import type { Path } from 'react-native-redash';
2
+ export declare function getXPositionForCurve(path: Path, index: number): number;
3
+ //# sourceMappingURL=getXPositionForCurve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getXPositionForCurve.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/line/utils/getXPositionForCurve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,UAM7D"}
@@ -3,3 +3,4 @@ export * from './getDomain';
3
3
  export * from './getPath';
4
4
  export * from './interpolatePath';
5
5
  export * from './lineChartDataPropToArray';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/line/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC"}
@@ -48,3 +48,4 @@ export declare function interpolatePathCommands(aCommandsInput: any, bCommandsIn
48
48
  * @returns {Function} Interpolation function that maps t ([0, 1]) to a path `d` string.
49
49
  */
50
50
  export declare function interpolatePath(a: any, b: any, excludeSegment: any): (t: any) => any;
51
+ //# sourceMappingURL=interpolatePath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interpolatePath.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/line/utils/interpolatePath.ts"],"names":[],"mappings":"AA6IA;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,YAAY,KAAA,EAAE,UAAU,KAAA,EAAE,YAAY,KAAA,QAahE;AA8QD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,KAAA;;IAiCvC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,KAAA,EACd,cAAc,KAAA,EACd,cAAc,KAAA,mBAsGf;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA,EAAE,cAAc,KAAA,mBAuCnD"}
@@ -1,2 +1,3 @@
1
1
  import type { TLineChartData, TLineChartDataProp } from '../types';
2
2
  export declare function lineChartDataPropToArray(dataProp: TLineChartDataProp): TLineChartData;
3
+ //# sourceMappingURL=lineChartDataPropToArray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineChartDataPropToArray.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/line/utils/lineChartDataPropToArray.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnE,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,kBAAkB,GAC3B,cAAc,CAoBhB"}
@@ -1,9 +1,10 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { TextProps as RNTextProps } from 'react-native';
3
3
  import Animated from 'react-native-reanimated';
4
4
  interface AnimatedTextProps {
5
5
  text: Animated.SharedValue<string>;
6
6
  style?: Animated.AnimateProps<RNTextProps>['style'];
7
7
  }
8
- export declare const AnimatedText: ({ text, style }: AnimatedTextProps) => JSX.Element;
8
+ export declare const AnimatedText: ({ text, style }: AnimatedTextProps) => React.JSX.Element;
9
9
  export {};
10
+ //# sourceMappingURL=AnimatedText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimatedText.d.ts","sourceRoot":"","sources":["../../../../src/components/AnimatedText.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAwB,SAAS,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;AAE9E,OAAO,QAGN,MAAM,yBAAyB,CAAC;AAIjC,UAAU,iBAAiB;IACzB,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC;CACrD;AAID,eAAO,MAAM,YAAY,oBAAqB,iBAAiB,sBAuC9D,CAAC"}
@@ -2,3 +2,4 @@ export * from './charts/candle';
2
2
  export * from './charts/line';
3
3
  export * from './components/AnimatedText';
4
4
  export * from './utils';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,SAAS,CAAC"}
@@ -6,3 +6,4 @@ export declare function formatDatetime({ value, locale, options, }: {
6
6
  locale?: string;
7
7
  options?: Intl.DateTimeFormatOptions;
8
8
  }): string;
9
+ //# sourceMappingURL=formatDatetime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatDatetime.d.ts","sourceRoot":"","sources":["../../../../src/utils/formatDatetime.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,MAAgB,EAChB,OAAY,GACb,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;CACtC,UAIA"}
@@ -6,3 +6,4 @@ export declare function formatPrice({ value: _value, defaultPrice: _defaultPrice
6
6
  defaultPrice?: string;
7
7
  precision?: number;
8
8
  }): string;
9
+ //# sourceMappingURL=formatPrice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatPrice.d.ts","sourceRoot":"","sources":["../../../../src/utils/formatPrice.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,aAAkB,EAChC,SAAS,GACV,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,UA4BA"}
@@ -1,3 +1,4 @@
1
1
  export * from './formatDatetime';
2
2
  export * from './formatPrice';
3
3
  export * from './usePrevious';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
@@ -1 +1,2 @@
1
1
  export declare function usePrevious<T>(value: T): T | undefined;
2
+ //# sourceMappingURL=usePrevious.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePrevious.d.ts","sourceRoot":"","sources":["../../../../src/utils/usePrevious.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,iBAUtC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-wagmi-charts",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
4
4
  "description": "A sweet candlestick chart for React Native",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -39,17 +39,18 @@
39
39
  "d3-interpolate-path": "^2.2.3",
40
40
  "d3-scale": "^2",
41
41
  "d3-shape": "^3.0.1",
42
+ "d3-array": "^3.1.6",
42
43
  "react-keyed-flatten-children": "^1.3.0",
43
44
  "react-native-redash": "^16.1.1"
44
45
  },
45
46
  "devDependencies": {
46
47
  "@commitlint/config-conventional": "^12.0.4",
47
48
  "@react-native-community/eslint-config": "^3.0.0",
48
- "@types/d3-array": "^3.0.4",
49
+ "@types/d3-array": "^3.0.5",
49
50
  "@types/d3-scale": "^4.0.3",
50
51
  "@types/jest": "^26.0.24",
51
- "@types/react": "^17.0.14",
52
- "@types/react-native": "^0.64.12",
52
+ "@types/react": "^18.2.45",
53
+ "@types/react-native": "^0.72.8",
53
54
  "eslint": "^7.31.0",
54
55
  "eslint-config-prettier": "^8.3.0",
55
56
  "eslint-plugin-prettier": "^3.4.0",
@@ -58,13 +59,13 @@
58
59
  "jest": "^27.0.6",
59
60
  "pod-install": "^0.1.24",
60
61
  "prettier": "^2.3.2",
61
- "react": "17.0.1",
62
- "react-native": "0.63.4",
63
- "react-native-builder-bob": "^0.18.1",
62
+ "react": "^18.2.0",
63
+ "react-native": "^0.72.8",
64
+ "react-native-builder-bob": "^0.23.2",
64
65
  "react-native-gesture-handler": "^2.1.0",
65
- "react-native-reanimated": "~2.3.1",
66
+ "react-native-reanimated": "~3.3.0",
66
67
  "react-native-svg": "^12.1.1",
67
- "typescript": "^4.3.5"
68
+ "typescript": "^5.3.3"
68
69
  },
69
70
  "peerDependencies": {
70
71
  "react": "*",
@@ -4,7 +4,6 @@ import Animated, {
4
4
  useAnimatedProps,
5
5
  } from 'react-native-reanimated';
6
6
  import {
7
- Color,
8
7
  Line,
9
8
  LineProps,
10
9
  NumberProp,
@@ -14,6 +13,7 @@ import {
14
13
 
15
14
  import type { TCandle, TDomain } from './types';
16
15
  import { getY, getHeight } from './utils';
16
+ import { ColorValue } from 'react-native';
17
17
 
18
18
  const AnimatedRect = Animated.createAnimatedComponent(Rect);
19
19
  const AnimatedLine = Animated.createAnimatedComponent(Line);
@@ -41,7 +41,7 @@ export type CandlestickChartCandleProps = {
41
41
  y: NumberProp;
42
42
  width: NumberProp;
43
43
  height: NumberProp;
44
- fill: Color;
44
+ fill: ColorValue;
45
45
  useAnimations: boolean;
46
46
  }) => React.ReactNode;
47
47
  renderLine?: ({
@@ -56,7 +56,7 @@ export type CandlestickChartCandleProps = {
56
56
  y1: NumberProp;
57
57
  x2: NumberProp;
58
58
  y2: NumberProp;
59
- stroke: Color;
59
+ stroke: ColorValue;
60
60
  strokeWidth: NumberProp;
61
61
  useAnimations: boolean;
62
62
  }) => React.ReactNode;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { StyleProp, TextStyle, ViewProps } from 'react-native';
2
+ import type { LayoutChangeEvent, StyleProp, TextStyle, ViewProps } from 'react-native';
3
3
  import { StyleSheet } from 'react-native';
4
4
  import Animated, {
5
5
  useAnimatedStyle,
@@ -49,7 +49,7 @@ export function CandlestickChartCrosshairTooltip({
49
49
  const elementWidth = useSharedValue(0);
50
50
 
51
51
  const handleLayout = React.useCallback(
52
- (event) => {
52
+ (event: LayoutChangeEvent) => {
53
53
  elementHeight.value = event.nativeEvent.layout.height;
54
54
  elementWidth.value = event.nativeEvent.layout.width;
55
55
  },
@@ -1,12 +1,13 @@
1
1
  import * as React from 'react';
2
2
  // @ts-ignore
3
3
  import * as d3Shape from 'd3-shape';
4
+
4
5
  import { Dimensions, StyleSheet, View, ViewProps } from 'react-native';
5
- import { LineChartContext } from './Context';
6
6
  import { LineChartIdProvider, useLineChartData } from './Data';
7
-
7
+ import { Path, parse } from 'react-native-redash';
8
8
  import { getArea, getPath } from './utils';
9
- import { parse, Path } from 'react-native-redash';
9
+
10
+ import { LineChartContext } from './Context';
10
11
 
11
12
  export const LineChartDimensionsContext = React.createContext({
12
13
  width: 0,
@@ -84,10 +85,11 @@ export function LineChart({
84
85
  gutter: yGutter,
85
86
  shape,
86
87
  yDomain,
88
+ xDomain,
87
89
  });
88
90
  }
89
91
  return '';
90
- }, [data, pathWidth, height, yGutter, shape, yDomain]);
92
+ }, [data, pathWidth, height, yGutter, shape, yDomain, xDomain]);
91
93
 
92
94
  const dataLength = data.length;
93
95
  const parsedPath = React.useMemo(() => parse(path), [path]);
@@ -1,25 +1,26 @@
1
1
  import * as React from 'react';
2
- import { StyleSheet } from 'react-native';
2
+
3
+ import Animated, {
4
+ runOnJS,
5
+ useAnimatedGestureHandler,
6
+ } from 'react-native-reanimated';
3
7
  import {
4
8
  GestureEvent,
5
9
  LongPressGestureHandler,
6
10
  LongPressGestureHandlerEventPayload,
7
11
  LongPressGestureHandlerProps,
8
12
  } from 'react-native-gesture-handler';
9
- import Animated, {
10
- runOnJS,
11
- useAnimatedGestureHandler,
12
- } from 'react-native-reanimated';
13
13
 
14
14
  import { LineChartDimensionsContext } from './Chart';
15
- import { useLineChart } from './useLineChart';
16
- import { scaleLinear } from 'd3-scale';
15
+ import { StyleSheet } from 'react-native';
17
16
  import { bisectCenter } from 'd3-array';
18
- import type { Path } from 'react-native-redash';
17
+ import { scaleLinear } from 'd3-scale';
18
+ import { useLineChart } from './useLineChart';
19
19
 
20
20
  export type LineChartCursorProps = LongPressGestureHandlerProps & {
21
21
  children: React.ReactNode;
22
22
  type: 'line' | 'crosshair';
23
+ // Does not work on web due to how the Cursor operates on web
23
24
  snapToPoint?: boolean;
24
25
  };
25
26
 
@@ -27,50 +28,6 @@ export const CursorContext = React.createContext({ type: '' });
27
28
 
28
29
  LineChartCursor.displayName = 'LineChartCursor';
29
30
 
30
- const linearScalePositionAndIndex = ({
31
- timestamps,
32
- width,
33
- xToUpdate,
34
- currentIndex,
35
- xPosition,
36
- path,
37
- xDomain,
38
- }: {
39
- timestamps: number[];
40
- width: number;
41
- xToUpdate: Animated.SharedValue<number>;
42
- currentIndex: Animated.SharedValue<number>;
43
- xPosition: number;
44
- path: Path | undefined;
45
- xDomain: [number, number] | undefined;
46
- }) => {
47
- if (!path) {
48
- return;
49
- }
50
-
51
- const domainArray = xDomain ?? [0, timestamps.length];
52
-
53
- // Same scale as in /src/charts/line/utils/getPath.ts
54
- const scaleX = scaleLinear().domain(domainArray).range([0, width]);
55
-
56
- // Calculate a scaled timestamp for the current touch position
57
- const xRelative = scaleX.invert(xPosition);
58
-
59
- const closestIndex = bisectCenter(timestamps, xRelative);
60
- const pathDataDelta = Math.abs(path.curves.length - timestamps.length); // sometimes there is a difference between data length and number of path curves.
61
- const closestPathCurve = Math.max(
62
- Math.min(bisectCenter(timestamps, xRelative), path.curves.length + 1) -
63
- pathDataDelta,
64
- 0
65
- );
66
-
67
- const p0 = (closestIndex > 0 ? path.curves[closestPathCurve].to : path.move)
68
- .x;
69
- // Update values
70
- currentIndex.value = closestIndex;
71
- xToUpdate.value = p0;
72
- };
73
-
74
31
  export function LineChartCursor({
75
32
  children,
76
33
  snapToPoint,
@@ -81,17 +38,53 @@ export function LineChartCursor({
81
38
  LineChartDimensionsContext
82
39
  );
83
40
  const { currentX, currentIndex, isActive, data, xDomain } = useLineChart();
41
+ const xValues = React.useMemo(
42
+ () => data.map(({ timestamp }, i) => (xDomain ? timestamp : i)),
43
+ [data, xDomain]
44
+ );
45
+
46
+ // Same scale as in /src/charts/line/utils/getPath.ts
47
+ const scaleX = React.useMemo(() => {
48
+ const domainArray = xDomain ?? [0, xValues.length];
49
+ return scaleLinear().domain(domainArray).range([0, width]);
50
+ }, [width, xDomain, xValues.length]);
51
+
52
+ const linearScalePositionAndIndex = ({
53
+ xPosition,
54
+ }: {
55
+ xPosition: number;
56
+ }) => {
57
+ if (!parsedPath) {
58
+ return;
59
+ }
60
+
61
+ // Calculate a scaled timestamp for the current touch position
62
+ const xRelative = scaleX.invert(xPosition);
63
+
64
+ const closestIndex = bisectCenter(xValues, xRelative);
65
+ const pathDataDelta = Math.abs(parsedPath.curves.length - xValues.length); // sometimes there is a difference between data length and number of path curves.
66
+ const closestPathCurve = Math.max(
67
+ Math.min(closestIndex, parsedPath.curves.length + 1) - pathDataDelta,
68
+ 0
69
+ );
70
+
71
+ const newXPosition = (
72
+ closestIndex > 0
73
+ ? parsedPath.curves[closestPathCurve].to
74
+ : parsedPath.move
75
+ ).x;
76
+ // Update values
77
+ currentIndex.value = closestIndex;
78
+ currentX.value = newXPosition;
79
+ };
84
80
 
85
81
  const onGestureEvent = useAnimatedGestureHandler<
86
82
  GestureEvent<LongPressGestureHandlerEventPayload>
87
83
  >({
88
84
  onActive: ({ x }) => {
89
85
  if (parsedPath) {
90
- const boundedX = Math.max(0, x <= width ? x : width);
86
+ const xPosition = Math.max(0, x <= width ? x : width);
91
87
  isActive.value = true;
92
- const xValues = data.map(({ timestamp }, i) =>
93
- xDomain ? timestamp : i
94
- );
95
88
 
96
89
  // on Web, we could drag the cursor to be negative, breaking it
97
90
  // so we clamp the index at 0 to fix it
@@ -99,22 +92,14 @@ export function LineChartCursor({
99
92
  const minIndex = 0;
100
93
  const boundedIndex = Math.max(
101
94
  minIndex,
102
- Math.round(boundedX / width / (1 / (data.length - 1)))
95
+ Math.round(xPosition / width / (1 / (data.length - 1)))
103
96
  );
104
97
 
105
98
  if (snapToPoint) {
106
99
  // We have to run this on the JS thread unfortunately as the scaleLinear functions won't work on UI thread
107
- runOnJS(linearScalePositionAndIndex)({
108
- timestamps: xValues,
109
- width,
110
- xToUpdate: currentX,
111
- currentIndex,
112
- xPosition: boundedX,
113
- path: parsedPath,
114
- xDomain,
115
- });
100
+ runOnJS(linearScalePositionAndIndex)({ xPosition });
116
101
  } else if (!snapToPoint) {
117
- currentX.value = boundedX;
102
+ currentX.value = xPosition;
118
103
  currentIndex.value = boundedIndex;
119
104
  }
120
105
  }
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+
2
3
  import Animated, {
3
4
  Easing,
4
5
  useAnimatedProps,
@@ -8,10 +9,11 @@ import Animated, {
8
9
  withTiming,
9
10
  } from 'react-native-reanimated';
10
11
  import { Circle, CircleProps } from 'react-native-svg';
11
- import { getYForX } from 'react-native-redash';
12
12
 
13
13
  import { LineChartDimensionsContext } from './Chart';
14
14
  import { LineChartPathContext } from './LineChartPathContext';
15
+ import { getXPositionForCurve } from './utils/getXPositionForCurve';
16
+ import { getYForX } from 'react-native-redash';
15
17
  import { useLineChart } from './useLineChart';
16
18
 
17
19
  const AnimatedCircle = Animated.createAnimatedComponent(Circle);
@@ -58,9 +60,7 @@ export function LineChartDot({
58
60
  outerSize = size * 4,
59
61
  }: LineChartDotProps) {
60
62
  const { isActive } = useLineChart();
61
- const { parsedPath, pointWidth } = React.useContext(
62
- LineChartDimensionsContext
63
- );
63
+ const { parsedPath } = React.useContext(LineChartDimensionsContext);
64
64
 
65
65
  ////////////////////////////////////////////////////////////
66
66
 
@@ -72,10 +72,10 @@ export function LineChartDot({
72
72
 
73
73
  ////////////////////////////////////////////////////////////
74
74
 
75
- const x = useDerivedValue(
76
- () => withTiming(pointWidth * at),
77
- [at, pointWidth]
78
- );
75
+ const x = useDerivedValue(() => {
76
+ return withTiming(getXPositionForCurve(parsedPath, at));
77
+ }, [at, parsedPath]);
78
+
79
79
  const y = useDerivedValue(
80
80
  () => withTiming(getYForX(parsedPath!, x.value) || 0),
81
81
  [parsedPath, x]
@@ -52,6 +52,7 @@ export function LineChartGradient({
52
52
  y1="0"
53
53
  y2="100%"
54
54
  >
55
+ {/*@ts-ignore*/}
55
56
  {children}
56
57
  </LinearGradient>
57
58
  </Defs>
@@ -1,13 +1,14 @@
1
- import React from 'react';
2
1
  import Animated, {
3
2
  useAnimatedProps,
4
3
  useDerivedValue,
5
4
  withTiming,
6
5
  } from 'react-native-reanimated';
7
- import { Line as SVGLine, LineProps } from 'react-native-svg';
8
- import { getYForX } from 'react-native-redash';
6
+ import { LineProps, Line as SVGLine } from 'react-native-svg';
9
7
 
10
8
  import { LineChartDimensionsContext } from './Chart';
9
+ import React from 'react';
10
+ import { getXPositionForCurve } from './utils/getXPositionForCurve';
11
+ import { getYForX } from 'react-native-redash';
11
12
  import { useLineChart } from './useLineChart';
12
13
 
13
14
  const AnimatedLine = Animated.createAnimatedComponent(SVGLine);
@@ -53,7 +54,7 @@ export function LineChartHorizontalLine({
53
54
  at = { index: 0 },
54
55
  offsetY = 0,
55
56
  }: HorizontalLineProps) {
56
- const { width, parsedPath, pointWidth, height, gutter } = React.useContext(
57
+ const { width, parsedPath, height, gutter } = React.useContext(
57
58
  LineChartDimensionsContext
58
59
  );
59
60
  const { yDomain } = useLineChart();
@@ -61,7 +62,8 @@ export function LineChartHorizontalLine({
61
62
  const y = useDerivedValue(() => {
62
63
  if (typeof at === 'number' || at.index != null) {
63
64
  const index = typeof at === 'number' ? at : at.index;
64
- const yForX = getYForX(parsedPath!, pointWidth * index) || 0;
65
+ const yForX =
66
+ getYForX(parsedPath!, getXPositionForCurve(parsedPath, index)) || 0;
65
67
  return withTiming(yForX + offsetY);
66
68
  }
67
69
  /**
@@ -82,16 +84,7 @@ export function LineChartHorizontalLine({
82
84
  const offsetTopPixels = gutter + percentageOffsetTop * heightBetweenGutters;
83
85
 
84
86
  return withTiming(offsetTopPixels + offsetY);
85
- }, [
86
- at,
87
- gutter,
88
- height,
89
- offsetY,
90
- parsedPath,
91
- pointWidth,
92
- yDomain.max,
93
- yDomain.min,
94
- ]);
87
+ }, [at, gutter, height, offsetY, parsedPath, yDomain.max, yDomain.min]);
95
88
 
96
89
  const lineAnimatedProps = useAnimatedProps(
97
90
  () => ({