5

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 ?

4

2 回答 2

6

为了澄清马克的答案,改变你的行

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

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

这似乎对我有用。

于 2012-11-22T22:18:39.197 回答
1

你想要“日期时间”,而不是“日期”。

于 2012-07-22T05:02:03.160 回答