高图 =>单击折线图时获取点的 id [英] Highcharts => Getting the id of a point when clicking on a line chart
问题描述
我正在构建一个折线图,我希望当我点击线的一个点时,显示一个包含有关该点的一些数据的弹出窗口.我试图解决的问题是获取 id、与这一点相关的系列或类似的东西.
I am building a line chart and I would like, when I click on a point of the line, to display a popup containing some data about this point. The issue I try to resolve is to get the id, the series associated with this point or something like that.
这是我的代码:
plotOptions: {
column: {
pointWidth: 20
},
series: {
cursor: 'pointer',
events: {
click: function(event) {
requestData(event.point);
}
}
}
我试过了
requestData(this.point)
,
requestData(this.point.id)
也是,但它不起作用.
我们如何获得一个点的id?
How do we get the id of a point ?
非常感谢.
推荐答案
根据文档,event.point 持有一个指向图上最近点的指针.
所以我会将 event.point
写入控制台,看看有什么可用的.
So I'd write the event.point
to the console, and see what's available.
console.log(event.point);
click:点击系列时触发.this 关键字指的是系列对象本身.一个参数,事件,被传递给函数.这包含基于 jQuery 或 MooTools 的常见事件信息,具体取决于使用哪个库作为 Highcharts 的基础.此外, event.point 持有指向图表上最近点的指针.
click: Fires when the series is clicked. The this keyword refers to the series object itself. One parameter, event, is passed to the function. This contains common event information based on jQuery or MooTools depending on which library is used as the base for Highcharts. Additionally, event.point holds a pointer to the nearest point on the graph.
示例基于文档中的示例: http://jsfiddle.net/5nTYd/
单击一个点,然后检查控制台.
Click a point, and check the console.
这篇关于高图 =>单击折线图时获取点的 id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!