I need the legends of Google chart to get wrapped (comes in new line) automatically if it exceeds container area. I don't want scroll button as it is not enough convenient. With available customization options, seems it cannot be done. Any other way?
Asked
Active
Viewed 1.3k times
3 Answers
25
Use the maxLines property for the legend. i.e.:
options.legend = {position: 'top', maxLines: 5};
Note that this undocumented property only works if the legend is positioned at the top and there is enough vertical space to render both the chart and multi-line legend.

Akin Williams
- 648
- 8
- 14
-
1legend:{ position: 'bottom', maxLines: 5 }, This does not change how it is displayed unfortunately. – Jakob Alexander Eichler Aug 31 '17 at 23:43
-
2See my answer: "Note that this undocumented property only works if the legend is positioned at the top..." – Akin Williams Sep 04 '17 at 10:54
0
with the maxLines property for the legends, chartArea with specific set of values can help in rendering the display.
legend: { position: "top", alignment: "start", maxLines: 2 },
chartArea: {top:50,bottom:30,right:0,left:50, 'width': '100%' }

Pranav
- 33
- 1
- 9
0
I did a lot of testing of this and it seems that you need to have chartArea width and height set to 'auto'. Still not perfect but sort of OK.

user1498970
- 69
- 4