I am using flot library to draw pie chart. I want to draw pie chart having combination of legend & pie labels. Wherein pie labels will only display slice percentage & corresponding label information from data series will be displayed in legend. Is this combination possible using flot charts?
2 Answers
8
votes
If you want the slices with percent only (no label), you need to define a custom formatter
for the label option:
$.plot($("#placeholder"), datapie, {
series: {
pie: {
show: true,
label: {
show: true,
// Added custom formatter here...
formatter: function(label,point){
return(point.percent.toFixed(2) + '%');
}
}
}
},
legend: {show: true}
});
Fiddle here.
3
votes
Yes this is possible, here is an example - http://jsfiddle.net/Rnusy/11/
datapie = [
{label: "Running", data: 19.5, color: '#e1ab0b'},
{label: "Stopped", data: 4.5, color: '#fe0000'},
{label: "Terminated", data: 36.6, color: '#93b40f'}
];
$.plot($("#placeholder"), datapie, {
series: {
pie: {show: true,
label: {show: true}
}
},
legend: {show: true}
});