admin管理员组文章数量:1279090
I have a pie chart where one of the points have drilldown and the other points do not. When I detect a click using plotOptions.series.point.events.click and try to return the name of the clicked point, it works for every point except the one with drilldown.
If I do:
plotOptions: {
series: {
point: {
events: {
click: function(e) {
console.log(this.name);
}
}
}
}
}
Then the proper name would show up for every point except the one with drilldown, which would return a null point. It might be because the graph updates first via drilldown and the point no longer exists when the event callback occurs. How can I make it so that both the regular points and drilldown points return properly when clicked?
I added a JSFiddle to illustrate my point: / I just took the pie drilldown example from Highcharts demo page and made it so that Firefox does not have a drilldown. Note in the browser's console that when I click Firefox, the name gets displayed. When I click any other slice, the displayed name is null.
I have a pie chart where one of the points have drilldown and the other points do not. When I detect a click using plotOptions.series.point.events.click and try to return the name of the clicked point, it works for every point except the one with drilldown.
If I do:
plotOptions: {
series: {
point: {
events: {
click: function(e) {
console.log(this.name);
}
}
}
}
}
Then the proper name would show up for every point except the one with drilldown, which would return a null point. It might be because the graph updates first via drilldown and the point no longer exists when the event callback occurs. How can I make it so that both the regular points and drilldown points return properly when clicked?
I added a JSFiddle to illustrate my point: http://jsfiddle/Pq6gb/2/ I just took the pie drilldown example from Highcharts demo page and made it so that Firefox does not have a drilldown. Note in the browser's console that when I click Firefox, the name gets displayed. When I click any other slice, the displayed name is null.
Share Improve this question edited Jul 3, 2014 at 16:26 user3758133 asked Jul 2, 2014 at 21:13 user3758133user3758133 2384 silver badges13 bronze badges 3- please create a fiddle of your code – Rahul Gupta Commented Jul 3, 2014 at 6:02
- JSFiddle added to my original question. – user3758133 Commented Jul 3, 2014 at 16:26
-
Word of explanation: It's caused by calling
drilldown
event beforepoint.click
- indrilldown
event, clicked point is destroyed. I will see why first we calldrilldown
, thenclick
event. – Paweł Fus Commented Jul 4, 2014 at 11:51
2 Answers
Reset to default 7This is fixed now in the current development version of drilldown.src.js: http://jsfiddle/highcharts/Pq6gb/3/
point: {
events: {
click: function(e) {
console.log(e.type, this.name);
}
}
}
Although not ideal, this would give you some event for regular and drilldown:
chart: {
...,
events: {
drilldown: function (e) {
console.log(e.point); // The point, with name, that was clicked
}
}
}
Along with your own code this would fire one event for regular points (your own code), and two events for drilldown points. You would then be able to check name == null
in series.point.events.click
, and ignore it, and handle it in chart.events.drilldown
(API reference).
本文标签: javascriptGet name of clicked point in Highcharts when the point has drilldownStack Overflow
版权声明:本文标题:javascript - Get name of clicked point in Highcharts when the point has drilldown - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741254930a2366486.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论