[英]flot pie chart label
flot餅圖默認以百分比顯示項目的標簽,但我需要顯示構成百分比而不是百分比的數字。 下面的代碼是我的數據和
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'
}
}
標簽格式化程序
function labelFormatter(label, series) {
return "<div style='font-size:8pt; text-align:center; padding:2px; color:white;'>"
+ label + "<br/>" + Math.round(series.percent) + "%</div>";
}
我的數據
[["ebbok1","1"],["ebook2","4"],["ebook3","4"],["something","3"]]
所以我需要1,4,4,3來顯示餅圖而不是計算的百分比
編輯
我剛剛嘗試過series.data[0][1]
,但它在圖表中顯示為空白
將labelFormatter更改為:
function labelFormatter(label, series) {
return "<div style='font-size:8pt; text-align:center; padding:2px; color:white;'>" + label + "<br/>" + series.data[0][1] + "%</div>";
}
即系列中第一個(唯一)點的y數據。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.