react-native-wagmi-charts 2.9.1 → 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
CHANGED
|
@@ -954,6 +954,7 @@ function in the form of a
|
|
|
954
954
|
| `color` | `string` | `"gray"` | Color of the cursor line |
|
|
955
955
|
| `lineProps` | `LineProps` | | Props of the cursor line. Takes React Native SVG's `Line` props. |
|
|
956
956
|
| `persistOnEnd` | `boolean` | `false` | Keep the cursor pinned at its last position after the gesture ends |
|
|
957
|
+
| `showLabel` | `boolean` | `true` | Show the bottom label for timestamp |
|
|
957
958
|
| `at` | `number` | | Index of followed `data` item. |
|
|
958
959
|
|
|
959
960
|
### LineChart.Dot
|
package/package.json
CHANGED
|
@@ -18,6 +18,7 @@ import { useLineChartPrice } from './usePrice';
|
|
|
18
18
|
type LineChartCursorLineProps = {
|
|
19
19
|
children?: React.ReactNode;
|
|
20
20
|
color?: string;
|
|
21
|
+
showLabel?: boolean;
|
|
21
22
|
lineProps?: Partial<LineProps>;
|
|
22
23
|
format?: TFormatterFn<string | number>;
|
|
23
24
|
textStyle?: TextStyle;
|
|
@@ -48,6 +49,7 @@ const AnimatedLine = Animated.createAnimatedComponent(SVGLine);
|
|
|
48
49
|
export function LineChartCursorLine({
|
|
49
50
|
children,
|
|
50
51
|
color = 'gray',
|
|
52
|
+
showLabel = true,
|
|
51
53
|
lineProps,
|
|
52
54
|
format,
|
|
53
55
|
textStyle,
|
|
@@ -105,7 +107,7 @@ export function LineChartCursorLine({
|
|
|
105
107
|
if (isHorizontal) return 0;
|
|
106
108
|
|
|
107
109
|
// For vertical cursor, extend line to the chart area (excluding reserved label space)
|
|
108
|
-
return height - SPACING.X_AXIS_LABEL_RESERVED_HEIGHT;
|
|
110
|
+
return showLabel ? height - SPACING.X_AXIS_LABEL_RESERVED_HEIGHT : height;
|
|
109
111
|
});
|
|
110
112
|
|
|
111
113
|
const containerStyle = useAnimatedStyle(() => ({
|
|
@@ -208,7 +210,9 @@ export function LineChartCursorLine({
|
|
|
208
210
|
{...lineProps}
|
|
209
211
|
/>
|
|
210
212
|
</Svg>
|
|
211
|
-
|
|
213
|
+
{showLabel && (
|
|
214
|
+
<AnimatedText text={displayText} style={textPositionStyle} />
|
|
215
|
+
)}
|
|
212
216
|
</Animated.View>
|
|
213
217
|
{children}
|
|
214
218
|
</LineChartCursor>
|
|
@@ -55,6 +55,9 @@ export function LineChartHorizontalLine({
|
|
|
55
55
|
);
|
|
56
56
|
const { yDomain } = useLineChart();
|
|
57
57
|
|
|
58
|
+
// Reserve space at the bottom for x-axis cursor labels
|
|
59
|
+
const X_AXIS_LABEL_RESERVED_HEIGHT = 40;
|
|
60
|
+
|
|
58
61
|
const y = useDerivedValue(() => {
|
|
59
62
|
if (typeof at === 'number' || at.index != null) {
|
|
60
63
|
const index = typeof at === 'number' ? at : at.index;
|
|
@@ -74,7 +77,8 @@ export function LineChartHorizontalLine({
|
|
|
74
77
|
|
|
75
78
|
const offsetTop = yDomain.max - at.value;
|
|
76
79
|
const percentageOffsetTop = offsetTop / (yDomain.max - yDomain.min);
|
|
77
|
-
const
|
|
80
|
+
const chartDrawingHeight = height - X_AXIS_LABEL_RESERVED_HEIGHT;
|
|
81
|
+
const heightBetweenGutters = chartDrawingHeight - gutter * 2;
|
|
78
82
|
const offsetTopPixels = gutter + percentageOffsetTop * heightBetweenGutters;
|
|
79
83
|
|
|
80
84
|
return withTiming(offsetTopPixels + offsetY);
|