chris666uk1
New pChart user
Joined: Sat Oct 15, 2011 10:21 pm Posts: 1
|
dates and times help please
right i got as far as adding datetime and got it working from database ok but when it add more than 5 days in mysql dates go messed up also how can i force it to show only the last 5 days in the dates and remove the times just show dates thanks for help Code: <?php /* CAT:Line chart */
/* pChart library inclusions */ include("pchart/class/pData.class.php"); include("pchart/class/pDraw.class.php"); include("pchart/class/pImage.class.php");
/* Create and populate the pData object */ $MyData = new pData();
/* Connect to the MySQL database */ $db = mysql_connect("localhost", "8conv", "******"); mysql_select_db("tempmonitor",$db);
/* Build the query that will returns the data to graph */ $Requete = "SELECT * FROM `8conv`"; $Result = mysql_query($Requete,$db); $timestamp=""; $temp1=""; $temp2=""; $temp3=""; $temp4=""; $temp5=""; $temp6=""; while($row = mysql_fetch_array($Result))
{ /* Get the data from the query result */ $timestamp = $row["timestamp"]; $temp1 = $row["temp1"]; $temp2 = $row["temp2"]; $temp3 = $row["temp3"]; $temp4 = $row["temp4"]; $temp5 = $row["temp5"]; $temp6 = $row["temp6"]; /* Save the data in the pData array */ $MyData->addPoints($timestamp,"timestamp"); $MyData->addPoints($temp1,"temp1"); $MyData->addPoints($temp2,"temp2"); $MyData->addPoints($temp3,"temp3"); $MyData->addPoints($temp4,"temp4"); $MyData->addPoints($temp5,"temp5"); $MyData->addPoints($temp6,"temp6"); }
/* Create the pChart object */ $myPicture = new pImage(900,400,$MyData);
/* Turn of Antialiasing */ $myPicture->Antialias = FALSE;
/* Draw the background */ $Settings = array("R"=>171, "G"=>179, "B"=>177);
$myPicture->drawFilledRectangle(0,0,900,400,$Settings);
$myPicture->drawRectangle(0,0,899,399,array("R"=>0,"G"=>0,"B"=>0));
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>50,"G"=>50,"B"=>50,"Alpha"=>20));
$myPicture->setFontProperties(array("FontName"=>"pchart/fonts/Forgotte.ttf","pchart/fontsize"=>14)); $TextSettings = array("Align"=>TEXT_ALIGN_TOPMIDDLE , "R"=>8, "G"=>8, "B"=>8); $myPicture->drawText(450,25,"8 Conv Temps",$TextSettings);
$MyData->setAxisName(0,"Temps oC ");
$myPicture->setShadow(FALSE); $myPicture->setGraphArea(50,50,875,360); $myPicture->setFontProperties(array("R"=>0,"G"=>0,"B"=>0,"FontName"=>"pchart/fonts/pf_arma_five.ttf","pchart/fontsize"=>6));
$MyData->setAbscissa("timestamp"); $MyData->setAbscissaName("Dates"); $Settings = array("Pos"=>SCALE_POS_LEFTRIGHT
, "Mode"=>SCALE_MODE_FLOATING , "LabelingMethod"=>LABELING_ALL , "GridR"=>255, "GridG"=>255, "GridB"=>255, "GridAlpha"=>50, "TickR"=>0, "TickG"=>0, "TickB"=>0, "TickAlpha"=>50, "LabelRotation"=>0, "CycleBackground"=>1, "DrawXLines"=>1, "DrawSubTicks"=>1, "SubTickR"=>255, "SubTickG"=>0, "SubTickB"=>0, "SubTickAlpha"=>50, "DrawYLines"=>ALL); $myPicture->drawScale($Settings);
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>50,"G"=>50,"B"=>50,"Alpha"=>10));
$Config = array("DisplayValues"=>1, "BreakVoid"=>0, "BreakR"=>234, "BreakG"=>55, "BreakB"=>26); $myPicture->drawSplineChart($Config);
$Config = array("FontR"=>0, "FontG"=>0, "FontB"=>0, "FontName"=>"pchart/fonts/pf_arma_five.ttf", "pchart/fontsize"=>6, "Margin"=>6, "Alpha"=>30, "BoxSize"=>5, "Style"=>LEGEND_NOBORDER , "Mode"=>LEGEND_HORIZONTAL ); $myPicture->drawLegend(50,10,$Config);
$myPicture->stroke(); ?>
|