pChart 2.x forum http://wiki.pchart.net/forum/ |
|
Draw a chart with fixed x-axis limits with type time http://wiki.pchart.net/forum/viewtopic.php?f=1&t=40206 |
Page 1 of 1 |
Author: | poempel [ Sat Jan 11, 2014 6:32 pm ] |
Post subject: | Draw a chart with fixed x-axis limits with type time |
Hi! I want to plot measured temperature for a whole day with a reset on midnight. I would like to have the x-axis always starting at midnight and ending at midnight. I get my data from a csv file with the following example content: Code: Dat,Zeit,Temp 11.01.2014, 00:00, 20.062 11.01.2014, 00:15, 20.125 11.01.2014, 00:30, 20.062 11.01.2014, 00:45, 20.062 11.01.2014, 01:00, 20.125 I ignore the first column and plot with the following code: Code: <?php error_reporting (E_ALL | E_STRICT); ini_set ('display_errors' , 1); include("pChart/class/pData.class.php"); include("pChart/class/pDraw.class.php"); include("pChart/class/pImage.class.php"); $myData = new pData(); $myData->importFromCSV("daten/tempdaten.txt",array("GotHeader"=>TRUE,"SkipColumns"=>array(0))); $myData->setAbscissa("Zeit"); $myData->setSerieTicks("Temp",0); $myData->setAxisPosition(0,AXIS_POSITION_LEFT); $myData->setAxisUnit(0," °C"); $myData->setPalette("Temp",array("R"=>96,"G"=>159,"B"=>212,"Alpha"=>80)); $myPicture = new pImage(800,600,$myData,TRUE); $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>50,"G"=>50,"B"=>50,"Alpha"=>0)); $myPicture->setFontProperties(array("FontName"=>"pChart/fonts/GeosansLight.ttf","FontSize"=>14)); $TextSettings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE , "R"=>0, "G"=>0, "B"=>0); $myPicture->drawText(160,25,"Temperaturverlauf",$TextSettings); $myPicture->setShadow(FALSE); $myPicture->setGraphArea(50,50,780,500); $myPicture->setFontProperties(array("R"=>0,"G"=>0,"B"=>0,"FontName"=>"pChart/fonts/GeosansLight.ttf","FontSize"=>8)); $Settings = array("Pos"=>SCALE_POS_LEFTRIGHT , "Mode"=>SCALE_MODE_MANUAL , "ManualScale"=>array(1=>array("Min"=>0,"Max"=>24),0=>array("Min"=>16,"Max"=>23)) , "LabelingMethod"=>LABELING_ALL , "GridR"=>255, "GridG"=>255, "GridB"=>255, "GridAlpha"=>50, "TickR"=>0, "TickG"=>0, "TickB"=>0, "TickAlpha"=>50, "LabelRotation"=>0, "LabelSkip"=>15, "CycleBackground"=>1, "DrawXLines"=>1, "DrawYLines"=>ALL); $myPicture->drawScale($Settings); $Config = array("ForceTransparency"=>100); $myPicture->drawFilledSplineChart($Config); $myPicture->render("temperatur/heute_php.png"); ?> Where can I make it work like I want? Sorry, I am quite new to pChart. Perhaps my code is not the best |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |