I am having issues with creating a column chart with a datetime
access. The data is coming in via XML and being converted to a
javascript date. The date object is valid in the js code and the code
has no errors. The dates in the XML are also sequential hourly values
spanning a 25 hour period.
I have tried a couple date formats in the XML and both convert to
valid date objects. Here are the I currently have in the XML: <dt>Fri
May 21 2010 11:00:00 PM</dt> or <dtb>May 21, 2010 23:00:00</dtb>
The column chart builds fine when the datetime is a string so I am
certain it is an issue with the datetime. When I change the code to
use a datetime column and a date object I receive the following
error: "inconsistent data type accross series on vertical axis"
Here’s the code less the XML calls:
var data = new google.visualization.DataTable();
data.addColumn('datetime', 'Hour');
data.addColumn('number','Watts/SF');
data.addRows(x.length);
/* XML call's removed */
for(i=0;i<x.length;i++) {
//dt=x[i].getElementsByTagName("dt")[0].firstChild.nodeValue;
var dt =
x[i].getElementsByTagName("dt")[0].firstChild.nodeValue;
alert(dt);
data.setValue(i,0, new Date(dt));
var myVal = x[i].getElementsByTagName("value")
[0].firstChild.nodeValue;
data.setValue(i,1,myVal*1);
}
var chart = new
google.visualization.ColumnChart(document.getElementById('elChart'));
chart.draw(data, {width: 1200, height: 750, title: 'Electric
Consumption', titleFontSize: 32,
hAxis: {title: 'Hour', titleColor:'red'}
});
Any ideas or known issues with the datetime format? Thanks
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.