diff --git a/page_profile/profil.css b/page_profile/profil.css index 6479734c8de162554c33bca70c1a9fc02f8b45da..eef143f4007cc3ed3bb7d6d3cd59fc05e1053006 100644 --- a/page_profile/profil.css +++ b/page_profile/profil.css @@ -87,7 +87,7 @@ div a:link{ color:red; } -#stats div{ +#stats + div{ width:100%; height:100%; border-top:0; @@ -133,3 +133,10 @@ a:link { text-align:center; margin:auto; } + +.title_graphs { + font-weight: bold; + color: white; + font-size: x-large; + text-shadow: black 0.1em 0.1em 0.2em +} diff --git a/page_profile/profil.php b/page_profile/profil.php index 84c30efc3924a08dfe114a4f95924ac74b8c68d4..a92ea2c782713a58309773ace409c36ac3f571f8 100644 --- a/page_profile/profil.php +++ b/page_profile/profil.php @@ -131,24 +131,156 @@ $youtube_fav = $_SESSION['youtube']; <div id='divindex' class='flex center sticky'> <div class='center orange' style='border-left:1px solid;'> - <a href='#a'> SON CHIFFRE D'AFFAIRE </a> + <a href='#a'> Evolution of Tweets likes </a> </div> <div class='center green'> - <a href='#b'> NOMBRE D'ABONNES </a> - </div> - <div class='center orange'> - <a href='#c'> LES PAYS CONQUIS </a> - </div> - <div class='center green'> - <a href='#d'> SON ACTIVITE </a> + <a href='#b'> Evolution of Tweets Retweets</a> </div> </div> <div id='stats'> - <div id='a'><br/><br/> SON CHIFFRE D'AFFAIRE<br/><br/><img src='graph.PNG' /></br><br/></div> - <div id='b'><br/><br/>NOMBRE D'ABONNES<br/><br/><img src='graph.PNG' /></br><br/></div> - <div id='c'><br/><br/>LES PAYS CONQUIS<br/><br/><img src='graph.PNG' /></br><br/></div> - <div id='d'><br/><br/>SON ACTIVITE<br/><br/><img src='graph.PNG' /></br><br/></div> + <div id='a'><br/><br/><span class="title_graphs">Evolution of Tweets Likes</span><br/><br/> + +<?php +/* Include the `fusioncharts.php` file that contains functions to embed the charts. */ +include("../graphs/fusioncharts-suite-xt/integrations/php/fusioncharts-wrapper/fusioncharts.php"); +require_once('../API_Twitter/tweetInfosFunctions.php'); +?> +<script type="text/javascript" src="../graphs/fusioncharts-suite-xt/js/fusioncharts.js"></script> +<script type="text/javascript" src="../graphs/fusioncharts-suite-xt/js/themes/fusioncharts.theme.fusion.js"></script> + <?php + // Nombre de tweets + $count = 50; + + // Chart Configuration stored in Associative Array + $arrChartConfig = array( + "chart" => array( + "caption" => "Evolution of likes : Last ".$count." tweets", + //"subCaption" => "In MMbbl = One Million barrels", + "xAxisName" => "Tweet (from most recent to oldest)", + "yAxisName" => "Likes", + "lineThickness" => "2", + "theme" => "fusion" + ) + ); + + // An array of hash objects which stores data + $arrChartData = []; + + $likes = getNbLikesOfUserByScreenName(getUserScreenName($id), $count); + + $likeMoyen = 0; + + $count = count($likes); + for ($i=0; $i<$count; $i++) { + $arrChartData[] = [ + 'label' => $i, + 'value' => $likes[$i] + ]; + $likeMoyen += $likes[$i]; + } + $likeMoyen = round($likeMoyen/$count, 2); + + // An array which stores trend-lines + $arrTrendLines = []; + $arrTrendLines[] = [ + "line" => [ + [ + "startvalue" => $likeMoyen, + "color" => "#1aaf5d", + "displayvalue" => "Like moyen = ".$likeMoyen, + "valueOnRight" => "1", + "thickness" => "2" + ] + ] + ]; + + $arrChartConfig["data"] = $arrChartData; + $arrChartConfig["trendLines"] = $arrTrendLines; + + // JSON Encode the data to retrieve the string containing the JSON representation of the data in the array. + $jsonEncodedData = json_encode($arrChartConfig); + + // chart object + $Chart = new FusionCharts("line", "MyFirstChart" , "700", "400", "chart-container", "json", $jsonEncodedData); + + // Render the chart + $Chart->render(); + ?> + <center> + <div id="chart-container">Chart will render here!</div> + </center> + + + + + </br><br/></div> + <div id='b'><br/><br/><span class="title_graphs">Evolution of Tweets Retweets</span><br/><br/> + + <?php + // Nombre de tweets + $count = 50; + + // Chart Configuration stored in Associative Array + $arrChartConfig = array( + "chart" => array( + "caption" => "Evolution of retweets : Last ".$count." tweets", + //"subCaption" => "In MMbbl = One Million barrels", + "xAxisName" => "Tweet (from most recent to oldest)", + "yAxisName" => "Retweets", + "lineThickness" => "2", + "theme" => "fusion" + ) + ); + + // An array of hash objects which stores data + $arrChartData = []; + + $retweets = getNbRetweetsOfUserByScreenName(getUserScreenName($id), $count); + + $retweetMoyen = 0; + + $count = count($retweets); + for ($i=0; $i<$count; $i++) { + $arrChartData[] = [ + 'label' => $i, + 'value' => $retweets[$i] + ]; + $retweetMoyen += $retweets[$i]; + } + $retweetMoyen = round($retweetMoyen/$count, 2); + + // An array which stores trend-lines + $arrTrendLines = []; + $arrTrendLines[] = [ + "line" => [ + [ + "startvalue" => $retweetMoyen, + "color" => "#1aaf5d", + "displayvalue" => "retweet moyen = ".$retweetMoyen, + "valueOnRight" => "1", + "thickness" => "2" + ] + ] + ]; + + $arrChartConfig["data"] = $arrChartData; + $arrChartConfig["trendLines"] = $arrTrendLines; + + // JSON Encode the data to retrieve the string containing the JSON representation of the data in the array. + $jsonEncodedData = json_encode($arrChartConfig); + + // chart object + $Chart = new FusionCharts("line", "MyFirstChart2" , "700", "400", "chart-container2", "json", $jsonEncodedData); + + // Render the chart + $Chart->render(); + ?> + <center> + <div id="chart-container2">Chart will render here!</div> + </center> + + </br><br/></div> </div> </div>