Advertisement
Guest User

Untitled

a guest
Jun 12th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.03 KB | None | 0 0
  1. <?php
  2. /*
  3.  * Server status chart generation
  4.  */
  5.  
  6. // Include the chart libraries
  7. include("pChart/pData.class");
  8. include("pChart/pChart.class");
  9.  
  10. // Get Data from MySQL and add points to graph
  11.  
  12. $DataSet = new pData;
  13.  
  14.  
  15. $db_host = "localhost";
  16. $db_user = "*USERNAME*";
  17. $db_pass = "*PASSWORD*";
  18. $db_name = "ninjagam_serversq";
  19.  
  20. $db_link = mysql_connect($db_host, $db_user, $db_pass);
  21. if(!$db_link){
  22.     die("MySQL Error:". mysql_error());
  23. }
  24. $sql_db = mysql_select_db($db_name,$db_link);
  25. if(!$sql_db){
  26.     die("MySQL Error:". mysql_error());
  27. }
  28.  
  29. $query = "SELECT `PLAYERS`
  30. FROM `historicaldata`
  31. ORDER BY `ID` DESC
  32. LIMIT 288";
  33.  
  34. $result = mysql_query($query,$db_link);
  35. while($row = mysql_fetch_array($result))
  36. {
  37.     $DataSet->AddPoint($row['PLAYERS'],"Serie1");
  38. }
  39. $DataSet->AddAllSeries();
  40.  
  41. $DataSet->SetSerieName("Players","Serie1");
  42. $DataSet->SetYAxisName("Players");
  43.  
  44. // Initialise the graph
  45. $Graph = new pChart(600,180);
  46. $Graph->setFontProperties("Fonts/tahoma.ttf",8);
  47. $Graph->setGraphArea(570,50,20,150);
  48. $Graph->drawFilledRoundedRectangle(7,7,590,170,5,240,240,240);
  49. $Graph->drawRoundedRectangle(5,5,595,175,5,17,17,17);
  50. $Graph->drawGraphArea(255,255,255,TRUE);
  51. $Graph->setFixedScale(0,18,3,0,0,5);
  52. $Graph->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,1,FALSE,50,FALSE);
  53. $Graph->drawGrid(4,TRUE,230,230,230,50);
  54.  
  55. // Draw the 0 line
  56. $Graph->setFontProperties("Fonts/tahoma.ttf",6);
  57. $Graph->drawTreshold(0,143,55,72,TRUE,TRUE);
  58.  
  59. // Draw the line graph
  60. $Graph->setLineStyle(5,0);
  61. $Graph->setcolorPalette(0,0,51,204);
  62. $Graph->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());
  63. // $Graph->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);
  64.  
  65. //Finish the graph
  66. $Graph->setFontProperties("Fonts/tahoma.ttf",8);
  67. $Graph->drawLegend(75,35,$DataSet->GetDataDescription(),255,255,255);    
  68. $Graph->setFontProperties("Fonts/tahoma.ttf",10);
  69. $Graph->drawTitle(60,22,"Players - Past 24 hours",50,50,50,585);
  70. $Graph->Render("players.png");
  71. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement