0
我已經有Kendo餅圖,它的傳奇依然顯示,即使沒有價值。 是否有可能隱藏沒有值或值= 0的圖例。我通過函數傳遞值,所以我不知道哪個值是0.我試圖設置數組中的數據,但我卡住了。任何人都可以幫我...如果值爲0,隱藏圖例 - Kendo UI餅圖
這裏是我的腳本:
function createPieChart(a,b,c,d) {
var e = a+b+c+d;
var aa = a/e*100;
var bb = b/e*100;
var cc = c/e*100;
var dd = d/e*100;
var perA = Math.round(aa*100.0)/100.0;
var perB = Math.round(bb*100.0)/100.0;
var perC = Math.round(cc*100.0)/100.0;
var perD = Math.round(dd*100.0)/100.0;
var arrValue = [perA, perB, perC, perD];
var data = [{
"source": "Positive",
"percentage": perA,
"color": "#9de219",
"explode": true
},{
"source": "Neutral",
"percentage": perB,
"color": "#90cc38"
},{
"source": "Negative",
"percentage": perC,
"color": "#068c35"
},{
"source": "Unknown",
"percentage": perD,
"color": "#006634"
}];
$("#chart_div").kendoChart({
dataSource: {
transport: {
read: function(e) {
e.success(data);
}
}
},
title: {
position: "top",
text: "Sentiment Result"
},
legend: {
position: "bottom",
visible: true
},
seriesDefaults: {
labels: {
visible: false,
template: "#= category #: \n #= value#%"
}
},
series: [{
type: "pie",
startAngle: 150,
field: "percentage",
categoryField: "source",
colorField: "color",
explodeField: "explode"
}],
tooltip: {
visible: true,
template: "${ category } - ${ value }%"
}
}
你介意減少你的代碼問題存在的地方,請詳細說明這個問題? – Zach
我找到了方法.. – N85