谷歌图表显示图例中的空白项目 [英] Google Charts Show Empty Items in Legend
问题描述
在Google Charts中使用饼图时,它似乎忽略值为零的项目。我很想让这些项目出现在图例中,即使它们的值为零,以便用户知道这是问题的可能答案。有没有一种方法可以在图例中显示零值项目?
将切片可见性阈值设置为0解决它对我来说。注意最后一个选项 sliceVisibilityThreshold
。
var chart = new google.visualization .PieChart(的document.getElementById( 'chart_div'));
chart.draw(data,{
title:'我昨晚吃了多少比萨',
width:400,
height:300,
sliceVisibilityThreshold:0
});
(取自示例饼图)。
默认情况下,阈值设置为1/720,这意味着(从文档):
切片相关部分,低于此值将不会单独显示。
没有超过此阈值的所有切片将合并为一个切片,其大小为所有大小的总和
。缺省值不是单独显示小于
半度的切片。
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?
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.
这篇关于谷歌图表显示图例中的空白项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!