What I'm trying to do is not print from a google spread sheet, but a page I generate dynamically on my server. What I am trying to understand is (what I think is anyway) the format necessary for importing the data. Does the data need to be in the JSON format?
I created the test page below: And I get a "All series on a given axis must be of the same type" error. I can use the addColumns, addRows kind of data loading, but I find it a bit clunky. I'd rather find a format where the data can be ingested all at once. If I look at the array below everything seems to be a valid array, but I might have made a mistake.
Any help will be appreciated.
Paul
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='content-type' content='text/html; charset=utf-8'/>
<title>Google Visualization API Sample</title>
<!-- One script tag loads all the required libraries! Do not specify any chart types in
the autoload statement.
-->
<script type="text/javascript" src="
https://www.google.com/jsapi"></script>s
<script type="text/javascript">
google.load('visualization', '1');
google.setOnLoadCallback(drawVisualization);
function drawVisualization() {
// Define the chart using setters:
var dTable = new google.visualization.DataTable({cols:[
{id:'A',label:'A',type:'string'},
{id:'B',label:'Country code',type:'string'},
{id:'C',label:'Population',type:'number'},
{id:'D',label:'Population Density',type:'number'}],
rows:[
{c:[{v:'China'}, {v:'CN'}, {v:1.32297E9,f:'1322970000'}, {v:137.0,f:'137'}]},
{c:[{v:'India'}, {v:'IN'}, {v:1.13013E9,f:'1130130000'}, {v:336.0,f:'336'}]},
{c:[{v:'United States'},{v:'US'}, {v:3.03605941E8,f:'303605941'}, {v:31.0,f:'31'}]},
{c:[{v:'Indonesia'}, {v:'ID'}, {v:2.31627E8,f:'231627000'}, {v:117.0,f:'117'}]},
{c:[{v:'Brazil'}, {v:'BR'}, {v:1.86315468E8,f:'186315468'}, {v:22.0,f:'22'}]},
{c:[{v:'Pakistan'}, {v:'PK'}, {v:1.626525E8,f:'162652500'}, {v:198.0,f:'198'}]},
{c:[{v:'Bangladesh'}, {v:'BD'}, {v:1.58665E8,f:'158665000'}, {v:1045.0,f:'1045'}]},
{c:[{v:'Nigeria'}, {v:'NG'}, {v:1.48093E8,f:'148093000'}, {v:142.0,f:'142'}]},
{c:[{v:'Russia'}, {v:'RU'}, {v:1.41933955E8,f:'141933955'}, {v:8.4,f:'8.4'}]},
{c:[{v:'Japan'}, {v:'JP'}, {v:1.2779E8,f:'127790000'}, {v:339.0,f:'339'}]}]});
var wrap = new google.visualization.ChartWrapper();
wrap.setChartType('LineChart');
wrap.setDataTable(dTable);
wrap.setContainerId('visualization');
wrap.setQuery('SELECT A,D WHERE D > 100 ORDER BY D');
wrap.setOptions({'title':'Population Density (people/km^2)', 'legend':'none', 'interpolatenulls' : 'true' });
wrap.draw();
}
</script>
</head>
<body>
<div id='visualization' style='height: 400px; width: 400px;'></div>
</body>
</html>