When working with the pie chart in Google Charts it seems to ignore items with a value of zero. I would really like to get these items to show up in the legend even though their value is zero so that the users knows that it was a possible answer to the question. Is there a way to have a zero value item still show up in the legend?
Use noData() method to enable "No data" label: chart. noData().
On the Layout tab, in the Labels group, click Legend. Do one of the following: To hide the legend, click None. Tip: To quickly remove a legend or a legend entry from a chart, you can select it, and then press DELETE.
To hide the legend in Google Chart with JavaScript, we set the legend property to 'none' . const options = { //... legend: "none", }; to set legend to 'none' in the options object to hide the legend.
Setting the slice visibility threshold to 0 solved it for me. Notice the last option sliceVisibilityThreshold
.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, {
title:'How Much Pizza I Ate Last Night',
width:400,
height:300,
sliceVisibilityThreshold:0
});
(taken from the sample pie chart).
By default, the threshold is set to 1/720, which means (from the docs):
The slice relative part, below which a slice will not show individually. All slices that have not passed this threshold will be combined to a single slice, whose size is the sum of all their sizes. Default is not to show individually any slice which is smaller than half a degree.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With