pChart 2.x forum
http://wiki.pchart.net/forum/

scaleFormat() method doesn't handle class-method callbacks
http://wiki.pchart.net/forum/viewtopic.php?f=5&t=29328
Page 1 of 1

Author:  ericnicolaas [ Thu May 17, 2012 2:36 am ]
Post subject:  scaleFormat() method doesn't handle class-method callbacks

I'm using AXIS_FORMAT_CUSTOM to generate y-axis labels, and want to use a class' method, rather than an isolated function. Currently, this doesn't work.

I've isolated the problem to pDraw::scaleFormat(), which performs a function_exists check on the callback function provided before executing it using call_user_func (see line 3134). I've managed to get by this by extending pImage and overriding scaleFormat, but this should be updated in the core, in my humble opinion :)

The following would provide an adequate check for class methods:

Code:
       
if ( $Mode == AXIS_FORMAT_CUSTOM ) {
    if ( function_exists($Format) || is_array($Format) && method_exists($Format[0], $Format[1]) ) {
        return( call_user_func($Format,$Value) );
    }
}


Cheers,
Eric

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/