View unanswered posts | View active topics It is currently Sun Jul 21, 2024 11:29 pm



Reply to topic  [ 11 posts ]  Go to page 1, 2  Next
Datetime at irregular intervals 
Author Message
pChart user
pChart user

Joined: Thu Feb 03, 2011 11:01 am
Posts: 4
Post Datetime at irregular intervals
First of all thanks for the very good chart Library!

I had the problem that I wanted to display a datetime series on the x axis which had irregular intervals. But the current version of pChart doesn't seem to support this way of scaling.
Attachment:
File comment: current
test_current_02.png
test_current_02.png [ 14.99 KiB | Viewed 34078 times ]


I expected it to look like this:
Attachment:
File comment: expected
test_expected_02.png
test_expected_02.png [ 13.26 KiB | Viewed 34078 times ]


I've just added the necessary functionality to auto scale to the drawScale, the drawStepChart and the drawFilledStepChart functions - more will come soon.
Find the unified diff file for pChart 2.1.0 attached.

It also adds the functionality to display lines in regular intervals:
Attachment:
File comment: current_lines
test_current_02_lines.png
test_current_02_lines.png [ 23.95 KiB | Viewed 34078 times ]


I hope you'll find it useful.


Fri Feb 04, 2011 2:35 pm
Profile
pChart user
pChart user

Joined: Thu Feb 03, 2011 11:01 am
Posts: 4
Post Re: Datetime at irregular intervals
Here is the attachment...

Attachment:
File comment: unified diff
pDraw.class.php_2.1.0.diff.zip [3.63 KiB]
Downloaded 1869 times


Fri Feb 04, 2011 2:38 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post Re: Datetime at irregular intervals
I really like this, I'll dig into it to integrate what's missing.

Thank you ;o)


Fri Feb 04, 2011 2:42 pm
Profile WWW
pChart user
pChart user

Joined: Thu Feb 03, 2011 11:01 am
Posts: 4
Post Re: Datetime at irregular intervals
Here is also some sample code (based on the stepchart example):

Code:
<?php   
/* CAT:Step chart */

/* 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(-4,VOID,VOID,12,8,3),"Probe 1");
$MyData->addPoints(array(3,12,15,8,5,-5),"Probe 2");
$MyData->addPoints(array(2,7,5,18,19,22),"Probe 3");
$MyData->setSerieTicks("Probe 2",4);
$MyData->setAxisName(0,"Temperatures");
$MyData->addPoints(array(1296299019,1296302903,1296307001,1296308071,1296309901,1296318931),"Labels");
$MyData->setSerieDescription("Labels","Timestamp");
$MyData->setXAxisDisplay(AXIS_FORMAT_DATE,"H:i");
$MyData->setAbscissa("Labels");

/* Create the pChart object */
$myPicture = new pImage(700,230,$MyData);

/* Draw the background */
$Settings = array("R"=>170, "G"=>183, "B"=>87, "Dash"=>1, "DashR"=>190, "DashG"=>203, "DashB"=>107);
$myPicture->drawFilledRectangle(0,0,700,230,$Settings);

/* Overlay with a gradient */
$Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);
$myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,$Settings);
$myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>80));

/* Add a border to the picture */
$myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));

/* Write the picture title */
$myPicture->setFontProperties(array("FontName"=>"../fonts/Silkscreen.ttf","FontSize"=>6));
$myPicture->drawText(10,13,"drawStepChart() - draw a step chart",array("R"=>255,"G"=>255,"B"=>255));

/* Write the chart title */
$myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>11));
$myPicture->drawText(250,55,"Average temperature",array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));

/* Draw the scale and the 1st chart */
$myPicture->setGraphArea(60,60,450,190);
$myPicture->drawFilledRectangle(60,60,450,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
$myPicture->drawScale(array("DrawSubTicks"=>TRUE,"LabelShowBoundaries"=>TRUE,"ScaleModeAuto"=>TRUE));
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
$myPicture->setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf","FontSize"=>6));
$myPicture->drawStepChart(array("DisplayValues"=>TRUE,"DisplayColor"=>DISPLAY_AUTO,"ScaleModeAuto"=>TRUE));
$myPicture->setShadow(FALSE);

/* Draw the scale and the 2nd chart */
$myPicture->setGraphArea(500,60,670,190);
$myPicture->drawFilledRectangle(500,60,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
$myPicture->drawScale(array("Pos"=>SCALE_POS_TOPBOTTOM,"DrawSubTicks"=>TRUE,"ScaleModeAuto"=>TRUE));
$myPicture->setShadow(TRUE,array("X"=>-1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
$myPicture->drawStepChart(array("ScaleModeAuto"=>TRUE));
$myPicture->setShadow(FALSE);

/* Write the chart legend */
$myPicture->drawLegend(510,205,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));

/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawStepChart.png");
?>


Result:
Attachment:
File comment: step chart auto scale
example.drawStepChartAutoScale.png
example.drawStepChartAutoScale.png [ 30.38 KiB | Viewed 34070 times ]


Fri Feb 04, 2011 3:00 pm
Profile
Experienced pChart user
Experienced pChart user

Joined: Wed Dec 22, 2010 9:00 pm
Posts: 30
Post Re: Datetime at irregular intervals
jean-damien wrote:
I really like this, I'll dig into it to integrate what's missing.

Thank you ;o)


Jean-damien,

Does this mean we can expect the datetime x-axis to work this way from now on? The improper spacing of datetime scales has been one of my biggest compliants about this library.

I don't mean to complain too much. This is a fantastic project and I use your library with a lot of respect for you Jean-damien


Last edited by sidkdbl07 on Wed Feb 09, 2011 10:30 pm, edited 1 time in total.



Tue Feb 08, 2011 12:24 am
Profile
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post Re: Datetime at irregular intervals
Hi,

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.

Kind regards,
JD.


Tue Feb 08, 2011 8:39 am
Profile WWW
New pChart user
New pChart user

Joined: Sun Jul 17, 2011 10:24 am
Posts: 1
Post Re: Datetime at irregular intervals
hi lukasr, what is the right way to apply the patch? i try to do this

Code:
patch < pDraw.class.php_2.1.0.diff


but i always get error messages saying hunk failed. Thanks before :)

update : silly of me :lol: , all of the problem because the file is dos type


Tue Aug 02, 2011 9:51 am
Profile
New pChart user
New pChart user

Joined: Mon Oct 24, 2011 7:30 pm
Posts: 1
Post Re: Datetime at irregular intervals
Hi,
is the patch already included in newer versions?
Is it possible for DrawLineChart, also?

Regards
form


Mon Oct 24, 2011 7:33 pm
Profile
pChart user
pChart user

Joined: Fri Nov 11, 2011 12:32 am
Posts: 4
Post Re: Datetime at irregular intervals
I would need this as well - ;-)


Fri Nov 11, 2011 1:53 pm
Profile
pChart user
pChart user

Joined: Mon Jul 09, 2012 9:23 pm
Posts: 4
Post Re: Datetime at irregular intervals
Hi !!!
Same problem!

Is newest version integer this capabiliies?

THNAX


Thu Jul 12, 2012 7:53 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 11 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users and 4 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