Reputation: 65
Is it possible to remove the kendo pie chart label which are displaying "0%". But we can display the legends though there are no data for that.
Below is a link which displays "0%" for Rain.
Please suggest me with your valuable ideas. Thanks.
Upvotes: 2
Views: 2504
Reputation: 24738
You can use the labels.visual property. With a template of "#: value #%", only return a label in the visual property if the text is not "0%":
labels: {
visible: true,
position: "insideEnd",
template: "#: value #%",
visual: function(e) {
if (e.text != "0%") {
return e.createVisual();
}
}
}
Updated DEMO
UPDATE: This can also be easily accomplished with just a label template:
labels: {
visible: true,
position: "insideEnd",
template: "#if (value > 0) {# #: value #% #}#",
}
Upvotes: 5
Reputation: 27526
You could remove the items with a zero value from the dataSource view data.
, dataBound: (function(e) {
var oa = e.sender.dataSource.view();
for (var i = oa.length-1; i >= 0; i--) {
if (oa[i].percentage == 0) { oa.splice(i,1); }
}
})
Of course this adjustment removes the rain item from the legend as well. I think that would be ok -- having an item in the legend that has no corresponding slice or category label could be confusing.
Upvotes: 1