react-highcharts Y轴类别以反应方式捕获事件点击

react-highcharts Y-axis categories catch event click in react way

我正在使用 react-highcharts,我正在尝试找到一种方法来在单击 Y 轴类别之一时触发事件。我正在使用 xrange graph.I 想要获得被点击的值的偏移量。例如,如果我有:

CatA

Catb

CatC

如果我点击 CatB,我会得到 1。

我找到了一个 jquery 解决方案,它本身就给了我价值。获取所有元素并对其进行迭代并自己找到偏移量不是问题。 jquery的解法:

$("#container .highcharts-yaxis-labels text").click(function() {
            alert($(this).text());
        });

我正在寻找 react/react-highcarts 解决方案。

更新

谢谢卡米尔库利格!我在图书馆遇到了麻烦。我将库导入为

import HighchartsCustomEvents from 'highcharts-custom-events';

什么也没发生,我还在 componentWillMount 函数中添加了这段代码:

template.yAxis.events.click = function () {
            alert(1);
        };

我看了文档,但没有找到任何偏移函数,这意味着我还是应该使用 jquery 吗?或者你有什么想法吗?

Highcharts 提供自定义事件模块,能够处理您需要的操作。

npm 上的模块参考: https://www.npmjs.com/package/highcharts-custom-events

Highcharts 网站上的模块参考: https://www.highcharts.com/products/plugin-registry/single/15/Custom-Events

示例代码:

    yAxis: {
        labels: {
            events: {
                click: function () {
                   // do something
                }
            }
        }
    }