Highcharts Pie charts get the selected pie id
highcharts
Solution
You want the event handling on the point config, not the series. Each wedge is a point in a single series:
var data = [{ name: 'One', y: 10, id: 0 },{ name: 'Two', y: 10, id: 1 }];
// some other code here...
series:[
{
"data": data,
type: 'pie',
animation: false,
point:{
events:{
click: function (event) {
alert(this.x + " " + this.y);
}
}
}
}
],
Fiddle here.
Full running code:
var chart;
point = null;
$(document).ready(function () {
var data = [{ name: 'One', y: 10, id: 0 },{ name: 'Two', y: 10, id: 1 }];
chart = new Highcharts.Chart(
{
series:[
{
"data": data,
type: 'pie',
animation: false,
point:{
events:{
click: function (event) {
alert(this.id);
}
}
}
}
],
"chart":{
"renderTo":"container"
},
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="width: 320px; height: 200px"></div>
Problem
How do I get Highcharts Pie charts get the selected pie id ? I have a data array ``` var data= { name: series[i], y: Data[i],id:categorydata[i] }; ``` Render the chart ``` new Highcharts.Chart({ .... .... series: [{ type: 'pie', name: 'Category', data: data }] }); ``` How do I get the id of the selected pie. I am doing this in ``` plotOptions: { series: { animation: false, events:{ click: function (event) { var point = this; //How do I Access the id??????? alert('value: ' + this.series); } } }, ```