我正在尝试使用 Victory Native 来显示一个图表,我可以在其中单击每个点来触发一个事件。但是,似乎并非每次都记录单击事件。经过长时间的尝试,如果我发送垃圾邮件,我有时会检测到点击。此外,奇怪的部分是被捕获的事件的名称是“onPress”,当它在文档中提到“onClick”时,在库本身中,它只显示“onclick”(没有驼峰式)作为有效事件.
代码:
<Svg style={{borderWidth: 5, width: ls(1200), height: ls(500)}}>
<VictoryChart
theme={theme}
maxDomain={{y: 1, x: MAX_NUMBER_SCORES}}
domainPadding={{x: 10}}
width={ls(1200)}
height={ls(500)}>
<VictoryAxis dependentAxis />
<VictoryAxis style={{tickLabels: {fontSize: 0}, ticks: {size: 0}}} />
<VictoryLine
data={data}
style={{data: {stroke: '#315356', strokeWidth: 4}}} />
<VictoryArea
style={{data: {fill: 'rgba(97, 214, 214, 0.1)'}}}
data={data} />
<VictoryScatter
data={data}
size={10}
style={{
data: {
fill: ({datum: {color, aboveThreshold}}) =>
color ??
(aboveThreshold
? graphColors.ACTIVE_DEFECT
: graphColors.NO_DEFECT),
},
}}
events={[
{
target: 'data',
eventHandlers: {
onPress: () => {
console.log('onPress');
},
onclick: () => console.log('onclick'),
onClick: () => console.log('onClick'),
onpress: () => console.log('onpress'),
},
},
]} />
</VictoryChart>
</Svg>
还有一种方法可以让每个点都响应触摸吗?
谢谢你。