Trouble with Chart Control

60 views
Skip to first unread message

Brent Bensten

unread,
Jan 5, 2016, 10:10:34 PM1/5/16
to Google Visualization API
Hello,

I am having issues getting a date control slider to work correctly. I am feeding the data in the format of " {"c":[{"v":"2016-01-04 17:05:01"}" but for some reason the slider draws showing "1970-01-01" I am sure I am missing something in the parsing of the date (string). If I take the control out, the chart draws perfectly. Please let me know what I am missing.

// Instantiate and draw our chart, passing in some options.
// Do not forget to check your div ID
var linechart = new google.visualization.LineChart(document.getElementById('linechart_div')); linechart.draw(linechartdata, linechart_options);

// We omit "var" so that programmaticSlider is visible to changeRange.
programmaticSlider = new google.visualization.ControlWrapper({
'controlType': 'DateRangeFilter',
'containerId': 'programmatic_control_div',
'options': {
// Filter by the date axis.
'filterColumnIndex': 0,
'ui.format': { 'pattern':'yyyy-MM-dd HH:mm:ss' },
'ui': {
'chartType': 'LineChart',
'chartOptions': {
'chartArea': {'width': '90%'},
'hAxis': {'baselineColor': 'none'}
},
// 1 day in milliseconds = 24 * 60 * 60 * 1000 = 86,400,000
'minRangeSize': 86400000
}
},
// Initial range: 2012-02-09 to 2012-03-20.
'state': {'range': {'start': new Date(2012, 1, 9), 'end': new Date(2016, 2, 20)}}
});
programmaticChart = new google.visualization.ChartWrapper({
'chartType': 'LineChart',
'containerId': 'linechart_div',
'options': {
is3D: 'true',
width: 1200,
height: 400,
series: {
0: { lineWidth: 2 },
1: { lineWidth: 2 },
2: { lineWidth: 2 },
3: { lineWidth: 4 },
4: { lineDashStyle: [14, 2, 2, 7] },
5: { lineWidth: 2 }
}
}
});

dashboard.bind(programmaticSlider,programmaticChart);
dashboard.draw(linechartdata);

}
</script>

Daniel LaLiberte

unread,
Jan 6, 2016, 12:21:19 PM1/6/16
to Google Visualization API
Brent,

I believe we have some issues with setting the 'state' of the DateRangeFilter, so if you can take that option out, it might work better.  

But your dates should not be formatted as strings that way.  If you need to use strings, use the form "Date(yyyy, MM, dd, hh, mm, ss)" whereMM is the zero-based month.


--
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 post to this group, send email to google-visua...@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/7d365bfd-aff9-4c7e-be3b-a31d98c9e9ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Brent Bensten

unread,
Jan 6, 2016, 2:24:38 PM1/6/16
to google-visua...@googlegroups.com
Hello,

I removed the “state” and that helped.  I still have an issue where the date the is being fed in is being tied to Epoch.   When I pull the data from the database I use the following 

"$temp[] = array('v' => (int) date('mdY',strtotime($r['INSERT_TIME'])));

I then try to build the DateRangeFilter with the following:

  programmaticSlider = new google.visualization.ControlWrapper({

'controlType': 'DateRangeFilter',

'containerId': 'programmatic_control_div',

 'options': {

            'filterColumnLabel': 'Time',

            'ui': {

             format:{pattern: "mdY"}

            }

          }

        });


The date in comes in as format: “12292015


I am so close with your help so I would really appreciate it if you could help steer me in the right direction.


Thanks!


You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/rVQodNfpCTs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.

Daniel LaLiberte

unread,
Jan 6, 2016, 4:17:07 PM1/6/16
to Google Visualization API
I don't know the language you are using on your server, but I would guess you want something more like this:

"$temp[] = array('v' => (int) date('Date(Y, m, d)',strtotime($r['INSERT_TIME'])));

I don't know what you mean by "tied to Epoch", but you may need to be aware of timezone issues.


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages