View unanswered posts | View active topics It is currently Thu Mar 28, 2024 11:26 am



Reply to topic  [ 1 post ] 
Draw a chart with fixed x-axis limits with type time 
Author Message
New pChart user
New pChart user

Joined: Sat Jan 11, 2014 6:25 pm
Posts: 1
Post 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 ;)


Sat Jan 11, 2014 6:32 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron