Depuis ce matin, j'essaie de faire afficher le camembert (pie) en utilisant les datas sql.
Peut-etre que j'ai oublié un truc
merci beaucoup de votre aide
<?php
include 'includes/functions.php';
$dbconnect = mysql_connect($dbhost,$dblogin,$dbpass);
mysql_query("SET NAMES UTF8");
$select = mysql_select_db($dbbase, $dbconnect);
$sql = "SELECT COUNT(rne) AS rne, dept FROM anuetab GROUP BY dept";
while($row = mysql_fetch_assoc($sql)){
$data[] = array(
'label'=>$row['dept'],
'data'=>$row['rne']
);
// echo '<pre>';
// print_r($data);
// echo '</pre>';
}
echo json_encode($data);
?>
[javascript] $(function () { $.ajax({
type:'POST',
dataType: "JSON",
url:'source_pie.php',
success: function(data) {
$.plot($("#pie2"), [data], {
series: {
pie: {
show: true,
radius: 1,
label: {
show: true,
radius: 2 / 3,
formatter: function(label, series)
{
return "<div style='font-size:11px; text-align:center; padding:2px; color:white;'>"+label+"<br/>"
+Math.round(series.percent)+"%</div>";
},
background:
{
opacity: 0.8
}
}
}
},
legend: {
show: false
},
grid:
{
hoverable: true
}
});
}
});
});
[/javascript]