Displaying hours in an Annotated Timeline scale

557 views
Skip to first unread message

desvin

unread,
Feb 18, 2009, 4:42:15 PM2/18/09
to Google Visualization API
Hello all,

I've struggling all day with Google's Annotated Timeline chart.
I'm using this chart to display an analysis of an internet site
visits.

To do so, I've got the data of how many users connected to this site
every hour for the last fifteen days.

I am able to display these data well but would like to show the hours
in the x scale.

Have you got an idae on how to do so ?

Thanks a lot for your help.

PS : a sample of the code I use :
...
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addColumn('number', 'Visits');
data.addRows(2);
data.setValue(0, 0, new Date(2008, 1 ,1, 1, 1, 1));
data.setValue(0, 1, 30000);
data.setValue(1, 0, new Date(2008, 1 ,2, 1, 1, 1));
data.setValue(1, 1, 14045);
var chart = new google.visualization.AnnotatedTimeLine
(document.getElementById('chart_div'));
chart.draw(data, {displayAnnotations: true});
}

...


Message has been deleted

desvin

unread,
Feb 18, 2009, 5:23:07 PM2/18/09
to Google Visualization API
Thanks for your help.

I've tried to modify my code using your advice but I can't get it
working.

From what I understand, you added a new column (data.addColumn
('number', 'Hours');) but you do not pass it any data, am I right ?

Thnaks for your help.

On 18 fév, 23:01, Diter <dmitry...@gmail.com> wrote:
> Try this way:
>
> function drawChart() {
>         var data = new google.visualization.DataTable();
>         data.addColumn('date', 'Date');
>         data.addColumn('number', 'Hours');
>         data.addColumn('number', 'Visits');
>
> data.addRow();

VizGuy

unread,
Feb 19, 2009, 4:25:15 AM2/19/09
to google-visua...@googlegroups.com
Your mistake is setting the first column to be of type 'date' and not 'datetime'.
This is described at http://code.google.com/apis/visualization/documentation/gallery/annotatedtimeline.html#Data_Format
("If the first column is of type date (and not datetime) then the time resolution on the X axis will not get below days.")


Regards,
VizGuy

Arshad

unread,
Feb 19, 2009, 9:16:07 AM2/19/09
to Google Visualization API
Hi,

My question is that I dont know that how many rows in JSON.. And this
JSON have huge data of JSON(alot or rows). Now my question is that how
can I use to this huge JSON's rows data using a
variable, please let me know that how can I use it.

And I am using to this js function, In this example I am using only 5
row but I dont know that how many rows are available in JSON data. So
I want to know that how can I use to dynamic rows of JSON data.

Javascript function for JSON:
-------------------------------------
/
*******************************************************************************************************************/
function drawChart() {
var data = new google.visualization.DataTable({
cols: [
{label: 'Date', type: 'date'},
{label: 'Volume', type: 'number'},
{label: 'Price', type: 'number'}],
rows: [
{c:[{v: new Date(2008, 3 ,26)}, {v:
4.482362E7}, {v:28.56}]},
{c:[{v: new Date(2008, 8, 26)}, {v:
4.477303E7}, {v:27.27}]},
{c:[{v: new Date(2008, 9, 16)}, {v:
1.116584E8}, {v:25.99}]},
{c:[{v: new Date(2008, 8, 4)}, {v:
6.040522E7}, {v:25.28}]},
{c:[{v: new Date(2008, 7, 11)}, {v:
6.810552E7}, {v:25.25}]}
]
});
var chart = new google.visualization.AnnotatedTimeLine
(document.getElementById('div1'));
chart.draw(data, {displayAnnotations: true});

}

/
*******************************************************************************************************************/

Thanks
- arsh



On Feb 18,

On Feb 19, 2:25 pm, VizGuy <viz...@google.com> wrote:
> Your mistake is setting the first column to be of type 'date' and not
> 'datetime'.
> This is described athttp://code.google.com/apis/visualization/documentation/gallery/annot...
> ("If the first column is of type date (and not datetime) then the time
> resolution on the X axis will not get below days.")
>
> Regards,
> VizGuy
>
> > > > ...- Hide quoted text -
>
> - Show quoted text -

VizGuy

unread,
Feb 19, 2009, 3:59:52 PM2/19/09
to google-visua...@googlegroups.com
I just don't see the connection between the rows number and the column type.

Have another look at the example you sent.
On the 3rd line you have:

{label: 'Date', type: 'date'},

Now, if this was:
{label: 'Date', type: 'datetime'},
this was working with hours.

Regards,
VizGuy
Reply all
Reply to author
Forward
0 new messages