summaryrefslogtreecommitdiffstats
path: root/tests/numeric_axis_test.php
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-05-26 09:50:50 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-05-26 09:50:50 +0000
commit89a8010b0b0869d07cb1d433351a1334bf232c57 (patch)
tree599f48a7030ba23dcb7e92f36cbcf082272dd681 /tests/numeric_axis_test.php
parentf13db279e32e2a4c323f5edeec486463e29fefc8 (diff)
downloadzetacomponents-graph-89a8010b0b0869d07cb1d433351a1334bf232c57.zip
zetacomponents-graph-89a8010b0b0869d07cb1d433351a1334bf232c57.tar.gz
- Moved axis renderer method to abstract ezcGraphElementAxis class
- Added coordinate calculation tests for both axis types - Implemented coordinate calculation
Diffstat (limited to 'tests/numeric_axis_test.php')
-rw-r--r--tests/numeric_axis_test.php231
1 files changed, 231 insertions, 0 deletions
diff --git a/tests/numeric_axis_test.php b/tests/numeric_axis_test.php
index ccbd9f5..b160d28 100644
--- a/tests/numeric_axis_test.php
+++ b/tests/numeric_axis_test.php
@@ -363,6 +363,237 @@ class ezcGraphNumericAxisTest extends ezcTestCase
);
}
+ public function testPositionLeft()
+ {
+ try
+ {
+ $chart = ezcGraph::create( 'Line' );
+ $chart->sample = array( 2000 => 1045, 1300, 1012, 1450 );
+ $chart->sample->color = '#FF0000';
+ $chart->Y_axis->position = ezcGraph::LEFT;
+ $chart->render( 500, 200 );
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+
+ $testBoundings = new ezcGraphBoundings();
+ $testBoundings->x0 = 50;
+ $testBoundings->x1 = 400;
+ $testBoundings->y0 = 75;
+ $testBoundings->y1 = 330;
+
+ $this->assertEquals(
+ 67.5,
+ $chart->Y_axis->getCoordinate( $testBoundings, false ),
+ 'Wrong initial axis position. '
+ );
+
+ $this->assertEquals(
+ 67.5,
+ $chart->Y_axis->getCoordinate( $testBoundings, 1000 ),
+ 'Wrong minimal value. '
+ );
+
+ $this->assertEquals(
+ 193.5,
+ $chart->Y_axis->getCoordinate( $testBoundings, 1200 ),
+ 'Wrong mid value. '
+ );
+
+ $this->assertEquals(
+ 382.5,
+ $chart->Y_axis->getCoordinate( $testBoundings, 1500 ),
+ 'Wrong maximum value. '
+ );
+ }
+
+ public function testPositionRight()
+ {
+ try
+ {
+ $chart = ezcGraph::create( 'Line' );
+ $chart->sample = array( 2000 => 1045, 1300, 1012, 1450 );
+ $chart->sample->color = '#FF0000';
+ $chart->Y_axis->position = ezcGraph::RIGHT;
+ $chart->render( 500, 200 );
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+
+ $testBoundings = new ezcGraphBoundings();
+ $testBoundings->x0 = 50;
+ $testBoundings->x1 = 400;
+ $testBoundings->y0 = 75;
+ $testBoundings->y1 = 330;
+
+ $this->assertEquals(
+ 382.5,
+ $chart->Y_axis->getCoordinate( $testBoundings, false ),
+ 'Wrong initial axis position. '
+ );
+
+ $this->assertEquals(
+ 382.5,
+ $chart->Y_axis->getCoordinate( $testBoundings, 1000 ),
+ 'Wrong minimal value. '
+ );
+
+ $this->assertEquals(
+ 256.5,
+ $chart->Y_axis->getCoordinate( $testBoundings, 1200 ),
+ 'Wrong mid value. '
+ );
+
+ $this->assertEquals(
+ 67.5,
+ $chart->Y_axis->getCoordinate( $testBoundings, 1500 ),
+ 'Wrong maximum value. '
+ );
+ }
+
+ public function testPositionTop()
+ {
+ try
+ {
+ $chart = ezcGraph::create( 'Line' );
+ $chart->sample = array( 2000 => 1045, 1300, 1012, 1450 );
+ $chart->sample->color = '#FF0000';
+ $chart->Y_axis->position = ezcGraph::TOP;
+ $chart->render( 500, 200 );
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+
+ $testBoundings = new ezcGraphBoundings();
+ $testBoundings->x0 = 50;
+ $testBoundings->x1 = 400;
+ $testBoundings->y0 = 75;
+ $testBoundings->y1 = 330;
+
+ $this->assertEquals(
+ 87.75,
+ $chart->Y_axis->getCoordinate( $testBoundings, false ),
+ 'Wrong initial axis position. '
+ );
+
+ $this->assertEquals(
+ 87.75,
+ $chart->Y_axis->getCoordinate( $testBoundings, 1000 ),
+ 'Wrong minimal value. '
+ );
+
+ $this->assertEquals(
+ 179.55,
+ $chart->Y_axis->getCoordinate( $testBoundings, 1200 ),
+ 'Wrong mid value. '
+ );
+
+ $this->assertEquals(
+ 317.25,
+ $chart->Y_axis->getCoordinate( $testBoundings, 1500 ),
+ 'Wrong maximum value. '
+ );
+ }
+
+ public function testPositionBottom()
+ {
+ try
+ {
+ $chart = ezcGraph::create( 'Line' );
+ $chart->sample = array( 2000 => 1045, 1300, 1012, 1450 );
+ $chart->sample->color = '#FF0000';
+ $chart->Y_axis->position = ezcGraph::BOTTOM;
+ $chart->render( 500, 200 );
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+
+ $testBoundings = new ezcGraphBoundings();
+ $testBoundings->x0 = 50;
+ $testBoundings->x1 = 400;
+ $testBoundings->y0 = 75;
+ $testBoundings->y1 = 330;
+
+ $this->assertEquals(
+ 317.25,
+ $chart->Y_axis->getCoordinate( $testBoundings, false ),
+ 'Wrong initial axis position. '
+ );
+
+ $this->assertEquals(
+ 317.25,
+ $chart->Y_axis->getCoordinate( $testBoundings, 1000 ),
+ 'Wrong minimal value. '
+ );
+
+ $this->assertEquals(
+ 225.45,
+ $chart->Y_axis->getCoordinate( $testBoundings, 1200 ),
+ 'Wrong mid value. '
+ );
+
+ $this->assertEquals(
+ 87.75,
+ $chart->Y_axis->getCoordinate( $testBoundings, 1500 ),
+ 'Wrong maximum value. '
+ );
+ }
+
+ public function testPositionLeftNegativMinimum()
+ {
+ try
+ {
+ $chart = ezcGraph::create( 'Line' );
+ $chart->sample = array( 2000 => -300, 1300, 1012, 1450 );
+ $chart->sample->color = '#FF0000';
+ $chart->Y_axis->majorStep = 500;
+ $chart->Y_axis->position = ezcGraph::LEFT;
+ $chart->render( 500, 200 );
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+
+ $testBoundings = new ezcGraphBoundings();
+ $testBoundings->x0 = 50;
+ $testBoundings->x1 = 400;
+ $testBoundings->y0 = 75;
+ $testBoundings->y1 = 330;
+
+ $this->assertEquals(
+ 67.5,
+ $chart->Y_axis->getCoordinate( $testBoundings, false ),
+ 'Wrong initial axis position. '
+ );
+
+ $this->assertEquals(
+ 67.5,
+ $chart->Y_axis->getCoordinate( $testBoundings, -500 ),
+ 'Wrong minimal value. '
+ );
+
+ $this->assertEquals(
+ 335.25,
+ $chart->Y_axis->getCoordinate( $testBoundings, 1200 ),
+ 'Wrong mid value. '
+ );
+
+ $this->assertEquals(
+ 382.5,
+ $chart->Y_axis->getCoordinate( $testBoundings, 1500 ),
+ 'Wrong maximum value. '
+ );
+ }
+
public function testRenderNumeric()
{
try
OpenPOWER on IntegriCloud