Forcing vertical chart to display all x-axis number

64 views
Skip to first unread message

Wesley Chin

unread,
Nov 29, 2012, 2:58:44 AM11/29/12
to google-visua...@googlegroups.com
Hi everyone, 

I have a vertical bar chart that is returning data for each day of the month.  The y-axis is the count of peaches and the x-axis is the days of the current month [ie. 1, 2, 3, etc].  These are dynamically populated according to what the current month is.

When I render the chart however, not every day is displaying, I am getting irregular intervals, 2, 9, 16, 23, 30 and not from 1-30.

Is there a way to solve this by forcing the chart to render all the days and not just intervals?

Any help will be greatly appreciated,
Wesley

asgallant

unread,
Nov 29, 2012, 10:46:01 AM11/29/12
to google-visua...@googlegroups.com
The hAxis.gridlines.count option controls how many labels you get on the x-axis, but it is currently broken for Date axes.  You can use a DataView to transform your Dates into strings and draw the chart with that instead.  Expermiment with the hAxis suboptions slantedText, slantedTextAngle, showTextEvery, maxAlternation, maxTextLines, and minTextSpacing to get all of the labels to show.  Here's the code you would use for the DataView:

var view new google.visualization.DataView(data);
view.setColumns([{
    type'string',
    labeldata.getColumnLabel(0),
    calcfunction (dtrow{
        return dt.getFormattedValue(row0);
    }
}/*, 2, 3, 4...etc*/]);
Reply all
Reply to author
Forward
0 new messages