Google 图表在图例中显示空项目

发布于 2024-12-24 21:52:14 字数 104 浏览 3 评论 0原文

在 Google Charts 中使用饼图时,它似乎会忽略值为零的项目。我真的很想让这些项目显示在图例中,即使它们的值为零,以便用户知道这是问题的可能答案。有没有办法让零值项目仍然显示在图例中?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只有一腔孤勇 2024-12-31 21:52:14

将切片可见性阈值设置为 0 为我解决了这个问题。请注意最后一个选项 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
});

(取自示例饼图)。

默认情况下,阈值设置为 1/720,这意味着(来自文档):

切片相关部分,其下方的切片将不会单独显示。所有切片
没有超过这个阈值的会被合并成一个切片,其大小为总和
所有尺寸。默认情况下不单独显示任何小于
半度。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文