You are on page 1of 3

Université Cadi Ayyad Faculté des Sciences Semlalia

de Marrakech (FSSM)

Exam Les graphes des


etudiant selon leur diplome

Module : Programmation Préparer par :


PHP avancée
EL BALFYQY ASMA
Filière: LP--‐TW
Prof: Ahmed EL OIRRAK

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>        

You might also like