Is there a way to get clicks on crosshairs in a candlestick chart?
jihoon8730 opened this issue · 2 comments
jihoon8730 commented
honeybadger26 commented
Hi @jihoon8730
Do you mean detecting if the crosshair is active? That can be done by using the CandlestickChart.useChart
hook and checking that currentX
and currentY
are not equal to -1
import { runOnJS, useDerivedValue } from 'react-native-reanimated';
import { CandlestickChart } from 'react-native-wagmi-charts';
const PositionText = () => {
const { currentX, currentY } = CandlestickChart.useChart(); // These are Reanimated shared values
const [crosshairActive, setCrosshairActive] = React.useState(false);
useDerivedValue(() => {
runOnJS(setCrosshairActive)(currentX.value !== -1 && currentY.value !== -1);
});
return <Text>Crosshair active: {crosshairActive ? 'Yes' : 'No'}</Text>;
};
jihoon8730 commented
This is an old post, but
but using a different chart solved it!
Thank you so much for your answer
I'll pin it in case it helps anyone else