Good morning, I have the following problem with Google Charts, I have created a script to load data in the chart through json and ajax, once the data is loaded, I can see them through console.log but when showing the graph it gives me the mistake..THANKS
Uncaught TypeError: google.visualization.PieChart is not a constructor
<script type="text/javascript">
google.charts.load('current', {'packages':['line']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
$.ajax({
url: "data.php?ne=<? echo $equipo;?>",
dataType: "json",
success: function (jsonData) {
var data = new google.visualization.DataTable();
// assumes "word" is a string and "count" is a number
data.addColumn('number', 'Day');
data.addColumn('number', 'C1');
data.addColumn('number', 'C2');
data.addColumn('number', 'C3');
for (var i = 0; i < jsonData.length; i++) {
console.log(jsonData[i]['c1'])
data.addRow([jsonData[i]['number'], 50, 5, 3]);
}
var options = {
chart: {
title: '<? echo $equipo;?>',
},
width: 300,
height: 200,
legend: {position: 'none'}
};
var chart = new google.visualization.PieChart(document.getElementById('<? echo $equipo;?>'));
chart.draw(data, options);
}
});
}