Highcharts highchart自定义菜单,当我向下钻取和向上钻取自定义事件(contextmenu)不工作时

Highcharts highchart自定义菜单,当我向下钻取和向上钻取自定义事件(contextmenu)不工作时,highcharts,drilldown,custom-events,Highcharts,Drilldown,Custom Events,我正在使用highchart上下文菜单(使用:)并向下和向上钻取 问题: chart: { type: 'pie', events: { load: function () { var chart = this; chart.series[0].customEventsEnabled = true; } } }, plotOptions: { series: { events: {

我正在使用highchart上下文菜单(使用:)并向下和向上钻取

问题:

  chart: {
    type: 'pie',
    events: {
      load: function () {
        var chart = this;

        chart.series[0].customEventsEnabled = true;
      }
    }
  },
  plotOptions: {
    series: {
      events: {
        contextmenu: function() {
          var series = this;

          if (series.customEventsEnabled || series.drilldownLevel) {
            console.log('working');
          }
        }
      }
    }
  }
当我右键单击饼图时,我们可以调用上下文菜单中的警报。同时,当我向下钻取和向上钻取,然后右键单击饼图时,contextmenu不起作用。在plotoption中工作正常,但我在plotoption中不需要它

代码:


此问题的解决方法是将事件添加到plotOptions,并检查事件是否发生在主系列上。检查下面发布的演示和代码

代码:

  chart: {
    type: 'pie',
    events: {
      load: function () {
        var chart = this;

        chart.series[0].customEventsEnabled = true;
      }
    }
  },
  plotOptions: {
    series: {
      events: {
        contextmenu: function() {
          var series = this;

          if (series.customEventsEnabled || series.drilldownLevel) {
            console.log('working');
          }
        }
      }
    }
  }
演示:

  chart: {
    type: 'pie',
    events: {
      load: function () {
        var chart = this;

        chart.series[0].customEventsEnabled = true;
      }
    }
  },
  plotOptions: {
    series: {
      events: {
        contextmenu: function() {
          var series = this;

          if (series.customEventsEnabled || series.drilldownLevel) {
            console.log('working');
          }
        }
      }
    }
  }

格式化代码部分,固定语法/拼写