I'm trying to format my query flot pie chart labels and legend.
This is what I've created so far:
This is what I'm trying to create (I did it using photoshop):
As you can see, I'm struggling to include percentage and values within the pie (see that percentage is bold and the value is not), and vertical-center align the legend.
Here's the code:
(function () {
var data = [
{ label: "Sales & Marketing", data: 9545, color: "#62A83B"},
{ label: "Research & Development", data: 16410, color: "#2897CB"},
{ label: "General & Administration", data: 4670, color: "#DEAB34"}
];
$(document).ready(function () {
$.plot($("#expenses-chart"), data, {
series: {
pie: {
show: true
}
},
legend: {
show: true,
labelFormatter: function(label, series) {
var percent= Math.round(series.percent);
var number= series.data[0][1]; //kinda weird, but this is what it takes
return(' <b>'+label+'</b>: '+ percent + '%');
}
}
});
});
})();
Any ideas? Thanks!