Highcharts Treegraph:如何防止 React 中节点展开/折叠默认点击行为?

问题描述 投票:0回答:1

我在 React 中使用 Highcharts,无法阻止树形图节点的默认展开/折叠单击行为。我尝试了几种方法,但没有任何效果。请参阅下面的代码片段,了解我所尝试的详细信息。我已经尝试了 allPointSelect 和单击属性之间的所有组合。

const series = [{
  type: "treegraph",
  data: [...],
  // I've tried setting allowPointSelect to true in combination 
  // with the point.event.click e.preventDefault() 
  // and returning false without success. 
  // I've also left allowPointSelect false without any success.
  allowPointSelect: true,
  point: {
    events: {
      click: (e) => {
        //I've tried different combinations of the 2 lines below without success
        e.preventDefault();
        return false;
      }
    }
  }
}]

reactjs highcharts
1个回答
0
投票

不幸的是,Highcharts 中没有任何选项可以阻止展开/折叠功能的发生。为了让它工作,你需要写一个包装。

Highcharts.wrap(Highcharts._modules['Series/Treegraph/TreegraphPoint.js'].prototype, 'toggleCollapse', function(proceed, a, flag) {
 if (flag) {
  proceed.apply(this, Array.prototype.slice.call(arguments, 1));
 }
});

文档: https://www.highcharts.com/docs/extending-highcharts/extending-highcharts

演示: https://jsfiddle.net/BlackLabel/05m2sjcL/

© www.soinside.com 2019 - 2024. All rights reserved.