View unanswered posts | View active topics It is currently Sat Apr 27, 2024 3:34 pm



Reply to topic  [ 2 posts ] 
more than 2 decimals for AXIS_FORMAT_CURRENCY 
Author Message
New pChart user
New pChart user

Joined: Fri Mar 23, 2012 12:25 am
Posts: 2
Post more than 2 decimals for AXIS_FORMAT_CURRENCY
hi all,

I m making a chart website for namecoin historical values, and for this I needed to print y axis values , with type AXIS_FORMAT_CURRENCY , with 4 decimals.

I explored all the options of the drawscale function, and couldnt find anyway to show more than 2 decimals.

After hours searching for the good parameter, I had a look at the pDraw.class.php function, and the number of decimals for AXIS_FORMAT_CURRENCY seem to be hardcoded to 2 .

I had to change line 3142 of pDraw.class.php
from
Code:
      { return($Format.number_format($Value,2)); }

to
Code:
      { return($Format.number_format($Value,4)); }


and immediately had the result I needed :

Image

with 4 decimals on the currency axis

so . . .I could obtain what I need, but i m surprised there is no other way to make it, shouldn t there be some parameter to set the number of decimals to show for a currency axis ? hardcoding my number of decimals in line 3142 of pDraw.class.php is not a long term solution . . .

PS before people say "no one need 4 decimals for currencies" : http://www.fxstreet.com/rates-charts/forex-rates/


Fri Mar 23, 2012 1:09 am
Profile
New pChart user
New pChart user

Joined: Tue May 14, 2013 10:26 pm
Posts: 1
Post Re: more than 2 decimals for AXIS_FORMAT_CURRENCY
Nice Work neofutur!!!

You saved me a lot of time. Thanks!

To add to your solution, it looks like one can create a new format pretty easily.

I added a line to pData.class.php
Code:
define("AXIS_FORMAT_CURRENCY_NODECIMAL"      , 680007);

note: make sure your value is not already in use (680007)

and then duplicated the code around line 3142 in pDraw.class.php and modified it:
Code:
     if ( $Mode == AXIS_FORMAT_CURRENCY_NODECIMAL )
      { return($Format.number_format($Value,0)); }


Seems to work great.


Tue May 14, 2013 10:37 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

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