UTC time on LineChart xAxis

153 views
Skip to first unread message

Jeff LaTray

unread,
Jul 10, 2020, 5:05:08 PM7/10/20
to Google Visualization API
These are the options I'm providing for hAxis on a line chart:

hAxis : {maxValue: startTime, 
             minValue: endTime, 
             viewWindowMode: 'maximized', 
             textPosition: 'in',
             format: 'HH:mm:ss',
            }


This produces the look that I like but I want all the times in the chart to be UTC rather than local.
I see references to DateFormat being able to take a timezone parameter (In this case 0)  but I am not seeing how I can apply this to the hAxis or to the table on a whole.

How do I do this?

Thank you

Daniel LaLiberte

unread,
Jul 10, 2020, 6:50:26 PM7/10/20
to google-visua...@googlegroups.com
Hi Jeff,

You can use the DateFormat to format a column of your data, as shown in this example:   https://jsfiddle.net/dlaliberte/cxkh14sj/3/
However, that doesn't format your tick values, and unfortunately, the format option for the axes does not currently accommodate the 'timeZone' option, as the DateFormat supports.   We need to fix that.

As a workaround, you can use the DateFormat formatValue method to format any date value using the same formatter, and use that to generate a list of formatted tick values, to set the 'ticks' option.   
  ticks: [{v: date1, f: formattedDate1} {v: date2, f: formattedDate2}, ...]

The main problem in doing it this way is that you have to determine which date values to use based on what is appropriate for your data, and that can be difficult if your dates vary each time you draw the chart.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/4b110bf0-47a3-484a-8a91-a4948a9a682co%40googlegroups.com.


--
Reply all
Reply to author
Forward
0 new messages