diff options
Diffstat (limited to 'src/axis/labeled.php')
-rw-r--r-- | src/axis/labeled.php | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/axis/labeled.php b/src/axis/labeled.php index a9550c7..ff413ca 100644 --- a/src/axis/labeled.php +++ b/src/axis/labeled.php @@ -69,7 +69,6 @@ */ class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis { - /** * Array with labeles for data * @@ -78,6 +77,13 @@ class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis protected $labels = array(); /** + * Labels indexed by thei name as key for faster lookups + * + * @var array + */ + protected $labelsIndexed = array(); + + /** * Reduced amount of labels which will be displayed in the chart * * @var array @@ -219,6 +225,7 @@ class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis } } ksort( $this->labels ); + $this->labelsIndexed = array_flip( $this->labels ); $this->properties['initialized'] = true; } @@ -415,9 +422,9 @@ class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis */ public function getCoordinate( $value ) { - if ( $value === false || - $value === null || - ( $key = array_search( $value, $this->labels ) ) === false ) + if ( ( $value === false ) || + ( $value === null ) || + ( !isset( $this->labelsIndexed[$value] ) ) ) { switch ( $this->position ) { @@ -431,6 +438,7 @@ class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis } else { + $key = $this->labelsIndexed[$value]; switch ( $this->position ) { case ezcGraph::LEFT: |