我想删除1/5并在Google饼图中显示所有图例

时间:2018-08-20 13:32:49

标签: google-visualization legend pie-chart google-chartwrapper legend-properties

https://i.stack.imgur.com/9w4KY.png

这里我总共有10个传说,但我想显示所有10个传说。

1 个答案:

答案 0 :(得分:0)

正如 WhiteHat 在他的评论中提到的那样,您必须将legend.position移到顶部并增加maxLines

但是另外,您必须将top属性添加到chartArea,以在图表顶部获得足够的空间。

    {
      width: '100%',
        height: '100%',
      legend: { 
         position: 'top',         // <--- top position
         alignment: 'center', 
         maxLines: 5             // <--- increase of max lines
      },
      chartArea: {
        height: "100%",
        width: "100%",
        top: "25%"           // <-- top space (you can use fix values as well. (e.x. 50))
      },
      sliceVisibilityThreshold: 0,
      pieHole: 0.4,
    }
相关问题