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,22 +1,5 @@
|
|
|
1
|
-
function _extends() {
|
|
2
|
-
|
|
3
|
-
(_extends = Object.assign
|
|
4
|
-
? Object.assign.bind()
|
|
5
|
-
: function (n) {
|
|
6
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
7
|
-
var t = arguments[e];
|
|
8
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
9
|
-
}
|
|
10
|
-
return n;
|
|
11
|
-
}),
|
|
12
|
-
_extends.apply(null, arguments)
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
import Animated, {
|
|
16
|
-
useAnimatedProps,
|
|
17
|
-
useDerivedValue,
|
|
18
|
-
withTiming,
|
|
19
|
-
} from 'react-native-reanimated';
|
|
1
|
+
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); }
|
|
2
|
+
import Animated, { useAnimatedProps, useDerivedValue, withTiming } from 'react-native-reanimated';
|
|
20
3
|
import { Line as SVGLine } from 'react-native-svg';
|
|
21
4
|
import { LineChartDimensionsContext } from './Chart';
|
|
22
5
|
import React from 'react';
|
|
@@ -29,19 +12,23 @@ export function LineChartHorizontalLine({
|
|
|
29
12
|
color = 'gray',
|
|
30
13
|
lineProps = {},
|
|
31
14
|
at = {
|
|
32
|
-
index: 0
|
|
15
|
+
index: 0
|
|
33
16
|
},
|
|
34
|
-
offsetY = 0
|
|
17
|
+
offsetY = 0
|
|
35
18
|
}) {
|
|
36
|
-
const {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
const {
|
|
20
|
+
width,
|
|
21
|
+
parsedPath,
|
|
22
|
+
height,
|
|
23
|
+
gutter
|
|
24
|
+
} = React.useContext(LineChartDimensionsContext);
|
|
25
|
+
const {
|
|
26
|
+
yDomain
|
|
27
|
+
} = useLineChart();
|
|
40
28
|
const y = useDerivedValue(() => {
|
|
41
29
|
if (typeof at === 'number' || at.index != null) {
|
|
42
30
|
const index = typeof at === 'number' ? at : at.index;
|
|
43
|
-
const yForX =
|
|
44
|
-
getYForX(parsedPath, getXPositionForCurve(parsedPath, index)) || 0;
|
|
31
|
+
const yForX = getYForX(parsedPath, getXPositionForCurve(parsedPath, index)) || 0;
|
|
45
32
|
return withTiming(yForX + offsetY);
|
|
46
33
|
}
|
|
47
34
|
/**
|
|
@@ -60,26 +47,17 @@ export function LineChartHorizontalLine({
|
|
|
60
47
|
const offsetTopPixels = gutter + percentageOffsetTop * heightBetweenGutters;
|
|
61
48
|
return withTiming(offsetTopPixels + offsetY);
|
|
62
49
|
}, [at, gutter, height, offsetY, parsedPath, yDomain.max, yDomain.min]);
|
|
63
|
-
const lineAnimatedProps = useAnimatedProps(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
{
|
|
76
|
-
animatedProps: lineAnimatedProps,
|
|
77
|
-
strokeWidth: 2,
|
|
78
|
-
stroke: color,
|
|
79
|
-
strokeDasharray: '3 3',
|
|
80
|
-
},
|
|
81
|
-
lineProps
|
|
82
|
-
)
|
|
83
|
-
);
|
|
50
|
+
const lineAnimatedProps = useAnimatedProps(() => ({
|
|
51
|
+
x1: 0,
|
|
52
|
+
x2: width,
|
|
53
|
+
y1: y.value,
|
|
54
|
+
y2: y.value
|
|
55
|
+
}), [width, y]);
|
|
56
|
+
return /*#__PURE__*/React.createElement(AnimatedLine, _extends({
|
|
57
|
+
animatedProps: lineAnimatedProps,
|
|
58
|
+
strokeWidth: 2,
|
|
59
|
+
stroke: color,
|
|
60
|
+
strokeDasharray: "3 3"
|
|
61
|
+
}, lineProps));
|
|
84
62
|
}
|
|
85
|
-
//# sourceMappingURL=HorizontalLine.js.map
|
|
63
|
+
//# sourceMappingURL=HorizontalLine.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export const LineChartHoverTrap = () =>
|
|
3
|
-
|
|
4
|
-
//# sourceMappingURL=index.js.map
|
|
2
|
+
export const LineChartHoverTrap = () => /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -45,10 +45,7 @@ class HoverStateManager {
|
|
|
45
45
|
this.initialized = true;
|
|
46
46
|
}
|
|
47
47
|
enableHover = () => {
|
|
48
|
-
if (
|
|
49
|
-
this.isEnabled ||
|
|
50
|
-
Date.now() - this.lastTouchTimestamp < HOVER_THRESHOLD_MS
|
|
51
|
-
) {
|
|
48
|
+
if (this.isEnabled || Date.now() - this.lastTouchTimestamp < HOVER_THRESHOLD_MS) {
|
|
52
49
|
return;
|
|
53
50
|
}
|
|
54
51
|
this.isEnabled = true;
|
|
@@ -80,42 +77,45 @@ class HoverStateManager {
|
|
|
80
77
|
// Singleton instance
|
|
81
78
|
const hoverStateManager = new HoverStateManager();
|
|
82
79
|
export const LineChartHoverTrap = () => {
|
|
83
|
-
const {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
isActive.value =
|
|
96
|
-
|
|
80
|
+
const {
|
|
81
|
+
width,
|
|
82
|
+
parsedPath
|
|
83
|
+
} = React.useContext(LineChartDimensionsContext);
|
|
84
|
+
const {
|
|
85
|
+
currentX,
|
|
86
|
+
currentIndex,
|
|
87
|
+
isActive,
|
|
88
|
+
data
|
|
89
|
+
} = useLineChart();
|
|
90
|
+
const onMouseMove = React.useCallback(e => {
|
|
91
|
+
if (!hoverStateManager.isHoverEnabled()) {
|
|
92
|
+
isActive.value = false;
|
|
93
|
+
currentIndex.value = -1;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (!parsedPath) return;
|
|
97
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
98
|
+
const boundedX = Math.min(e.clientX - rect.left, width);
|
|
99
|
+
isActive.value = true;
|
|
100
|
+
currentX.value = boundedX;
|
|
97
101
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
);
|
|
106
|
-
currentIndex.value = boundedIndex;
|
|
107
|
-
},
|
|
108
|
-
[currentIndex, currentX, data, isActive, parsedPath, width]
|
|
109
|
-
);
|
|
102
|
+
// on Web, we could drag the cursor to be negative, breaking it
|
|
103
|
+
// so we clamp the index at 0 to fix it
|
|
104
|
+
// https://github.com/coinjar/react-native-wagmi-charts/issues/24
|
|
105
|
+
const minIndex = 0;
|
|
106
|
+
const boundedIndex = Math.max(minIndex, Math.round(boundedX / width / (1 / (data ? data.length - 1 : 1))));
|
|
107
|
+
currentIndex.value = boundedIndex;
|
|
108
|
+
}, [currentIndex, currentX, data, isActive, parsedPath, width]);
|
|
110
109
|
const onMouseLeave = React.useCallback(() => {
|
|
111
110
|
isActive.value = false;
|
|
112
111
|
currentIndex.value = -1;
|
|
113
112
|
}, [currentIndex, isActive]);
|
|
114
|
-
return /*#__PURE__*/
|
|
115
|
-
style: StyleSheet.absoluteFill
|
|
113
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
114
|
+
style: StyleSheet.absoluteFill
|
|
116
115
|
// @ts-expect-error mouse move event
|
|
116
|
+
,
|
|
117
117
|
onMouseMove: onMouseMove,
|
|
118
|
-
onMouseLeave: onMouseLeave
|
|
118
|
+
onMouseLeave: onMouseLeave
|
|
119
119
|
});
|
|
120
120
|
};
|
|
121
|
-
//# sourceMappingURL=index.web.js.map
|
|
121
|
+
//# sourceMappingURL=index.web.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export const LineChartPathContext = /*#__PURE__*/
|
|
2
|
+
export const LineChartPathContext = /*#__PURE__*/React.createContext({
|
|
3
3
|
color: '',
|
|
4
4
|
isInactive: false,
|
|
5
|
-
isTransitionEnabled: true
|
|
5
|
+
isTransitionEnabled: true
|
|
6
6
|
});
|
|
7
|
-
//# sourceMappingURL=LineChartPathContext.js.map
|
|
7
|
+
//# sourceMappingURL=LineChartPathContext.js.map
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
function _extends() {
|
|
2
|
-
return (
|
|
3
|
-
(_extends = Object.assign
|
|
4
|
-
? Object.assign.bind()
|
|
5
|
-
: function (n) {
|
|
6
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
7
|
-
var t = arguments[e];
|
|
8
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
9
|
-
}
|
|
10
|
-
return n;
|
|
11
|
-
}),
|
|
12
|
-
_extends.apply(null, arguments)
|
|
13
|
-
);
|
|
14
|
-
}
|
|
1
|
+
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); }
|
|
15
2
|
import * as React from 'react';
|
|
16
3
|
import Animated from 'react-native-reanimated';
|
|
17
4
|
import { Path } from 'react-native-svg';
|
|
@@ -26,25 +13,25 @@ export function LineChartPath({
|
|
|
26
13
|
width: strokeWidth = 3,
|
|
27
14
|
...props
|
|
28
15
|
}) {
|
|
29
|
-
const {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const {
|
|
16
|
+
const {
|
|
17
|
+
path
|
|
18
|
+
} = React.useContext(LineChartDimensionsContext);
|
|
19
|
+
const {
|
|
20
|
+
isTransitionEnabled,
|
|
21
|
+
isInactive
|
|
22
|
+
} = React.useContext(LineChartPathContext);
|
|
23
|
+
const {
|
|
24
|
+
animatedProps
|
|
25
|
+
} = useAnimatedPath({
|
|
33
26
|
enabled: isTransitionEnabled,
|
|
34
|
-
path
|
|
27
|
+
path
|
|
35
28
|
});
|
|
36
|
-
return /*#__PURE__*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
strokeOpacity: isInactive && !inactiveColor ? 0.2 : 1,
|
|
44
|
-
strokeWidth: strokeWidth,
|
|
45
|
-
},
|
|
46
|
-
props
|
|
47
|
-
)
|
|
48
|
-
);
|
|
29
|
+
return /*#__PURE__*/React.createElement(AnimatedPath, _extends({
|
|
30
|
+
animatedProps: animatedProps,
|
|
31
|
+
fill: "transparent",
|
|
32
|
+
stroke: isInactive ? inactiveColor || color : color,
|
|
33
|
+
strokeOpacity: isInactive && !inactiveColor ? 0.2 : 1,
|
|
34
|
+
strokeWidth: strokeWidth
|
|
35
|
+
}, props));
|
|
49
36
|
}
|
|
50
|
-
//# sourceMappingURL=Path.js.map
|
|
37
|
+
//# sourceMappingURL=Path.js.map
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { Text } from 'react-native';
|
|
3
|
-
import {
|
|
4
|
-
useDerivedValue,
|
|
5
|
-
useAnimatedReaction,
|
|
6
|
-
runOnJS,
|
|
7
|
-
} from 'react-native-reanimated';
|
|
3
|
+
import { useDerivedValue, useAnimatedReaction, runOnJS } from 'react-native-reanimated';
|
|
8
4
|
import { useLineChartPrice } from './usePrice';
|
|
9
5
|
import { useLineChart } from './useLineChart';
|
|
10
6
|
import { AnimatedText } from '../../components/AnimatedText';
|
|
@@ -16,21 +12,24 @@ export function LineChartPriceText({
|
|
|
16
12
|
style,
|
|
17
13
|
index,
|
|
18
14
|
useOptimizedRendering = false,
|
|
19
|
-
getTextColor
|
|
15
|
+
getTextColor
|
|
20
16
|
}) {
|
|
21
17
|
const price = useLineChartPrice({
|
|
22
18
|
format,
|
|
23
19
|
precision,
|
|
24
|
-
index
|
|
20
|
+
index
|
|
25
21
|
});
|
|
26
22
|
|
|
27
23
|
// If we have a custom format function and optimized rendering is enabled,
|
|
28
24
|
// use regular React state instead of AnimatedText
|
|
29
25
|
if (format && useOptimizedRendering) {
|
|
30
|
-
const {
|
|
26
|
+
const {
|
|
27
|
+
currentIndex,
|
|
28
|
+
data
|
|
29
|
+
} = useLineChart();
|
|
31
30
|
const [displayText, setDisplayText] = useState('');
|
|
32
31
|
const [textColor, setTextColor] = useState('#000000');
|
|
33
|
-
const updateText =
|
|
32
|
+
const updateText = newText => {
|
|
34
33
|
setDisplayText(newText);
|
|
35
34
|
// Update color if getTextColor function is provided
|
|
36
35
|
if (getTextColor) {
|
|
@@ -41,56 +40,40 @@ export function LineChartPriceText({
|
|
|
41
40
|
if (!data) {
|
|
42
41
|
return '';
|
|
43
42
|
}
|
|
44
|
-
if (
|
|
45
|
-
(typeof currentIndex.value === 'undefined' ||
|
|
46
|
-
currentIndex.value === -1) &&
|
|
47
|
-
index == null
|
|
48
|
-
) {
|
|
43
|
+
if ((typeof currentIndex.value === 'undefined' || currentIndex.value === -1) && index == null) {
|
|
49
44
|
return '';
|
|
50
45
|
}
|
|
51
46
|
let price = 0;
|
|
52
|
-
price =
|
|
53
|
-
data[Math.min(index ?? currentIndex.value, data.length - 1)].value;
|
|
47
|
+
price = data[Math.min(index ?? currentIndex.value, data.length - 1)].value;
|
|
54
48
|
const valueString = price.toFixed(precision).toString();
|
|
55
49
|
|
|
56
50
|
// Call format function directly in worklet
|
|
57
51
|
return format({
|
|
58
52
|
value: valueString,
|
|
59
|
-
formatted: valueString
|
|
53
|
+
formatted: valueString
|
|
60
54
|
});
|
|
61
55
|
}, [currentIndex, data, precision]);
|
|
62
56
|
|
|
63
57
|
// Use useAnimatedReaction to update React state with runOnJS
|
|
64
|
-
useAnimatedReaction(
|
|
65
|
-
()
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
[textValue]
|
|
72
|
-
);
|
|
58
|
+
useAnimatedReaction(() => textValue.value, (current, previous) => {
|
|
59
|
+
if (current !== previous) {
|
|
60
|
+
runOnJS(updateText)(current);
|
|
61
|
+
}
|
|
62
|
+
}, [textValue]);
|
|
73
63
|
|
|
74
64
|
// Merge the text color with the provided style
|
|
75
|
-
const dynamicStyle = [
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return /*#__PURE__*/ React.createElement(
|
|
82
|
-
Text,
|
|
83
|
-
{
|
|
84
|
-
style: dynamicStyle,
|
|
85
|
-
},
|
|
86
|
-
displayText
|
|
87
|
-
);
|
|
65
|
+
const dynamicStyle = [style, {
|
|
66
|
+
color: textColor
|
|
67
|
+
}];
|
|
68
|
+
return /*#__PURE__*/React.createElement(Text, {
|
|
69
|
+
style: dynamicStyle
|
|
70
|
+
}, displayText);
|
|
88
71
|
}
|
|
89
72
|
|
|
90
73
|
// For non-custom format, use the original approach
|
|
91
|
-
return /*#__PURE__*/
|
|
74
|
+
return /*#__PURE__*/React.createElement(AnimatedText, {
|
|
92
75
|
text: price[variant],
|
|
93
|
-
style: style
|
|
76
|
+
style: style
|
|
94
77
|
});
|
|
95
78
|
}
|
|
96
|
-
//# sourceMappingURL=PriceText.js.map
|
|
79
|
+
//# sourceMappingURL=PriceText.js.map
|