summaryrefslogtreecommitdiffstats
path: root/tests/logarithmical_axis_test.php
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2007-04-12 12:45:42 +0000
committerKore Nordmann <github@kore-nordmann.de>2007-04-12 12:45:42 +0000
commite3c691c66bc360caae052a7387a258ac8af0c2a1 (patch)
treeeda7c4184d615f590e20bf142b7dcd24bbe7f20c /tests/logarithmical_axis_test.php
parent40b5444276af768209c8a6b0df633b150da86ac8 (diff)
downloadzetacomponents-graph-e3c691c66bc360caae052a7387a258ac8af0c2a1.zip
zetacomponents-graph-e3c691c66bc360caae052a7387a258ac8af0c2a1.tar.gz
- Added feature #10470: Add support for format callback functions on all axis
Diffstat (limited to 'tests/logarithmical_axis_test.php')
-rw-r--r--tests/logarithmical_axis_test.php67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/logarithmical_axis_test.php b/tests/logarithmical_axis_test.php
index 2bda3d1..8285673 100644
--- a/tests/logarithmical_axis_test.php
+++ b/tests/logarithmical_axis_test.php
@@ -399,5 +399,72 @@ class ezcGraphLogarithmicalAxisTest extends ezcGraphTestCase
$this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
);
}
+
+ public function testRenderedLabels()
+ {
+ try
+ {
+ $chart = new ezcGraphLineChart();
+ $chart->yAxis = new ezcGraphChartElementLogarithmicalAxis();
+ $chart->data['sample'] = new ezcGraphArrayDataSet( array( .03, 12, 43, 1023, .02, 1.5, 9823 ) );
+ $chart->render( 500, 200 );
+ }
+ catch ( ezcGraphFontRenderingException $e )
+ {
+ // Ignore
+ }
+
+ $steps = $chart->yAxis->getSteps();
+
+ $expectedLabels = array(
+ '10^-2', '10^-1', '10^0', '10^1', '10^2', '10^3', '10^4',
+ );
+
+ foreach ( $steps as $nr => $step )
+ {
+ $this->assertSame(
+ $step->label,
+ $expectedLabels[$nr],
+ 'Label not as expected'
+ );
+ }
+ }
+
+ public function testRenderedLabelsWithLabelFormattingCallback()
+ {
+ try
+ {
+ $chart = new ezcGraphLineChart();
+
+ $chart->yAxis = new ezcGraphChartElementLogarithmicalAxis();
+ $chart->yAxis->labelCallback = create_function(
+ '$label',
+ 'return "*$label*";'
+ );
+
+ $chart->data['sample'] = new ezcGraphArrayDataSet( array( .03, 12, 43, 1023, .02, 1.5, 9823 ) );
+
+ $chart->render( 500, 200 );
+ }
+ catch ( ezcGraphFontRenderingException $e )
+ {
+ // Ignore
+ }
+
+ $steps = $chart->yAxis->getSteps();
+
+ $expectedLabels = array(
+ '*10^-2*', '*10^-1*', '*10^0*', '*10^1*', '*10^2*', '*10^3*', '*10^4*',
+ );
+
+ foreach ( $steps as $nr => $step )
+ {
+ $this->assertSame(
+ $step->label,
+ $expectedLabels[$nr],
+ 'Label not as expected'
+ );
+ }
+ }
}
?>
OpenPOWER on IntegriCloud