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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.