jeudi 26 mars 2015

Error in query: Invalid JSON string when Creating a Chart from a Spreadsheet? GAS


Why am I getting the error Error in query: Invalid JSON string when attempting to create a chart from a spreadsheet using the Google example script from their documentation here?


I can't figure it out. The only thing that I changed is the spreadsheet URL. The rest is directly from the documentation example. I provided all of my code below. Any help you guys could give would be greatly appreciated. Thanks, Brandon





function doGet() {
return HtmlService.createTemplateFromFile('index')
.evaluate()
.setSandboxMode(HtmlService.SandboxMode.NATIVE);
};

function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename).getContent();
};






<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="http://ift.tt/JuZcy0"></script>
<script type="text/javascript">

// Load the Visualization API and the controls package.
google.load("visualization", '1', {packages:['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var query = new google.visualization.Query(
'http://ift.tt/1M0dNkF');
query.send(handleQueryResponse);
}

function handleQueryResponse(response) {
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}

var data = response.getDataTable();
var chart = new google.visualization.ColumnChart(document.getElementById('columnchart'));
chart.draw(data, { legend: { position: 'none' } });
}
</script>

<title>Data from a Spreadsheet</title>
</head>

<body>
<span id='columnchart'></span>
</body>
</html>






<div id="EntireSite">

<div>
<?!= include('Chart'); ?>
</div>



enter image description here



Aucun commentaire:

Enregistrer un commentaire