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
@@ -1,38 +1,12 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true,
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
5
  });
6
6
  exports.getArea = getArea;
7
- var shape = _interopRequireWildcard(require('d3-shape'));
8
- var _d3Scale = require('d3-scale');
9
- function _interopRequireWildcard(e, t) {
10
- if ('function' == typeof WeakMap)
11
- var r = new WeakMap(),
12
- n = new WeakMap();
13
- return (_interopRequireWildcard = function (e, t) {
14
- if (!t && e && e.__esModule) return e;
15
- var o,
16
- i,
17
- f = { __proto__: null, default: e };
18
- if (null === e || ('object' != typeof e && 'function' != typeof e))
19
- return f;
20
- if ((o = t ? n : r)) {
21
- if (o.has(e)) return o.get(e);
22
- o.set(e, f);
23
- }
24
- for (const t in e)
25
- 'default' !== t &&
26
- {}.hasOwnProperty.call(e, t) &&
27
- ((i =
28
- (o = Object.defineProperty) &&
29
- Object.getOwnPropertyDescriptor(e, t)) &&
30
- (i.get || i.set)
31
- ? o(f, t, i)
32
- : (f[t] = e[t]));
33
- return f;
34
- })(e, t);
35
- }
7
+ var shape = _interopRequireWildcard(require("d3-shape"));
8
+ var _d3Scale = require("d3-scale");
9
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
36
10
  function getArea({
37
11
  data,
38
12
  width,
@@ -40,21 +14,14 @@ function getArea({
40
14
  gutter,
41
15
  shape: _shape,
42
16
  yDomain,
43
- xDomain,
17
+ xDomain
44
18
  }) {
45
- const timestamps = data.map(({ timestamp }, i) => (xDomain ? timestamp : i));
46
- const scaleX = (0, _d3Scale.scaleLinear)()
47
- .domain(xDomain ?? [Math.min(...timestamps), Math.max(...timestamps)])
48
- .range([0, width]);
49
- const scaleY = (0, _d3Scale.scaleLinear)()
50
- .domain([yDomain.min, yDomain.max])
51
- .range([height - gutter, gutter]);
52
- const area = shape
53
- .area()
54
- .x((_, i) => scaleX(xDomain ? timestamps[i] ?? i : i))
55
- .y0((d) => scaleY(d.value))
56
- .y1(() => height)
57
- .curve(_shape)(data);
19
+ const timestamps = data.map(({
20
+ timestamp
21
+ }, i) => xDomain ? timestamp : i);
22
+ const scaleX = (0, _d3Scale.scaleLinear)().domain(xDomain ?? [Math.min(...timestamps), Math.max(...timestamps)]).range([0, width]);
23
+ const scaleY = (0, _d3Scale.scaleLinear)().domain([yDomain.min, yDomain.max]).range([height - gutter, gutter]);
24
+ const area = shape.area().x((_, i) => scaleX(xDomain ? timestamps[i] ?? i : i)).y0(d => scaleY(d.value)).y1(() => height).curve(_shape)(data);
58
25
  return area || '';
59
26
  }
60
- //# sourceMappingURL=getArea.js.map
27
+ //# sourceMappingURL=getArea.js.map
@@ -1,13 +1,16 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true,
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
5
  });
6
6
  exports.getDomain = getDomain;
7
7
  function getDomain(rows) {
8
8
  'worklet';
9
9
 
10
- const values = rows.map(({ value }) => value);
10
+ if (rows.length === 0) return [0, 0];
11
+ const values = rows.map(({
12
+ value
13
+ }) => value);
11
14
  return [Math.min(...values), Math.max(...values)];
12
15
  }
13
- //# sourceMappingURL=getDomain.js.map
16
+ //# sourceMappingURL=getDomain.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getDomain","rows","values","map","value","Math","min","max"],"sourceRoot":"../../../../../src","sources":["charts/line/utils/getDomain.ts"],"mappings":";;;;;;AAEO,SAASA,SAASA,CAACC,IAAuB,EAAoB;EACnE,SAAS;;EACT,MAAMC,MAAM,GAAGD,IAAI,CAACE,GAAG,CAAC,CAAC;IAAEC;EAAM,CAAC,KAAKA,KAAK,CAAC;EAC7C,OAAO,CAACC,IAAI,CAACC,GAAG,CAAC,GAAGJ,MAAM,CAAC,EAAEG,IAAI,CAACE,GAAG,CAAC,GAAGL,MAAM,CAAC,CAAC;AACnD","ignoreList":[]}
1
+ {"version":3,"names":["getDomain","rows","length","values","map","value","Math","min","max"],"sourceRoot":"../../../../../src","sources":["charts/line/utils/getDomain.ts"],"mappings":";;;;;;AAEO,SAASA,SAASA,CAACC,IAAuB,EAAoB;EACnE,SAAS;;EACT,IAAIA,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;EACpC,MAAMC,MAAM,GAAGF,IAAI,CAACG,GAAG,CAAC,CAAC;IAAEC;EAAM,CAAC,KAAKA,KAAK,CAAC;EAC7C,OAAO,CAACC,IAAI,CAACC,GAAG,CAAC,GAAGJ,MAAM,CAAC,EAAEG,IAAI,CAACE,GAAG,CAAC,GAAGL,MAAM,CAAC,CAAC;AACnD","ignoreList":[]}
@@ -1,38 +1,12 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true,
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
5
  });
6
6
  exports.getPath = getPath;
7
- var shape = _interopRequireWildcard(require('d3-shape'));
8
- var _d3Scale = require('d3-scale');
9
- function _interopRequireWildcard(e, t) {
10
- if ('function' == typeof WeakMap)
11
- var r = new WeakMap(),
12
- n = new WeakMap();
13
- return (_interopRequireWildcard = function (e, t) {
14
- if (!t && e && e.__esModule) return e;
15
- var o,
16
- i,
17
- f = { __proto__: null, default: e };
18
- if (null === e || ('object' != typeof e && 'function' != typeof e))
19
- return f;
20
- if ((o = t ? n : r)) {
21
- if (o.has(e)) return o.get(e);
22
- o.set(e, f);
23
- }
24
- for (const t in e)
25
- 'default' !== t &&
26
- {}.hasOwnProperty.call(e, t) &&
27
- ((i =
28
- (o = Object.defineProperty) &&
29
- Object.getOwnPropertyDescriptor(e, t)) &&
30
- (i.get || i.set)
31
- ? o(f, t, i)
32
- : (f[t] = e[t]));
33
- return f;
34
- })(e, t);
35
- }
7
+ var shape = _interopRequireWildcard(require("d3-shape"));
8
+ var _d3Scale = require("d3-scale");
9
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
36
10
  function getPath({
37
11
  data,
38
12
  from,
@@ -42,27 +16,14 @@ function getPath({
42
16
  gutter,
43
17
  shape: _shape,
44
18
  yDomain,
45
- xDomain,
19
+ xDomain
46
20
  }) {
47
- const timestamps = data.map(({ timestamp }, i) => (xDomain ? timestamp : i));
48
- const scaleX = (0, _d3Scale.scaleLinear)()
49
- .domain(xDomain ?? [Math.min(...timestamps), Math.max(...timestamps)])
50
- .range([0, width]);
51
- const scaleY = (0, _d3Scale.scaleLinear)()
52
- .domain([yDomain.min, yDomain.max])
53
- .range([height - gutter, gutter]);
54
- const path = shape
55
- .line()
56
- .defined((d) =>
57
- from || to
58
- ? !!data
59
- .slice(from, to ? to + 1 : undefined)
60
- .find((item) => item.timestamp === d.timestamp)
61
- : true
62
- )
63
- .x((_, i) => scaleX(xDomain ? timestamps[i] ?? i : i))
64
- .y((d) => scaleY(d.value))
65
- .curve(_shape)(data);
21
+ const timestamps = data.map(({
22
+ timestamp
23
+ }, i) => xDomain ? timestamp : i);
24
+ const scaleX = (0, _d3Scale.scaleLinear)().domain(xDomain ?? [Math.min(...timestamps), Math.max(...timestamps)]).range([0, width]);
25
+ const scaleY = (0, _d3Scale.scaleLinear)().domain([yDomain.min, yDomain.max]).range([height - gutter, gutter]);
26
+ 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);
66
27
  return path || '';
67
28
  }
68
- //# sourceMappingURL=getPath.js.map
29
+ //# sourceMappingURL=getPath.js.map
@@ -1,7 +1,7 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true,
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
5
  });
6
6
  exports.getXPositionForCurve = getXPositionForCurve;
7
7
  function getXPositionForCurve(path, index) {
@@ -12,11 +12,8 @@ function getXPositionForCurve(path, index) {
12
12
  }
13
13
  const point = path.curves[index - 1];
14
14
  if (point === undefined) {
15
- throw new Error(
16
- `Index out of bounds: ${index}. ` +
17
- `Expected an integer in the range [0, ${path.curves.length}]`
18
- );
15
+ throw new Error(`Index out of bounds: ${index}. ` + `Expected an integer in the range [0, ${path.curves.length}]`);
19
16
  }
20
17
  return point.to.x;
21
18
  }
22
- //# sourceMappingURL=getXPositionForCurve.js.map
19
+ //# sourceMappingURL=getXPositionForCurve.js.map
@@ -1,61 +1,61 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true,
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
5
  });
6
- var _getArea = require('./getArea');
6
+ var _getArea = require("./getArea");
7
7
  Object.keys(_getArea).forEach(function (key) {
8
- if (key === 'default' || key === '__esModule') return;
8
+ if (key === "default" || key === "__esModule") return;
9
9
  if (key in exports && exports[key] === _getArea[key]) return;
10
10
  Object.defineProperty(exports, key, {
11
11
  enumerable: true,
12
12
  get: function () {
13
13
  return _getArea[key];
14
- },
14
+ }
15
15
  });
16
16
  });
17
- var _getDomain = require('./getDomain');
17
+ var _getDomain = require("./getDomain");
18
18
  Object.keys(_getDomain).forEach(function (key) {
19
- if (key === 'default' || key === '__esModule') return;
19
+ if (key === "default" || key === "__esModule") return;
20
20
  if (key in exports && exports[key] === _getDomain[key]) return;
21
21
  Object.defineProperty(exports, key, {
22
22
  enumerable: true,
23
23
  get: function () {
24
24
  return _getDomain[key];
25
- },
25
+ }
26
26
  });
27
27
  });
28
- var _getPath = require('./getPath');
28
+ var _getPath = require("./getPath");
29
29
  Object.keys(_getPath).forEach(function (key) {
30
- if (key === 'default' || key === '__esModule') return;
30
+ if (key === "default" || key === "__esModule") return;
31
31
  if (key in exports && exports[key] === _getPath[key]) return;
32
32
  Object.defineProperty(exports, key, {
33
33
  enumerable: true,
34
34
  get: function () {
35
35
  return _getPath[key];
36
- },
36
+ }
37
37
  });
38
38
  });
39
- var _interpolatePath = require('./interpolatePath');
39
+ var _interpolatePath = require("./interpolatePath");
40
40
  Object.keys(_interpolatePath).forEach(function (key) {
41
- if (key === 'default' || key === '__esModule') return;
41
+ if (key === "default" || key === "__esModule") return;
42
42
  if (key in exports && exports[key] === _interpolatePath[key]) return;
43
43
  Object.defineProperty(exports, key, {
44
44
  enumerable: true,
45
45
  get: function () {
46
46
  return _interpolatePath[key];
47
- },
47
+ }
48
48
  });
49
49
  });
50
- var _lineChartDataPropToArray = require('./lineChartDataPropToArray');
50
+ var _lineChartDataPropToArray = require("./lineChartDataPropToArray");
51
51
  Object.keys(_lineChartDataPropToArray).forEach(function (key) {
52
- if (key === 'default' || key === '__esModule') return;
52
+ if (key === "default" || key === "__esModule") return;
53
53
  if (key in exports && exports[key] === _lineChartDataPropToArray[key]) return;
54
54
  Object.defineProperty(exports, key, {
55
55
  enumerable: true,
56
56
  get: function () {
57
57
  return _lineChartDataPropToArray[key];
58
- },
58
+ }
59
59
  });
60
60
  });
61
- //# sourceMappingURL=index.js.map
61
+ //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true,
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
5
  });
6
6
  exports.interpolatePath = interpolatePath;
7
7
  exports.interpolatePathCommands = interpolatePathCommands;
@@ -45,10 +45,7 @@ function decasteljau(points, t) {
45
45
  if (i === newPoints.length - 1) {
46
46
  right.push(points[i + 1]);
47
47
  }
48
- newPoints[i] = [
49
- (1 - t) * points[i][0] + t * points[i + 1][0],
50
- (1 - t) * points[i][1] + t * points[i + 1][1],
51
- ];
48
+ newPoints[i] = [(1 - t) * points[i][0] + t * points[i + 1][0], (1 - t) * points[i][1] + t * points[i + 1][1]];
52
49
  }
53
50
  decasteljauRecurse(newPoints, t);
54
51
  }
@@ -58,7 +55,7 @@ function decasteljau(points, t) {
58
55
  }
59
56
  return {
60
57
  left,
61
- right: right.reverse(),
58
+ right: right.reverse()
62
59
  };
63
60
  }
64
61
 
@@ -175,11 +172,11 @@ const typeMap = {
175
172
  Q: ['x1', 'y1', 'x', 'y'],
176
173
  T: ['x', 'y'],
177
174
  A: ['rx', 'ry', 'xAxisRotation', 'largeArcFlag', 'sweepFlag', 'x', 'y'],
178
- Z: [],
175
+ Z: []
179
176
  };
180
177
 
181
178
  // Add lower case entries too matching uppercase (e.g. 'm' == 'M')
182
- Object.keys(typeMap).forEach((key) => {
179
+ Object.keys(typeMap).forEach(key => {
183
180
  typeMap[key.toLowerCase()] = typeMap[key];
184
181
  });
185
182
  function arrayOfLength(length, value) {
@@ -200,9 +197,7 @@ function arrayOfLength(length, value) {
200
197
  function commandToString(command) {
201
198
  'worklet';
202
199
 
203
- return `${command.type}${typeMap[command.type]
204
- .map((p) => command[p])
205
- .join(',')}`;
200
+ return `${command.type}${typeMap[command.type].map(p => command[p]).join(',')}`;
206
201
  }
207
202
 
208
203
  /**
@@ -232,14 +227,14 @@ function convertToSameType(aCommand, bCommand) {
232
227
  x1: 'x',
233
228
  y1: 'y',
234
229
  x2: 'x',
235
- y2: 'y',
230
+ y2: 'y'
236
231
  };
237
232
  const readFromBKeys = ['xAxisRotation', 'largeArcFlag', 'sweepFlag'];
238
233
 
239
234
  // convert (but ignore M types)
240
235
  if (aCommand.type !== bCommand.type && bCommand.type.toUpperCase() !== 'M') {
241
236
  const aConverted = {};
242
- Object.keys(bCommand).forEach((bKey) => {
237
+ Object.keys(bCommand).forEach(bKey => {
243
238
  const bValue = bCommand[bKey];
244
239
  // first read from the A command
245
240
  let aValue = aCommand[bKey];
@@ -288,14 +283,8 @@ function splitSegment(commandStart, commandEnd, segmentCount) {
288
283
  let segments = [];
289
284
 
290
285
  // line, quadratic bezier, or cubic bezier
291
- if (
292
- commandEnd.type === 'L' ||
293
- commandEnd.type === 'Q' ||
294
- commandEnd.type === 'C'
295
- ) {
296
- segments = segments.concat(
297
- splitCurve(commandStart, commandEnd, segmentCount)
298
- );
286
+ if (commandEnd.type === 'L' || commandEnd.type === 'Q' || commandEnd.type === 'C') {
287
+ segments = segments.concat(splitCurve(commandStart, commandEnd, segmentCount));
299
288
 
300
289
  // general case - just copy the same point
301
290
  } else {
@@ -305,9 +294,7 @@ function splitSegment(commandStart, commandEnd, segmentCount) {
305
294
  if (copyCommand.type === 'M') {
306
295
  copyCommand.type = 'L';
307
296
  }
308
- segments = segments.concat(
309
- arrayOfLength(segmentCount - 1).map(() => copyCommand)
310
- );
297
+ segments = segments.concat(arrayOfLength(segmentCount - 1).map(() => copyCommand));
311
298
  segments.push(commandEnd);
312
299
  }
313
300
  return segments;
@@ -340,69 +327,56 @@ function extend(commandsToExtend, referenceCommands, excludeSegment) {
340
327
  // should be added in that segment (should always be >= 1 since we need each
341
328
  // point itself).
342
329
  // 0 = segment 0-1, 1 = segment 1-2, n-1 = last vertex
343
- const countPointsPerSegment = arrayOfLength(numReferenceSegments).reduce(
344
- (accum, d, i) => {
345
- let insertIndex = Math.floor(segmentRatio * i);
346
-
347
- // handle excluding segments
348
- if (
349
- excludeSegment &&
350
- insertIndex < commandsToExtend.length - 1 &&
351
- excludeSegment(
352
- commandsToExtend[insertIndex],
353
- commandsToExtend[insertIndex + 1]
354
- )
355
- ) {
356
- // set the insertIndex to the segment that this point should be added to:
357
-
358
- // round the insertIndex essentially so we split half and half on
359
- // neighbouring segments. hence the segmentRatio * i < 0.5
360
- const addToPriorSegment = (segmentRatio * i) % 1 < 0.5;
361
-
362
- // only skip segment if we already have 1 point in it (can't entirely remove a segment)
363
- if (accum[insertIndex]) {
364
- // TODO - Note this is a naive algorithm that should work for most d3-area use cases
365
- // but if two adjacent segments are supposed to be skipped, this will not perform as
366
- // expected. Could be updated to search for nearest segment to place the point in, but
367
- // will only do that if necessary.
368
-
369
- // add to the prior segment
370
- if (addToPriorSegment) {
371
- if (insertIndex > 0) {
372
- insertIndex -= 1;
373
-
374
- // not possible to add to previous so adding to next
375
- } else if (insertIndex < commandsToExtend.length - 1) {
376
- insertIndex += 1;
377
- }
378
- // add to next segment
330
+ const countPointsPerSegment = arrayOfLength(numReferenceSegments).reduce((accum, d, i) => {
331
+ let insertIndex = Math.floor(segmentRatio * i);
332
+
333
+ // handle excluding segments
334
+ if (excludeSegment && insertIndex < commandsToExtend.length - 1 && excludeSegment(commandsToExtend[insertIndex], commandsToExtend[insertIndex + 1])) {
335
+ // set the insertIndex to the segment that this point should be added to:
336
+
337
+ // round the insertIndex essentially so we split half and half on
338
+ // neighbouring segments. hence the segmentRatio * i < 0.5
339
+ const addToPriorSegment = segmentRatio * i % 1 < 0.5;
340
+
341
+ // only skip segment if we already have 1 point in it (can't entirely remove a segment)
342
+ if (accum[insertIndex]) {
343
+ // TODO - Note this is a naive algorithm that should work for most d3-area use cases
344
+ // but if two adjacent segments are supposed to be skipped, this will not perform as
345
+ // expected. Could be updated to search for nearest segment to place the point in, but
346
+ // will only do that if necessary.
347
+
348
+ // add to the prior segment
349
+ if (addToPriorSegment) {
350
+ if (insertIndex > 0) {
351
+ insertIndex -= 1;
352
+
353
+ // not possible to add to previous so adding to next
379
354
  } else if (insertIndex < commandsToExtend.length - 1) {
380
355
  insertIndex += 1;
381
-
382
- // not possible to add to next so adding to previous
383
- } else if (insertIndex > 0) {
384
- insertIndex -= 1;
385
356
  }
357
+ // add to next segment
358
+ } else if (insertIndex < commandsToExtend.length - 1) {
359
+ insertIndex += 1;
360
+
361
+ // not possible to add to next so adding to previous
362
+ } else if (insertIndex > 0) {
363
+ insertIndex -= 1;
386
364
  }
387
365
  }
388
- accum[insertIndex] = (accum[insertIndex] || 0) + 1;
389
- return accum;
390
- },
391
- []
392
- );
366
+ }
367
+ accum[insertIndex] = (accum[insertIndex] || 0) + 1;
368
+ return accum;
369
+ }, []);
393
370
 
394
371
  // extend each segment to have the correct number of points for a smooth interpolation
395
372
  const extended = countPointsPerSegment.reduce((extended, segmentCount, i) => {
396
373
  // if last command, just add `segmentCount` number of times
397
374
  if (i === commandsToExtend.length - 1) {
398
- const lastCommandCopies = arrayOfLength(
399
- segmentCount,
400
- Object.assign({}, commandsToExtend[commandsToExtend.length - 1])
401
- );
375
+ const lastCommandCopies = arrayOfLength(segmentCount, Object.assign({}, commandsToExtend[commandsToExtend.length - 1]));
402
376
 
403
377
  // convert M to L
404
378
  if (lastCommandCopies[0].type === 'M') {
405
- lastCommandCopies.forEach((d) => {
379
+ lastCommandCopies.forEach(d => {
406
380
  d.type = 'L';
407
381
  });
408
382
  }
@@ -410,9 +384,7 @@ function extend(commandsToExtend, referenceCommands, excludeSegment) {
410
384
  }
411
385
 
412
386
  // otherwise, split the segment segmentCount times.
413
- return extended.concat(
414
- splitSegment(commandsToExtend[i], commandsToExtend[i + 1], segmentCount)
415
- );
387
+ return extended.concat(splitSegment(commandsToExtend[i], commandsToExtend[i + 1], segmentCount));
416
388
  }, []);
417
389
 
418
390
  // add in the very first point since splitSegment only adds in the ones after it
@@ -443,7 +415,7 @@ function pathCommandsFromString(d) {
443
415
  // new command found:
444
416
  if (commandArgs) {
445
417
  command = {
446
- type: tokens[i],
418
+ type: tokens[i]
447
419
  };
448
420
 
449
421
  // add each of the expected args for this command:
@@ -476,11 +448,7 @@ function pathCommandsFromString(d) {
476
448
  * end command object and returns true if the segment should be excluded from splitting.
477
449
  * @returns {Function} Interpolation function that maps t ([0, 1]) to an array of path commands.
478
450
  */
479
- function interpolatePathCommands(
480
- aCommandsInput,
481
- bCommandsInput,
482
- excludeSegment
483
- ) {
451
+ function interpolatePathCommands(aCommandsInput, bCommandsInput, excludeSegment) {
484
452
  'worklet';
485
453
 
486
454
  // make a copy so we don't mess with the input arrays
@@ -497,9 +465,7 @@ function interpolatePathCommands(
497
465
  }
498
466
 
499
467
  // do we add Z during interpolation? yes if both have it. (we'd expect both to have it or not)
500
- const addZ =
501
- (aCommands.length === 0 || aCommands[aCommands.length - 1].type === 'Z') &&
502
- (bCommands.length === 0 || bCommands[bCommands.length - 1].type === 'Z');
468
+ const addZ = (aCommands.length === 0 || aCommands[aCommands.length - 1].type === 'Z') && (bCommands.length === 0 || bCommands[bCommands.length - 1].type === 'Z');
503
469
 
504
470
  // we temporarily remove Z
505
471
  if (aCommands.length > 0 && aCommands[aCommands.length - 1].type === 'Z') {
@@ -535,18 +501,16 @@ function interpolatePathCommands(
535
501
 
536
502
  // commands have same length now.
537
503
  // convert commands in A to the same type as those in B
538
- aCommands = aCommands.map((aCommand, i) =>
539
- convertToSameType(aCommand, bCommands[i])
540
- );
504
+ aCommands = aCommands.map((aCommand, i) => convertToSameType(aCommand, bCommands[i]));
541
505
 
542
506
  // create mutable interpolated command objects
543
- const interpolatedCommands = aCommands.map((aCommand) => aCommand);
507
+ const interpolatedCommands = aCommands.map(aCommand => aCommand);
544
508
  if (addZ) {
545
509
  interpolatedCommands.push({
546
- type: 'Z',
510
+ type: 'Z'
547
511
  });
548
512
  aCommands.push({
549
- type: 'Z',
513
+ type: 'Z'
550
514
  }); // required for when returning at t == 0
551
515
  }
552
516
  return function pathCommandInterpolator(t) {
@@ -608,11 +572,7 @@ function interpolatePath(a, b, excludeSegment) {
608
572
  return '';
609
573
  };
610
574
  }
611
- const commandInterpolator = interpolatePathCommands(
612
- aCommands,
613
- bCommands,
614
- excludeSegment
615
- );
575
+ const commandInterpolator = interpolatePathCommands(aCommands, bCommands, excludeSegment);
616
576
  return function pathStringInterpolator(t) {
617
577
  'worklet';
618
578
 
@@ -631,4 +591,4 @@ function interpolatePath(a, b, excludeSegment) {
631
591
  return interpolatedString;
632
592
  };
633
593
  }
634
- //# sourceMappingURL=interpolatePath.js.map
594
+ //# sourceMappingURL=interpolatePath.js.map
@@ -1,7 +1,7 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true,
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
5
  });
6
6
  exports.lineChartDataPropToArray = lineChartDataPropToArray;
7
7
  function lineChartDataPropToArray(dataProp) {
@@ -14,11 +14,11 @@ function lineChartDataPropToArray(dataProp) {
14
14
  return dataProp;
15
15
  }
16
16
  const data = [];
17
- Object.values(dataProp).forEach((dataSet) => {
17
+ Object.values(dataProp).forEach(dataSet => {
18
18
  if (dataSet) {
19
19
  data.push(...dataSet);
20
20
  }
21
21
  });
22
22
  return data;
23
23
  }
24
- //# sourceMappingURL=lineChartDataPropToArray.js.map
24
+ //# sourceMappingURL=lineChartDataPropToArray.js.map