Salut à tous

J'utilise Google Chart Tools pour un projet mais j' rencontre un ptit soucis sur lequel je coinces depuis un bon moment et ça commence à sévèrement me taper sur les nerfs ...

Je récupère mes infos en BDD en ajax, voilà ma petite fonction :

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
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
 
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(stat_homme_femme);
 
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function stat_homme_femme()
{
    var jsonData = $.ajax({
        url: "./include/traitement_stat.php",
        type: "POST",
        data: "h_f=1",
        dataType: 'json',
        async: false
    }).responseText;
 
    // Create our data table out of JSON data loaded from server.
      var data = new google.visualization.DataTable();
      data.addColumn('string', 'Topping');
      data.addColumn('number', 'Slices');
      data.addRows(jsonData);
 
      // Instantiate and draw our chart, passing in some options.
      var chart = new google.visualization.PieChart(document.getElementById('chart_hf'));
      chart.draw(data, {width: 400, height: 240});
}

la requête Ajax récupère les données après passage dans un json_encode dans ma fonction PHP

Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
$tab = array(
    array('Homme', 3),
    array('Femme', 3)
);
return json_encode($tab, JSON_NUMERIC_CHECK);

ce qui me renvoi le résultat sous cette forme

Code : Sélectionner tout - Visualiser dans une fenêtre à part
[["Homme",3],["Femme", 3]]
Lorsque je recharge ma page, j'ai firebug qui hurle en me disant "Error: Argument given to addRows must be either a number or an array"

Mais si je je remplace

Code : Sélectionner tout - Visualiser dans une fenêtre à part
data.addRows(jsonData);
par

Code : Sélectionner tout - Visualiser dans une fenêtre à part
data.addRows([["Homme",3],["Femme",3]]);
Et bien le camembert s'affiche comme il faut ...

Si quelqu'un peut me donner un ptit coup de patte ce serait vraiment cool !

Merci d'avance