How do I determine what Date units chart is using?

22 views
Skip to first unread message

Inquisitor

unread,
Dec 13, 2017, 9:03:06 AM12/13/17
to Google Visualization API
I have a written some generic JavaScript to zoom in/out on some time based line chart data using the mouse wheel.  I've set up the hAxis:gridlines:units properties to have the full range of units from years down to milliseconds...

            units: {
                years: { format: ["yyyy"] },
                months: { format: ["M/dd/yy"] },
                days: { format: ["M/dd/yy"] },
                hours: { format: ["haa"] },
                minutes: { format: ["h:mmaa"] },
                seconds: { format: ["m:ss"] },
                milliseconds: { format: ["s.SSS"] }
            }

This, I have working fine and Google's chart code nicely formats the most appropriate range for the current viewWindow.  One minor issue... I'd like to improve clarity, by changing the hAxis:title when the Google chart code changes ranges...  ie   time (years), time (hours), etc.  How do I query the chart about what set of units it is currently using?

Daniel LaLiberte

unread,
Dec 13, 2017, 9:50:26 AM12/13/17
to Google Visualization API
Hi Dennis,

There is no method for determining what the date units are for the ticks.  The best you could do currently would be to get information about the current viewWindow via the getChartLayoutInterface method and associated methods.  

It would be a good idea to provide this info somehow, or at least allow customization of the axis title based on the units used.  

--
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-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/a0b35ae2-8c58-40ca-a40f-bd0c5780fb09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Inquisitor

unread,
Dec 13, 2017, 10:42:39 AM12/13/17
to Google Visualization API
Thank you for responding so quickly.  I'll take a look at rolling my own as you suggested.


Reply all
Reply to author
Forward
0 new messages