<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Brand Monitoring stats</title>
<script type="text/javascript">
(function() {
$.getJSON( brandStatsAPI, {
after: "2013-01-01",
before: "2014-04-30"
})
.done(function( jsonData ) {
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart());
function drawChart() {
console.log(jsonData);
var data = google.visualization.arrayToDataTable(jsonData);
console.log(data);
var options = {
title: 'Brands presence'
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
})
.fail(function( jqxhr, textStatus, error ) {
var err = textStatus + ", " + error + jqxhr;
console.log( "Request Failed: " + err );
console.log(jqxhr);
});
})();
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
I tried to move "google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(drawChart());" to the top but doesn't work neither (drawChart doesn't declared). Have you any idea how I can do that ?
My use case is pretty simple, load a formatted json for google char and load it inside a line graph ! :)