Invalid row index 5. Should be in the range

3,012 views
Skip to first unread message

Marcel Marcel

unread,
Sep 16, 2011, 7:37:07 AM9/16/11
to Google Visualization API
hi everyone,

i always get this error:
[13:34:46.151] Invalid row index 5. Should be in the range [0-4]. @
https://www.google.com/uds/api/visualization/1.0/cd9282b3113b5d80b6043070ddbc00e4/default,corechart.I.js:251

if i load my test page (i think it is (execpt of the data) equal to
the sample code on http://code.google.com/apis/chart/interactive/docs/gallery/linechart.html):

where is my mistake?

<html>
<head>
<script type="text/javascript" src="https://www.google.com/
jsapi"></script>
<script type="text/javascript">

google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();

data.addColumn('string', 'Month');
data.addColumn('number', 'FOO');
data.addColumn('number', 'FOO2');
data.addColumn('number', 'FOO3');
data.addRows(5);
data.setValue(0, 0, 'October');
data.setValue(0, 1, 12521.67);
data.setValue(0, 2, 8398.94);
data.setValue(0, 3, 6685.84);
data.setValue(1, 0, 'November');
data.setValue(1, 1, 11636.14);
data.setValue(1, 2, 8303.70);
data.setValue(1, 3, 6346.80);
data.setValue(2, 0, 'December');
data.setValue(2, 1, 11139.73);
data.setValue(2, 2, 7619.64);
data.setValue(2, 3, 6078.37);
data.setValue(3, 0, 'January');
data.setValue(3, 1, 10334.47);
data.setValue(3, 2, 6299.14);
data.setValue(3, 3, 5978.79);
data.setValue(4, 0, 'February');
data.setValue(4, 1, 9615.78);
data.setValue(4, 2, 5506.87);
data.setValue(4, 3, 5554.51);
data.setValue(5, 0, 'March');
data.setValue(5, 1, 8728.23);
data.setValue(5, 2, 5013.35);
data.setValue(5, 3, 4762.21);
var chart = new
google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, {width: 400, height: 240, title: 'Test'});
}
</script>
</head>

<body>
<div id="chart_div"></div>
</body>
</html>

Riccardo Govoni ☢

unread,
Sep 16, 2011, 10:56:31 AM9/16/11
to google-visua...@googlegroups.com
You are creating a datatable with 5 rows:

data.addRows(5);

but you are trying to insert 6 of them:

 data.setValue(5, 0, 'March');

(rows are numbered starting from 0, so row 5 is the 6th one). Increase the number in data.addRows() to fix the issue.

--R.


--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.


Reply all
Reply to author
Forward
0 new messages