0

我形成图表并具有这样的系列格式:

series: {
                            id  : '001',
                            name: 'name,
                            data: [],
                            color: '#fff'
                        }

在 plotOptions 我创建了 onClick 事件:

plotOptions: {
                series: {
                    stacking: 'normal',
                    cursor: 'pointer',
                    allowPointSelect: true,
                    marker: {
                        states: {
                            select: {
                                enabled: true
                            }
                        }
                    },
                    point: {
                        events: {
                            click: function () {
                                console.log('!!!!!', this);
                            }
                        }
                    }
                }
            }

时钟后我在日志中得到对象。除了 id: '001' 之外的所有信息。我怎么才能得到它?

4

1 回答 1

2

您将单击事件附加到该点,因此this在回调内部引用该点对象。Id 在系列的选项中定义。

您可以从series.options对象访问它:

point: {
  events: {
    click: function() {
      console.log('!!!!!', this.series.options.id);
    }
  }
}

现场示例:http: //jsfiddle.net/4s3ayhfy/

于 2018-03-12T12:03:58.413 回答