Professional Documents
Culture Documents
de Marrakech (FSSM)
Année Universitaire
2022/2023
Crud php native :
Utilisation de Pie chart pour afficher le graphe des etudiant selon leur dilome:
Code du gaphe :
<?php
include("connexion.php");
connexion();
$result = mysqli_query($conn,"SELECT diplome , count(*) as nbr FROM student
group by diplome");
$i=1;
while($row = mysqli_fetch_array($result)) {
$dataPoints []= array("label"=>$row["diplome"], "y"=>$row["nbr"]);
}
?>
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
title: {
text: "Graphe des etudiant selon leur diplome"
},
subtitles: [{
text: "janvier 2023"
}],
data: [{
type: "pie",
yValueFormatString: "#,##0.00\"%\"",
indexLabel: "{label} ({y})",
dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?
>
}]
});
chart.render();
}
</script>
</head>
<body>
<div id="chartContainer" style="height: 370px; width: 100%;"></div>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
</body>
</html>