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.
- package/README.md +143 -66
- package/lib/commonjs/charts/candle/Candle.js +92 -177
- package/lib/commonjs/charts/candle/Candles.js +39 -66
- package/lib/commonjs/charts/candle/Chart.js +26 -37
- package/lib/commonjs/charts/candle/Context.js +49 -69
- package/lib/commonjs/charts/candle/Crosshair.js +82 -183
- package/lib/commonjs/charts/candle/Crosshair.js.map +1 -1
- package/lib/commonjs/charts/candle/CrosshairTooltip.js +61 -140
- package/lib/commonjs/charts/candle/DatetimeText.js +14 -19
- package/lib/commonjs/charts/candle/Line.js +27 -73
- package/lib/commonjs/charts/candle/PriceText.js +14 -19
- package/lib/commonjs/charts/candle/index.js +64 -67
- package/lib/commonjs/charts/candle/types.js +4 -4
- package/lib/commonjs/charts/candle/useCandleData.js +12 -9
- package/lib/commonjs/charts/candle/useCandlestickChart.js +7 -9
- package/lib/commonjs/charts/candle/useDatetime.js +18 -16
- package/lib/commonjs/charts/candle/usePrice.js +22 -21
- package/lib/commonjs/charts/candle/utils/getDomain.js +9 -5
- package/lib/commonjs/charts/candle/utils/getDomain.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/getHeight.js +11 -12
- package/lib/commonjs/charts/candle/utils/getHeight.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/getPrice.js +11 -12
- package/lib/commonjs/charts/candle/utils/getPrice.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/getY.js +11 -12
- package/lib/commonjs/charts/candle/utils/getY.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/index.js +16 -16
- package/lib/commonjs/charts/line/Axis.js +148 -268
- package/lib/commonjs/charts/line/Chart.js +62 -129
- package/lib/commonjs/charts/line/Chart.js.map +1 -1
- package/lib/commonjs/charts/line/ChartPath.js +105 -285
- package/lib/commonjs/charts/line/Context.js +37 -95
- package/lib/commonjs/charts/line/Cursor.js +74 -125
- package/lib/commonjs/charts/line/Cursor.js.map +1 -1
- package/lib/commonjs/charts/line/CursorCrosshair.js +56 -134
- package/lib/commonjs/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/commonjs/charts/line/CursorLine.js +67 -152
- package/lib/commonjs/charts/line/CursorLine.js.map +1 -1
- package/lib/commonjs/charts/line/Data.js +34 -73
- package/lib/commonjs/charts/line/DatetimeText.js +15 -20
- package/lib/commonjs/charts/line/Dot.js +56 -149
- package/lib/commonjs/charts/line/Gradient.js +53 -124
- package/lib/commonjs/charts/line/Group.js +23 -54
- package/lib/commonjs/charts/line/Group.js.map +1 -1
- package/lib/commonjs/charts/line/Highlight.js +47 -115
- package/lib/commonjs/charts/line/HorizontalLine.js +39 -92
- package/lib/commonjs/charts/line/HoverTrap/index.js +7 -10
- package/lib/commonjs/charts/line/HoverTrap/index.web.js +43 -48
- package/lib/commonjs/charts/line/LineChartPathContext.js +11 -14
- package/lib/commonjs/charts/line/Path.js +32 -78
- package/lib/commonjs/charts/line/PriceText.js +36 -78
- package/lib/commonjs/charts/line/Tooltip.js +102 -188
- package/lib/commonjs/charts/line/Tooltip.js.map +1 -1
- package/lib/commonjs/charts/line/index.js +65 -65
- package/lib/commonjs/charts/line/types.js +4 -4
- package/lib/commonjs/charts/line/useAnimatedPath.js +22 -27
- package/lib/commonjs/charts/line/useCurrentY.js +17 -17
- package/lib/commonjs/charts/line/useDatetime.js +28 -32
- package/lib/commonjs/charts/line/useLineChart.js +15 -20
- package/lib/commonjs/charts/line/usePrice.js +26 -28
- package/lib/commonjs/charts/line/utils/getArea.js +14 -47
- package/lib/commonjs/charts/line/utils/getDomain.js +8 -5
- package/lib/commonjs/charts/line/utils/getDomain.js.map +1 -1
- package/lib/commonjs/charts/line/utils/getPath.js +14 -53
- package/lib/commonjs/charts/line/utils/getXPositionForCurve.js +5 -8
- package/lib/commonjs/charts/line/utils/index.js +19 -19
- package/lib/commonjs/charts/line/utils/interpolatePath.js +60 -100
- package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js +5 -5
- package/lib/commonjs/components/AnimatedText.js +29 -67
- package/lib/commonjs/index.js +19 -19
- package/lib/commonjs/types.js +2 -2
- package/lib/commonjs/utils/formatDatetime.js +9 -5
- package/lib/commonjs/utils/formatPrice.js +6 -10
- package/lib/commonjs/utils/index.js +13 -13
- package/lib/commonjs/utils/usePrevious.js +6 -8
- package/lib/module/charts/candle/Candle.js +76 -126
- package/lib/module/charts/candle/Candles.js +30 -52
- package/lib/module/charts/candle/Chart.js +19 -22
- package/lib/module/charts/candle/Context.js +29 -47
- package/lib/module/charts/candle/Crosshair.js +69 -142
- package/lib/module/charts/candle/Crosshair.js.map +1 -1
- package/lib/module/charts/candle/CrosshairTooltip.js +51 -101
- package/lib/module/charts/candle/DatetimeText.js +5 -5
- package/lib/module/charts/candle/Line.js +19 -37
- package/lib/module/charts/candle/PriceText.js +5 -5
- package/lib/module/charts/candle/index.js +2 -2
- package/lib/module/charts/candle/types.js +1 -1
- package/lib/module/charts/candle/useCandleData.js +7 -3
- package/lib/module/charts/candle/useCandlestickChart.js +1 -1
- package/lib/module/charts/candle/useDatetime.js +12 -10
- package/lib/module/charts/candle/usePrice.js +14 -12
- package/lib/module/charts/candle/utils/getDomain.js +6 -2
- package/lib/module/charts/candle/utils/getDomain.js.map +1 -1
- package/lib/module/charts/candle/utils/getHeight.js +8 -9
- package/lib/module/charts/candle/utils/getHeight.js.map +1 -1
- package/lib/module/charts/candle/utils/getPrice.js +8 -4
- package/lib/module/charts/candle/utils/getPrice.js.map +1 -1
- package/lib/module/charts/candle/utils/getY.js +8 -4
- package/lib/module/charts/candle/utils/getY.js.map +1 -1
- package/lib/module/charts/candle/utils/index.js +1 -1
- package/lib/module/charts/line/Axis.js +113 -189
- package/lib/module/charts/line/Chart.js +40 -73
- package/lib/module/charts/line/Chart.js.map +1 -1
- package/lib/module/charts/line/ChartPath.js +90 -238
- package/lib/module/charts/line/Context.js +29 -61
- package/lib/module/charts/line/Cursor.js +61 -82
- package/lib/module/charts/line/Cursor.js.map +1 -1
- package/lib/module/charts/line/CursorCrosshair.js +47 -99
- package/lib/module/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/module/charts/line/CursorLine.js +52 -107
- package/lib/module/charts/line/CursorLine.js.map +1 -1
- package/lib/module/charts/line/Data.js +28 -41
- package/lib/module/charts/line/DatetimeText.js +5 -5
- package/lib/module/charts/line/Dot.js +39 -93
- package/lib/module/charts/line/Gradient.js +41 -79
- package/lib/module/charts/line/Group.js +14 -15
- package/lib/module/charts/line/Group.js.map +1 -1
- package/lib/module/charts/line/Highlight.js +32 -61
- package/lib/module/charts/line/HorizontalLine.js +27 -49
- package/lib/module/charts/line/HoverTrap/index.js +2 -3
- package/lib/module/charts/line/HoverTrap/index.web.js +34 -34
- package/lib/module/charts/line/LineChartPathContext.js +3 -3
- package/lib/module/charts/line/Path.js +20 -33
- package/lib/module/charts/line/PriceText.js +25 -42
- package/lib/module/charts/line/Tooltip.js +89 -151
- package/lib/module/charts/line/Tooltip.js.map +1 -1
- package/lib/module/charts/line/index.js +2 -2
- package/lib/module/charts/line/types.js +1 -1
- package/lib/module/charts/line/useAnimatedPath.js +16 -22
- package/lib/module/charts/line/useCurrentY.js +9 -4
- package/lib/module/charts/line/useDatetime.js +22 -26
- package/lib/module/charts/line/useLineChart.js +7 -10
- package/lib/module/charts/line/usePrice.js +20 -22
- package/lib/module/charts/line/utils/getArea.js +8 -15
- package/lib/module/charts/line/utils/getDomain.js +5 -2
- package/lib/module/charts/line/utils/getDomain.js.map +1 -1
- package/lib/module/charts/line/utils/getPath.js +8 -21
- package/lib/module/charts/line/utils/getXPositionForCurve.js +2 -5
- package/lib/module/charts/line/utils/index.js +1 -1
- package/lib/module/charts/line/utils/interpolatePath.js +57 -97
- package/lib/module/charts/line/utils/lineChartDataPropToArray.js +2 -2
- package/lib/module/components/AnimatedText.js +21 -25
- package/lib/module/index.js +1 -1
- package/lib/module/types.js +2 -1
- package/lib/module/utils/formatDatetime.js +6 -2
- package/lib/module/utils/formatPrice.js +3 -7
- package/lib/module/utils/index.js +1 -1
- package/lib/module/utils/usePrevious.js +1 -1
- package/lib/typescript/src/charts/candle/Candle.d.ts +31 -45
- package/lib/typescript/src/charts/candle/Candles.d.ts +13 -24
- package/lib/typescript/src/charts/candle/Chart.d.ts +7 -12
- package/lib/typescript/src/charts/candle/Context.d.ts +7 -12
- package/lib/typescript/src/charts/candle/Crosshair.d.ts +9 -17
- package/lib/typescript/src/charts/candle/CrosshairTooltip.d.ts +8 -15
- package/lib/typescript/src/charts/candle/DatetimeText.d.ts +9 -15
- package/lib/typescript/src/charts/candle/Line.d.ts +5 -10
- package/lib/typescript/src/charts/candle/PriceText.d.ts +7 -13
- package/lib/typescript/src/charts/candle/index.d.ts +13 -32
- package/lib/typescript/src/charts/candle/types.d.ts +16 -16
- package/lib/typescript/src/charts/candle/useCandleData.d.ts +1 -1
- package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts +1 -1
- package/lib/typescript/src/charts/candle/useDatetime.d.ts +9 -13
- package/lib/typescript/src/charts/candle/usePrice.d.ts +7 -11
- package/lib/typescript/src/charts/candle/utils/getDomain.d.ts +1 -1
- package/lib/typescript/src/charts/candle/utils/getDomain.d.ts.map +1 -1
- package/lib/typescript/src/charts/candle/utils/getHeight.d.ts +5 -9
- package/lib/typescript/src/charts/candle/utils/getPrice.d.ts +5 -9
- package/lib/typescript/src/charts/candle/utils/getY.d.ts +5 -9
- package/lib/typescript/src/charts/candle/utils/index.d.ts +1 -1
- package/lib/typescript/src/charts/line/Axis.d.ts +14 -27
- package/lib/typescript/src/charts/line/Chart.d.ts +23 -33
- package/lib/typescript/src/charts/line/Chart.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/ChartPath.d.ts +15 -28
- package/lib/typescript/src/charts/line/Context.d.ts +9 -16
- package/lib/typescript/src/charts/line/Cursor.d.ts +14 -22
- package/lib/typescript/src/charts/line/Cursor.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/CursorCrosshair.d.ts +11 -23
- package/lib/typescript/src/charts/line/CursorCrosshair.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/CursorLine.d.ts +9 -15
- package/lib/typescript/src/charts/line/CursorLine.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/Data.d.ts +13 -17
- package/lib/typescript/src/charts/line/DatetimeText.d.ts +8 -14
- package/lib/typescript/src/charts/line/Dot.d.ts +25 -38
- package/lib/typescript/src/charts/line/Gradient.d.ts +5 -9
- package/lib/typescript/src/charts/line/Group.d.ts +3 -6
- package/lib/typescript/src/charts/line/Group.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/Highlight.d.ts +9 -17
- package/lib/typescript/src/charts/line/HorizontalLine.d.ts +22 -30
- package/lib/typescript/src/charts/line/HoverTrap/index.d.ts +1 -1
- package/lib/typescript/src/charts/line/HoverTrap/index.web.d.ts +1 -1
- package/lib/typescript/src/charts/line/LineChartPathContext.d.ts +4 -4
- package/lib/typescript/src/charts/line/Path.d.ts +23 -28
- package/lib/typescript/src/charts/line/PriceText.d.ts +20 -28
- package/lib/typescript/src/charts/line/Tooltip.d.ts +20 -32
- package/lib/typescript/src/charts/line/index.d.ts +20 -33
- package/lib/typescript/src/charts/line/types.d.ts +17 -19
- package/lib/typescript/src/charts/line/useAnimatedPath.d.ts +7 -10
- package/lib/typescript/src/charts/line/useCurrentY.d.ts +2 -2
- package/lib/typescript/src/charts/line/useDatetime.d.ts +7 -11
- package/lib/typescript/src/charts/line/useLineChart.d.ts +10 -10
- package/lib/typescript/src/charts/line/usePrice.d.ts +7 -11
- package/lib/typescript/src/charts/line/utils/getArea.d.ts +9 -17
- package/lib/typescript/src/charts/line/utils/getDomain.d.ts +1 -1
- package/lib/typescript/src/charts/line/utils/getDomain.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/utils/getPath.d.ts +11 -21
- package/lib/typescript/src/charts/line/utils/getXPositionForCurve.d.ts +1 -1
- package/lib/typescript/src/charts/line/utils/index.d.ts +1 -1
- package/lib/typescript/src/charts/line/utils/interpolatePath.d.ts +5 -17
- package/lib/typescript/src/charts/line/utils/lineChartDataPropToArray.d.ts +2 -4
- package/lib/typescript/src/components/AnimatedText.d.ts +4 -7
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/types.d.ts +4 -7
- package/lib/typescript/src/utils/formatDatetime.d.ts +5 -9
- package/lib/typescript/src/utils/formatPrice.d.ts +5 -9
- package/lib/typescript/src/utils/index.d.ts +1 -1
- package/lib/typescript/src/utils/usePrevious.d.ts +1 -1
- package/package.json +1 -1
- package/src/charts/line/CursorLine.tsx +6 -2
- package/src/charts/line/HorizontalLine.tsx +5 -1
|
@@ -1,51 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CandlestickChartCandle = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require(
|
|
8
|
-
var _reactNativeReanimated = _interopRequireWildcard(
|
|
9
|
-
|
|
10
|
-
);
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
98
|
-
fill,
|
|
99
|
-
high,
|
|
100
|
-
isPositive,
|
|
101
|
-
low,
|
|
51
|
+
x2: x + width / 2,
|
|
52
|
+
y2: (0, _utils.getY)({
|
|
102
53
|
maxHeight,
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CandlestickChartCandles = CandlestickChartCandles;
|
|
7
|
-
var _react = _interopRequireDefault(require(
|
|
8
|
-
var _reactNativeSvg = require(
|
|
9
|
-
var _Chart = require(
|
|
10
|
-
var _Candle = require(
|
|
11
|
-
var _useCandlestickChart = require(
|
|
12
|
-
function _interopRequireDefault(e) {
|
|
13
|
-
|
|
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 {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
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(
|
|
9
|
-
var _reactNative = require(
|
|
10
|
-
var _useCandlestickChart = require(
|
|
11
|
-
function _interopRequireDefault(e) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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 {
|
|
28
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
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(
|
|
9
|
-
var _reactNativeReanimated = require(
|
|
10
|
-
var _utils = require(
|
|
11
|
-
function _interopRequireDefault(e) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|