I am using google visualization to draw charts from data that I am sending by JSON. I read the data with JQUERY, however, when I want to use it in the javascript I get the variable undefined problem. Here is my code:
google.load("jquery", "1.3.2");
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(function(){
$.get("http://localhost:8081/petclinic/users/7/campaigns/2/queries/4/analyze", function(data){
console.log(data);
results.push(data[0][0]);
results.push(data[0][1]);
for (var i = 1; i < data.length; i++) {
results.push(data[i][0]);
results.push(parseInt(data[i][1]));
}
console.log(results);
});
var data = google.visualization.arrayToDataTable(results);
var options = {
title: 'Company Performance'
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
});