diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2007-03-05 11:03:43 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2007-03-05 11:03:43 +0000 |
commit | c47be4e29322e2319f33229dd054fb0c24c6b44f (patch) | |
tree | 1e2625970b4abcc9882145943f05fbac3e4a88fc /tests/labeled_axis_test.php | |
parent | 3565724f24ef7d6989756ee2a3ee70cc37d97a88 (diff) | |
download | zetacomponents-graph-c47be4e29322e2319f33229dd054fb0c24c6b44f.zip zetacomponents-graph-c47be4e29322e2319f33229dd054fb0c24c6b44f.tar.gz |
- Implemented #10375: Manually reduce or increase the label count on labeled axis
Diffstat (limited to 'tests/labeled_axis_test.php')
-rw-r--r-- | tests/labeled_axis_test.php | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/tests/labeled_axis_test.php b/tests/labeled_axis_test.php index 6097eeb..2bdc2ab 100644 --- a/tests/labeled_axis_test.php +++ b/tests/labeled_axis_test.php @@ -462,6 +462,119 @@ class ezcGraphLabeledAxisTest extends ezcGraphTestCase $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } + + public function testChartElementNumericAxisPropertyLabelCount() + { + $options = new ezcGraphChartElementLabeledAxis(); + + $this->assertSame( + null, + $options->labelCount, + 'Wrong default value for property labelCount in class ezcGraphChartElementNumericAxis' + ); + + $options->labelCount = 10; + $this->assertSame( + 10, + $options->labelCount, + 'Setting property value did not work for property labelCount in class ezcGraphChartElementNumericAxis' + ); + + try + { + $options->labelCount = 1; + } + catch ( ezcBaseValueException $e ) + { + return true; + } + + $this->fail( 'Expected ezcBaseValueException.' ); + } + + public function testRenderManualLabelCount1() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $labelCount = 4; + + // Make this reproducible + mt_srand( 2 ); + + for ( $i = 0; $i < $labelCount; ++$i ) + { + $data[(string) ( 2000 + $i )] = mt_rand( 500, 2000 ); + } + + $chart = new ezcGraphLineChart(); + $chart->data['sample'] = new ezcGraphArrayDataSet( $data ); + + // Set manual label count + $chart->xAxis->labelCount = 3; + + $chart->render( 500, 200, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + + public function testRenderManualLabelCount2() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $labelCount = 4; + + // Make this reproducible + mt_srand( 2 ); + + for ( $i = 0; $i < $labelCount; ++$i ) + { + $data[(string) ( 2000 + $i )] = mt_rand( 500, 2000 ); + } + + $chart = new ezcGraphLineChart(); + $chart->data['sample'] = new ezcGraphArrayDataSet( $data ); + + // Set manual label count + $chart->xAxis->labelCount = 10; + + $chart->render( 500, 200, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + + public function testRenderManualLabelCount3() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $labelCount = 35; + + // Make this reproducible + mt_srand( 2 ); + + for ( $i = 0; $i < $labelCount; ++$i ) + { + $data[(string) ( 2000 + $i )] = mt_rand( 500, 2000 ); + } + + $chart = new ezcGraphLineChart(); + $chart->data['sample'] = new ezcGraphArrayDataSet( $data ); + + // Set manual label count + $chart->xAxis->labelCount = 7; + + $chart->render( 500, 200, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } } ?> |