react-native-wagmi-charts 2.9.0 → 2.10.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 (218) hide show
  1. package/README.md +143 -66
  2. package/lib/commonjs/charts/candle/Candle.js +92 -177
  3. package/lib/commonjs/charts/candle/Candles.js +39 -66
  4. package/lib/commonjs/charts/candle/Chart.js +26 -37
  5. package/lib/commonjs/charts/candle/Context.js +49 -69
  6. package/lib/commonjs/charts/candle/Crosshair.js +82 -183
  7. package/lib/commonjs/charts/candle/Crosshair.js.map +1 -1
  8. package/lib/commonjs/charts/candle/CrosshairTooltip.js +61 -140
  9. package/lib/commonjs/charts/candle/DatetimeText.js +14 -19
  10. package/lib/commonjs/charts/candle/Line.js +27 -73
  11. package/lib/commonjs/charts/candle/PriceText.js +14 -19
  12. package/lib/commonjs/charts/candle/index.js +64 -67
  13. package/lib/commonjs/charts/candle/types.js +4 -4
  14. package/lib/commonjs/charts/candle/useCandleData.js +12 -9
  15. package/lib/commonjs/charts/candle/useCandlestickChart.js +7 -9
  16. package/lib/commonjs/charts/candle/useDatetime.js +18 -16
  17. package/lib/commonjs/charts/candle/usePrice.js +22 -21
  18. package/lib/commonjs/charts/candle/utils/getDomain.js +9 -5
  19. package/lib/commonjs/charts/candle/utils/getDomain.js.map +1 -1
  20. package/lib/commonjs/charts/candle/utils/getHeight.js +11 -12
  21. package/lib/commonjs/charts/candle/utils/getHeight.js.map +1 -1
  22. package/lib/commonjs/charts/candle/utils/getPrice.js +11 -12
  23. package/lib/commonjs/charts/candle/utils/getPrice.js.map +1 -1
  24. package/lib/commonjs/charts/candle/utils/getY.js +11 -12
  25. package/lib/commonjs/charts/candle/utils/getY.js.map +1 -1
  26. package/lib/commonjs/charts/candle/utils/index.js +16 -16
  27. package/lib/commonjs/charts/line/Axis.js +148 -268
  28. package/lib/commonjs/charts/line/Chart.js +62 -129
  29. package/lib/commonjs/charts/line/Chart.js.map +1 -1
  30. package/lib/commonjs/charts/line/ChartPath.js +105 -285
  31. package/lib/commonjs/charts/line/Context.js +37 -95
  32. package/lib/commonjs/charts/line/Cursor.js +74 -125
  33. package/lib/commonjs/charts/line/Cursor.js.map +1 -1
  34. package/lib/commonjs/charts/line/CursorCrosshair.js +56 -134
  35. package/lib/commonjs/charts/line/CursorCrosshair.js.map +1 -1
  36. package/lib/commonjs/charts/line/CursorLine.js +67 -152
  37. package/lib/commonjs/charts/line/CursorLine.js.map +1 -1
  38. package/lib/commonjs/charts/line/Data.js +34 -73
  39. package/lib/commonjs/charts/line/DatetimeText.js +15 -20
  40. package/lib/commonjs/charts/line/Dot.js +56 -149
  41. package/lib/commonjs/charts/line/Gradient.js +53 -124
  42. package/lib/commonjs/charts/line/Group.js +23 -54
  43. package/lib/commonjs/charts/line/Group.js.map +1 -1
  44. package/lib/commonjs/charts/line/Highlight.js +47 -115
  45. package/lib/commonjs/charts/line/HorizontalLine.js +39 -92
  46. package/lib/commonjs/charts/line/HoverTrap/index.js +7 -10
  47. package/lib/commonjs/charts/line/HoverTrap/index.web.js +43 -48
  48. package/lib/commonjs/charts/line/LineChartPathContext.js +11 -14
  49. package/lib/commonjs/charts/line/Path.js +32 -78
  50. package/lib/commonjs/charts/line/PriceText.js +36 -78
  51. package/lib/commonjs/charts/line/Tooltip.js +102 -188
  52. package/lib/commonjs/charts/line/Tooltip.js.map +1 -1
  53. package/lib/commonjs/charts/line/index.js +65 -65
  54. package/lib/commonjs/charts/line/types.js +4 -4
  55. package/lib/commonjs/charts/line/useAnimatedPath.js +22 -27
  56. package/lib/commonjs/charts/line/useCurrentY.js +17 -17
  57. package/lib/commonjs/charts/line/useDatetime.js +28 -32
  58. package/lib/commonjs/charts/line/useLineChart.js +15 -20
  59. package/lib/commonjs/charts/line/usePrice.js +26 -28
  60. package/lib/commonjs/charts/line/utils/getArea.js +14 -47
  61. package/lib/commonjs/charts/line/utils/getDomain.js +8 -5
  62. package/lib/commonjs/charts/line/utils/getDomain.js.map +1 -1
  63. package/lib/commonjs/charts/line/utils/getPath.js +14 -53
  64. package/lib/commonjs/charts/line/utils/getXPositionForCurve.js +5 -8
  65. package/lib/commonjs/charts/line/utils/index.js +19 -19
  66. package/lib/commonjs/charts/line/utils/interpolatePath.js +60 -100
  67. package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js +5 -5
  68. package/lib/commonjs/components/AnimatedText.js +29 -67
  69. package/lib/commonjs/index.js +19 -19
  70. package/lib/commonjs/types.js +2 -2
  71. package/lib/commonjs/utils/formatDatetime.js +9 -5
  72. package/lib/commonjs/utils/formatPrice.js +6 -10
  73. package/lib/commonjs/utils/index.js +13 -13
  74. package/lib/commonjs/utils/usePrevious.js +6 -8
  75. package/lib/module/charts/candle/Candle.js +76 -126
  76. package/lib/module/charts/candle/Candles.js +30 -52
  77. package/lib/module/charts/candle/Chart.js +19 -22
  78. package/lib/module/charts/candle/Context.js +29 -47
  79. package/lib/module/charts/candle/Crosshair.js +69 -142
  80. package/lib/module/charts/candle/Crosshair.js.map +1 -1
  81. package/lib/module/charts/candle/CrosshairTooltip.js +51 -101
  82. package/lib/module/charts/candle/DatetimeText.js +5 -5
  83. package/lib/module/charts/candle/Line.js +19 -37
  84. package/lib/module/charts/candle/PriceText.js +5 -5
  85. package/lib/module/charts/candle/index.js +2 -2
  86. package/lib/module/charts/candle/types.js +1 -1
  87. package/lib/module/charts/candle/useCandleData.js +7 -3
  88. package/lib/module/charts/candle/useCandlestickChart.js +1 -1
  89. package/lib/module/charts/candle/useDatetime.js +12 -10
  90. package/lib/module/charts/candle/usePrice.js +14 -12
  91. package/lib/module/charts/candle/utils/getDomain.js +6 -2
  92. package/lib/module/charts/candle/utils/getDomain.js.map +1 -1
  93. package/lib/module/charts/candle/utils/getHeight.js +8 -9
  94. package/lib/module/charts/candle/utils/getHeight.js.map +1 -1
  95. package/lib/module/charts/candle/utils/getPrice.js +8 -4
  96. package/lib/module/charts/candle/utils/getPrice.js.map +1 -1
  97. package/lib/module/charts/candle/utils/getY.js +8 -4
  98. package/lib/module/charts/candle/utils/getY.js.map +1 -1
  99. package/lib/module/charts/candle/utils/index.js +1 -1
  100. package/lib/module/charts/line/Axis.js +113 -189
  101. package/lib/module/charts/line/Chart.js +40 -73
  102. package/lib/module/charts/line/Chart.js.map +1 -1
  103. package/lib/module/charts/line/ChartPath.js +90 -238
  104. package/lib/module/charts/line/Context.js +29 -61
  105. package/lib/module/charts/line/Cursor.js +61 -82
  106. package/lib/module/charts/line/Cursor.js.map +1 -1
  107. package/lib/module/charts/line/CursorCrosshair.js +47 -99
  108. package/lib/module/charts/line/CursorCrosshair.js.map +1 -1
  109. package/lib/module/charts/line/CursorLine.js +52 -107
  110. package/lib/module/charts/line/CursorLine.js.map +1 -1
  111. package/lib/module/charts/line/Data.js +28 -41
  112. package/lib/module/charts/line/DatetimeText.js +5 -5
  113. package/lib/module/charts/line/Dot.js +39 -93
  114. package/lib/module/charts/line/Gradient.js +41 -79
  115. package/lib/module/charts/line/Group.js +14 -15
  116. package/lib/module/charts/line/Group.js.map +1 -1
  117. package/lib/module/charts/line/Highlight.js +32 -61
  118. package/lib/module/charts/line/HorizontalLine.js +27 -49
  119. package/lib/module/charts/line/HoverTrap/index.js +2 -3
  120. package/lib/module/charts/line/HoverTrap/index.web.js +34 -34
  121. package/lib/module/charts/line/LineChartPathContext.js +3 -3
  122. package/lib/module/charts/line/Path.js +20 -33
  123. package/lib/module/charts/line/PriceText.js +25 -42
  124. package/lib/module/charts/line/Tooltip.js +89 -151
  125. package/lib/module/charts/line/Tooltip.js.map +1 -1
  126. package/lib/module/charts/line/index.js +2 -2
  127. package/lib/module/charts/line/types.js +1 -1
  128. package/lib/module/charts/line/useAnimatedPath.js +16 -22
  129. package/lib/module/charts/line/useCurrentY.js +9 -4
  130. package/lib/module/charts/line/useDatetime.js +22 -26
  131. package/lib/module/charts/line/useLineChart.js +7 -10
  132. package/lib/module/charts/line/usePrice.js +20 -22
  133. package/lib/module/charts/line/utils/getArea.js +8 -15
  134. package/lib/module/charts/line/utils/getDomain.js +5 -2
  135. package/lib/module/charts/line/utils/getDomain.js.map +1 -1
  136. package/lib/module/charts/line/utils/getPath.js +8 -21
  137. package/lib/module/charts/line/utils/getXPositionForCurve.js +2 -5
  138. package/lib/module/charts/line/utils/index.js +1 -1
  139. package/lib/module/charts/line/utils/interpolatePath.js +57 -97
  140. package/lib/module/charts/line/utils/lineChartDataPropToArray.js +2 -2
  141. package/lib/module/components/AnimatedText.js +21 -25
  142. package/lib/module/index.js +1 -1
  143. package/lib/module/types.js +2 -1
  144. package/lib/module/utils/formatDatetime.js +6 -2
  145. package/lib/module/utils/formatPrice.js +3 -7
  146. package/lib/module/utils/index.js +1 -1
  147. package/lib/module/utils/usePrevious.js +1 -1
  148. package/lib/typescript/src/charts/candle/Candle.d.ts +31 -45
  149. package/lib/typescript/src/charts/candle/Candles.d.ts +13 -24
  150. package/lib/typescript/src/charts/candle/Chart.d.ts +7 -12
  151. package/lib/typescript/src/charts/candle/Context.d.ts +7 -12
  152. package/lib/typescript/src/charts/candle/Crosshair.d.ts +9 -17
  153. package/lib/typescript/src/charts/candle/CrosshairTooltip.d.ts +8 -15
  154. package/lib/typescript/src/charts/candle/DatetimeText.d.ts +9 -15
  155. package/lib/typescript/src/charts/candle/Line.d.ts +5 -10
  156. package/lib/typescript/src/charts/candle/PriceText.d.ts +7 -13
  157. package/lib/typescript/src/charts/candle/index.d.ts +13 -32
  158. package/lib/typescript/src/charts/candle/types.d.ts +16 -16
  159. package/lib/typescript/src/charts/candle/useCandleData.d.ts +1 -1
  160. package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts +1 -1
  161. package/lib/typescript/src/charts/candle/useDatetime.d.ts +9 -13
  162. package/lib/typescript/src/charts/candle/usePrice.d.ts +7 -11
  163. package/lib/typescript/src/charts/candle/utils/getDomain.d.ts +1 -1
  164. package/lib/typescript/src/charts/candle/utils/getDomain.d.ts.map +1 -1
  165. package/lib/typescript/src/charts/candle/utils/getHeight.d.ts +5 -9
  166. package/lib/typescript/src/charts/candle/utils/getPrice.d.ts +5 -9
  167. package/lib/typescript/src/charts/candle/utils/getY.d.ts +5 -9
  168. package/lib/typescript/src/charts/candle/utils/index.d.ts +1 -1
  169. package/lib/typescript/src/charts/line/Axis.d.ts +14 -27
  170. package/lib/typescript/src/charts/line/Chart.d.ts +23 -33
  171. package/lib/typescript/src/charts/line/Chart.d.ts.map +1 -1
  172. package/lib/typescript/src/charts/line/ChartPath.d.ts +15 -28
  173. package/lib/typescript/src/charts/line/Context.d.ts +9 -16
  174. package/lib/typescript/src/charts/line/Cursor.d.ts +14 -22
  175. package/lib/typescript/src/charts/line/Cursor.d.ts.map +1 -1
  176. package/lib/typescript/src/charts/line/CursorCrosshair.d.ts +11 -23
  177. package/lib/typescript/src/charts/line/CursorCrosshair.d.ts.map +1 -1
  178. package/lib/typescript/src/charts/line/CursorLine.d.ts +9 -15
  179. package/lib/typescript/src/charts/line/CursorLine.d.ts.map +1 -1
  180. package/lib/typescript/src/charts/line/Data.d.ts +13 -17
  181. package/lib/typescript/src/charts/line/DatetimeText.d.ts +8 -14
  182. package/lib/typescript/src/charts/line/Dot.d.ts +25 -38
  183. package/lib/typescript/src/charts/line/Gradient.d.ts +5 -9
  184. package/lib/typescript/src/charts/line/Group.d.ts +3 -6
  185. package/lib/typescript/src/charts/line/Group.d.ts.map +1 -1
  186. package/lib/typescript/src/charts/line/Highlight.d.ts +9 -17
  187. package/lib/typescript/src/charts/line/HorizontalLine.d.ts +22 -30
  188. package/lib/typescript/src/charts/line/HoverTrap/index.d.ts +1 -1
  189. package/lib/typescript/src/charts/line/HoverTrap/index.web.d.ts +1 -1
  190. package/lib/typescript/src/charts/line/LineChartPathContext.d.ts +4 -4
  191. package/lib/typescript/src/charts/line/Path.d.ts +23 -28
  192. package/lib/typescript/src/charts/line/PriceText.d.ts +20 -28
  193. package/lib/typescript/src/charts/line/Tooltip.d.ts +20 -32
  194. package/lib/typescript/src/charts/line/index.d.ts +20 -33
  195. package/lib/typescript/src/charts/line/types.d.ts +17 -19
  196. package/lib/typescript/src/charts/line/useAnimatedPath.d.ts +7 -10
  197. package/lib/typescript/src/charts/line/useCurrentY.d.ts +2 -2
  198. package/lib/typescript/src/charts/line/useDatetime.d.ts +7 -11
  199. package/lib/typescript/src/charts/line/useLineChart.d.ts +10 -10
  200. package/lib/typescript/src/charts/line/usePrice.d.ts +7 -11
  201. package/lib/typescript/src/charts/line/utils/getArea.d.ts +9 -17
  202. package/lib/typescript/src/charts/line/utils/getDomain.d.ts +1 -1
  203. package/lib/typescript/src/charts/line/utils/getDomain.d.ts.map +1 -1
  204. package/lib/typescript/src/charts/line/utils/getPath.d.ts +11 -21
  205. package/lib/typescript/src/charts/line/utils/getXPositionForCurve.d.ts +1 -1
  206. package/lib/typescript/src/charts/line/utils/index.d.ts +1 -1
  207. package/lib/typescript/src/charts/line/utils/interpolatePath.d.ts +5 -17
  208. package/lib/typescript/src/charts/line/utils/lineChartDataPropToArray.d.ts +2 -4
  209. package/lib/typescript/src/components/AnimatedText.d.ts +4 -7
  210. package/lib/typescript/src/index.d.ts +1 -1
  211. package/lib/typescript/src/types.d.ts +4 -7
  212. package/lib/typescript/src/utils/formatDatetime.d.ts +5 -9
  213. package/lib/typescript/src/utils/formatPrice.d.ts +5 -9
  214. package/lib/typescript/src/utils/index.d.ts +1 -1
  215. package/lib/typescript/src/utils/usePrevious.d.ts +1 -1
  216. package/package.json +1 -1
  217. package/src/charts/line/CursorLine.tsx +6 -2
  218. package/src/charts/line/HorizontalLine.tsx +5 -1
@@ -9,27 +9,14 @@ export function getPath({
9
9
  gutter,
10
10
  shape: _shape,
11
11
  yDomain,
12
- xDomain,
12
+ xDomain
13
13
  }) {
14
- const timestamps = data.map(({ timestamp }, i) => (xDomain ? timestamp : i));
15
- const scaleX = scaleLinear()
16
- .domain(xDomain ?? [Math.min(...timestamps), Math.max(...timestamps)])
17
- .range([0, width]);
18
- const scaleY = scaleLinear()
19
- .domain([yDomain.min, yDomain.max])
20
- .range([height - gutter, gutter]);
21
- const path = shape
22
- .line()
23
- .defined((d) =>
24
- from || to
25
- ? !!data
26
- .slice(from, to ? to + 1 : undefined)
27
- .find((item) => item.timestamp === d.timestamp)
28
- : true
29
- )
30
- .x((_, i) => scaleX(xDomain ? timestamps[i] ?? i : i))
31
- .y((d) => scaleY(d.value))
32
- .curve(_shape)(data);
14
+ const timestamps = data.map(({
15
+ timestamp
16
+ }, i) => xDomain ? timestamp : i);
17
+ const scaleX = scaleLinear().domain(xDomain ?? [Math.min(...timestamps), Math.max(...timestamps)]).range([0, width]);
18
+ const scaleY = scaleLinear().domain([yDomain.min, yDomain.max]).range([height - gutter, gutter]);
19
+ const path = shape.line().defined(d => from || to ? !!data.slice(from, to ? to + 1 : undefined).find(item => item.timestamp === d.timestamp) : true).x((_, i) => scaleX(xDomain ? timestamps[i] ?? i : i)).y(d => scaleY(d.value)).curve(_shape)(data);
33
20
  return path || '';
34
21
  }
35
- //# sourceMappingURL=getPath.js.map
22
+ //# sourceMappingURL=getPath.js.map
@@ -6,11 +6,8 @@ export function getXPositionForCurve(path, index) {
6
6
  }
7
7
  const point = path.curves[index - 1];
8
8
  if (point === undefined) {
9
- throw new Error(
10
- `Index out of bounds: ${index}. ` +
11
- `Expected an integer in the range [0, ${path.curves.length}]`
12
- );
9
+ throw new Error(`Index out of bounds: ${index}. ` + `Expected an integer in the range [0, ${path.curves.length}]`);
13
10
  }
14
11
  return point.to.x;
15
12
  }
16
- //# sourceMappingURL=getXPositionForCurve.js.map
13
+ //# sourceMappingURL=getXPositionForCurve.js.map
@@ -3,4 +3,4 @@ export * from './getDomain';
3
3
  export * from './getPath';
4
4
  export * from './interpolatePath';
5
5
  export * from './lineChartDataPropToArray';
6
- //# sourceMappingURL=index.js.map
6
+ //# sourceMappingURL=index.js.map
@@ -36,10 +36,7 @@ function decasteljau(points, t) {
36
36
  if (i === newPoints.length - 1) {
37
37
  right.push(points[i + 1]);
38
38
  }
39
- newPoints[i] = [
40
- (1 - t) * points[i][0] + t * points[i + 1][0],
41
- (1 - t) * points[i][1] + t * points[i + 1][1],
42
- ];
39
+ newPoints[i] = [(1 - t) * points[i][0] + t * points[i + 1][0], (1 - t) * points[i][1] + t * points[i + 1][1]];
43
40
  }
44
41
  decasteljauRecurse(newPoints, t);
45
42
  }
@@ -49,7 +46,7 @@ function decasteljau(points, t) {
49
46
  }
50
47
  return {
51
48
  left,
52
- right: right.reverse(),
49
+ right: right.reverse()
53
50
  };
54
51
  }
55
52
 
@@ -166,11 +163,11 @@ const typeMap = {
166
163
  Q: ['x1', 'y1', 'x', 'y'],
167
164
  T: ['x', 'y'],
168
165
  A: ['rx', 'ry', 'xAxisRotation', 'largeArcFlag', 'sweepFlag', 'x', 'y'],
169
- Z: [],
166
+ Z: []
170
167
  };
171
168
 
172
169
  // Add lower case entries too matching uppercase (e.g. 'm' == 'M')
173
- Object.keys(typeMap).forEach((key) => {
170
+ Object.keys(typeMap).forEach(key => {
174
171
  typeMap[key.toLowerCase()] = typeMap[key];
175
172
  });
176
173
  function arrayOfLength(length, value) {
@@ -191,9 +188,7 @@ function arrayOfLength(length, value) {
191
188
  function commandToString(command) {
192
189
  'worklet';
193
190
 
194
- return `${command.type}${typeMap[command.type]
195
- .map((p) => command[p])
196
- .join(',')}`;
191
+ return `${command.type}${typeMap[command.type].map(p => command[p]).join(',')}`;
197
192
  }
198
193
 
199
194
  /**
@@ -223,14 +218,14 @@ function convertToSameType(aCommand, bCommand) {
223
218
  x1: 'x',
224
219
  y1: 'y',
225
220
  x2: 'x',
226
- y2: 'y',
221
+ y2: 'y'
227
222
  };
228
223
  const readFromBKeys = ['xAxisRotation', 'largeArcFlag', 'sweepFlag'];
229
224
 
230
225
  // convert (but ignore M types)
231
226
  if (aCommand.type !== bCommand.type && bCommand.type.toUpperCase() !== 'M') {
232
227
  const aConverted = {};
233
- Object.keys(bCommand).forEach((bKey) => {
228
+ Object.keys(bCommand).forEach(bKey => {
234
229
  const bValue = bCommand[bKey];
235
230
  // first read from the A command
236
231
  let aValue = aCommand[bKey];
@@ -279,14 +274,8 @@ function splitSegment(commandStart, commandEnd, segmentCount) {
279
274
  let segments = [];
280
275
 
281
276
  // line, quadratic bezier, or cubic bezier
282
- if (
283
- commandEnd.type === 'L' ||
284
- commandEnd.type === 'Q' ||
285
- commandEnd.type === 'C'
286
- ) {
287
- segments = segments.concat(
288
- splitCurve(commandStart, commandEnd, segmentCount)
289
- );
277
+ if (commandEnd.type === 'L' || commandEnd.type === 'Q' || commandEnd.type === 'C') {
278
+ segments = segments.concat(splitCurve(commandStart, commandEnd, segmentCount));
290
279
 
291
280
  // general case - just copy the same point
292
281
  } else {
@@ -296,9 +285,7 @@ function splitSegment(commandStart, commandEnd, segmentCount) {
296
285
  if (copyCommand.type === 'M') {
297
286
  copyCommand.type = 'L';
298
287
  }
299
- segments = segments.concat(
300
- arrayOfLength(segmentCount - 1).map(() => copyCommand)
301
- );
288
+ segments = segments.concat(arrayOfLength(segmentCount - 1).map(() => copyCommand));
302
289
  segments.push(commandEnd);
303
290
  }
304
291
  return segments;
@@ -331,69 +318,56 @@ function extend(commandsToExtend, referenceCommands, excludeSegment) {
331
318
  // should be added in that segment (should always be >= 1 since we need each
332
319
  // point itself).
333
320
  // 0 = segment 0-1, 1 = segment 1-2, n-1 = last vertex
334
- const countPointsPerSegment = arrayOfLength(numReferenceSegments).reduce(
335
- (accum, d, i) => {
336
- let insertIndex = Math.floor(segmentRatio * i);
337
-
338
- // handle excluding segments
339
- if (
340
- excludeSegment &&
341
- insertIndex < commandsToExtend.length - 1 &&
342
- excludeSegment(
343
- commandsToExtend[insertIndex],
344
- commandsToExtend[insertIndex + 1]
345
- )
346
- ) {
347
- // set the insertIndex to the segment that this point should be added to:
348
-
349
- // round the insertIndex essentially so we split half and half on
350
- // neighbouring segments. hence the segmentRatio * i < 0.5
351
- const addToPriorSegment = (segmentRatio * i) % 1 < 0.5;
352
-
353
- // only skip segment if we already have 1 point in it (can't entirely remove a segment)
354
- if (accum[insertIndex]) {
355
- // TODO - Note this is a naive algorithm that should work for most d3-area use cases
356
- // but if two adjacent segments are supposed to be skipped, this will not perform as
357
- // expected. Could be updated to search for nearest segment to place the point in, but
358
- // will only do that if necessary.
359
-
360
- // add to the prior segment
361
- if (addToPriorSegment) {
362
- if (insertIndex > 0) {
363
- insertIndex -= 1;
364
-
365
- // not possible to add to previous so adding to next
366
- } else if (insertIndex < commandsToExtend.length - 1) {
367
- insertIndex += 1;
368
- }
369
- // add to next segment
321
+ const countPointsPerSegment = arrayOfLength(numReferenceSegments).reduce((accum, d, i) => {
322
+ let insertIndex = Math.floor(segmentRatio * i);
323
+
324
+ // handle excluding segments
325
+ if (excludeSegment && insertIndex < commandsToExtend.length - 1 && excludeSegment(commandsToExtend[insertIndex], commandsToExtend[insertIndex + 1])) {
326
+ // set the insertIndex to the segment that this point should be added to:
327
+
328
+ // round the insertIndex essentially so we split half and half on
329
+ // neighbouring segments. hence the segmentRatio * i < 0.5
330
+ const addToPriorSegment = segmentRatio * i % 1 < 0.5;
331
+
332
+ // only skip segment if we already have 1 point in it (can't entirely remove a segment)
333
+ if (accum[insertIndex]) {
334
+ // TODO - Note this is a naive algorithm that should work for most d3-area use cases
335
+ // but if two adjacent segments are supposed to be skipped, this will not perform as
336
+ // expected. Could be updated to search for nearest segment to place the point in, but
337
+ // will only do that if necessary.
338
+
339
+ // add to the prior segment
340
+ if (addToPriorSegment) {
341
+ if (insertIndex > 0) {
342
+ insertIndex -= 1;
343
+
344
+ // not possible to add to previous so adding to next
370
345
  } else if (insertIndex < commandsToExtend.length - 1) {
371
346
  insertIndex += 1;
372
-
373
- // not possible to add to next so adding to previous
374
- } else if (insertIndex > 0) {
375
- insertIndex -= 1;
376
347
  }
348
+ // add to next segment
349
+ } else if (insertIndex < commandsToExtend.length - 1) {
350
+ insertIndex += 1;
351
+
352
+ // not possible to add to next so adding to previous
353
+ } else if (insertIndex > 0) {
354
+ insertIndex -= 1;
377
355
  }
378
356
  }
379
- accum[insertIndex] = (accum[insertIndex] || 0) + 1;
380
- return accum;
381
- },
382
- []
383
- );
357
+ }
358
+ accum[insertIndex] = (accum[insertIndex] || 0) + 1;
359
+ return accum;
360
+ }, []);
384
361
 
385
362
  // extend each segment to have the correct number of points for a smooth interpolation
386
363
  const extended = countPointsPerSegment.reduce((extended, segmentCount, i) => {
387
364
  // if last command, just add `segmentCount` number of times
388
365
  if (i === commandsToExtend.length - 1) {
389
- const lastCommandCopies = arrayOfLength(
390
- segmentCount,
391
- Object.assign({}, commandsToExtend[commandsToExtend.length - 1])
392
- );
366
+ const lastCommandCopies = arrayOfLength(segmentCount, Object.assign({}, commandsToExtend[commandsToExtend.length - 1]));
393
367
 
394
368
  // convert M to L
395
369
  if (lastCommandCopies[0].type === 'M') {
396
- lastCommandCopies.forEach((d) => {
370
+ lastCommandCopies.forEach(d => {
397
371
  d.type = 'L';
398
372
  });
399
373
  }
@@ -401,9 +375,7 @@ function extend(commandsToExtend, referenceCommands, excludeSegment) {
401
375
  }
402
376
 
403
377
  // otherwise, split the segment segmentCount times.
404
- return extended.concat(
405
- splitSegment(commandsToExtend[i], commandsToExtend[i + 1], segmentCount)
406
- );
378
+ return extended.concat(splitSegment(commandsToExtend[i], commandsToExtend[i + 1], segmentCount));
407
379
  }, []);
408
380
 
409
381
  // add in the very first point since splitSegment only adds in the ones after it
@@ -434,7 +406,7 @@ export function pathCommandsFromString(d) {
434
406
  // new command found:
435
407
  if (commandArgs) {
436
408
  command = {
437
- type: tokens[i],
409
+ type: tokens[i]
438
410
  };
439
411
 
440
412
  // add each of the expected args for this command:
@@ -467,11 +439,7 @@ export function pathCommandsFromString(d) {
467
439
  * end command object and returns true if the segment should be excluded from splitting.
468
440
  * @returns {Function} Interpolation function that maps t ([0, 1]) to an array of path commands.
469
441
  */
470
- export function interpolatePathCommands(
471
- aCommandsInput,
472
- bCommandsInput,
473
- excludeSegment
474
- ) {
442
+ export function interpolatePathCommands(aCommandsInput, bCommandsInput, excludeSegment) {
475
443
  'worklet';
476
444
 
477
445
  // make a copy so we don't mess with the input arrays
@@ -488,9 +456,7 @@ export function interpolatePathCommands(
488
456
  }
489
457
 
490
458
  // do we add Z during interpolation? yes if both have it. (we'd expect both to have it or not)
491
- const addZ =
492
- (aCommands.length === 0 || aCommands[aCommands.length - 1].type === 'Z') &&
493
- (bCommands.length === 0 || bCommands[bCommands.length - 1].type === 'Z');
459
+ const addZ = (aCommands.length === 0 || aCommands[aCommands.length - 1].type === 'Z') && (bCommands.length === 0 || bCommands[bCommands.length - 1].type === 'Z');
494
460
 
495
461
  // we temporarily remove Z
496
462
  if (aCommands.length > 0 && aCommands[aCommands.length - 1].type === 'Z') {
@@ -526,18 +492,16 @@ export function interpolatePathCommands(
526
492
 
527
493
  // commands have same length now.
528
494
  // convert commands in A to the same type as those in B
529
- aCommands = aCommands.map((aCommand, i) =>
530
- convertToSameType(aCommand, bCommands[i])
531
- );
495
+ aCommands = aCommands.map((aCommand, i) => convertToSameType(aCommand, bCommands[i]));
532
496
 
533
497
  // create mutable interpolated command objects
534
- const interpolatedCommands = aCommands.map((aCommand) => aCommand);
498
+ const interpolatedCommands = aCommands.map(aCommand => aCommand);
535
499
  if (addZ) {
536
500
  interpolatedCommands.push({
537
- type: 'Z',
501
+ type: 'Z'
538
502
  });
539
503
  aCommands.push({
540
- type: 'Z',
504
+ type: 'Z'
541
505
  }); // required for when returning at t == 0
542
506
  }
543
507
  return function pathCommandInterpolator(t) {
@@ -599,11 +563,7 @@ export function interpolatePath(a, b, excludeSegment) {
599
563
  return '';
600
564
  };
601
565
  }
602
- const commandInterpolator = interpolatePathCommands(
603
- aCommands,
604
- bCommands,
605
- excludeSegment
606
- );
566
+ const commandInterpolator = interpolatePathCommands(aCommands, bCommands, excludeSegment);
607
567
  return function pathStringInterpolator(t) {
608
568
  'worklet';
609
569
 
@@ -622,4 +582,4 @@ export function interpolatePath(a, b, excludeSegment) {
622
582
  return interpolatedString;
623
583
  };
624
584
  }
625
- //# sourceMappingURL=interpolatePath.js.map
585
+ //# sourceMappingURL=interpolatePath.js.map
@@ -8,11 +8,11 @@ export function lineChartDataPropToArray(dataProp) {
8
8
  return dataProp;
9
9
  }
10
10
  const data = [];
11
- Object.values(dataProp).forEach((dataSet) => {
11
+ Object.values(dataProp).forEach(dataSet => {
12
12
  if (dataSet) {
13
13
  data.push(...dataSet);
14
14
  }
15
15
  });
16
16
  return data;
17
17
  }
18
- //# sourceMappingURL=lineChartDataPropToArray.js.map
18
+ //# sourceMappingURL=lineChartDataPropToArray.js.map
@@ -3,46 +3,42 @@
3
3
  import React from 'react';
4
4
  import { Platform, StyleSheet } from 'react-native';
5
5
  import { TextInput } from 'react-native';
6
- import Animated, {
7
- useAnimatedProps,
8
- useAnimatedReaction,
9
- } from 'react-native-reanimated';
6
+ import Animated, { useAnimatedProps, useAnimatedReaction } from 'react-native-reanimated';
10
7
  Animated.addWhitelistedNativeProps({
11
- text: true,
8
+ text: true
12
9
  });
13
10
  const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);
14
- export const AnimatedText = ({ text, style }) => {
11
+ export const AnimatedText = ({
12
+ text,
13
+ style
14
+ }) => {
15
15
  const inputRef = React.useRef(null);
16
- useAnimatedReaction(
17
- () => text.value,
18
- (data, prevData) => {
19
- // Only execute for web platform
20
- if (Platform.OS === 'web' && data !== prevData && inputRef.current) {
21
- // @ts-expect-error - web TextInput has value property
22
- inputRef.current.value = data;
23
- }
24
- },
25
- [text]
26
- );
16
+ useAnimatedReaction(() => text.value, (data, prevData) => {
17
+ // Only execute for web platform
18
+ if (Platform.OS === 'web' && data !== prevData && inputRef.current) {
19
+ // @ts-expect-error - web TextInput has value property
20
+ inputRef.current.value = data;
21
+ }
22
+ }, [text]);
27
23
  const animatedProps = useAnimatedProps(() => {
28
24
  return {
29
- text: text.value,
25
+ text: text.value
30
26
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
27
  };
32
28
  });
33
- return /*#__PURE__*/ React.createElement(AnimatedTextInput, {
34
- underlineColorAndroid: 'transparent',
29
+ return /*#__PURE__*/React.createElement(AnimatedTextInput, {
30
+ underlineColorAndroid: "transparent",
35
31
  editable: false,
36
32
  ref: Platform.select({
37
- web: inputRef,
33
+ web: inputRef
38
34
  }),
39
35
  style: [styles.text, style],
40
- animatedProps: animatedProps,
36
+ animatedProps: animatedProps
41
37
  });
42
38
  };
43
39
  const styles = StyleSheet.create({
44
40
  text: {
45
- color: 'black',
46
- },
41
+ color: 'black'
42
+ }
47
43
  });
48
- //# sourceMappingURL=AnimatedText.js.map
44
+ //# sourceMappingURL=AnimatedText.js.map
@@ -3,4 +3,4 @@ export * from './charts/line';
3
3
  export * from './components/AnimatedText';
4
4
  export * from './utils';
5
5
  export * from './types';
6
- //# sourceMappingURL=index.js.map
6
+ //# sourceMappingURL=index.js.map
@@ -1 +1,2 @@
1
- //# sourceMappingURL=types.js.map
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -1,10 +1,14 @@
1
1
  /**
2
2
  * @worklet
3
3
  */
4
- export function formatDatetime({ value, locale = 'en-US', options = {} }) {
4
+ export function formatDatetime({
5
+ value,
6
+ locale = 'en-US',
7
+ options = {}
8
+ }) {
5
9
  'worklet';
6
10
 
7
11
  const d = new Date(value);
8
12
  return d.toLocaleString(locale, options);
9
13
  }
10
- //# sourceMappingURL=formatDatetime.js.map
14
+ //# sourceMappingURL=formatDatetime.js.map
@@ -4,7 +4,7 @@
4
4
  export function formatPrice({
5
5
  value: _value,
6
6
  defaultPrice: _defaultPrice = '',
7
- precision,
7
+ precision
8
8
  }) {
9
9
  'worklet';
10
10
 
@@ -16,11 +16,7 @@ export function formatPrice({
16
16
  if (!value) {
17
17
  return `0.00`;
18
18
  }
19
- const decimals =
20
- precision ??
21
- (Number(value) < 1
22
- ? Math.min(8, value.toString().slice(2).search(/[^0]/g) + 3)
23
- : 2);
19
+ const decimals = precision ?? (Number(value) < 1 ? Math.min(8, value.toString().slice(2).search(/[^0]/g) + 3) : 2);
24
20
  let res = `${Number(value).toFixed(decimals)}`;
25
21
  const vals = res.split('.');
26
22
  if (vals.length > 0 && vals[0]) {
@@ -31,4 +27,4 @@ export function formatPrice({
31
27
  }
32
28
  return res;
33
29
  }
34
- //# sourceMappingURL=formatPrice.js.map
30
+ //# sourceMappingURL=formatPrice.js.map
@@ -1,4 +1,4 @@
1
1
  export * from './formatDatetime';
2
2
  export * from './formatPrice';
3
3
  export * from './usePrevious';
4
- //# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=index.js.map
@@ -10,4 +10,4 @@ export function usePrevious(value) {
10
10
  // Return previous value (happens before update in useEffect above)
11
11
  return ref.current;
12
12
  }
13
- //# sourceMappingURL=usePrevious.js.map
13
+ //# sourceMappingURL=usePrevious.js.map
@@ -3,50 +3,36 @@ import { ColorValue } from 'react-native';
3
3
  import { LineProps, NumberProp, RectProps } from 'react-native-svg';
4
4
  import type { TCandle, TDomain } from './types';
5
5
  export type CandlestickChartCandleProps = {
6
- candle: TCandle;
7
- domain: TDomain;
8
- maxHeight: number;
9
- margin?: number;
10
- positiveColor?: string;
11
- negativeColor?: string;
12
- index: number;
13
- width: number;
14
- rectProps?: RectProps;
15
- lineProps?: LineProps;
16
- useAnimations?: boolean;
17
- renderRect?: (renderRectOptions: {
18
- x: NumberProp;
19
- y: NumberProp;
20
- width: NumberProp;
21
- height: NumberProp;
22
- fill: ColorValue;
23
- useAnimations: boolean;
24
6
  candle: TCandle;
25
- }) => React.ReactNode;
26
- renderLine?: (renderLineOptions: {
27
- x1: NumberProp;
28
- y1: NumberProp;
29
- x2: NumberProp;
30
- y2: NumberProp;
31
- stroke: ColorValue;
32
- strokeWidth: NumberProp;
33
- useAnimations: boolean;
34
- candle: TCandle;
35
- }) => React.ReactNode;
7
+ domain: TDomain;
8
+ maxHeight: number;
9
+ margin?: number;
10
+ positiveColor?: string;
11
+ negativeColor?: string;
12
+ index: number;
13
+ width: number;
14
+ rectProps?: RectProps;
15
+ lineProps?: LineProps;
16
+ useAnimations?: boolean;
17
+ renderRect?: (renderRectOptions: {
18
+ x: NumberProp;
19
+ y: NumberProp;
20
+ width: NumberProp;
21
+ height: NumberProp;
22
+ fill: ColorValue;
23
+ useAnimations: boolean;
24
+ candle: TCandle;
25
+ }) => React.ReactNode;
26
+ renderLine?: (renderLineOptions: {
27
+ x1: NumberProp;
28
+ y1: NumberProp;
29
+ x2: NumberProp;
30
+ y2: NumberProp;
31
+ stroke: ColorValue;
32
+ strokeWidth: NumberProp;
33
+ useAnimations: boolean;
34
+ candle: TCandle;
35
+ }) => React.ReactNode;
36
36
  };
37
- export declare const CandlestickChartCandle: ({
38
- candle,
39
- maxHeight,
40
- domain,
41
- margin,
42
- positiveColor,
43
- negativeColor,
44
- rectProps: overrideRectProps,
45
- lineProps: overrideLineProps,
46
- index,
47
- width,
48
- useAnimations,
49
- renderLine,
50
- renderRect,
51
- }: CandlestickChartCandleProps) => React.JSX.Element;
52
- //# sourceMappingURL=Candle.d.ts.map
37
+ export declare const CandlestickChartCandle: ({ candle, maxHeight, domain, margin, positiveColor, negativeColor, rectProps: overrideRectProps, lineProps: overrideLineProps, index, width, useAnimations, renderLine, renderRect, }: CandlestickChartCandleProps) => React.JSX.Element;
38
+ //# sourceMappingURL=Candle.d.ts.map
@@ -2,29 +2,18 @@ import React from 'react';
2
2
  import { SvgProps } from 'react-native-svg';
3
3
  import { CandlestickChartCandleProps } from './Candle';
4
4
  type CandlestickChartCandlesProps = SvgProps & {
5
- width?: number;
6
- height?: number;
7
- margin?: CandlestickChartCandleProps['margin'];
8
- positiveColor?: CandlestickChartCandleProps['positiveColor'];
9
- negativeColor?: CandlestickChartCandleProps['negativeColor'];
10
- renderRect?: CandlestickChartCandleProps['renderRect'];
11
- renderLine?: CandlestickChartCandleProps['renderLine'];
12
- rectProps?: CandlestickChartCandleProps['rectProps'];
13
- lineProps?: CandlestickChartCandleProps['lineProps'];
14
- candleProps?: Partial<CandlestickChartCandleProps>;
15
- useAnimations?: boolean;
5
+ width?: number;
6
+ height?: number;
7
+ margin?: CandlestickChartCandleProps['margin'];
8
+ positiveColor?: CandlestickChartCandleProps['positiveColor'];
9
+ negativeColor?: CandlestickChartCandleProps['negativeColor'];
10
+ renderRect?: CandlestickChartCandleProps['renderRect'];
11
+ renderLine?: CandlestickChartCandleProps['renderLine'];
12
+ rectProps?: CandlestickChartCandleProps['rectProps'];
13
+ lineProps?: CandlestickChartCandleProps['lineProps'];
14
+ candleProps?: Partial<CandlestickChartCandleProps>;
15
+ useAnimations?: boolean;
16
16
  };
17
- export declare function CandlestickChartCandles({
18
- positiveColor,
19
- negativeColor,
20
- rectProps,
21
- lineProps,
22
- margin,
23
- useAnimations,
24
- renderRect,
25
- renderLine,
26
- candleProps,
27
- ...props
28
- }: CandlestickChartCandlesProps): React.JSX.Element;
17
+ export declare function CandlestickChartCandles({ positiveColor, negativeColor, rectProps, lineProps, margin, useAnimations, renderRect, renderLine, candleProps, ...props }: CandlestickChartCandlesProps): React.JSX.Element;
29
18
  export {};
30
- //# sourceMappingURL=Candles.d.ts.map
19
+ //# sourceMappingURL=Candles.d.ts.map
@@ -1,19 +1,14 @@
1
1
  import React from 'react';
2
2
  import { ViewProps } from 'react-native';
3
3
  export declare const CandlestickChartDimensionsContext: React.Context<{
4
- width: number;
5
- height: number;
4
+ width: number;
5
+ height: number;
6
6
  }>;
7
7
  type CandlestickChartProps = ViewProps & {
8
- children: React.ReactNode;
9
- width?: number;
10
- height?: number;
8
+ children: React.ReactNode;
9
+ width?: number;
10
+ height?: number;
11
11
  };
12
- export declare function CandlestickChart({
13
- children,
14
- width,
15
- height,
16
- ...props
17
- }: CandlestickChartProps): React.JSX.Element;
12
+ export declare function CandlestickChart({ children, width, height, ...props }: CandlestickChartProps): React.JSX.Element;
18
13
  export {};
19
- //# sourceMappingURL=Chart.d.ts.map
14
+ //# sourceMappingURL=Chart.d.ts.map