【问题标题】:HighCharts - Angular 7 - Sunburst drillup event not triggeringHighCharts - Angular 7 - 未触发 Sunburst 钻取事件
【发布时间】:2020-07-15 19:36:30
【问题描述】:

我正在使用 highcharts-angular 库来渲染旭日形图。我能够通过使用单击事件深入了解并捕获事件。但是当我单击后退按钮时,我无法捕获向上钻取事件。我尝试使用钻取事件,但这似乎不起作用。

我也导入了向下钻取模块。下面是我的代码。

TS:

import HC_sunburst from 'highcharts/modules/sunburst';
import Drilldown from 'highcharts/modules/drilldown';
HC_sunburst(Highcharts);
HC_stock(Highcharts);
Drilldown(Highcharts);

highcharts1: typeof Highcharts = Highcharts;
chartOptions1: Highcharts.Options;

    this.chartOptions1 =  {
      chart: {
        height: '100%'
      },
      title: {
        text: ''
      },
      subtitle: {
        text: ''
      },
      series: [{
        type: 'sunburst',
        data: sunburstSampleData,
        allowDrillToNode: true,
        cursor: 'pointer',
        events: {
          click: (e) => {
            alert('drilldown');
          },
          drillup: (e) => {
            alert('drillup');
          }
        },
        dataLabels: {
          format: '{point.name}',
          filter: {
            property: 'innerArcLength',
            operator: '>',
            value: 16
          }
        },
        levels: [{
          level: 1,
          levelIsConstant: false,
          dataLabels: {
            filter: {
              property: 'outerArcLength',
              operator: '>',
              value: 64
            }
          }
        }, {
          level: 2,
          colorByPoint: true
        },
        {
          level: 3,
          colorVariation: {
            key: 'brightness',
            to: -0.5
          }
        }, {
          level: 4,
          colorVariation: {
            key: 'brightness',
            to: 0.5
          }
        }]

      }]
    };

HTML

<highcharts-chart *ngIf="chartOptions1"
    [Highcharts]="highcharts1"
    [options]="chartOptions1"
    style="width: 100%; height: 500px; display: block;">

package.json

"highcharts": "^7.1.1",
"highcharts-angular": "^2.4.0",

我在这里有什么遗漏吗?请帮帮我。

【问题讨论】:

    标签: highcharts event-handling angular7 drilldown angular2-highcharts


    【解决方案1】:

    它不起作用,因为series.events 上没有drilldown() 这样的东西。要使其正常工作,您可以使用chart.events.drilldown / chart.events.drillup

    API 参考:
    https://api.highcharts.com/highcharts/chart.events.drillup https://api.highcharts.com/highcharts/chart.events.drilldown

    【讨论】:

    • 您能否在我可以处理的在线编辑器(如 stackblitz)中重现该问题?到时候找到问题的根源就容易多了。基本模板:stackblitz.com/edit/highcharts-angular-basic-line
    • 无法使图表在在线编辑器中工作。你能给我看一个带有钻取事件的旭日图的工作示例吗?
    • 好的,我刚刚尝试了一些东西,它奏效了。所以,chart.events.click 捕获了向上钻取事件,chart.series.events.click 捕获了向下钻取事件。奇怪的!不过还是谢谢!
    • 对不起,我好像错了。我在上面发布的属性不起作用,因为树形图/旭日形系列正在使用不同类型的向下钻取。您可以在此 GitHub 问题线程中阅读更多相关信息:github.com/highcharts/highcharts/issues/9812
    • 啊好吧..没问题..但是如果你能给我看一个捕捉到向上事件的旭日形图(使用角度而不是香草js)的例子,那真的很有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-06
    • 1970-01-01
    • 2019-04-10
    • 1970-01-01
    • 1970-01-01
    • 2016-11-21
    • 1970-01-01
    相关资源
    最近更新 更多