pChart 2.x forum http://wiki.pchart.net/forum/ |
|
[Fix] Static Method callback http://wiki.pchart.net/forum/viewtopic.php?f=5&t=2220 |
Page 1 of 1 |
Author: | willybarro [ Thu Oct 27, 2011 12:16 am ] |
Post subject: | [Fix] Static Method callback |
Hi guys, I've found a bug while trying to use a static method (custom callback) for formatting my axis values. Those two valid callbacks (based on PHP standards for callbacks) fails on [pDraw.class.php ~ ln 3133, is_function function]: Code: ... $pData->setAxisDisplay(0, AXIS_FORMAT_CUSTOM, 'class::method'); ... and Code: ... $pData->setAxisDisplay(0, AXIS_FORMAT_CUSTOM, array('class', 'method')); ... (Both are valid callbacks!) I fixed it by changing (on pDraw.class.php ~ ln 3133): Code: ... if(function_exists($Format)) { ... for: Code: ... if(is_callable($Format)) { ... As is_callable is available since PHP 4 >= 4.0.6, I think we will not have problems with Backward Compatibility. It's also the recommended way to check for valid and compatible callbacks those times.... Then, every instance method, static method or simple function can be used. Maybe it could be added to the next minor... Oh, and Jean, thanks for the awesome library! |
Author: | emiswelt [ Wed Feb 29, 2012 10:28 pm ] |
Post subject: | Re: [Fix] Static Method callback |
I just wanted to push this bug report, as I ran into the bug: Providing a method as callback for AXIS_FORMAT_CUSTOM produces a warning message, which leads to corruption of the image file, when directly sent to the browser. Code: class SplineChart { /* snip */ public function plot() { /* snip */ $dataSet->setAxisDisplay(0, AXIS_FORMAT_CUSTOM, array($this,"yAxisFormat")); /* snip */ } function yAxisFormat($value) { /* snip */ } } Message produced by server: Code: Warning: function_exists() expects parameter 1 to be string, array given in C:\xampp\htdocs\MeasurementServer\pchart\class\pDraw.class.php on line 3134 The fix suggested by willybarro works perfectly for me. with best regards and thanks for your awsome work, Emi |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |