Highcharts 如何使用data.table或data.csv和其他数据进行单击事件处理
我使用data.table(HTML表)构建了一个饼图 我想使用表的第三列来驱动对特定URL的单击Highcharts 如何使用data.table或data.csv和其他数据进行单击事件处理,highcharts,Highcharts,我使用data.table(HTML表)构建了一个饼图 我想使用表的第三列来驱动对特定URL的单击 series:[ { type: 'pie', animation: false, point:{ events:{ click: function (event)
series:[
{
type: 'pie',
animation: false,
point:{
events:{
click:
function (event)
{
// I want to get the 3rd column of the table's value
// that corresponds to this point.
alert(this.y);
}
}
}
}
]
您可以使用jQuery选择器从第三列中获取所有
td
s,并在需要时将此单击事件中的this.x
与从jQuery选择器获得的数组进行匹配
例如,使用jQuery选择器获取第三列:
var thirdColumn = $("#smry_t_pb_outlay_by_account tr td:nth-child(3)");
然后在point.events中使用此数组。单击获取数据:
point: {
events: {
click: function (event) {
alert(thirdColumn[this.x].innerHTML);
}
}
}
请参阅代码的一部分。找到了答案:
诀窍是添加一个seriesMapping值(在本例中我称之为“accountCode”),该值可以在point.click处理程序中使用
data: {
table: 'smry_t_pb_outlay_by_account',
seriesMapping: [{
x: 0, // X values are pulled from column 0 by default
y: 1, // Y values are pulled from column 1 by default
accountCode: 2 // used in the point.click below
}]
},
events: {
click:
function (event) {
alert(this.accountCode);
}
}