How to control X Axis labels?

76 views
Skip to first unread message

B7

unread,
Dec 9, 2011, 10:17:14 AM12/9/11
to Google Visualization API
I have a small chart (about 250 px wide). There are (too) many labels
on the X axis, and they are displayed as '8/...'. They are supposed to
be dates (8/22/2011), but since there are too many, they are replaced
by ellipsis.

How do you reduce the number of labels so that the dates show up
properly? If possible I would like to limit it to 5, regardless of how
many points.

I tried hAxis.showTextEvery: 4,
but this threw an error.

Thanks.

asgallant

unread,
Dec 9, 2011, 10:46:31 AM12/9/11
to google-visua...@googlegroups.com
I believe that hAxis.showTextEvery is the correct option for this.  Make sure you are using it correctly, ie:

hAxis: {showTextEvery: 4}

not hAxis.showTextEvery: 4

B7

unread,
Dec 9, 2011, 10:52:41 AM12/9/11
to Google Visualization API
OK, that worked. Thanks!!!

Is there a way to set the total number of labels, instead of the
number to skip?

asgallant

unread,
Dec 9, 2011, 12:13:11 PM12/9/11
to google-visua...@googlegroups.com
No, but you can calculate the showTextEvery value based on the number of rows in your dataTable; it would be (roughly):

var showEvery = parseInt(data.getNumberOfRows() / <desired number of labels>);

B7

unread,
Dec 9, 2011, 12:38:10 PM12/9/11
to Google Visualization API
Awesome. Thank you!!!
Reply all
Reply to author
Forward
0 new messages