diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2007-04-12 12:45:42 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2007-04-12 12:45:42 +0000 |
commit | e3c691c66bc360caae052a7387a258ac8af0c2a1 (patch) | |
tree | eda7c4184d615f590e20bf142b7dcd24bbe7f20c /src/axis | |
parent | 40b5444276af768209c8a6b0df633b150da86ac8 (diff) | |
download | zetacomponents-graph-e3c691c66bc360caae052a7387a258ac8af0c2a1.zip zetacomponents-graph-e3c691c66bc360caae052a7387a258ac8af0c2a1.tar.gz |
- Added feature #10470: Add support for format callback functions on all axis
Diffstat (limited to 'src/axis')
-rw-r--r-- | src/axis/date.php | 15 | ||||
-rw-r--r-- | src/axis/labeled.php | 15 | ||||
-rw-r--r-- | src/axis/logarithmic.php | 27 | ||||
-rw-r--r-- | src/axis/numeric.php | 15 |
4 files changed, 65 insertions, 7 deletions
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'] ); + } } /** |