Bonjour,

après mon code php , j'obtiens un tableau qui passé dans la fonction json_encode me donne le résultat suivant après echo $json_var :
[["15:42",7],["15:43",13],["15:44",20],["15:45",20],["15:46",20],["15:47",13],["15:48",10],["15:49",10],["15:50",3]]
j'ai suivi les instructions pour générer le graphe via google charts mais ça ne marche pas.
Besoin d'aide pour savoir ou se trouve l'erreur.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<html>
<head>
<!--Load the Ajax API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
 
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['corechart']});
 
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
 
function drawChart() {
 
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable();
data.addColumn('string','time');
data.addColumn('number', 'quantity');
data.addRows(<?=json_var?>);
 
var options = {
title: 'my_graph',
is3D: 'true',
width: 800,
height: 600
};
 
// Instantiate and draw our chart, passing in some options.
// Do not forget to check your div ID
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
 
<body>
<!--this is the div that will hold the pie chart-->
<div id="chart_div"></div>
</body>
</html>