如何获取在highcharts的点击事件中点击的图表的值
"series": [
{
"name": "Requests",
"colorByPoint": true,
"data": [
{
"name": "Pending",
"y": 62,
"drilldown": "Pending"
},
{
"name": "Completed",
"y": 20,
"drilldown": "Completed"
},
{
"name": "Rejected",
"y": 18,
"drilldown": "Rejected"
},
]
}
],
"drilldown": {
"series": [
{
"name": "Requests",
"id": "Pending",
"data": [
[
"New Version",
21
],
[
"HotFixes",
13
],
],
point: {
events: {
click: function() {
alert("here we are");
}
}
}
},
这里假设我点击了“新版本”,那么我怎样才能获取点击“新版本”点击事件中的值。
答案 0 :(得分:1)
您需要将该功能粘贴到$.ajax({ success: function (data)
{
ReturValue = data.d; //issue here
},
error: function (err)
{
ReturValue = err.d;
}
});
不在plotOptions
范围内,而只是在主要配置中
series
这会在点击时提醒给定类别,加上y值。
您可以在Highcharts API中找到更多信息。此API还链接到显示如何使用警报功能的this JSFiddle。
总结一下,您的代码应该如下所示(即使您提供给我们的内容不是完整代码)。您可能需要稍微更改警报功能以显示您想要的内容。
plotOptions: {
series: {
cursor: 'pointer',
point: {
events: {
click: function () {
alert('Category: ' + this.category + ', value: ' + this.y);
}
}
}
}
},