pChart 2.x forum http://wiki.pchart.net/forum/ |
|
more than 2 decimals for AXIS_FORMAT_CURRENCY http://wiki.pchart.net/forum/viewtopic.php?f=1&t=2533 |
Page 1 of 1 |
Author: | neofutur [ Fri Mar 23, 2012 1:09 am ] |
Post subject: | 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 : 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/ |
Author: | chenopod [ Tue May 14, 2013 10:37 pm ] |
Post subject: | 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. |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |