flot pie chart shows the label of the items by default in percentage, but i need to show the number which make up the percent instead of the percentages. the code below is my data and
var pieOptions={
series: {
pie: {
show: true,
radius: 1,
label: {
show: true,
radius: 3/4,
formatter: labelFormatter,
background: {
opacity: 0.5,
color: '#000'
}
}
}
},
grid: {
hoverable: true,
clickable: true
},
legend: {
container: '#pieLegend'
}
}
the label formatter
function labelFormatter(label, series) {
return "<div style='font-size:8pt; text-align:center; padding:2px; color:white;'>"
+ label + "<br/>" + Math.round(series.percent) + "%</div>";
}
my data
[["ebbok1","1"],["ebook2","4"],["ebook3","4"],["something","3"]]
so i need 1,4,4,3 to show on the pie chart instead of the calculated percentages
Edit
i just tried series.data[0][1]
, but it showed blank in the chart
Change the labelFormatter to:
function labelFormatter(label, series) {
return "<div style='font-size:8pt; text-align:center; padding:2px; color:white;'>" + label + "<br/>" + series.data[0][1] + "%</div>";
}
That the y data of the first (only) point in the series.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With