1
votes

I'm having a hard time getting the horizontal gridlines to show up in my google charts.

Here is my hAxis settings. I suspect it has something to do with datetime format so I wrote a formatter.

hAxis: {
    title: 'DateTime (UTC)',
    slantedText: true,
    gridlines: {
        count: 30
    }
}

var formatter = new google.visualization.DateFormat({pattern: 'yyyy-MM-dd HH:mm:ss'});
formatter.format(data, 0);

Anytbody know what I'm doing wrong?

The Site: http://redditsnaps.com/r/dataisbeautiful/top-posts-chart

1
Working for me, though it takes a whilejuvian
Do you mean the vertical gridlines? You do not see those because your dates are not actually Date objects - they are strings. Vertical gridlines are only supported on continuous axes, and strings create discrete axes. You should convert your date strings to Date objects to get the gridlines to show.asgallant

1 Answers

1
votes

From the title of the hAxis I understand you want to represent date time in UTC time zone. To do so you need to specify the time zone in the formatter, like this

var formatter = new google.visualization.DateFormat({pattern: 'yyyy-MM-dd HH:mm:ss', timeZone: +0});

This will affect only the values and the tooltips, though. You will still have the ticks label of the horizontal axis represented in your local time zone. I've been struggling myself to figure out how to change time zone of the ticks label, but no luck so far.

Thomas