你好啊从上面的图像,如果我触摸一个区域,我应该从胜利区得到y轴值。我在VictoryArea组件events={[{ target: 'data', eventHandlers: { onPressIn: (props) => { console.log(props); } } }]}上尝试将其作为 prop我在 prop 里面找不到
events={[{ target: 'data', eventHandlers: { onPressIn: (props) => { console.log(props); } } }]}
cngwdvgl1#
要在React Native中获取Victory区域图中按下的y轴值,可以使用Victory提供的onPress事件处理程序。
import React, { useState } from "react"; import { VictoryArea } from "victory-native"; const Chart = () => { const [yValue, setYValue] = useState(null); const handlePress = (event, props) => { const { y } = props.datum; setYValue(y); }; return ( <> <VictoryArea data={[ { x: 1, y: 2 }, { x: 2, y: 3 }, { x: 3, y: 5 }, { x: 4, y: 4 }, { x: 5, y: 7 }, ]} onPress={handlePress} /> {yValue && <Text>Y value on press: {yValue}</Text>} </> ); }; export default Chart;
1条答案
按热度按时间cngwdvgl1#
要在React Native中获取Victory区域图中按下的y轴值,可以使用Victory提供的onPress事件处理程序。