Using DateTime instead of Date in Google chart CandlestickChart

google-visualization, javascript

Solution

To clarify Mark's answer, change your line

data.addColumn('date', 'Date');

to

data.addColumn('datetime', 'Time');

this seems to work for me.

Problem

I'm trying to use datetime instead of date to build chart using the Google-chart API. Based on the sample from Google (sample) ``` var data = new google.visualization.DataTable(); data.addColumn('date', 'Date'); data.addColumn('number', 'Stock low'); data.addColumn('number', 'Stock open'); data.addColumn('number', 'Stock close'); data.addColumn('number', 'Stock high'); data.addRows([ [new Date(2008, 1 ,1), 1000, 1000, 1500, 2000], [new Date(2008, 1 ,2), 500, 1000, 1500, 2500], [new Date(2008, 1 ,3), 1000, 1000, 1500, 2000] ]); ``` I can play with dates, but I want to use date & hours, something like ``` data.addRows([ [new Date(2008, 1 ,1, 00, 00, 00), 1000, 1000, 1500, 2000], [new Date(2008, 1 ,1, 01, 00, 00), 500, 1000, 1500, 2500], [new Date(2008, 1 ,1, 02, 00, 00), 1000, 1000, 1500, 2000] ]); ``` This give me the following output Any idea ?

Original source