View unanswered posts | View active topics It is currently Fri Mar 01, 2024 1:56 pm

Reply to topic  [ 4 posts ] 
Author Message
Regular pChart user
Regular pChart user

Joined: Wed Jun 01, 2011 11:42 am
Posts: 9
Hi there

I felt in the pitfall, that AXIS_FORMAT_TIME is not meant to be a duration measurement but a 24h clock measure. So because I record runtime durations of tasks (hh:mm:ss), this was not suitable because they may exceed 24h and the am/pm format is also not suitable.

Now here comes the hack:

pData.class.php (add to the axis configuration starting at line 16:
define("AXIS_FORMAT_DURATION", 680006);

pDraw.class.php (add to the scaleFormat function starting at line 2765):
if ( $Mode == AXIS_FORMAT_DURATION ) {
$hours = floor($Value / 3600);
$Value -= $hours * 3600;
$minutes = floor($Value / 60);
$seconds = $Value % 60;
return (sprintf("%d:%02d:%02d", $hours, $minutes, $seconds));

Formatting is not supported in this hack, however it's quiet easy changeable until it may get it's way into the official code. Just modify the sprintf feedback to the calling function. Remember that the dataset must be given in seconds.

@Jean-Damien: The way these axis formats can be modified is so easy, really good work! It took me maybe 20 minutes to do the hack without having ever been working with pChart before. Just one thing - can you loose some words on the "minDivHeight" and "Factors" parameter for drawScale?

Oh.. and one more thing.. I downloaded pchart as zip file but in reality it was a .zip.gz (therefore I had to gunzip first and unzip afterwards). Maybe u should fix that...


durationchart.png [ 14.44 KiB | Viewed 12342 times ]
Wed Jun 01, 2011 1:28 pm
New pChart user
New pChart user

Joined: Thu Jul 28, 2011 10:19 pm
Posts: 1
I figure out now about the Factors parameter. It's an array that stands for the minor unit for Y-Axis and represents how many subdivisions the scale can have, depending on the max and mix axis values.

$settings = array("Factors"=>array(1,2));

The code above sets the minor unit for one or half, as 0---0.5---1---1.5---2---2.5---3.

$settings = array("Factors"=>array(1));

The code above sets the minor unit for one , as 0---1---2---3...

I hope it helps!

Thu Jul 28, 2011 10:41 pm
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Good idea! I'll add this new format in the next sub release.

Thanks for your help ;o)

Kind regards,

Sun Jul 31, 2011 8:13 am
Profile WWW
New pChart user
New pChart user

Joined: Mon Jul 08, 2013 4:37 am
Posts: 2
public static void main(String[] args) {
Duration dur = new Duration();

SimpleDateFormat simpDate = new SimpleDateFormat("kk:mm");

I need to know from you dude. Id thids ok to use above format I required HH:mm but didn't.

_________________ | | how to check a paper for plagiarism for free

Mon Jul 08, 2013 4:43 am
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

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: