I'm using Google Charts Tools, specifically the Pie Chart.
Naturally, if a item has a value of 0, it is not displayed in the pie (since it occupies 0% of the pie). However, it doesn't display in the legend either.
How can I manipulate the initialization options to still show a 0 value item in the legend, so that users can see that the item exists, it just has a 0 value?
Use noData() method to enable "No data" label: chart. noData().
How to display both Percentage and Values in Google Pie Chart ? You can't display both on the slice labels, but if you set the pieSliceText option to 'label' and the legend. position option to 'labeled' , you will see the value on the slice and the percent on the legend label.
setting sliceVisibilityThreshold
as zero will solve your problem.
function drawVisualization() { // Create and populate the data table. var data = google.visualization.arrayToDataTable([ ['Task', 'Hours per Day'], ['Work', 11], ['Eat', 0], ['Commute', 2], ['Watch TV', 2], ['Sleep', 7] ]); // Create and draw the visualization. new google.visualization.PieChart(document.getElementById('visualization')). draw(data, {title:"So, how was your day?", sliceVisibilityThreshold:0 }); }
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