From e3c691c66bc360caae052a7387a258ac8af0c2a1 Mon Sep 17 00:00:00 2001 From: Kore Nordmann Date: Thu, 12 Apr 2007 12:45:42 +0000 Subject: - Added feature #10470: Add support for format callback functions on all axis --- src/axis/date.php | 15 ++++++++++++++- src/axis/labeled.php | 15 +++++++++++++++ src/axis/logarithmic.php | 27 ++++++++++++++++++++++----- src/axis/numeric.php | 15 ++++++++++++++- 4 files changed, 65 insertions(+), 7 deletions(-) (limited to 'src/axis') diff --git a/src/axis/date.php b/src/axis/date.php index bbf2bd4..9f72306 100644 --- a/src/axis/date.php +++ b/src/axis/date.php @@ -454,7 +454,20 @@ class ezcGraphChartElementDateAxis extends ezcGraphChartElementAxis */ public function getLabel( $step ) { - return date( $this->properties['dateFormat'], $this->startDate + ( $step * $this->interval ) ); + if ( $this->properties['labelCallback'] !== null ) + { + return call_user_func_array( + $this->properties['labelCallback'], + array( + date( $this->properties['dateFormat'], $this->startDate + ( $step * $this->interval ) ), + $step, + ) + ); + } + else + { + return date( $this->properties['dateFormat'], $this->startDate + ( $step * $this->interval ) ); + } } /** diff --git a/src/axis/labeled.php b/src/axis/labeled.php index d169d1e..131e302 100644 --- a/src/axis/labeled.php +++ b/src/axis/labeled.php @@ -167,6 +167,21 @@ class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis { $this->steps = array(); + // Apply label format callback function + if ( $this->properties['labelCallback'] !== null ) + { + foreach ( $this->labels as $nr => $label ) + { + $this->labels[$nr] = call_user_func_array( + $this->properties['labelCallback'], + array( + $label, + $nr + ) + ); + } + } + $labelCount = count( $this->labels ) - 1; if ( $labelCount === 0 ) diff --git a/src/axis/logarithmic.php b/src/axis/logarithmic.php index 370057d..a697a2d 100644 --- a/src/axis/logarithmic.php +++ b/src/axis/logarithmic.php @@ -259,11 +259,28 @@ class ezcGraphChartElementLogarithmicalAxis extends ezcGraphChartElementAxis */ public function getLabel( $step ) { - return sprintf( - $this->properties['logarithmicalFormatString'], - $this->properties['base'], - $this->properties['min'] + ( $step * $this->properties['majorStep'] ) - ); + if ( $this->properties['labelCallback'] !== null ) + { + return call_user_func_array( + $this->properties['labelCallback'], + array( + sprintf( + $this->properties['logarithmicalFormatString'], + $this->properties['base'], + $this->properties['min'] + ( $step * $this->properties['majorStep'] ) + ), + $step, + ) + ); + } + else + { + return sprintf( + $this->properties['logarithmicalFormatString'], + $this->properties['base'], + $this->properties['min'] + ( $step * $this->properties['majorStep'] ) + ); + } } /** diff --git a/src/axis/numeric.php b/src/axis/numeric.php index 9dd594c..563bb1d 100644 --- a/src/axis/numeric.php +++ b/src/axis/numeric.php @@ -348,7 +348,20 @@ class ezcGraphChartElementNumericAxis extends ezcGraphChartElementAxis */ public function getLabel( $step ) { - return $this->properties['min'] + ( $step * $this->properties['majorStep'] ); + if ( $this->properties['labelCallback'] !== null ) + { + return call_user_func_array( + $this->properties['labelCallback'], + array( + $this->properties['min'] + ( $step * $this->properties['majorStep'] ), + $step, + ) + ); + } + else + { + return $this->properties['min'] + ( $step * $this->properties['majorStep'] ); + } } /** -- cgit v1.1