有没有办法在 Nivo 图表的栏上制作 onClick 处理程序?

is there a way to make onClick hanlder on a bar on Nivo charts?

我是 Nivo.rocks 的新手,这是一个基于 React 的图表库。我正在尝试将点击处理程序添加到栏中,以仅 console.log 该栏上的数据。目前,该组件带有自己的 'tool tip',当您将鼠标悬停在栏上时会显示此数据,但我不希望那样。

我看过文档,但没有清楚地说明如何做到这一点,这可能吗? 到目前为止,我已经制作了一个按钮,可以从两个栏中注销数据

主要代码与此沙箱相同: https://codesandbox.io/s/nivo-0xy2m?file=/src/index.js

我的按钮:

const clickHandler = () =>{
    console.log(
        `all the people that disagreed for ${data[0].statement} = ${data[0].disagree}`
    )
}

您可以使用 onClick 道具 :

onClick={(data) => {
    console.log(
    `all the people that ${data["id"]} for ${data["key"]} = ${data["value"]}`
    );
}}

sandbox example