Jquery HighCharts onclick this.point.name未定义
我想在HighCharts饼图中添加一个onclick侦听器。 饼图和onnclick都起作用。 我使用返回json数据的php脚本返回图表的数据 我的问题是,虽然我可以返回this.x和this.y值以及this.series.name,但我无法返回this.point.name值。每当我尝试时,我都可以在firebug中看到,未定义的this.point会生成一个错误。这个问题的一个例子是,如果我将Jquery警报附加到click事件处理程序,并使用这个.y,我将返回与工具提示相同的值。但是如果我尝试这个.point.name,它会失败。下面你可以看到我的例子。您可以看到,对于工具提示和dataLabels,此值有效,但不适用于series point事件。有什么想法吗 代码如下:Jquery HighCharts onclick this.point.name未定义,jquery,highcharts,Jquery,Highcharts,我想在HighCharts饼图中添加一个onclick侦听器。 饼图和onnclick都起作用。 我使用返回json数据的php脚本返回图表的数据 我的问题是,虽然我可以返回this.x和this.y值以及this.series.name,但我无法返回this.point.name值。每当我尝试时,我都可以在firebug中看到,未定义的this.point会生成一个错误。这个问题的一个例子是,如果我将Jquery警报附加到click事件处理程序,并使用这个.y,我将返回与工具提示相同的值。但是
$(document).ready(function() {
var options = {
chart: {
renderTo: 'pie_main',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'Values by Type'
},
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.y;
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.y;
}
}
},
series: {
point: {
events: {
click: function () {
alert(this.point.name);
}
}
}
}
},
series: [{
type: 'pie',
name: 'Browser share',
data: []
}]
}
$.getJSON("../php/get_pie_cnts.php", function(json) {
options.series[0].data = json;
chart = new Highcharts.Chart(options);
});
});
对于单击点事件,您正在查找this.name,因为它指的是执行单击的点对象,如中所定义 在两个格式化程序函数中,这有一组非常特定的可用数据。它提供了对this.point和this.series等的访问,如中所定义
请参阅所有三个正在使用的点单击事件中的一个。以了解您要查找的点单击事件。名称,因为它指的是在其上执行单击的点对象,如中所定义 在两个格式化程序函数中,这有一组非常特定的可用数据。它提供了对this.point和this.series等的访问,如中所定义
请参阅使用中的所有三个选项。谢谢!!这正是我想要实现的。感谢您不仅解释,而且链接API位置。我一直在搜索,但找不到这个。谢谢!!这正是我想要实现的。感谢您不仅解释,而且链接API位置。我一直在找,找不到这个。