Error in xAxis label with datetime column.

18 views
Skip to first unread message

Rattle PenH

unread,
Apr 19, 2017, 4:41:50 PM4/19/17
to Google Visualization API
Hallo.

I have a problem and I can't find where i did wrong.

I draw a Line Chart loading data from a JSON table generated by a php file. the data looks like this:

{
 
"cols": [
 
{"DT":"", "label":"Data ora","pattern":"","type":"datetime"},
 
{"TIn":"", "label":"TIn","pattern":"","type":"number"},
 
{"TOut":"", "label":"TOut","pattern":"","type":"number"},
 
{"t_min":"", "label":"t_min","pattern":"","type":"number"},
 
{"t_max":"", "label":"t_max","pattern":"","type":"number"},
 
{"t_floor":"", "label":"t_floor","pattern":"","type":"number"},
 
{"t_ceiling":"", "label":"t_ceiling","pattern":"","type":"number"}
 
],
"rows": [
 
{"c":[{"v":"Date(2017, 04, 19, 11, 38, 22)","f":null},{"v":20.562, "f":null},{"v":15.5, "f":null},{"v":19.5, "f":null},{"v":23.5, "f":null},{"v":18.0, "f":null},{"v":25.0, "f":null}]},
 
{"c":[{"v":"Date(2017, 04, 19, 11, 40, 29)","f":null},{"v":20.5, "f":null},{"v":15.5, "f":null},{"v":19.5, "f":null},{"v":23.5, "f":null},{"v":18.0, "f":null},{"v":25.0, "f":null}]},
 
{"c":[{"v":"Date(2017, 04, 19, 11, 41, 32)","f":null},{"v":20.375, "f":null},{"v":15.562, "f":null},{"v":19.5, "f":null},{"v":23.5, "f":null},{"v":18.0, "f":null},{"v":25.0, "f":null}]},
 
{"c":[{"v":"Date(2017, 04, 19, 11, 43, 37)","f":null},{"v":20.25, "f":null},{"v":15.562, "f":null},{"v":19.5, "f":null},{"v":23.5, "f":null},{"v":18.0, "f":null},{"v":25.0, "f":null}]},
....

The chart is customized like this:

      var options = {   width: 1200,
                                                height: 600,
                                                vAxis:  {minValue: 14, maxValue:26},
                                                hAxis: {        format: 'dd/MMM   HH:mm',
                                                                        slantedText: true,
                                                                        slantedTextAngle: 30,
                                                                        textStyle: {fontSize:10}},
                                                series: {       0: {color: '#66FF66', lineWidth: 4, pointSize: 5},
                                                                        1: {color: '#11AA11', lineWidth: 3, pointSize: 5},
                                                                        2: {color: '#9999FF', lineDashStyle: [4, 2], enableInteractivity: false},
                                                                        3: {color: '#FF9999', lineDashStyle: [4, 2], enableInteractivity: false},
                                                                        4: {color: '#999999', lineDashStyle: [4, 4], enableInteractivity: false},
                                                                        5: {color: '#999999', lineDashStyle: [4, 4], enableInteractivity: false}
                                                                }
                                        }

but when i draw the chart i get the lables on the xAxis with the wrong data. In fact I get "19/May  12:00", "19/May  14:00" and so on.

I cannot find out where I am wrong. Can anybody help?

Daniel LaLiberte

unread,
Apr 19, 2017, 4:46:23 PM4/19/17
to Google Visualization API
Months start at 0.  This is documented here:  https://developers.google.com/chart/interactive/docs/datesandtimes

--
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/1904e5d2-f27c-487b-8592-e2789c720f02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Rattle PenH

unread,
Apr 20, 2017, 3:04:59 AM4/20/17
to Google Visualization API
Reply all
Reply to author
Forward
0 new messages