Reputation: 3335
I am trying to display browser visits for my site using flot pie chart. Everything is working properly except the series name displays as undefined. Data for the series is.
[
[
"Chrome",
"54"
],
[
"Firefox",
"51"
],
[
"Internet Explorer",
"9"
],
[
"Opera Mini",
"2"
],
[
"Safari",
"2"
]
]
and the JavaScript is
$('#browserVisits').css({
height: '300px',
width: '100%'
});
$.plot($('#browserVisits'), visits, {
series: {
pie: {
show: true
}
},
grid: {
hoverable: true,
clickable: true
},
legend: {
show: false
}
});
And the result for this series is like
Why the series name displays undefined instead of browser name? What am I doing wrong and what can be the solution? Thanks.
Upvotes: 0
Views: 680
Reputation: 477
Well you just have to add formatter function in pie block as follows
label: {
show: true,
formatter: function(label,point){
return(point.label + '<br>'+ point.percent.toFixed(2) + '%');
}
}
Also i have created a sample fiddle for you take a look http://jsfiddle.net/coolbhushans/03kd2mav/
Upvotes: 2