0

我正在开发一个需要显示明细图的应用程序。我为此使用了 highcharts,我想在用户单击第二个图表的条形(钻一个)时触发 click 事件。

我正在使用代码,但这也在第一个图表上触发事件。有没有办法只在第二张图表上触发它?或检查是否从哪个图表引发了事件?

 plotOptions: {
    series: {
        events:{
              click: function (event) {
               
                console.log(event);
                   alert("testing" + event.point.name)
                
              }
        }
    }
  }

示例在这里 - https://highcharts-angular-drilldown-zqmyd9.stackblitz.io/

4

1 回答 1

0

尝试将您的图表定义为全局变量,并添加条件以检查 chart.drilldownUpButton 是否存在到您的点击回调中。

演示:https ://jsfiddle.net/BlackLabel/uhbored9/

  plotOptions: {
    series: {
      events: {
        click: function(event) {
            if (chart.drillUpButton) {
                alert("testing" + event.point.name)
           }
        }
      }
    }
  },
于 2020-09-10T12:49:52.473 回答