From 724f713334360344e6c121f76e66a88e5301ea4e Mon Sep 17 00:00:00 2001 From: Kore Nordmann Date: Tue, 11 Jul 2006 11:38:12 +0000 Subject: - Fixed boundings calculation for axis and data --- tests/complete_rendering_test.php | 46 +++++++++++++++++++++++++++++++++++-- tests/line_test.php | 22 +++++++++--------- tests/pie_test.php | 12 +++++----- tests/renderer_2d_test.php | 48 +++++++++++++++++++-------------------- 4 files changed, 85 insertions(+), 43 deletions(-) (limited to 'tests') diff --git a/tests/complete_rendering_test.php b/tests/complete_rendering_test.php index ff8d954..92b4d83 100644 --- a/tests/complete_rendering_test.php +++ b/tests/complete_rendering_test.php @@ -15,7 +15,7 @@ * @package ImageAnalysis * @subpackage Tests */ -class ezcGraphCompleteRenderingTest extends ezcTestCase +class ezcGraphCompleteRenderingTest extends ezcImageTestCase { protected $testFiles = array( @@ -58,7 +58,7 @@ class ezcGraphCompleteRenderingTest extends ezcTestCase $filename = $this->tempDir . __FUNCTION__ . '.png'; $chart = ezcGraph::create( 'line' ); - $chart->palette = 'black'; + $chart->palette = 'Black'; $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613); @@ -74,6 +74,48 @@ class ezcGraphCompleteRenderingTest extends ezcTestCase ); } + public function testRenderLineChartAxis() + { + $filename = $this->tempDir . __FUNCTION__ . '.png'; + + $renderer = $this->getMock( 'ezcGraphRenderer2D', array( + 'drawAxis', + ) ); + + $chart = ezcGraph::create( 'line' ); + $chart->palette = 'Black'; + + $renderer + ->expects( $this->at( 0 ) ) + ->method( 'drawAxis' ) + ->with( + $this->equalTo( new ezcGraphBoundings( 100, 0, 500, 200 ), 1. ), + $this->equalTo( new ezcGraphCoordinate( 0, 180 ), 1. ), + $this->equalTo( new ezcGraphCoordinate( 400, 180 ), 1. ), + $this->equalTo( $chart->xAxis ), + $this->equalTo( $chart->xAxis->axisLabelRenderer ) + ); + $renderer + ->expects( $this->at( 1 ) ) + ->method( 'drawAxis' ) + ->with( + $this->equalTo( new ezcGraphBoundings( 100, 0, 500, 200 ), 1. ), + $this->equalTo( new ezcGraphCoordinate( 40, 200 ), 1. ), + $this->equalTo( new ezcGraphCoordinate( 40, 0 ), 1. ), + $this->equalTo( $chart->yAxis ), + $this->equalTo( $chart->yAxis->axisLabelRenderer ) + ); + + $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); + $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613); + + $chart->renderer = $renderer; + + $chart->driver = new ezcGraphGdDriver(); + $chart->options->font = $this->basePath . 'font.ttf'; + $chart->render( 500, 200, $filename ); + } + public function testRenderWithTransparentBackground() { $filename = $this->tempDir . __FUNCTION__ . '.png'; diff --git a/tests/line_test.php b/tests/line_test.php index 34491ca..820bc75 100644 --- a/tests/line_test.php +++ b/tests/line_test.php @@ -110,7 +110,7 @@ class ezcGraphLineChartTest extends ezcTestCase ->expects( $this->at( 0 ) ) ->method( 'drawDataLine' ) ->with( - $this->equalTo( new ezcGraphBoundings( 101, 18, 499, 182 ) ), + $this->equalTo( new ezcGraphBoundings( 140., 20., 464., 182. ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ), $this->equalTo( new ezcGraphCoordinate( .0, .415 ), .05 ), $this->equalTo( new ezcGraphCoordinate( .0, .415 ), .05 ), @@ -122,7 +122,7 @@ class ezcGraphLineChartTest extends ezcTestCase ->expects( $this->at( 1 ) ) ->method( 'drawDataLine' ) ->with( - $this->equalTo( new ezcGraphBoundings( 101, 18, 499, 182 ) ), + $this->equalTo( new ezcGraphBoundings( 140., 20., 464., 182. ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ), $this->equalTo( new ezcGraphCoordinate( .0, .415 ), .05 ), $this->equalTo( new ezcGraphCoordinate( .25, .95 ), .05 ), @@ -134,7 +134,7 @@ class ezcGraphLineChartTest extends ezcTestCase ->expects( $this->at( 2 ) ) ->method( 'drawDataLine' ) ->with( - $this->equalTo( new ezcGraphBoundings( 101, 18, 499, 182 ) ), + $this->equalTo( new ezcGraphBoundings( 140., 20., 464., 182. ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ), $this->equalTo( new ezcGraphCoordinate( .25, .95 ), .05 ), $this->equalTo( new ezcGraphCoordinate( .5, .2 ), .05 ), @@ -146,7 +146,7 @@ class ezcGraphLineChartTest extends ezcTestCase ->expects( $this->at( 3 ) ) ->method( 'drawDataLine' ) ->with( - $this->equalTo( new ezcGraphBoundings( 101, 18, 499, 182 ) ), + $this->equalTo( new ezcGraphBoundings( 140., 20., 464., 182. ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ), $this->equalTo( new ezcGraphCoordinate( .5, .2 ), .05 ), $this->equalTo( new ezcGraphCoordinate( .75, .7 ), .05 ), @@ -158,7 +158,7 @@ class ezcGraphLineChartTest extends ezcTestCase ->expects( $this->at( 4 ) ) ->method( 'drawDataLine' ) ->with( - $this->equalTo( new ezcGraphBoundings( 101, 18, 499, 182 ) ), + $this->equalTo( new ezcGraphBoundings( 140., 20., 464., 182. ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ), $this->equalTo( new ezcGraphCoordinate( .75, .7 ), .05 ), $this->equalTo( new ezcGraphCoordinate( 1., .9975 ), .05 ), @@ -187,7 +187,7 @@ class ezcGraphLineChartTest extends ezcTestCase ->expects( $this->at( 0 ) ) ->method( 'drawDataLine' ) ->with( - $this->equalTo( new ezcGraphBoundings( 103, 20, 497, 180 ) ), + $this->equalTo( new ezcGraphBoundings( 140., 20., 464., 182. ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#3465A4' ) ), $this->equalTo( new ezcGraphCoordinate( .0, .165 ), .05 ), $this->equalTo( new ezcGraphCoordinate( .0, .165 ), .05 ), @@ -199,7 +199,7 @@ class ezcGraphLineChartTest extends ezcTestCase ->expects( $this->at( 1 ) ) ->method( 'drawDataLine' ) ->with( - $this->equalTo( new ezcGraphBoundings( 103, 20, 497, 180 ) ), + $this->equalTo( new ezcGraphBoundings( 140., 20., 464., 182. ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#3465A4' ) ), $this->equalTo( new ezcGraphCoordinate( .0, .165 ), .05 ), $this->equalTo( new ezcGraphCoordinate( .25, .6975 ), .05 ), @@ -211,7 +211,7 @@ class ezcGraphLineChartTest extends ezcTestCase ->expects( $this->at( 4 ) ) ->method( 'drawDataLine' ) ->with( - $this->equalTo( new ezcGraphBoundings( 103, 20, 497, 180 ) ), + $this->equalTo( new ezcGraphBoundings( 140., 20., 464., 182. ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#3465A4' ) ), $this->equalTo( new ezcGraphCoordinate( .75, .45 ), .05 ), $this->equalTo( new ezcGraphCoordinate( 1., .5 ), .05 ), @@ -241,7 +241,7 @@ class ezcGraphLineChartTest extends ezcTestCase ->expects( $this->at( 0 ) ) ->method( 'drawDataLine' ) ->with( - $this->equalTo( new ezcGraphBoundings( 103, 20, 497, 180 ) ), + $this->equalTo( new ezcGraphBoundings( 140., 20., 464., 182. ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#729FCF' ) ), $this->equalTo( new ezcGraphCoordinate( .0, .415 ), .05 ), $this->equalTo( new ezcGraphCoordinate( .0, .415 ), .05 ), @@ -253,7 +253,7 @@ class ezcGraphLineChartTest extends ezcTestCase ->expects( $this->at( 2 ) ) ->method( 'drawDataLine' ) ->with( - $this->equalTo( new ezcGraphBoundings( 103, 20, 497, 180 ) ), + $this->equalTo( new ezcGraphBoundings( 140., 20., 464., 182. ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#729FCF' ) ), $this->equalTo( new ezcGraphCoordinate( .25, .9475 ), .05 ), $this->equalTo( new ezcGraphCoordinate( .5, .19 ), .05 ), @@ -265,7 +265,7 @@ class ezcGraphLineChartTest extends ezcTestCase ->expects( $this->at( 4 ) ) ->method( 'drawDataLine' ) ->with( - $this->equalTo( new ezcGraphBoundings( 103, 20, 497, 180 ) ), + $this->equalTo( new ezcGraphBoundings( 140., 20., 464., 182. ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#729FCF' ) ), $this->equalTo( new ezcGraphCoordinate( .75, .7 ), .05 ), $this->equalTo( new ezcGraphCoordinate( 1., .9975 ), .05 ), diff --git a/tests/pie_test.php b/tests/pie_test.php index c3fa240..ccf88a8 100644 --- a/tests/pie_test.php +++ b/tests/pie_test.php @@ -103,7 +103,7 @@ class ezcGraphPieChartTest extends ezcTestCase ->expects( $this->at( 0 ) ) ->method( 'drawPieSegment' ) ->with( - $this->equalTo( new ezcGraphBoundings( 81, 18, 399, 182 ) ), + $this->equalTo( new ezcGraphBoundings( 80, 0, 400, 200 ) ), $this->equalTo( ezcGraphColor::fromHex( '#4E9A06' ) ), $this->equalTo( 0., 1. ), $this->equalTo( 220.5, .1 ), @@ -114,8 +114,8 @@ class ezcGraphPieChartTest extends ezcTestCase ->expects( $this->at( 1 ) ) ->method( 'drawPieSegment' ) ->with( - $this->equalTo( new ezcGraphBoundings( 81, 18, 399, 182 ) ), - $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ), + $this->equalTo( new ezcGraphBoundings( 80, 0, 400, 200 ) ), + $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ), $this->equalTo( 220.5, .1 ), $this->equalTo( 238., 1. ), $this->equalTo( 'IE' ), @@ -125,7 +125,7 @@ class ezcGraphPieChartTest extends ezcTestCase ->expects( $this->at( 2 ) ) ->method( 'drawPieSegment' ) ->with( - $this->equalTo( new ezcGraphBoundings( 81, 18, 399, 182 ) ), + $this->equalTo( new ezcGraphBoundings( 80, 0, 400, 200 ) ), $this->equalTo( ezcGraphColor::fromHex( '#EDD400' ) ), $this->equalTo( 238., 1. ), $this->equalTo( 298.6, 1. ), @@ -136,7 +136,7 @@ class ezcGraphPieChartTest extends ezcTestCase ->expects( $this->at( 3 ) ) ->method( 'drawPieSegment' ) ->with( - $this->equalTo( new ezcGraphBoundings( 81, 18, 399, 182 ) ), + $this->equalTo( new ezcGraphBoundings( 80, 0, 400, 200 ) ), $this->equalTo( ezcGraphColor::fromHex( '#75505B' ) ), $this->equalTo( 298.6, 1. ), $this->equalTo( 310., 1. ), @@ -147,7 +147,7 @@ class ezcGraphPieChartTest extends ezcTestCase ->expects( $this->at( 4 ) ) ->method( 'drawPieSegment' ) ->with( - $this->equalTo( new ezcGraphBoundings( 81, 18, 399, 182 ) ), + $this->equalTo( new ezcGraphBoundings( 80, 0, 400, 200 ) ), $this->equalTo( ezcGraphColor::fromHex( '#F57900' ) ), $this->equalTo( 310., 1. ), $this->equalTo( 360., 1. ), diff --git a/tests/renderer_2d_test.php b/tests/renderer_2d_test.php index 49d7a39..41ed9d8 100644 --- a/tests/renderer_2d_test.php +++ b/tests/renderer_2d_test.php @@ -1331,8 +1331,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase ->expects( $this->at( 0 ) ) ->method( 'drawLine' ) ->with( - $this->equalTo( new ezcGraphCoordinate( 20., 200. ), 1. ), - $this->equalTo( new ezcGraphCoordinate( 20., 0. ), 1. ), + $this->equalTo( new ezcGraphCoordinate( 120., 220. ), 1. ), + $this->equalTo( new ezcGraphCoordinate( 120., 20. ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ), $this->equalTo( 1 ) ); @@ -1341,16 +1341,16 @@ class ezcGraphRenderer2dTest extends ezcTestCase ->method( 'drawPolygon' ) ->with( $this->equalTo( array( - new ezcGraphCoordinate( 20., 0. ), - new ezcGraphCoordinate( 22.5, 5. ), - new ezcGraphCoordinate( 17.5, 5. ), + new ezcGraphCoordinate( 120., 20. ), + new ezcGraphCoordinate( 122.5, 25. ), + new ezcGraphCoordinate( 117.5, 25. ), ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ), $this->equalTo( true ) ); $this->renderer->drawAxis( - new ezcGraphBoundings( 0, 0, 200, 400 ), + new ezcGraphBoundings( 100, 20, 500, 220 ), new ezcGraphCoordinate( 20, 200 ), new ezcGraphCoordinate( 20, 0 ), $chart->yAxis @@ -1365,8 +1365,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase ->expects( $this->at( 0 ) ) ->method( 'drawLine' ) ->with( - $this->equalTo( new ezcGraphCoordinate( 20., 0. ), 1. ), - $this->equalTo( new ezcGraphCoordinate( 20., 200. ), 1. ), + $this->equalTo( new ezcGraphCoordinate( 120., 20. ), 1. ), + $this->equalTo( new ezcGraphCoordinate( 120., 220. ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ), $this->equalTo( 1 ) ); @@ -1375,16 +1375,16 @@ class ezcGraphRenderer2dTest extends ezcTestCase ->method( 'drawPolygon' ) ->with( $this->equalTo( array( - new ezcGraphCoordinate( 20., 200. ), - new ezcGraphCoordinate( 17.5, 195. ), - new ezcGraphCoordinate( 22.5, 195. ), + new ezcGraphCoordinate( 120., 220. ), + new ezcGraphCoordinate( 117.5, 215. ), + new ezcGraphCoordinate( 122.5, 215. ), ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ), $this->equalTo( true ) ); $this->renderer->drawAxis( - new ezcGraphBoundings( 0, 0, 200, 400 ), + new ezcGraphBoundings( 100, 20, 500, 220 ), new ezcGraphCoordinate( 20, 0 ), new ezcGraphCoordinate( 20, 200 ), $chart->yAxis @@ -1399,8 +1399,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase ->expects( $this->at( 0 ) ) ->method( 'drawLine' ) ->with( - $this->equalTo( new ezcGraphCoordinate( 50., 100. ), 1. ), - $this->equalTo( new ezcGraphCoordinate( 350., 100. ), 1. ), + $this->equalTo( new ezcGraphCoordinate( 150., 120. ), 1. ), + $this->equalTo( new ezcGraphCoordinate( 450., 120. ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ), $this->equalTo( 1 ) ); @@ -1409,16 +1409,16 @@ class ezcGraphRenderer2dTest extends ezcTestCase ->method( 'drawPolygon' ) ->with( $this->equalTo( array( - new ezcGraphCoordinate( 350., 100. ), - new ezcGraphCoordinate( 342., 96. ), - new ezcGraphCoordinate( 342., 104. ), + new ezcGraphCoordinate( 450., 120. ), + new ezcGraphCoordinate( 442., 116. ), + new ezcGraphCoordinate( 442., 124. ), ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ), $this->equalTo( true ) ); $this->renderer->drawAxis( - new ezcGraphBoundings( 0, 0, 200, 400 ), + new ezcGraphBoundings( 100, 20, 500, 220 ), new ezcGraphCoordinate( 50, 100 ), new ezcGraphCoordinate( 350, 100 ), $chart->yAxis @@ -1433,8 +1433,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase ->expects( $this->at( 0 ) ) ->method( 'drawLine' ) ->with( - $this->equalTo( new ezcGraphCoordinate( 350., 100. ), 1. ), - $this->equalTo( new ezcGraphCoordinate( 50., 100. ), 1. ), + $this->equalTo( new ezcGraphCoordinate( 450., 120. ), 1. ), + $this->equalTo( new ezcGraphCoordinate( 150., 120. ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ), $this->equalTo( 1 ) ); @@ -1443,16 +1443,16 @@ class ezcGraphRenderer2dTest extends ezcTestCase ->method( 'drawPolygon' ) ->with( $this->equalTo( array( - new ezcGraphCoordinate( 50., 100. ), - new ezcGraphCoordinate( 57., 103.5 ), - new ezcGraphCoordinate( 57., 96.5 ), + new ezcGraphCoordinate( 150., 120. ), + new ezcGraphCoordinate( 157., 123.5 ), + new ezcGraphCoordinate( 157., 116.5 ), ), 1. ), $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ), $this->equalTo( true ) ); $this->renderer->drawAxis( - new ezcGraphBoundings( 0, 0, 200, 400 ), + new ezcGraphBoundings( 100, 20, 500, 220 ), new ezcGraphCoordinate( 350, 100 ), new ezcGraphCoordinate( 50, 100 ), $chart->yAxis -- cgit v1.1