简体   繁体   中英

How do I get see the zero value in a Google Sheets Chart?

In this list of "Dogs on tap" we have Shitzu but none on tap. The charting tool in Google Sheets doesn't even acknowledge that we have Shitzu. Nevertheless, I would like the fact that we have the breed (even if we have none on tap at the moment) reflected in the pie chart.

数据和图表

I have read about sliceVisibilityThreshold and have fiddled with someone else's work such that if I change

        var options = {
          title: 'My Daily Activities'
        };

to

        var options = {
          title: 'My Daily Activities',
          sliceVisibilityThreshold : 0
        };

the legend will at least acknowledge the zero value. Now how do I get that same behaviour into my Google Sheets chart?

You can use a "close to zero" value:

在此处输入图像描述

To take this further you could use and onEdit Apps Script simple trigger to change all 0 values to 0.00000...01 while keeping the display at only a few significant figures, so it displays as 0 too.

function onEdit(e) {
  let s = SpreadsheetApp.getActive() // This line can be deleted after authorization
  let rng = e.range
  if (e.value == 0){
    rng.setValue(0.00000000000001)
  }
}

Run this function once in the editor to grant the authorizations necessary. Then it should automatically replace all 0 values behind the scenes, and will show up in the chart after a short delay:

在此处输入图像描述

Ideally there would be an option, though it could be argued that if something occupies 0% of the pie, it shouldn't show up in a pie chart. In any case, you can always make a feature request if you think it should have its own option.

Reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM