only use last 5 days of data help

please can you help me i am trying to get my graph to only show last 5 days of data and only the dates and not dates and times thanks for looking

[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”, “dangun”);
mysql_select_db(“tempmonitor”,$db);

/* Build the query that will returns the data to graph */
$Requete = “SELECT * FROM 8conv“;
$Requete = $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 = TRUE;

/* 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”);
$MyData->setXAxisDisplay(AXIS_FORMAT_CUSTOM,“XAxisFormat”);

$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();

function YAxisFormat($Value) { return(abs($Value)); }

?>[/code]

can u tell/show us how does your database look like ?

Instead of:
$Requete = "SELECT * FROM 8conv";
You can try:
$Requete = “SELECT * FROM 8conv WHERE timestamp BETWEEN timestamptoday AND timestamp5daysago ORDER BY timestamp ASC”;
Where you replace timestamptoday and timestamp5days ago with the appropriate timestamps.

Instead of:
$MyData->setXAxisDisplay(AXIS_FORMAT_CUSTOM,“XAxisFormat”);
You can try:
$MyData->setXAxisDisplay(AXIS_FORMAT_DATE,“Y-m-d”);

Sponsor our Newsletter | Privacy Policy | Terms of Service