From 4f61c1a7ba8e633fd11ef4213134c89b6057cbc8 Mon Sep 17 00:00:00 2001
From: hugo <hugo.sellambin1@gmail.com>
Date: Wed, 18 Dec 2019 23:23:30 +0100
Subject: [PATCH] ajout graphique favoris

---
 favoris.php | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/favoris.php b/favoris.php
index 287cc8f..2e12a74 100644
--- a/favoris.php
+++ b/favoris.php
@@ -67,7 +67,10 @@ if (isset($_SESSION["authent"]) && $_SESSION['authent'] == 0){
             
         </table>
         <?php if ($compt2==1) echo "Pas de favoris <br/><br/><br/>"; ?>
-
+    </div>
+</section>
+<section class="one" style="background-color:#efefef;">
+    <div class="container">
         <h2>Mes Favoris</h2>
         <div class="divider"></div>
         <table class="table">
@@ -101,8 +104,51 @@ if (isset($_SESSION["authent"]) && $_SESSION['authent'] == 0){
         </table>
     </div>
 </section>
+<section class="one">
+    <div class="container">
+        <h2>Statistiques</h2>
+        <div class="divider"></div>
+        <div id="chartContainer" style="height: 370px; max-width: 920px; margin: 0px auto;"></div>
+        
+    </div>
+</section>
+
+<script src="ressources/canvasjs/canvasjs.min.js"></script>
+<script>
+
+var influ = new Array();
+<?php 
+$result2 = mysqli_query($link, "SELECT nom_artiste, nb_youtube + nb_instagram as nb, tag_instagram FROM influenceurs NATURAL JOIN favoris WHERE nb_youtube != 0 && nb_instagram != 0 && id_user = ".$_SESSION["id"]." ORDER BY nb DESC LIMIT 10");
+while($row = mysqli_fetch_assoc($result2)) :?>
+    influ.push({y: <?= $row['nb'] ?>,label: '<?= $row['nom_artiste'] ?>'});
+<?php endwhile; ?>
+
 
+window.onload = function () {
 
+var chart = new CanvasJS.Chart("chartContainer", {
+    backgroundColor: "transparent ",
+	theme: "theme2",
+	animationEnabled: true,
+	title:{
+		text: "Répartitions des 10 premier favoris"
+	},
+	legend:{
+		cursor: "pointer",
+	},
+	data: [{
+		type: "doughnut",
+        innerRadius: 90,
+        toolTipContent: "<b>{label}</b>: {y} foollowers (#percent%)",
+		dataPoints: influ,
+	}]
+});
+chart.options.data[0].dataPoints = influ;
+chart.render();
+
+
+}
+</script>
 
 <?php   
 include "footer.php"
-- 
GitLab