summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2009-09-28 13:53:59 +0000
committerKore Nordmann <github@kore-nordmann.de>2009-09-28 13:53:59 +0000
commita33a0b5ce41af2eb5ba9636ac2a749f1e6261592 (patch)
treef41b3278c4f2642990924045c627cc64be81182a
parentf796ddc606c36350ada71a11c7acc703b98437d7 (diff)
downloadzetacomponents-graph-a33a0b5ce41af2eb5ba9636ac2a749f1e6261592.zip
zetacomponents-graph-a33a0b5ce41af2eb5ba9636ac2a749f1e6261592.tar.gz
- Fixed #15578: formatString not working with numeric axis
-rw-r--r--ChangeLog5
-rw-r--r--src/axis/numeric.php4
-rw-r--r--tests/numeric_axis_test.php32
3 files changed, 41 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c52fd77..b610354 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+1.5alpha2 - Tuesday 01 September 2009
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- Fixed #15578: formatString not working with numeric axis.
+
1.5alpha1 - Tuesday 01 September 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/axis/numeric.php b/src/axis/numeric.php
index 34995db..f9c61a8 100644
--- a/src/axis/numeric.php
+++ b/src/axis/numeric.php
@@ -478,6 +478,10 @@ class ezcGraphChartElementNumericAxis extends ezcGraphChartElementAxis
)
);
}
+ elseif ( $this->properties['formatString'] !== null )
+ {
+ return sprintf( $this->properties['formatString'], $this->properties['min'] + ( $step * $this->properties['majorStep'] ) );
+ }
else
{
return $this->properties['min'] + ( $step * $this->properties['majorStep'] );
diff --git a/tests/numeric_axis_test.php b/tests/numeric_axis_test.php
index 087d318..4448f4c 100644
--- a/tests/numeric_axis_test.php
+++ b/tests/numeric_axis_test.php
@@ -1090,6 +1090,38 @@ class ezcGraphNumericAxisTest extends ezcTestCase
);
}
}
+
+ public function testRenderedLabelsWithLabelFormatString()
+ {
+ try
+ {
+ $chart = new ezcGraphLineChart();
+
+ $chart->yAxis->formatString = '%d $';
+
+ $chart->data['sampleData'] = new ezcGraphArrayDataSet( array( 'sample 1' => 234, 'sample 2' => -21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1) );
+ $chart->render( 500, 200 );
+ }
+ catch ( ezcGraphFontRenderingException $e )
+ {
+ // Ignore
+ }
+
+ $steps = $chart->yAxis->getSteps();
+
+ $expectedLabels = array(
+ '-100 $', '0 $', '100 $', '200 $', '300 $', '400 $',
+ );
+
+ foreach ( $steps as $nr => $step )
+ {
+ $this->assertSame(
+ $step->label,
+ $expectedLabels[$nr],
+ 'Label not as expected'
+ );
+ }
+ }
}
?>
OpenPOWER on IntegriCloud