admin管理员组文章数量:1296900
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
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
1 Answer
Reset to default 8Change 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.
本文标签: javascriptflot pie chart labelStack Overflow
版权声明:本文标题:javascript - flot pie chart label - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741641666a2389953.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论