Initial Github commit
This commit is contained in:
70
webdata/wallboard/30min24hr.php
Normal file
70
webdata/wallboard/30min24hr.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/* Include all the classes */
|
||||
include("../graph/pchart/class/pData.class.php");
|
||||
include("../graph/pchart/class/pDraw.class.php");
|
||||
include("../graph/pchart/class/pImage.class.php");
|
||||
include("../includes/db_config.php");
|
||||
if(isset($_GET['port'])){
|
||||
$varService = $_GET['port'];
|
||||
}else{
|
||||
$varService = 0;
|
||||
}
|
||||
|
||||
/* Create your dataset object */
|
||||
$myData = new pData();
|
||||
|
||||
$db = mysql_connect($servername, $username, $password); //location of server, db username, db pass
|
||||
mysql_select_db("$dbname", $db);
|
||||
|
||||
$Requete = "SELECT amount, time, type FROM stats WHERE service = '".$varService."' and type = '30min' AND time > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 24 HOUR) ORDER BY time"; //table name
|
||||
$Result = mysql_query($Requete, $db);
|
||||
|
||||
/*This fetches the data from the mysql database, and adds it to pchart as points*/
|
||||
while($row = mysql_fetch_array($Result))
|
||||
{
|
||||
//$Sample_Number = $row["Sample_Number"]; //Not using this data
|
||||
//$myData->addPoints($Sample_Number,"Sample_Number");
|
||||
|
||||
$Time = $row["time"];
|
||||
$myData->addPoints($Time,"time");
|
||||
|
||||
$Amt = $row["amount"];
|
||||
$myData->addPoints($Amt,"amount");
|
||||
|
||||
// $Type = $row["type"];
|
||||
// $myData->addPoints($Type,"type");
|
||||
}
|
||||
|
||||
$myData-> setSerieOnAxis("amount", 0); //assigns the data to the frist axis
|
||||
$myData-> setAxisName(0, "# of Connections"); //adds the label to the first axis
|
||||
|
||||
//$myData-> setSerieOnAxis("type", 1);
|
||||
//$myData-> setAxisName(1, "Service");
|
||||
|
||||
$myData-> setAxisPosition(1,AXIS_POSITION_LEFT); //moves the second axis to the far left
|
||||
|
||||
$myData->setAbscissa("time"); //sets the time data set as the x axis label
|
||||
|
||||
|
||||
$myPicture = new pImage(900,320,$myData); /* Create a pChart object and associate your dataset */
|
||||
$rectsettings = array("R"=>40, "G"=>40, "B"=>40, "Dash"=>1, "DashR"=>80, "DashG"=>80, "DashB"=>80);
|
||||
$myPicture->drawFilledRectangle(0,0,900,320,$rectsettings);
|
||||
$myPicture->setFontProperties(array("FontName"=>"../graph/pchart/fonts/verdana.ttf","FontSize"=>8, "R"=>248, "G"=>248, "B"=>248)); /* Choose a nice font */
|
||||
|
||||
$myPicture->setGraphArea(60,20,850,200); /* Define the boundaries of the graph area */
|
||||
|
||||
$Settings = array("R"=>40, "G"=>40, "B"=>40, "Dash"=>1, "DashR"=>255, "DashG"=>255, "DashB"=>255);
|
||||
|
||||
$myPicture->drawScale(array("LabelRotation"=>295)); /* Draw the scale, keep everything automatic */
|
||||
$myPicture->drawFilledRectangle(60,20,850,200,array("R"=>46,"G"=>46,"B"=>46,"Surrounding"=>-200,"Alpha"=>10));
|
||||
/*The combination makes a cool looking graph*/
|
||||
$myPicture->drawPlotChart();
|
||||
$myPicture->drawLineChart();
|
||||
|
||||
|
||||
//$myPicture->drawLegend(90,20); //adds the legend
|
||||
|
||||
$myPicture->autoOutput(); /* Build the PNG file and send it to the web browser */
|
||||
|
||||
?>
|
Reference in New Issue
Block a user