I'm trying to generate a column chart from an array but get this error 
message: 

Uncaught Error: Not a valid 2D array. 

The script does work if I manually add the array, but that's not going to 
work for the project. 

If I replace the variable newRows, which contains the array, with some test 
data, the script works fine. 

If you want, replace newRows with this test data: 

['1901',2], ['1902',4], ['1903',4], ['1904',6], ['1905',8], ['1906',4], 
['1907',3] 

Obviously, I'm not handling the variable correctly. 

Any help will be appreciated. 

Bob Brueckner



Here is the script: 

*<!DOCTYPE html> <html> <head> <meta name="viewport" 
content="initial-scale=1.0, user-scalable=no"> <meta charset="UTF-8"> 
<title>Duke football records</title> <script type="text/javascript" 
src="http://maps.google.com/maps/api/js?sensor=false";></script> <script 
type="text/javascript" src="http://www.google.com/jsapi";></script> <script 
type="text/javascript"> google.load('visualization', '1', 
{'packages':['corechart','table']}); var whereClause = ""; var newData = 
""; var newRows = []; function drawRecords() { var queryText = 
encodeURIComponent("SELECT 'Year', 'Overall Win' as 'Overall Wins', 'Conf 
Win', 'Coach', 'Overall', 'Conference', 'Finish' as 'Conf. finish', 'AP' as 
'AP rank' from 10ocotrV2UnYOaMyYguVZFoEuxzzszRGrEINBy1o" + whereClause); 
var query = new 
google.visualization.Query('http://www.google.com/fusiontables/gvizdata?tq=' 
+ queryText); query.send(handleQueryResponse); function 
handleQueryResponse(response) { if (response.isError()) { alert('Error in 
query: ' + response.getMessage() + ' ' + response.getDetailedMessage()); 
return; } var data = response.getDataTable(); var thisCoach = "Wallace 
Wade"; var newRowNumber = data.getNumberOfRows(); for (var i = 0; i < 
newRowNumber; i++){ if (thisCoach == data.getValue(i,3)) { var newYear = 
(data.getValue(i,0)); var newWins = parseInt(data.getValue(i,1)); 
newRows.push("\n[" + "'" + newYear + "'", newWins+ "]"); } else { var 
newYear = (data.getValue(i,0)); var newWins = parseInt(0); 
newRows.push("\n[" + "'" + newYear + "'", newWins+ "]"); } } var newData = 
new google.visualization.arrayToDataTable([ ['Season', 'Wins'], newRows ]); 
var newchart = new google.visualization.ColumnChart( 
document.getElementById('newChart')); var options = { height: 300, width: 
900, legend: {position: 'bottom'} }; newchart.draw(newData, options); } } 
google.setOnLoadCallback(drawRecords); </script> </head> <body> <table 
style="width:900px; vertical-align:top;"> <tr> <td style="width:900px; 
height:600px; vertical-align:top;" colspan="2"> <div id="newChart"></div> 
</td> </tr> </table> </body> </html>* 



-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/0yyTYfDXLBsJ.
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.

Reply via email to