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,51 +1,17 @@
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.CandlestickChartCandle = void 0;
7
- var _react = _interopRequireDefault(require('react'));
8
- var _reactNativeReanimated = _interopRequireWildcard(
9
- require('react-native-reanimated')
10
- );
11
- var _reactNativeSvg = require('react-native-svg');
12
- var _utils = require('./utils');
13
- function _interopRequireWildcard(e, t) {
14
- if ('function' == typeof WeakMap)
15
- var r = new WeakMap(),
16
- n = new WeakMap();
17
- return (_interopRequireWildcard = function (e, t) {
18
- if (!t && e && e.__esModule) return e;
19
- var o,
20
- i,
21
- f = { __proto__: null, default: e };
22
- if (null === e || ('object' != typeof e && 'function' != typeof e))
23
- return f;
24
- if ((o = t ? n : r)) {
25
- if (o.has(e)) return o.get(e);
26
- o.set(e, f);
27
- }
28
- for (const t in e)
29
- 'default' !== t &&
30
- {}.hasOwnProperty.call(e, t) &&
31
- ((i =
32
- (o = Object.defineProperty) &&
33
- Object.getOwnPropertyDescriptor(e, t)) &&
34
- (i.get || i.set)
35
- ? o(f, t, i)
36
- : (f[t] = e[t]));
37
- return f;
38
- })(e, t);
39
- }
40
- function _interopRequireDefault(e) {
41
- return e && e.__esModule ? e : { default: e };
42
- }
43
- const AnimatedRect = _reactNativeReanimated.default.createAnimatedComponent(
44
- _reactNativeSvg.Rect
45
- );
46
- const AnimatedLine = _reactNativeReanimated.default.createAnimatedComponent(
47
- _reactNativeSvg.Line
48
- );
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
9
+ var _reactNativeSvg = require("react-native-svg");
10
+ var _utils = require("./utils");
11
+ 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); }
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ const AnimatedRect = _reactNativeReanimated.default.createAnimatedComponent(_reactNativeSvg.Rect);
14
+ const AnimatedLine = _reactNativeReanimated.default.createAnimatedComponent(_reactNativeSvg.Line);
49
15
  const CandlestickChartCandle = ({
50
16
  candle,
51
17
  maxHeight,
@@ -58,148 +24,97 @@ const CandlestickChartCandle = ({
58
24
  index,
59
25
  width,
60
26
  useAnimations = true,
61
- renderLine = (props) =>
62
- props.useAnimations
63
- ? /*#__PURE__*/ _react.default.createElement(AnimatedLine, props)
64
- : /*#__PURE__*/ _react.default.createElement(_reactNativeSvg.Line, props),
65
- renderRect = (props) =>
66
- props.useAnimations
67
- ? /*#__PURE__*/ _react.default.createElement(AnimatedRect, props)
68
- : /*#__PURE__*/ _react.default.createElement(_reactNativeSvg.Rect, props),
27
+ renderLine = props => props.useAnimations ? /*#__PURE__*/_react.default.createElement(AnimatedLine, props) : /*#__PURE__*/_react.default.createElement(_reactNativeSvg.Line, props),
28
+ renderRect = props => props.useAnimations ? /*#__PURE__*/_react.default.createElement(AnimatedRect, props) : /*#__PURE__*/_react.default.createElement(_reactNativeSvg.Rect, props)
69
29
  }) => {
70
- const { close, open, high, low } = candle;
30
+ const {
31
+ close,
32
+ open,
33
+ high,
34
+ low
35
+ } = candle;
71
36
  const isPositive = close > open;
72
37
  const fill = isPositive ? positiveColor : negativeColor;
73
38
  const x = index * width;
74
39
  const max = Math.max(open, close);
75
40
  const min = Math.min(open, close);
76
- const lineProps = _react.default.useMemo(
77
- () => ({
78
- stroke: fill,
79
- strokeWidth: 1,
80
- direction: isPositive ? 'positive' : 'negative',
81
- x1: x + width / 2,
82
- y1: (0, _utils.getY)({
83
- maxHeight,
84
- value: low,
85
- domain,
86
- }),
87
- x2: x + width / 2,
88
- y2: (0, _utils.getY)({
89
- maxHeight,
90
- value: high,
91
- domain,
92
- }),
93
- candle: candle,
94
- ...overrideLineProps,
41
+ const lineProps = _react.default.useMemo(() => ({
42
+ stroke: fill,
43
+ strokeWidth: 1,
44
+ direction: isPositive ? 'positive' : 'negative',
45
+ x1: x + width / 2,
46
+ y1: (0, _utils.getY)({
47
+ maxHeight,
48
+ value: low,
49
+ domain
95
50
  }),
96
- [
97
- domain,
98
- fill,
99
- high,
100
- isPositive,
101
- low,
51
+ x2: x + width / 2,
52
+ y2: (0, _utils.getY)({
102
53
  maxHeight,
103
- overrideLineProps,
104
- width,
105
- x,
106
- candle,
107
- ]
108
- );
109
- const animatedLineProps = (0, _reactNativeReanimated.useAnimatedProps)(
110
- () => ({
111
- x1: (0, _reactNativeReanimated.withTiming)(x + width / 2),
112
- y1: (0, _reactNativeReanimated.withTiming)(
113
- (0, _utils.getY)({
114
- maxHeight,
115
- value: low,
116
- domain,
117
- })
118
- ),
119
- x2: (0, _reactNativeReanimated.withTiming)(x + width / 2),
120
- y2: (0, _reactNativeReanimated.withTiming)(
121
- (0, _utils.getY)({
122
- maxHeight,
123
- value: high,
124
- domain,
125
- })
126
- ),
127
- })
128
- );
129
- const rectProps = _react.default.useMemo(
130
- () => ({
131
- width: width - margin * 2,
132
- fill: fill,
133
- direction: isPositive ? 'positive' : 'negative',
134
- x: x + margin,
135
- y: (0, _utils.getY)({
136
- maxHeight,
137
- value: max,
138
- domain,
139
- }),
140
- height: (0, _utils.getHeight)({
141
- maxHeight,
142
- value: max - min,
143
- domain,
144
- }),
145
- candle: candle,
146
- ...overrideRectProps,
54
+ value: high,
55
+ domain
147
56
  }),
148
- [
149
- domain,
150
- fill,
151
- isPositive,
152
- margin,
153
- max,
57
+ candle: candle,
58
+ ...overrideLineProps
59
+ }), [domain, fill, high, isPositive, low, maxHeight, overrideLineProps, width, x, candle]);
60
+ const animatedLineProps = (0, _reactNativeReanimated.useAnimatedProps)(() => ({
61
+ x1: (0, _reactNativeReanimated.withTiming)(x + width / 2),
62
+ y1: (0, _reactNativeReanimated.withTiming)((0, _utils.getY)({
63
+ maxHeight,
64
+ value: low,
65
+ domain
66
+ })),
67
+ x2: (0, _reactNativeReanimated.withTiming)(x + width / 2),
68
+ y2: (0, _reactNativeReanimated.withTiming)((0, _utils.getY)({
154
69
  maxHeight,
155
- min,
156
- overrideRectProps,
157
- width,
158
- x,
159
- candle,
160
- ]
161
- );
162
- const animatedRectProps = (0, _reactNativeReanimated.useAnimatedProps)(
163
- () => ({
164
- x: (0, _reactNativeReanimated.withTiming)(x + margin),
165
- y: (0, _reactNativeReanimated.withTiming)(
166
- (0, _utils.getY)({
167
- maxHeight,
168
- value: max,
169
- domain,
170
- })
171
- ),
172
- height: (0, _reactNativeReanimated.withTiming)(
173
- (0, _utils.getHeight)({
174
- maxHeight,
175
- value: max - min,
176
- domain,
177
- })
178
- ),
179
- })
180
- );
181
- return /*#__PURE__*/ _react.default.createElement(
182
- _react.default.Fragment,
183
- null,
184
- renderLine({
185
- ...lineProps,
186
- useAnimations,
187
- ...(useAnimations
188
- ? {
189
- animatedProps: animatedLineProps,
190
- }
191
- : {}),
70
+ value: high,
71
+ domain
72
+ }))
73
+ }));
74
+ const rectProps = _react.default.useMemo(() => ({
75
+ width: width - margin * 2,
76
+ fill: fill,
77
+ direction: isPositive ? 'positive' : 'negative',
78
+ x: x + margin,
79
+ y: (0, _utils.getY)({
80
+ maxHeight,
81
+ value: max,
82
+ domain
192
83
  }),
193
- renderRect({
194
- ...rectProps,
195
- useAnimations,
196
- ...(useAnimations
197
- ? {
198
- animatedProps: animatedRectProps,
199
- }
200
- : {}),
201
- })
202
- );
84
+ height: (0, _utils.getHeight)({
85
+ maxHeight,
86
+ value: max - min,
87
+ domain
88
+ }),
89
+ candle: candle,
90
+ ...overrideRectProps
91
+ }), [domain, fill, isPositive, margin, max, maxHeight, min, overrideRectProps, width, x, candle]);
92
+ const animatedRectProps = (0, _reactNativeReanimated.useAnimatedProps)(() => ({
93
+ x: (0, _reactNativeReanimated.withTiming)(x + margin),
94
+ y: (0, _reactNativeReanimated.withTiming)((0, _utils.getY)({
95
+ maxHeight,
96
+ value: max,
97
+ domain
98
+ })),
99
+ height: (0, _reactNativeReanimated.withTiming)((0, _utils.getHeight)({
100
+ maxHeight,
101
+ value: max - min,
102
+ domain
103
+ }))
104
+ }));
105
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, renderLine({
106
+ ...lineProps,
107
+ useAnimations,
108
+ ...(useAnimations ? {
109
+ animatedProps: animatedLineProps
110
+ } : {})
111
+ }), renderRect({
112
+ ...rectProps,
113
+ useAnimations,
114
+ ...(useAnimations ? {
115
+ animatedProps: animatedRectProps
116
+ } : {})
117
+ }));
203
118
  };
204
119
  exports.CandlestickChartCandle = CandlestickChartCandle;
205
- //# sourceMappingURL=Candle.js.map
120
+ //# sourceMappingURL=Candle.js.map
@@ -1,31 +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.CandlestickChartCandles = CandlestickChartCandles;
7
- var _react = _interopRequireDefault(require('react'));
8
- var _reactNativeSvg = require('react-native-svg');
9
- var _Chart = require('./Chart');
10
- var _Candle = require('./Candle');
11
- var _useCandlestickChart = require('./useCandlestickChart');
12
- function _interopRequireDefault(e) {
13
- return e && e.__esModule ? e : { default: e };
14
- }
15
- function _extends() {
16
- return (
17
- (_extends = Object.assign
18
- ? Object.assign.bind()
19
- : function (n) {
20
- for (var e = 1; e < arguments.length; e++) {
21
- var t = arguments[e];
22
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
23
- }
24
- return n;
25
- }),
26
- _extends.apply(null, arguments)
27
- );
28
- }
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactNativeSvg = require("react-native-svg");
9
+ var _Chart = require("./Chart");
10
+ var _Candle = require("./Candle");
11
+ var _useCandlestickChart = require("./useCandlestickChart");
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
29
14
  function CandlestickChartCandles({
30
15
  positiveColor,
31
16
  negativeColor,
@@ -38,45 +23,33 @@ function CandlestickChartCandles({
38
23
  candleProps,
39
24
  ...props
40
25
  }) {
41
- const { width, height } = _react.default.useContext(
42
- _Chart.CandlestickChartDimensionsContext
43
- );
44
- const { data, domain, step } = (0,
45
- _useCandlestickChart.useCandlestickChart)();
46
- return /*#__PURE__*/ _react.default.createElement(
47
- _reactNativeSvg.Svg,
48
- _extends(
49
- {
50
- width: width,
51
- height: height,
52
- },
53
- props
54
- ),
55
- step > 0 &&
56
- data.map((candle, index) =>
57
- /*#__PURE__*/ _react.default.createElement(
58
- _Candle.CandlestickChartCandle,
59
- _extends(
60
- {
61
- key: index,
62
- domain: domain,
63
- margin: margin,
64
- maxHeight: height,
65
- width: step,
66
- positiveColor: positiveColor,
67
- negativeColor: negativeColor,
68
- renderRect: renderRect,
69
- renderLine: renderLine,
70
- rectProps: rectProps,
71
- lineProps: lineProps,
72
- useAnimations: useAnimations,
73
- candle: candle,
74
- index: index,
75
- },
76
- candleProps
77
- )
78
- )
79
- )
80
- );
26
+ const {
27
+ width,
28
+ height
29
+ } = _react.default.useContext(_Chart.CandlestickChartDimensionsContext);
30
+ const {
31
+ data,
32
+ domain,
33
+ step
34
+ } = (0, _useCandlestickChart.useCandlestickChart)();
35
+ return /*#__PURE__*/_react.default.createElement(_reactNativeSvg.Svg, _extends({
36
+ width: width,
37
+ height: height
38
+ }, props), step > 0 && data.map((candle, index) => /*#__PURE__*/_react.default.createElement(_Candle.CandlestickChartCandle, _extends({
39
+ key: index,
40
+ domain: domain,
41
+ margin: margin,
42
+ maxHeight: height,
43
+ width: step,
44
+ positiveColor: positiveColor,
45
+ negativeColor: negativeColor,
46
+ renderRect: renderRect,
47
+ renderLine: renderLine,
48
+ rectProps: rectProps,
49
+ lineProps: lineProps,
50
+ useAnimations: useAnimations,
51
+ candle: candle,
52
+ index: index
53
+ }, candleProps))));
81
54
  }
82
- //# sourceMappingURL=Candles.js.map
55
+ //# sourceMappingURL=Candles.js.map
@@ -1,52 +1,41 @@
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.CandlestickChart = CandlestickChart;
7
7
  exports.CandlestickChartDimensionsContext = void 0;
8
- var _react = _interopRequireDefault(require('react'));
9
- var _reactNative = require('react-native');
10
- var _useCandlestickChart = require('./useCandlestickChart');
11
- function _interopRequireDefault(e) {
12
- return e && e.__esModule ? e : { default: e };
13
- }
14
- const CandlestickChartDimensionsContext =
15
- (exports.CandlestickChartDimensionsContext =
16
- /*#__PURE__*/ _react.default.createContext({
17
- width: 0,
18
- height: 0,
19
- }));
20
- const { width: screenWidth } = _reactNative.Dimensions.get('window');
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactNative = require("react-native");
10
+ var _useCandlestickChart = require("./useCandlestickChart");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const CandlestickChartDimensionsContext = exports.CandlestickChartDimensionsContext = /*#__PURE__*/_react.default.createContext({
13
+ width: 0,
14
+ height: 0
15
+ });
16
+ const {
17
+ width: screenWidth
18
+ } = _reactNative.Dimensions.get('window');
21
19
  function CandlestickChart({
22
20
  children,
23
21
  width = screenWidth,
24
22
  height = screenWidth,
25
23
  ...props
26
24
  }) {
27
- const { setWidth, setHeight } = (0,
28
- _useCandlestickChart.useCandlestickChart)();
25
+ const {
26
+ setWidth,
27
+ setHeight
28
+ } = (0, _useCandlestickChart.useCandlestickChart)();
29
29
  _react.default.useEffect(() => {
30
30
  setWidth(width);
31
31
  setHeight(height);
32
32
  }, [height, setHeight, setWidth, width]);
33
- const contextValue = _react.default.useMemo(
34
- () => ({
35
- width,
36
- height,
37
- }),
38
- [height, width]
39
- );
40
- return /*#__PURE__*/ _react.default.createElement(
41
- CandlestickChartDimensionsContext.Provider,
42
- {
43
- value: contextValue,
44
- },
45
- /*#__PURE__*/ _react.default.createElement(
46
- _reactNative.View,
47
- props,
48
- children
49
- )
50
- );
33
+ const contextValue = _react.default.useMemo(() => ({
34
+ width,
35
+ height
36
+ }), [height, width]);
37
+ return /*#__PURE__*/_react.default.createElement(CandlestickChartDimensionsContext.Provider, {
38
+ value: contextValue
39
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.View, props, children));
51
40
  }
52
- //# sourceMappingURL=Chart.js.map
41
+ //# sourceMappingURL=Chart.js.map
@@ -1,85 +1,65 @@
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.CandlestickChartContext = void 0;
7
7
  exports.CandlestickChartProvider = CandlestickChartProvider;
8
- var _react = _interopRequireDefault(require('react'));
9
- var _reactNativeReanimated = require('react-native-reanimated');
10
- var _utils = require('./utils');
11
- function _interopRequireDefault(e) {
12
- return e && e.__esModule ? e : { default: e };
13
- }
14
- const CandlestickChartContext = (exports.CandlestickChartContext =
15
- /*#__PURE__*/ _react.default.createContext({
16
- currentX: {
17
- value: -1,
18
- },
19
- currentY: {
20
- value: -1,
21
- },
22
- currentIndex: {
23
- value: -1,
24
- },
25
- data: [],
26
- height: 0,
27
- width: 0,
28
- domain: [0, 0],
29
- step: 0,
30
- setWidth: () => undefined,
31
- setHeight: () => undefined,
32
- }));
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactNativeReanimated = require("react-native-reanimated");
10
+ var _utils = require("./utils");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const CandlestickChartContext = exports.CandlestickChartContext = /*#__PURE__*/_react.default.createContext({
13
+ currentX: {
14
+ value: -1
15
+ },
16
+ currentY: {
17
+ value: -1
18
+ },
19
+ currentIndex: {
20
+ value: -1
21
+ },
22
+ data: [],
23
+ height: 0,
24
+ width: 0,
25
+ domain: [0, 0],
26
+ step: 0,
27
+ setWidth: () => undefined,
28
+ setHeight: () => undefined
29
+ });
33
30
  function CandlestickChartProvider({
34
31
  children,
35
32
  data = [],
36
33
  valueRangeY,
37
- onCurrentIndexChange,
34
+ onCurrentIndexChange
38
35
  }) {
39
36
  const [width, setWidth] = _react.default.useState(0);
40
37
  const [height, setHeight] = _react.default.useState(0);
41
38
  const currentX = (0, _reactNativeReanimated.useSharedValue)(-1);
42
39
  const currentY = (0, _reactNativeReanimated.useSharedValue)(-1);
43
40
  const currentIndex = (0, _reactNativeReanimated.useSharedValue)(-1);
44
- const domain = _react.default.useMemo(
45
- () => valueRangeY ?? (0, _utils.getDomain)(data),
46
- [data, valueRangeY]
47
- );
48
- const step = _react.default.useMemo(
49
- () => width / data.length,
50
- [data.length, width]
51
- );
52
- const contextValue = _react.default.useMemo(
53
- () => ({
54
- currentX,
55
- currentY,
56
- currentIndex,
57
- data,
58
- width,
59
- height,
60
- domain,
61
- step,
62
- setWidth,
63
- setHeight,
64
- }),
65
- [currentIndex, currentX, currentY, data, domain, height, step, width]
66
- );
67
- (0, _reactNativeReanimated.useAnimatedReaction)(
68
- () => currentIndex.value,
69
- (x, prevX) => {
70
- if (x !== prevX && onCurrentIndexChange) {
71
- (0, _reactNativeReanimated.runOnJS)(onCurrentIndexChange)(x);
72
- }
73
- },
74
- [currentIndex]
75
- );
76
- return /*#__PURE__*/ _react.default.createElement(
77
- CandlestickChartContext.Provider,
78
- {
79
- value: contextValue,
80
- },
81
- children
82
- );
41
+ const domain = _react.default.useMemo(() => valueRangeY ?? (0, _utils.getDomain)(data), [data, valueRangeY]);
42
+ const step = _react.default.useMemo(() => width / data.length, [data.length, width]);
43
+ const contextValue = _react.default.useMemo(() => ({
44
+ currentX,
45
+ currentY,
46
+ currentIndex,
47
+ data,
48
+ width,
49
+ height,
50
+ domain,
51
+ step,
52
+ setWidth,
53
+ setHeight
54
+ }), [currentIndex, currentX, currentY, data, domain, height, step, width]);
55
+ (0, _reactNativeReanimated.useAnimatedReaction)(() => currentIndex.value, (x, prevX) => {
56
+ if (x !== prevX && onCurrentIndexChange) {
57
+ (0, _reactNativeReanimated.runOnJS)(onCurrentIndexChange)(x);
58
+ }
59
+ }, [currentIndex]);
60
+ return /*#__PURE__*/_react.default.createElement(CandlestickChartContext.Provider, {
61
+ value: contextValue
62
+ }, children);
83
63
  }
84
64
  CandlestickChartProvider.displayName = 'CandlestickChartProvider';
85
- //# sourceMappingURL=Context.js.map
65
+ //# sourceMappingURL=Context.js.map