Timeline Error when crossing months

39 views
Skip to first unread message

Timothy Sikora

unread,
Feb 13, 2014, 12:41:01 PM2/13/14
to google-visua...@googlegroups.com
I am not sure if this is a bug or something with my code but I get the following error when I run the code attached.  I tried to find the line referenced in the error message but didn't find any dates referring to May 1 as I am passing March and April as the month in the Date.  Trying to figure out what may be going wrong.  Appreciate the help.


Invalid data at row #15: start(Thu May 01 2014 20:35:00 GMT-0700 (Pacific Daylight Time)) > end(Thu May 01 2014 07:50:00 GMT-0700 (Pacific Daylight Time)).×


<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1','packages':['timeline']}]}"></script>
<script type="text/javascript">
google.setOnLoadCallback(drawChart);
function drawChart() {
var container = document.getElementById('schedule');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Line_Number' });
dataTable.addColumn({ type: 'string', id: 'Flight' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows([
['1', 'AL0200 FRA - MIA / 748', new Date(2014,3,30,9,5,0), new Date(2014,3,30,20,30,0)],
['2', 'AL0224 FRA - LAX / 748', new Date(2014,3,30,9,20,0), new Date(2014,3,30,21,0,0)],
['3', 'AL0207 NRT - DEN / 748', new Date(2014,3,30,9,30,0), new Date(2014,3,30,21,20,0)],
['4', 'AL0202 FRA - DEN / 748', new Date(2014,3,30,12,5,0), new Date(2014,3,30,19,5,0)],
['5', 'AL0220 FRA - DXB / 748', new Date(2014,3,30,12,20,0), new Date(2014,3,30,18,35,0)],
['4', 'AL0206 DEN - NRT / 748', new Date(2014,3,30,20,35,0), new Date(2014,3,31,7,50,0)],
['5', 'AL0219 DXB - FRA / 748', new Date(2014,3,30,21,50,0), new Date(2014,3,31,4,55,0)],
['1', 'AL0201 MIA - FRA / 748', new Date(2014,3,30,22,55,0), new Date(2014,3,31,7,0,0)],
['2', 'AL0225 LAX - FRA / 748', new Date(2014,3,30,23,10,0), new Date(2014,3,31,10,0,0)],
['3', 'AL0203 DEN - FRA / 748', new Date(2014,3,31,1,30,0), new Date(2014,3,31,10,0,0)],
['1', 'AL0200 FRA - MIA / 748', new Date(2014,3,31,9,5,0), new Date(2014,3,31,20,30,0)],
['5', 'AL0224 FRA - LAX / 748', new Date(2014,3,31,9,20,0), new Date(2014,3,31,21,0,0)],
['4', 'AL0207 NRT - DEN / 748', new Date(2014,3,31,9,30,0), new Date(2014,3,31,21,20,0)],
['2', 'AL0202 FRA - DEN / 748', new Date(2014,3,31,12,5,0), new Date(2014,3,31,19,5,0)],
['3', 'AL0220 FRA - DXB / 748', new Date(2014,3,31,12,20,0), new Date(2014,3,31,18,35,0)],
['2', 'AL0206 DEN - NRT / 748', new Date(2014,3,31,20,35,0), new Date(2014,4,1,7,50,0)],
['3', 'AL0219 DXB - FRA / 748', new Date(2014,3,31,21,50,0), new Date(2014,4,1,4,55,0)],
['1', 'AL0201 MIA - FRA / 748', new Date(2014,3,31,22,55,0), new Date(2014,4,1,7,0,0)],
['5', 'AL0225 LAX - FRA / 748', new Date(2014,3,31,23,10,0), new Date(2014,4,1,10,0,0)],
['4', 'AL0203 DEN - FRA / 748', new Date(2014,4,1,1,30,0), new Date(2014,4,1,10,0,0)],
['1', 'AL0200 FRA - MIA / 748', new Date(2014,4,1,9,5,0), new Date(2014,4,1,20,30,0)],
['3', 'AL0224 FRA - LAX / 748', new Date(2014,4,1,9,20,0), new Date(2014,4,1,21,0,0)],
['2', 'AL0207 NRT - DEN / 748', new Date(2014,4,1,9,30,0), new Date(2014,4,1,21,20,0)],
['4', 'AL0202 FRA - DEN / 748', new Date(2014,4,1,12,5,0), new Date(2014,4,1,19,5,0)],
['5', 'AL0220 FRA - DXB / 748', new Date(2014,4,1,12,20,0), new Date(2014,4,1,18,35,0)],
['4', 'AL0206 DEN - NRT / 748', new Date(2014,4,1,20,35,0), new Date(2014,4,2,7,50,0)],
['5', 'AL0219 DXB - FRA / 748', new Date(2014,4,1,21,50,0), new Date(2014,4,2,4,55,0)],
['1', 'AL0201 MIA - FRA / 748', new Date(2014,4,1,22,55,0), new Date(2014,4,2,7,0,0)],
['3', 'AL0225 LAX - FRA / 748', new Date(2014,4,1,23,10,0), new Date(2014,4,2,10,0,0)],
['2', 'AL0203 DEN - FRA / 748', new Date(2014,4,2,1,30,0), new Date(2014,4,2,10,0,0)],
['1', 'AL0200 FRA - MIA / 748', new Date(2014,4,2,9,5,0), new Date(2014,4,2,20,30,0)],
['5', 'AL0224 FRA - LAX / 748', new Date(2014,4,2,9,20,0), new Date(2014,4,2,21,0,0)],
['4', 'AL0207 NRT - DEN / 748', new Date(2014,4,2,9,30,0), new Date(2014,4,2,21,20,0)],
['2', 'AL0202 FRA - DEN / 748', new Date(2014,4,2,12,5,0), new Date(2014,4,2,19,5,0)],
['3', 'AL0220 FRA - DXB / 748', new Date(2014,4,2,12,20,0), new Date(2014,4,2,18,35,0)],
['2', 'AL0206 DEN - NRT / 748', new Date(2014,4,2,20,35,0), new Date(2014,4,3,7,50,0)],
['3', 'AL0219 DXB - FRA / 748', new Date(2014,4,2,21,50,0), new Date(2014,4,3,4,55,0)],
['1', 'AL0201 MIA - FRA / 748', new Date(2014,4,2,22,55,0), new Date(2014,4,3,7,0,0)],
['5', 'AL0225 LAX - FRA / 748', new Date(2014,4,2,23,10,0), new Date(2014,4,3,10,0,0)],
['4', 'AL0203 DEN - FRA / 748', new Date(2014,4,3,1,30,0), new Date(2014,4,3,10,0,0)],
['1', 'AL0200 FRA - MIA / 748', new Date(2014,4,3,9,5,0), new Date(2014,4,3,20,30,0)],
['3', 'AL0224 FRA - LAX / 748', new Date(2014,4,3,9,20,0), new Date(2014,4,3,21,0,0)],
['2', 'AL0207 NRT - DEN / 748', new Date(2014,4,3,9,30,0), new Date(2014,4,3,21,20,0)],
['4', 'AL0202 FRA - DEN / 748', new Date(2014,4,3,12,5,0), new Date(2014,4,3,19,5,0)],
['5', 'AL0220 FRA - DXB / 748', new Date(2014,4,3,12,20,0), new Date(2014,4,3,18,35,0)],
['4', 'AL0206 DEN - NRT / 748', new Date(2014,4,3,20,35,0), new Date(2014,4,4,7,50,0)],
['5', 'AL0219 DXB - FRA / 748', new Date(2014,4,3,21,50,0), new Date(2014,4,4,4,55,0)],
['1', 'AL0201 MIA - FRA / 748', new Date(2014,4,3,22,55,0), new Date(2014,4,4,7,0,0)],
['3', 'AL0225 LAX - FRA / 748', new Date(2014,4,3,23,10,0), new Date(2014,4,4,10,0,0)],
['2', 'AL0203 DEN - FRA / 748', new Date(2014,4,4,1,30,0), new Date(2014,4,4,10,0,0)],
['1', 'AL0200 FRA - MIA / 748', new Date(2014,4,4,9,5,0), new Date(2014,4,4,20,30,0)],
['5', 'AL0224 FRA - LAX / 748', new Date(2014,4,4,9,20,0), new Date(2014,4,4,21,0,0)],
['4', 'AL0207 NRT - DEN / 748', new Date(2014,4,4,9,30,0), new Date(2014,4,4,21,20,0)],
['2', 'AL0202 FRA - DEN / 748', new Date(2014,4,4,12,5,0), new Date(2014,4,4,19,5,0)],
['3', 'AL0220 FRA - DXB / 748', new Date(2014,4,4,12,20,0), new Date(2014,4,4,18,35,0)],
['2', 'AL0206 DEN - NRT / 748', new Date(2014,4,4,20,35,0), new Date(2014,4,5,7,50,0)],
['3', 'AL0219 DXB - FRA / 748', new Date(2014,4,4,21,50,0), new Date(2014,4,5,4,55,0)],
['1', 'AL0201 MIA - FRA / 748', new Date(2014,4,4,22,55,0), new Date(2014,4,5,7,0,0)],
['5', 'AL0225 LAX - FRA / 748', new Date(2014,4,4,23,10,0), new Date(2014,4,5,10,0,0)],
['4', 'AL0203 DEN - FRA / 748', new Date(2014,4,5,1,30,0), new Date(2014,4,5,10,0,0)],
['1', 'AL0200 FRA - MIA / 748', new Date(2014,4,5,9,5,0), new Date(2014,4,5,20,30,0)],
['3', 'AL0224 FRA - LAX / 748', new Date(2014,4,5,9,20,0), new Date(2014,4,5,21,0,0)],
['2', 'AL0207 NRT - DEN / 748', new Date(2014,4,5,9,30,0), new Date(2014,4,5,21,20,0)],
['4', 'AL0202 FRA - DEN / 748', new Date(2014,4,5,12,5,0), new Date(2014,4,5,19,5,0)],
['5', 'AL0220 FRA - DXB / 748', new Date(2014,4,5,12,20,0), new Date(2014,4,5,18,35,0)],
['4', 'AL0206 DEN - NRT / 748', new Date(2014,4,5,20,35,0), new Date(2014,4,6,7,50,0)],
['5', 'AL0219 DXB - FRA / 748', new Date(2014,4,5,21,50,0), new Date(2014,4,6,4,55,0)],
['1', 'AL0201 MIA - FRA / 748', new Date(2014,4,5,22,55,0), new Date(2014,4,6,7,0,0)],
['3', 'AL0225 LAX - FRA / 748', new Date(2014,4,5,23,10,0), new Date(2014,4,6,10,0,0)],
['2', 'AL0203 DEN - FRA / 748', new Date(2014,4,6,1,30,0), new Date(2014,4,6,10,0,0)]]);
var formatter_date = new google.visualization.DateFormat({pattern: "MM-dd KK:mm",timeZone: 0});
formatter_date.format(dataTable,1);
formatter_date.format(dataTable,2);
var options = {
timeline: { singleColor: '#5D99D4' },
};
chart.draw(dataTable, options);
}
</script>

asgallant

unread,
Feb 13, 2014, 1:45:56 PM2/13/14
to google-visua...@googlegroups.com
You are passing April and May, not March and April, as javascript's months are zero-indexed (so January is 0, February is 1, etc).  The line this is referring to is this one:

['2', 'AL0206 DEN - NRT / 748', new Date(2014,3,31,20,35,0), new Date(2014,4,1,7,50,0)],

because in javascript terms, 3/31 is the 31st day of April, or May 1, so you have the start at 30:35 on May 1 and the end at 07:50 on May 1.  If you fix your month indices by subtracting 1 from each, the problem will go away.

which is correct.

Timothy Sikora

unread,
Feb 13, 2014, 1:47:43 PM2/13/14
to google-visua...@googlegroups.com
Thanks - just realized I was sending the month wrong.


--
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/vI3aCpbls6A/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 http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages