dimanche 19 avril 2015

Uncaught TypeError: string is not a function - on google Chart

Hi i have 2 google chart (1 calendar and the other LineChart) im getting the Uncaught TypeError: string is not a function and Uncaught TypeError: undefined is not a function. Yesterday it worked fine and i could see the two, but today i get this error and i can only display one of the char or the calendar. In separated files i dont get any error, i revised the json and it shows the data i want to retrieve.



<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="http://ift.tt/JuZcy0"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">

// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':["corechart"]});

google.load("visualization", "1.1", {packages:["calendar"]});

// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawCalendar);


function drawCalendar() {

$.ajax({
url: 'getCalendario.php',
dataType: 'json',
success: function (jsonData) {
var options = {
title: "Calendario",
height: 200,

daysOfWeek: 'LMMJVSD'
};


// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable(jsonData);
var chart = new google.visualization.Calendar(document.getElementById('calendar'));



// Instantiate and draw our chart, passing in some options.

chart.draw(data, options);
}
});
$.ajax({
url: 'getChart.php',
dataType: 'json',
success: function (jsonData) {
// Create our data table out of JSON data loaded from server.
var options = {
title: 'Estado de Bateria',
width: 800,
height: 400,
vAxis: {
minValue: 0,
maxValue: 100,

}

};
var data = new google.visualization.DataTable(jsonData);

// Instantiate and draw our chart, passing in some options.
var chartBat = new google.visualization.LineChart(document.getElementById('battery'));


chartBat.draw(data, options);
}
});
}
</script>
</head>

<body>
<!--Div that will hold the pie chart-->
<div id="calendar" ></div>
<div id="battery"></div>
</body>
</html>

Aucun commentaire:

Enregistrer un commentaire