|
|
Page 1 of 1
|
[ 7 posts ] |
|
[Solved] TimeSeries support?
Author |
Message |
zigzag
pChart user
Joined: Wed Jan 04, 2012 10:02 pm Posts: 5
|
[Solved] TimeSeries support?
[Sorry for my bad english] Hello, thank you for this great library, but despite reading almost all the documentation, i haven't found a way to generate time series graphs. Here's a sample dataset : (please note the timestamp in this example is "human readable" dd/mm@hh:mm) Serie 1 (Probe 1) Timestamp | Level 02/01@10:00| 0.11 02/01@14:00| 0.91 03/01@08:00| 0.58 04/01@10:00| 1.11 Serie 2 (Probe 2) 02/01@10:00| 1.18 03/01@18:30| 0.1 04/01@20:48| 2.1 No data Serie 3 (Probe 3) 02/01@10:00| 0.14 02/01@14:00| 1.02 03/01@09:00| 0.73 04/01@10:00| 0.80 Pchart allow me to display my datas (level) with one adaptive Y-scale, but on the X-scale i'm stuck, i can't pass the timestamp of all my Series without ruining the graph I know this can be done with Jpgraph ( LinePlot($datay,$datax) ), but i really don't want jpgraph anymore. Thank you
Last edited by zigzag on Thu Jan 12, 2012 2:54 pm, edited 1 time in total.
|
Wed Jan 04, 2012 10:25 pm |
|
|
mila76
Regular pChart user
Joined: Mon Dec 19, 2011 12:19 am Posts: 14
|
Re: TimeSeries support?
|
Thu Jan 05, 2012 3:18 am |
|
|
zigzag
pChart user
Joined: Wed Jan 04, 2012 10:02 pm Posts: 5
|
Re: TimeSeries support?
Hello, yes :
$MyData->setXAxisDisplay(AXIS_FORMAT_TIME,"d/m\nH:i");
|
Thu Jan 05, 2012 4:13 am |
|
|
mila76
Regular pChart user
Joined: Mon Dec 19, 2011 12:19 am Posts: 14
|
Re: TimeSeries support?
post your code, this example work Code: <?php /* pChart library inclusions */ include("../class/pData.class.php"); include("../class/pDraw.class.php"); include("../class/pImage.class.php");
/* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(0.11, 0.91, 0.58, 1.11),"Probe 1"); $MyData->setAxisName(0,"Temperatures"); $MyData->addPoints(array(1328112000, 1328126400, 1330610400, 1330617600),"Labels"); $MyData->setAbscissa("Labels"); $MyData->setXAxisDisplay(AXIS_FORMAT_TIME,"d/m\nH:i");
/* Create the pChart object */ $myPicture = new pImage(600,280,$MyData);
/* Turn of Antialiasing */ $myPicture->Antialias = FALSE;
/* Add a border to the picture */ $myPicture->drawRectangle(0,0,599,279,array("R"=>0,"G"=>0,"B"=>0)); /* Set the default font */ $myPicture->setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf","FontSize"=>6));
/* Define the chart area */ $myPicture->setGraphArea(40,16,580,244);
/* Draw the scale */ $scaleSettings = array("XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE); $myPicture->drawScale($scaleSettings);
/* Turn on Antialiasing */ $myPicture->Antialias = TRUE;
/* Draw the line chart */ $myPicture->drawLineChart();
/* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawLineChart.simple.png"); ?>
Attachments:
ex.png [ 8.97 KiB | Viewed 8614 times ]
|
Thu Jan 12, 2012 10:52 am |
|
|
zigzag
pChart user
Joined: Wed Jan 04, 2012 10:02 pm Posts: 5
|
Re: TimeSeries support?
Hi, i don't have the original code since i found a solution. I'm going to try to explain what's wrong with this code. Code: $MyData->addPoints(array(0.11, 0.91, 0.58, 1.11),"Probe 1"); $MyData->setAxisName(0,"Temperatures"); $MyData->addPoints(array(1328112000, 1328126400, 1330610400, 1330617600),"Labels"); This code IS working, but for ONE probe and ONE timestamp, or X probes that have exactly the same timestamps. I have 5 probes, and for each probe i have both the timestamp and the data. With your code, you can have 5 probes but the probes have to share the same timestamp as you defined here : $MyData->addPoints(array(1328112000, 1328126400, 1330610400, 1330617600),"Labels"); The workaround i've found is to merge all my timestamps and add VOIDs to my probe datas if timestamp is not found. Sorry if it's confusing, i know my english is not good.
|
Thu Jan 12, 2012 12:11 pm |
|
|
mila76
Regular pChart user
Joined: Mon Dec 19, 2011 12:19 am Posts: 14
|
Re: TimeSeries support?
Quote: Sorry if it's confusing, i know my english is not good. your point is clear... for how pChart work i don't think there is another way in this topic viewtopic.php?f=1&t=173 jean-damien says: Quote: I'm thinking on how to get it implemented yes. My guess is that non-linear X scales will be implemented directly withing the current scaling methods. This will force a rewritting of some part of the scaling and charting functions --nothing too complicated hopefully.
I can't promise it for the next sub release but it will come in the following one.
Last edited by mila76 on Fri Jan 13, 2012 7:11 pm, edited 1 time in total.
|
Thu Jan 12, 2012 1:17 pm |
|
|
zigzag
pChart user
Joined: Wed Jan 04, 2012 10:02 pm Posts: 5
|
Re: TimeSeries support?
Ok, thanks for your help, hope this feature will come with the next pChat release
|
Thu Jan 12, 2012 2:54 pm |
|
|
|
Page 1 of 1
|
[ 7 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 16 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
|
|
|