summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-07-11 08:49:26 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-07-11 08:49:26 +0000
commit6f359d97e38932b0da23abb0940f32bf5380c0d8 (patch)
treebc6221534bf65aa6777245e7f555e943cdd2bbc6 /tests
parent663493a7224dc7869c6c63d770016f9fd8850e2a (diff)
downloadzetacomponents-graph-6f359d97e38932b0da23abb0940f32bf5380c0d8.zip
zetacomponents-graph-6f359d97e38932b0da23abb0940f32bf5380c0d8.tar.gz
- Refactored ezcGraphRenderer
# Most test run again, but complete result is still errnous
Diffstat (limited to 'tests')
-rw-r--r--tests/axis_renderer_test.php161
-rw-r--r--tests/complete_rendering_test.php103
-rw-r--r--tests/labeled_axis_test.php508
-rw-r--r--tests/legend_test.php355
-rw-r--r--tests/line_test.php350
-rw-r--r--tests/numeric_axis_test.php675
-rw-r--r--tests/pie_test.php365
-rw-r--r--tests/renderer_2d_test.php1357
-rw-r--r--tests/suite.php6
-rw-r--r--tests/text_test.php47
10 files changed, 1795 insertions, 2132 deletions
diff --git a/tests/axis_renderer_test.php b/tests/axis_renderer_test.php
new file mode 100644
index 0000000..97739cd
--- /dev/null
+++ b/tests/axis_renderer_test.php
@@ -0,0 +1,161 @@
+<?php
+/**
+ * ezcGraphAxisRendererTest
+ *
+ * @package Graph
+ * @version //autogen//
+ * @subpackage Tests
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Tests for ezcGraph class.
+ *
+ * @package ImageAnalysis
+ * @subpackage Tests
+ */
+class ezcGraphAxisRendererTest extends ezcTestCase
+{
+
+ protected $renderer;
+
+ protected $driver;
+
+ public static function suite()
+ {
+ return new ezcTestSuite( "ezcGraphAxisRendererTest" );
+ }
+
+ /**
+ * setUp
+ *
+ * @access public
+ */
+ public function setUp()
+ {
+ $this->renderer = new ezcGraphRenderer2D();
+
+ $this->driver = $this->getMock( 'ezcGraphGdDriver', array(
+ 'drawPolygon',
+ 'drawLine',
+ 'drawTextBox',
+ 'drawCircleSector',
+ 'drawCircularArc',
+ 'drawCircle',
+ 'drawImage',
+ ) );
+ $this->renderer->setDriver( $this->driver );
+
+ $this->driver->options->width = 400;
+ $this->driver->options->height = 200;
+ }
+
+ /**
+ * tearDown
+ *
+ * @access public
+ */
+ public function tearDown()
+ {
+ }
+
+ public function testDetermineCuttingPoint()
+ {
+ $aStart = new ezcGraphCoordinate( -1, -5 );
+ $aDir = new ezcGraphCoordinate( 4, 3 );
+
+ $bStart = new ezcGraphCoordinate( 1, 2 );
+ $bDir = new ezcGraphCoordinate( 1, -2 );
+
+ $axisLabelRenderer = new ezcGraphAxisExactLabelRenderer();
+ $cuttingPosition = $axisLabelRenderer->determineLineCuttingPoint( $aStart, $aDir, $bStart, $bDir );
+
+ $this->assertEquals(
+ $cuttingPosition,
+ 2.,
+ 'Cutting position should be <2>',
+ .1
+ );
+
+ $cuttingPoint = new ezcGraphCoordinate(
+ $bStart->x + $cuttingPosition * $bDir->x,
+ $bStart->y + $cuttingPosition * $bDir->y
+ );
+
+ $this->assertEquals(
+ $cuttingPoint,
+ new ezcGraphCoordinate( 3., -2. ),
+ 'Wrong cutting point.',
+ .1
+ );
+ }
+
+ public function testDetermineCuttingPoint2()
+ {
+ $aStart = new ezcGraphCoordinate( 0, 2 );
+ $aDir = new ezcGraphCoordinate( 3, 1 );
+
+ $bStart = new ezcGraphCoordinate( 2, -1 );
+ $bDir = new ezcGraphCoordinate( 1, 2 );
+
+ $axisLabelRenderer = new ezcGraphAxisExactLabelRenderer();
+ $cuttingPosition = $axisLabelRenderer->determineLineCuttingPoint( $aStart, $aDir, $bStart, $bDir );
+
+ $this->assertEquals(
+ $cuttingPosition,
+ 2.2,
+ 'Cutting position should be <2.2>',
+ .1
+ );
+
+ $cuttingPoint = new ezcGraphCoordinate(
+ $bStart->x + $cuttingPosition * $bDir->x,
+ $bStart->y + $cuttingPosition * $bDir->y
+ );
+
+ $this->assertEquals(
+ $cuttingPoint,
+ new ezcGraphCoordinate( 4.2, 3.4 ),
+ 'Wrong cutting point.',
+ .1
+ );
+ }
+
+ public function testNoCuttingPoint()
+ {
+ $aStart = new ezcGraphCoordinate( 0, 0 );
+ $aDir = new ezcGraphCoordinate( 1, 0 );
+
+ $bStart = new ezcGraphCoordinate( 0, 1 );
+ $bDir = new ezcGraphCoordinate( 3, 0 );
+
+ $axisLabelRenderer = new ezcGraphAxisExactLabelRenderer();
+ $cuttingPosition = $axisLabelRenderer->determineLineCuttingPoint( $aStart, $aDir, $bStart, $bDir );
+
+ $this->assertSame(
+ $cuttingPosition,
+ false,
+ 'There should not be a cutting point.'
+ );
+ }
+
+ public function testRenderAxisSteps()
+ {
+ $aStart = new ezcGraphCoordinate( 0, 0 );
+ $aDir = new ezcGraphCoordinate( 1, 0 );
+
+ $bStart = new ezcGraphCoordinate( 0, 1 );
+ $bDir = new ezcGraphCoordinate( 3, 0 );
+
+ $axisLabelRenderer = new ezcGraphAxisExactLabelRenderer();
+ $cuttingPosition = $axisLabelRenderer->determineLineCuttingPoint( $aStart, $aDir, $bStart, $bDir );
+
+ $this->assertSame(
+ $cuttingPosition,
+ false,
+ 'There should not be a cutting point.'
+ );
+ }
+}
+?>
diff --git a/tests/complete_rendering_test.php b/tests/complete_rendering_test.php
new file mode 100644
index 0000000..ff8d954
--- /dev/null
+++ b/tests/complete_rendering_test.php
@@ -0,0 +1,103 @@
+<?php
+/**
+ * ezcGraphCompleteRenderingTest
+ *
+ * @package Graph
+ * @version //autogen//
+ * @subpackage Tests
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Tests for ezcGraph class.
+ *
+ * @package ImageAnalysis
+ * @subpackage Tests
+ */
+class ezcGraphCompleteRenderingTest extends ezcTestCase
+{
+
+ protected $testFiles = array(
+ 'png' => 'png.png',
+ );
+
+ protected $basePath;
+
+ protected $tempDir;
+
+ public static function suite()
+ {
+ return new ezcTestSuite( "ezcGraphCompleteRenderingTest" );
+ }
+
+ /**
+ * setUp
+ *
+ * @access public
+ */
+ public function setUp()
+ {
+ static $i = 0;
+ $this->tempDir = $this->createTempDir( 'ezcGraphGdDriverTest' . sprintf( '_%03d_', ++$i ) ) . '/';
+ $this->basePath = dirname( __FILE__ ) . '/data/';
+ }
+
+ /**
+ * tearDown
+ *
+ * @access public
+ */
+ public function tearDown()
+ {
+ // $this->removeTempDir();
+ }
+
+ public function testRenderLineChart()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'line' );
+ $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);
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertEquals(
+ '1d586728bba88ddd9a6c18d42449a948',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testRenderWithTransparentBackground()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'line' );
+ $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart->palette = 'Black';
+ $chart->options->backgroundImage = $this->basePath . $this->testFiles['png'];
+ $chart->options->background = '#2E343655';
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '1d586728bba88ddd9a6c18d42449a948',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+}
+?>
diff --git a/tests/labeled_axis_test.php b/tests/labeled_axis_test.php
index 27c8af1..0a92895 100644
--- a/tests/labeled_axis_test.php
+++ b/tests/labeled_axis_test.php
@@ -115,40 +115,39 @@ class ezcGraphLabeledAxisTest extends ezcTestCase
$chart->xAxis->position = ezcGraph::LEFT;
$chart->render( 500, 200 );
- $testBoundings = new ezcGraphBoundings();
- $testBoundings->x0 = 50;
- $testBoundings->x1 = 400;
- $testBoundings->y0 = 75;
- $testBoundings->y1 = 330;
-
$this->assertEquals(
- 67.5,
- $chart->xAxis->getCoordinate( $testBoundings, false ),
- 'Wrong initial axis position. '
+ .0,
+ $chart->xAxis->getCoordinate( false ),
+ 'Wrong initial axis position. ',
+ .05
);
$this->assertEquals(
- 67.5,
- $chart->xAxis->getCoordinate( $testBoundings, '2000' ),
- 'Wrong minimal value. '
+ .0,
+ $chart->xAxis->getCoordinate( '2000' ),
+ 'Wrong minimal value. ',
+ .05
);
$this->assertEquals(
- 172.5,
- $chart->xAxis->getCoordinate( $testBoundings, 2001 ),
- 'Wrong mid value. '
+ .33,
+ $chart->xAxis->getCoordinate( 2001 ),
+ 'Wrong mid value. ',
+ .05
);
$this->assertEquals(
- 382.5,
- $chart->xAxis->getCoordinate( $testBoundings, '2003' ),
- 'Wrong maximum value. '
+ 1.,
+ $chart->xAxis->getCoordinate( '2003' ),
+ 'Wrong maximum value. ',
+ .05
);
$this->assertEquals(
- 67.5,
- $chart->xAxis->getCoordinate( $testBoundings, '1991' ),
- 'Wrong return for unknown value. '
+ .0,
+ $chart->xAxis->getCoordinate( '1991' ),
+ 'Wrong return for unknown value. ',
+ .05
);
}
@@ -159,40 +158,39 @@ class ezcGraphLabeledAxisTest extends ezcTestCase
$chart->xAxis->position = ezcGraph::RIGHT;
$chart->render( 500, 200 );
- $testBoundings = new ezcGraphBoundings();
- $testBoundings->x0 = 50;
- $testBoundings->x1 = 400;
- $testBoundings->y0 = 75;
- $testBoundings->y1 = 330;
-
$this->assertEquals(
- 382.5,
- $chart->xAxis->getCoordinate( $testBoundings, false ),
- 'Wrong initial axis position. '
+ 1.,
+ $chart->xAxis->getCoordinate( false ),
+ 'Wrong initial axis position. ',
+ .05
);
$this->assertEquals(
- 382.5,
- $chart->xAxis->getCoordinate( $testBoundings, '2000' ),
- 'Wrong minimal value. '
+ 1.,
+ $chart->xAxis->getCoordinate( '2000' ),
+ 'Wrong minimal value. ',
+ .05
);
$this->assertEquals(
- 277.5,
- $chart->xAxis->getCoordinate( $testBoundings, 2001 ),
- 'Wrong mid value. '
+ .66,
+ $chart->xAxis->getCoordinate( 2001 ),
+ 'Wrong mid value. ',
+ .05
);
$this->assertEquals(
- 67.5,
- $chart->xAxis->getCoordinate( $testBoundings, '2003' ),
- 'Wrong maximum value. '
+ .0,
+ $chart->xAxis->getCoordinate( '2003' ),
+ 'Wrong maximum value. ',
+ .05
);
$this->assertEquals(
- 382.5,
- $chart->xAxis->getCoordinate( $testBoundings, '1991' ),
- 'Wrong return for unknown value. '
+ 1.,
+ $chart->xAxis->getCoordinate( '1991' ),
+ 'Wrong return for unknown value. ',
+ .05
);
}
@@ -203,40 +201,39 @@ class ezcGraphLabeledAxisTest extends ezcTestCase
$chart->xAxis->position = ezcGraph::TOP;
$chart->render( 500, 200 );
- $testBoundings = new ezcGraphBoundings();
- $testBoundings->x0 = 50;
- $testBoundings->x1 = 400;
- $testBoundings->y0 = 75;
- $testBoundings->y1 = 330;
-
$this->assertEquals(
- 87.75,
- $chart->xAxis->getCoordinate( $testBoundings, false ),
- 'Wrong initial axis position. '
+ .0,
+ $chart->xAxis->getCoordinate( false ),
+ 'Wrong initial axis position. ',
+ .05
);
$this->assertEquals(
- 87.75,
- $chart->xAxis->getCoordinate( $testBoundings, '2000' ),
- 'Wrong minimal value. '
+ .0,
+ $chart->xAxis->getCoordinate( '2000' ),
+ 'Wrong minimal value. ',
+ .05
);
$this->assertEquals(
- 164.25,
- $chart->xAxis->getCoordinate( $testBoundings, 2001 ),
- 'Wrong mid value. '
+ .33,
+ $chart->xAxis->getCoordinate( 2001 ),
+ 'Wrong mid value. ',
+ .05
);
$this->assertEquals(
- 317.25,
- $chart->xAxis->getCoordinate( $testBoundings, '2003' ),
- 'Wrong maximum value. '
+ 1.,
+ $chart->xAxis->getCoordinate( '2003' ),
+ 'Wrong maximum value. ',
+ .05
);
$this->assertEquals(
- 87.75,
- $chart->xAxis->getCoordinate( $testBoundings, '1991' ),
- 'Wrong return for unknown value. '
+ .0,
+ $chart->xAxis->getCoordinate( '1991' ),
+ 'Wrong return for unknown value. ',
+ .05
);
}
@@ -247,384 +244,39 @@ class ezcGraphLabeledAxisTest extends ezcTestCase
$chart->xAxis->position = ezcGraph::BOTTOM;
$chart->render( 500, 200 );
- $testBoundings = new ezcGraphBoundings();
- $testBoundings->x0 = 50;
- $testBoundings->x1 = 400;
- $testBoundings->y0 = 75;
- $testBoundings->y1 = 330;
-
$this->assertEquals(
- 317.25,
- $chart->xAxis->getCoordinate( $testBoundings, false ),
- 'Wrong initial axis position. '
+ 1.,
+ $chart->xAxis->getCoordinate( false ),
+ 'Wrong initial axis position. ',
+ .05
);
$this->assertEquals(
- 317.25,
- $chart->xAxis->getCoordinate( $testBoundings, '2000' ),
- 'Wrong minimal value. '
+ 1.,
+ $chart->xAxis->getCoordinate( '2000' ),
+ 'Wrong minimal value. ',
+ .05
);
$this->assertEquals(
- 240.75,
- $chart->xAxis->getCoordinate( $testBoundings, 2001 ),
- 'Wrong mid value. '
+ .66,
+ $chart->xAxis->getCoordinate( 2001 ),
+ 'Wrong mid value. ',
+ .05
);
$this->assertEquals(
- 87.75,
- $chart->xAxis->getCoordinate( $testBoundings, '2003' ),
- 'Wrong maximum value. '
+ .0,
+ $chart->xAxis->getCoordinate( '2003' ),
+ 'Wrong maximum value. ',
+ .05
);
$this->assertEquals(
- 317.25,
- $chart->xAxis->getCoordinate( $testBoundings, '1991' ),
- 'Wrong return for unknown value. '
- );
- }
-
- public function testRenderLabeledAxisBase()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 );
- $chart['sample2'] = array( 2000 => 1270, 1170, 1610, 1370 );
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawLine',
- ) );
-
- // X-Axis
- $mockedRenderer
- ->expects( $this->at( 0 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 100, 190 ) ),
- $this->equalTo( new ezcGraphCoordinate( 500, 190 ) ),
- $this->equalTo( false )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderLabeledAxisArrowHead()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 );
- $chart['sample2'] = array( 2000 => 1270, 1170, 1610, 1370 );
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawPolygon',
- ) );
-
- // X-Axis
- $mockedRenderer
- ->expects( $this->at( 0 ) )
- ->method( 'drawPolygon' )
- ->with(
- $this->equalTo( array(
- new ezcGraphCoordinate( 500, 190 ),
- new ezcGraphCoordinate( 492, 186 ),
- new ezcGraphCoordinate( 492, 194 ),
- ) ),
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( true )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderLabeledAxisMajor()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 );
- $chart['sample2'] = array( 2000 => 1270, 1170, 1610, 1370 );
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawLine',
- ) );
-
- // X-Axis
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 120, 194 ) ),
- $this->equalTo( new ezcGraphCoordinate( 120, 186 ) ),
- $this->equalTo( false )
- );
- $mockedRenderer
- ->expects( $this->at( 2 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 240, 194 ) ),
- $this->equalTo( new ezcGraphCoordinate( 240, 186 ) ),
- $this->equalTo( false )
- );
- $mockedRenderer
- ->expects( $this->at( 3 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 361, 194 ) ),
- $this->equalTo( new ezcGraphCoordinate( 361, 186 ) ),
- $this->equalTo( false )
- );
- $mockedRenderer
- ->expects( $this->at( 4 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 481, 194 ) ),
- $this->equalTo( new ezcGraphCoordinate( 481, 186 ) ),
- $this->equalTo( false )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderNumericAxisMajorGrid()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 );
- $chart->xAxis->grid = '#BBBBBB';
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawLine',
- ) );
-
- // X-Axis
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ),
- $this->equalTo( new ezcGraphCoordinate( 120, 0 ) ),
- $this->equalTo( new ezcGraphCoordinate( 120, 200 ) ),
- $this->equalTo( false )
- );
- $mockedRenderer
- ->expects( $this->at( 3 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ),
- $this->equalTo( new ezcGraphCoordinate( 240, 0 ) ),
- $this->equalTo( new ezcGraphCoordinate( 240, 200 ) ),
- $this->equalTo( false )
- );
- $mockedRenderer
- ->expects( $this->at( 5 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ),
- $this->equalTo( new ezcGraphCoordinate( 361, 0 ) ),
- $this->equalTo( new ezcGraphCoordinate( 361, 200 ) ),
- $this->equalTo( false )
- );
- $mockedRenderer
- ->expects( $this->at( 7 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ),
- $this->equalTo( new ezcGraphCoordinate( 481, 0 ) ),
- $this->equalTo( new ezcGraphCoordinate( 481, 200 ) ),
- $this->equalTo( false )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderLabeledAxisLabels()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 );
- $chart['sample2'] = array( 2000 => 1270, 1170, 1610, 1370 );
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawTextBox',
- ) );
-
- // X-Axis
- $mockedRenderer
- ->expects( $this->at( 2 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 122, 192 ) ),
- $this->equalTo( '2000' ),
- $this->equalTo( 88 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::LEFT | ezcGraph::TOP )
- );
- $mockedRenderer
- ->expects( $this->at( 3 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 212, 192 ) ),
- $this->equalTo( '2001' ),
- $this->equalTo( 88 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::CENTER | ezcGraph::TOP )
- );
- $mockedRenderer
- ->expects( $this->at( 4 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 303, 192 ) ),
- $this->equalTo( '2002' ),
- $this->equalTo( 88 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::CENTER | ezcGraph::TOP )
- );
- $mockedRenderer
- ->expects( $this->at( 5 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 393, 192 ) ),
- $this->equalTo( '2003' ),
- $this->equalTo( 88 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::TOP )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderNumericAxisCustomLabels()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 );
- $chart['sample2'] = array( 2000 => 1270, 1170, 1610, 1370 );
- $chart->xAxis->formatString = 'test';
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawTextBox',
- ) );
-
- // X-Axis
- $mockedRenderer
- ->expects( $this->at( 2 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 122, 192 ) ),
- $this->equalTo( 'test' ),
- $this->equalTo( 88 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::LEFT | ezcGraph::TOP )
- );
- $mockedRenderer
- ->expects( $this->at( 3 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 212, 192 ) ),
- $this->equalTo( 'test' ),
- $this->equalTo( 88 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::CENTER | ezcGraph::TOP )
- );
- $mockedRenderer
- ->expects( $this->at( 4 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 303, 192 ) ),
- $this->equalTo( 'test' ),
- $this->equalTo( 88 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::CENTER | ezcGraph::TOP )
- );
- $mockedRenderer
- ->expects( $this->at( 5 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 393, 192 ) ),
- $this->equalTo( 'test' ),
- $this->equalTo( 88 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::TOP )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderLabeledAxisWithManyPoints()
- {
- $data = array();
- for ( $i = -100; $i <= 500; ++$i )
- {
- $data[$i] = 25 * sin( $i / 50 );
- }
- $chart = ezcGraph::create( 'Line' );
- $chart['sinus'] = $data;
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawTextBox',
- ) );
-
- // X-Axis
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 122, 102 ) ),
- $this->equalTo( '-100' ),
- $this->equalTo( 31 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::LEFT | ezcGraph::TOP )
- );
- $mockedRenderer
- ->expects( $this->at( 2 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 155, 102 ) ),
- $this->equalTo( '-40' ),
- $this->equalTo( 31 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::CENTER | ezcGraph::TOP )
- );
- $mockedRenderer
- ->expects( $this->at( 11 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 450, 102 ) ),
- $this->equalTo( '500' ),
- $this->equalTo( 31 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::TOP )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testSetNumericAxis()
- {
- $chart = ezcGraph::create( 'line' );
- $chart->xAxis = new ezcGraphChartElementLabeledAxis();
- $chart->yAxis = new ezcGraphChartElementLabeledAxis();
-
- $this->assertTrue(
- $chart->xAxis instanceof ezcGraphChartElementLabeledAxis,
- 'X axis should be labeled.'
- );
-
- $this->assertTrue(
- $chart->yAxis instanceof ezcGraphChartElementLabeledAxis,
- 'Y axis should be labeled.'
+ 1.,
+ $chart->xAxis->getCoordinate( '1991' ),
+ 'Wrong return for unknown value. ',
+ .05
);
}
}
diff --git a/tests/legend_test.php b/tests/legend_test.php
index 6c7f2ce..bd125de 100644
--- a/tests/legend_test.php
+++ b/tests/legend_test.php
@@ -125,360 +125,5 @@ class ezcGraphLegendTest extends ezcTestCase
$this->getNonPublicProperty( $chart->legend, 'position' )
);
}
-
- public function testRenderLegendBackground()
- {
- $chart = ezcGraph::create( 'Line' );
- $this->addSampleData( $chart );
- $chart->legend->background = '#0000FF';
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawBackground',
- ) );
-
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawBackground' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
- $this->equalTo( new ezcGraphCoordinate( 0, 0 ) ),
- $this->equalTo( 100 ),
- $this->equalTo( 200 )
- );
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderLegendSymbols()
- {
- $chart = ezcGraph::create( 'Line' );
- $this->addSampleData( $chart );
- $chart->legend->background = '#0000FF';
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawSymbol',
- ) );
-
- $mockedRenderer
- ->expects( $this->at( 0 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
- $this->equalTo( new ezcGraphCoordinate( 2, 2 ) ),
- $this->equalTo( 12 ),
- $this->equalTo( 12 ),
- ezcGraph::DIAMOND
- );
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 2, 18 ) ),
- $this->equalTo( 12 ),
- $this->equalTo( 12 ),
- ezcGraph::NO_SYMBOL
- );
- $mockedRenderer
- ->expects( $this->at( 2 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 2, 34 ) ),
- $this->equalTo( 12 ),
- $this->equalTo( 12 ),
- ezcGraph::NO_SYMBOL
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderLegendText()
- {
- $chart = ezcGraph::create( 'Line' );
- $this->addSampleData( $chart );
- $chart->legend->background = '#0000FF';
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawTextBox',
- ) );
-
- $mockedRenderer
- ->expects( $this->at( 0 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 17, 2 ) ),
- 'sampleData',
- $this->equalTo( 81 ),
- $this->equalTo( 12 ),
- $this->equalTo( ezcGraph::LEFT | ezcGraph::MIDDLE )
- );
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 17, 18 ) ),
- 'moreData',
- $this->equalTo( 81 ),
- $this->equalTo( 12 ),
- $this->equalTo( ezcGraph::LEFT | ezcGraph::MIDDLE )
-
- );
- $mockedRenderer
- ->expects( $this->at( 2 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 17, 34 ) ),
- 'Even more data',
- $this->equalTo( 81 ),
- $this->equalTo( 12 ),
- $this->equalTo( ezcGraph::LEFT | ezcGraph::MIDDLE )
-
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderLegendBackgroundRight()
- {
- $chart = ezcGraph::create( 'Line' );
- $this->addSampleData( $chart );
- $chart->legend->background = '#0000FF';
- $chart->legend->position = ezcGraph::RIGHT;
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawBackground',
- 'drawTextBox',
- 'drawSymbol',
- 'drawLine',
- ) );
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawBackground' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
- $this->equalTo( new ezcGraphCoordinate( 400, 0 ) ),
- $this->equalTo( 100 ),
- $this->equalTo( 200 )
- );
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderLegendSymbolsRight()
- {
- $chart = ezcGraph::create( 'Line' );
- $this->addSampleData( $chart );
- $chart->legend->background = '#0000FF';
- $chart->legend->position = ezcGraph::RIGHT;
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawSymbol',
- ) );
-
- $mockedRenderer
- ->expects( $this->at( 0 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
- $this->equalTo( new ezcGraphCoordinate( 402, 2 ) ),
- $this->equalTo( 12 ),
- $this->equalTo( 12 ),
- ezcGraph::DIAMOND
- );
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 402, 18 ) ),
- $this->equalTo( 12 ),
- $this->equalTo( 12 ),
- ezcGraph::NO_SYMBOL
- );
- $mockedRenderer
- ->expects( $this->at( 2 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 402, 34 ) ),
- $this->equalTo( 12 ),
- $this->equalTo( 12 ),
- ezcGraph::NO_SYMBOL
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderLegendBackgroundBottom()
- {
- $chart = ezcGraph::create( 'Line' );
- $this->addSampleData( $chart );
- $chart->legend->background = '#0000FF';
- $chart->legend->position = ezcGraph::BOTTOM;
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawBackground',
- ) );
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawBackground' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
- $this->equalTo( new ezcGraphCoordinate( 0, 180 ) ),
- $this->equalTo( 500 ),
- $this->equalTo( 20 )
- );
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderLegendSymbolsBottom()
- {
- $chart = ezcGraph::create( 'Line' );
- $this->addSampleData( $chart );
- $chart->legend->background = '#0000FF';
- $chart->legend->position = ezcGraph::BOTTOM;
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawSymbol',
- ) );
-
- $mockedRenderer
- ->expects( $this->at( 0 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
- $this->equalTo( new ezcGraphCoordinate( 2, 182 ) ),
- $this->equalTo( 12 ),
- $this->equalTo( 12 ),
- ezcGraph::DIAMOND
- );
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 101, 182 ) ),
- $this->equalTo( 12 ),
- $this->equalTo( 12 ),
- ezcGraph::NO_SYMBOL
- );
- $mockedRenderer
- ->expects( $this->at( 2 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 200, 182 ) ),
- $this->equalTo( 12 ),
- $this->equalTo( 12 ),
- ezcGraph::NO_SYMBOL
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 300, 200 );
- }
-
- public function testRenderLegendTextBottom()
- {
- $chart = ezcGraph::create( 'Line' );
- $this->addSampleData( $chart );
- $chart->legend->background = '#0000FF';
- $chart->legend->position = ezcGraph::TOP;
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawTextBox',
- ) );
-
- $mockedRenderer
- ->expects( $this->at( 0 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 18, 2 ) ),
- 'sampleData',
- $this->equalTo( 182 ),
- $this->equalTo( 12 )
- );
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 217, 2 ) ),
- 'moreData',
- $this->equalTo( 182 ),
- $this->equalTo( 12 )
- );
- $mockedRenderer
- ->expects( $this->at( 2 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 416, 2 ) ),
- 'Even more data',
- $this->equalTo( 182 ),
- $this->equalTo( 12 )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 600, 200 );
- }
-
- public function testRenderLegendBigSymbolsPadding()
- {
- $chart = ezcGraph::create( 'Line' );
- $this->addSampleData( $chart );
- $chart->legend->background = '#0000FF';
- $chart->legend->padding = 3;
- $chart->legend->symbolSize = 20;
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawSymbol',
- ) );
-
- $mockedRenderer
- ->expects( $this->at( 0 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
- $this->equalTo( new ezcGraphCoordinate( 6, 6 ) ),
- $this->equalTo( 14 ),
- $this->equalTo( 14 ),
- ezcGraph::DIAMOND
- );
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 6, 28 ) ),
- $this->equalTo( 14 ),
- $this->equalTo( 14 ),
- ezcGraph::NO_SYMBOL
- );
- $mockedRenderer
- ->expects( $this->at( 2 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 6, 50 ) ),
- $this->equalTo( 14 ),
- $this->equalTo( 14 ),
- ezcGraph::NO_SYMBOL
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
}
?>
diff --git a/tests/line_test.php b/tests/line_test.php
index 0d89592..34491ca 100644
--- a/tests/line_test.php
+++ b/tests/line_test.php
@@ -103,122 +103,68 @@ class ezcGraphLineChartTest extends ezcTestCase
$chart['sampleData']->symbol = ezcGraph::DIAMOND;
$mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawLine',
+ 'drawDataLine',
) );
$mockedRenderer
- ->expects( $this->at( 28 ) )
- ->method( 'drawLine' )
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawDataLine' )
->with(
+ $this->equalTo( new ezcGraphBoundings( 101, 18, 499, 182 ) ),
$this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 120, 85 ) ),
- $this->equalTo( new ezcGraphCoordinate( 210, 181 ) ),
- $this->equalTo( 2 )
- );
- $mockedRenderer
- ->expects( $this->at( 29 ) )
- ->method( 'drawLine' )
- ->with(
+ $this->equalTo( new ezcGraphCoordinate( .0, .415 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( .0, .415 ), .05 ),
+ $this->equalTo( ezcGraph::DIAMOND ),
$this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 210, 181 ) ),
- $this->equalTo( new ezcGraphCoordinate( 300, 44 ) ),
- $this->equalTo( 2 )
+ $this->equalTo( null )
);
$mockedRenderer
- ->expects( $this->at( 30 ) )
- ->method( 'drawLine' )
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawDataLine' )
->with(
+ $this->equalTo( new ezcGraphBoundings( 101, 18, 499, 182 ) ),
$this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 300, 44 ) ),
- $this->equalTo( new ezcGraphCoordinate( 390, 136 ) ),
- $this->equalTo( 2 )
- );
- $mockedRenderer
- ->expects( $this->at( 31 ) )
- ->method( 'drawLine' )
- ->with(
+ $this->equalTo( new ezcGraphCoordinate( .0, .415 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( .25, .95 ), .05 ),
+ $this->equalTo( ezcGraph::DIAMOND ),
$this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 390, 136 ) ),
- $this->equalTo( new ezcGraphCoordinate( 480, 190 ) ),
- $this->equalTo( 2 )
+ $this->equalTo( null )
);
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderChartFilledLines()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => -46, 'sample 4' => 120 );
- $chart->palette = 'Black';
- $chart->options->fillLines = 100;
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawPolygon',
- ) );
-
$mockedRenderer
->expects( $this->at( 2 ) )
- ->method( 'drawPolygon' )
+ ->method( 'drawDataLine' )
->with(
- $this->equalTo( array(
- new ezcGraphCoordinate( 120, 40 ),
- new ezcGraphCoordinate( 240, 136 ),
- new ezcGraphCoordinate( 240, 145 ),
- new ezcGraphCoordinate( 120, 145 ),
- ) ),
- $this->equalTo( ezcGraphColor::fromHex( '#3465A464' ) ),
- $this->equalTo( true )
+ $this->equalTo( new ezcGraphBoundings( 101, 18, 499, 182 ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .25, .95 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( .5, .2 ), .05 ),
+ $this->equalTo( ezcGraph::DIAMOND ),
+ $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
+ $this->equalTo( null )
);
$mockedRenderer
->expects( $this->at( 3 ) )
- ->method( 'drawPolygon' )
- ->with(
- $this->equalTo( array(
- new ezcGraphCoordinate( 240, 136 ),
- new ezcGraphCoordinate( 276, 145 ),
- new ezcGraphCoordinate( 240, 145 ),
- ) ),
- $this->equalTo( ezcGraphColor::fromHex( '#3465A464' ) ),
- $this->equalTo( true )
- );
- $mockedRenderer
- ->expects( $this->at( 4 ) )
- ->method( 'drawPolygon' )
- ->with(
- $this->equalTo( array(
- new ezcGraphCoordinate( 360, 166 ),
- new ezcGraphCoordinate( 276, 145 ),
- new ezcGraphCoordinate( 360, 145 ),
- ) ),
- $this->equalTo( ezcGraphColor::fromHex( '#3465A464' ) ),
- $this->equalTo( true )
- );
- $mockedRenderer
- ->expects( $this->at( 5 ) )
- ->method( 'drawPolygon' )
+ ->method( 'drawDataLine' )
->with(
- $this->equalTo( array(
- new ezcGraphCoordinate( 360, 166 ),
- new ezcGraphCoordinate( 394, 145 ),
- new ezcGraphCoordinate( 360, 145 ),
- ) ),
- $this->equalTo( ezcGraphColor::fromHex( '#3465A464' ) ),
- $this->equalTo( true )
+ $this->equalTo( new ezcGraphBoundings( 101, 18, 499, 182 ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .5, .2 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( .75, .7 ), .05 ),
+ $this->equalTo( ezcGraph::DIAMOND ),
+ $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
+ $this->equalTo( null )
);
$mockedRenderer
- ->expects( $this->at( 6 ) )
- ->method( 'drawPolygon' )
+ ->expects( $this->at( 4 ) )
+ ->method( 'drawDataLine' )
->with(
- $this->equalTo( array(
- new ezcGraphCoordinate( 480, 91 ),
- new ezcGraphCoordinate( 394, 145 ),
- new ezcGraphCoordinate( 480, 145 ),
- ) ),
- $this->equalTo( ezcGraphColor::fromHex( '#3465A464' ) ),
- $this->equalTo( true )
+ $this->equalTo( new ezcGraphBoundings( 101, 18, 499, 182 ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .75, .7 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( 1., .9975 ), .05 ),
+ $this->equalTo( ezcGraph::DIAMOND ),
+ $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
+ $this->equalTo( null )
);
$chart->renderer = $mockedRenderer;
@@ -226,84 +172,52 @@ class ezcGraphLineChartTest extends ezcTestCase
$chart->render( 500, 200 );
}
-
- public function testRenderChartFilledLinesZero()
+ public function testRenderChartFilledLines()
{
$chart = ezcGraph::create( 'Line' );
- $chart['sampleData'] = array( 'sample 1' => 0, 'sample 2' => 0 );
+ $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => -46, 'sample 4' => 120, 'sample 5' => 100 );
$chart->palette = 'Black';
$chart->options->fillLines = 100;
$mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawPolygon',
- ) );
-
- $mockedRenderer
- ->expects( $this->at( 2 ) )
- ->method( 'drawPolygon' )
- ->with(
- $this->equalTo( array(
- new ezcGraphCoordinate( 120, 190 ),
- new ezcGraphCoordinate( 480, 190 ),
- new ezcGraphCoordinate( 480, 190 ),
- new ezcGraphCoordinate( 120, 190 ),
- ) ),
- $this->equalTo( ezcGraphColor::fromHex( '#3465A464' ) ),
- $this->equalTo( true )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderChartLinesModifiedThickness()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $chart['sampleData']->color = '#CC0000';
- $chart['sampleData']->symbol = ezcGraph::DIAMOND;
- $chart->options->lineThickness = 1;
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawLine',
+ 'drawDataLine',
) );
$mockedRenderer
- ->expects( $this->at( 28 ) )
- ->method( 'drawLine' )
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawDataLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 120, 85 ) ),
- $this->equalTo( new ezcGraphCoordinate( 210, 181 ) ),
- $this->equalTo( 1 )
- );
- $mockedRenderer
- ->expects( $this->at( 29 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 210, 181 ) ),
- $this->equalTo( new ezcGraphCoordinate( 300, 44 ) ),
- $this->equalTo( 1 )
+ $this->equalTo( new ezcGraphBoundings( 103, 20, 497, 180 ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#3465A4' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .0, .165 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( .0, .165 ), .05 ),
+ $this->equalTo( ezcGraph::NO_SYMBOL ),
+ $this->equalTo( ezcGraphColor::fromHex( '#3465A4' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#3465A464' ) )
);
$mockedRenderer
- ->expects( $this->at( 30 ) )
- ->method( 'drawLine' )
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawDataLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 300, 44 ) ),
- $this->equalTo( new ezcGraphCoordinate( 390, 136 ) ),
- $this->equalTo( 1 )
+ $this->equalTo( new ezcGraphBoundings( 103, 20, 497, 180 ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#3465A4' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .0, .165 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( .25, .6975 ), .05 ),
+ $this->equalTo( ezcGraph::NO_SYMBOL ),
+ $this->equalTo( ezcGraphColor::fromHex( '#3465A4' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#3465A464' ) )
);
$mockedRenderer
- ->expects( $this->at( 31 ) )
- ->method( 'drawLine' )
+ ->expects( $this->at( 4 ) )
+ ->method( 'drawDataLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 390, 136 ) ),
- $this->equalTo( new ezcGraphCoordinate( 480, 190 ) ),
- $this->equalTo( 1 )
+ $this->equalTo( new ezcGraphBoundings( 103, 20, 497, 180 ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#3465A4' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .75, .45 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( 1., .5 ), .05 ),
+ $this->equalTo( ezcGraph::NO_SYMBOL ),
+ $this->equalTo( ezcGraphColor::fromHex( '#3465A4' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#3465A464' ) )
);
$chart->renderer = $mockedRenderer;
@@ -314,123 +228,55 @@ class ezcGraphLineChartTest extends ezcTestCase
public function testRenderChartSymbols()
{
$chart = ezcGraph::create( 'Line' );
+ $chart->palette = 'Black';
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $chart['sampleData']->color = '#CC0000';
$chart['sampleData']->symbol = ezcGraph::DIAMOND;
+ $chart['sampleData']->symbol['sample 3'] = ezcGraph::CIRCLE;
$mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawSymbol',
+ 'drawDataLine',
) );
$mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawSymbol' )
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawDataLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 116, 81 ) ),
- $this->equalTo( 8 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::DIAMOND )
+ $this->equalTo( new ezcGraphBoundings( 103, 20, 497, 180 ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#729FCF' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .0, .415 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( .0, .415 ), .05 ),
+ $this->equalTo( ezcGraph::DIAMOND ),
+ $this->equalTo( ezcGraphColor::fromHex( '#729FCF' ) ),
+ $this->equalTo( null )
);
$mockedRenderer
->expects( $this->at( 2 ) )
- ->method( 'drawSymbol' )
+ ->method( 'drawDataLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 206, 177 ) ),
- $this->equalTo( 8 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::DIAMOND )
- );
- $mockedRenderer
- ->expects( $this->at( 3 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 296, 40 ) ),
- $this->equalTo( 8 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::DIAMOND )
+ $this->equalTo( new ezcGraphBoundings( 103, 20, 497, 180 ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#729FCF' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .25, .9475 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( .5, .19 ), .05 ),
+ $this->equalTo( ezcGraph::CIRCLE ),
+ $this->equalTo( ezcGraphColor::fromHex( '#729FCF' ) ),
+ $this->equalTo( null )
);
$mockedRenderer
->expects( $this->at( 4 ) )
- ->method( 'drawSymbol' )
+ ->method( 'drawDataLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 386, 132 ) ),
- $this->equalTo( 8 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::DIAMOND )
- );
- $mockedRenderer
- ->expects( $this->at( 5 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 476, 186 ) ),
- $this->equalTo( 8 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::DIAMOND )
+ $this->equalTo( new ezcGraphBoundings( 103, 20, 497, 180 ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#729FCF' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .75, .7 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( 1., .9975 ), .05 ),
+ $this->equalTo( ezcGraph::DIAMOND ),
+ $this->equalTo( ezcGraphColor::fromHex( '#729FCF' ) ),
+ $this->equalTo( null )
);
$chart->renderer = $mockedRenderer;
$chart->render( 500, 200 );
}
-
- public function testCompleteRendering()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.png';
-
- $chart = ezcGraph::create( 'Line' );
- $chart->title = 'Test graph';
- $chart->palette = 'Black';
-
- $this->addSampleData( $chart );
- $chart->driver = new ezcGraphGdDriver();
-
- $chart->options->font = $this->basePath . 'font.ttf';
- $chart->legend->font = $this->basePath . 'font2.ttf';
- $chart->render( 500, 200, $filename );
-
- $this->assertTrue(
- file_exists( $filename ),
- 'No image was generated.'
- );
-
- $this->assertEquals(
- '9466947154bc1f6f908a1f5905c0b207',
- md5_file( $filename ),
- 'Incorrect image rendered.'
- );
- }
-
- public function testCompleteRenderingWithoutLegend()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.png';
-
- $chart = ezcGraph::create( 'Line' );
- $chart->title = 'Test graph';
- $chart->palette = 'Black';
-
- $this->addSampleData( $chart );
- $chart->legend = false;
- $chart->driver = new ezcGraphGdDriver();
-
- $chart->options->font = $this->basePath . 'font.ttf';
- $chart->legend->font = $this->basePath . 'font2.ttf';
- $chart->render( 500, 200, $filename );
-
- $this->assertTrue(
- file_exists( $filename ),
- 'No image was generated.'
- );
-
- $this->assertEquals(
- '8735eff094555c48d2121c50d7359266',
- md5_file( $filename ),
- 'Incorrect image rendered.'
- );
- }
}
?>
diff --git a/tests/numeric_axis_test.php b/tests/numeric_axis_test.php
index fa9d7f7..f5b7a28 100644
--- a/tests/numeric_axis_test.php
+++ b/tests/numeric_axis_test.php
@@ -404,34 +404,32 @@ class ezcGraphNumericAxisTest extends ezcTestCase
$chart->yAxis->position = ezcGraph::LEFT;
$chart->render( 500, 200 );
- $testBoundings = new ezcGraphBoundings();
- $testBoundings->x0 = 50;
- $testBoundings->x1 = 400;
- $testBoundings->y0 = 75;
- $testBoundings->y1 = 330;
-
$this->assertEquals(
- 67.5,
- $chart->yAxis->getCoordinate( $testBoundings, false ),
- 'Wrong initial axis position. '
+ 0.,
+ $chart->yAxis->getCoordinate( false ),
+ 'Wrong initial axis position. ',
+ .05
);
$this->assertEquals(
- 67.5,
- $chart->yAxis->getCoordinate( $testBoundings, 1000 ),
- 'Wrong minimal value. '
+ 0.,
+ $chart->yAxis->getCoordinate( 1000 ),
+ 'Wrong minimal value. ',
+ .05
);
$this->assertEquals(
- 193.5,
- $chart->yAxis->getCoordinate( $testBoundings, 1200 ),
- 'Wrong mid value. '
+ .4,
+ $chart->yAxis->getCoordinate( 1200 ),
+ 'Wrong mid value. ',
+ .05
);
$this->assertEquals(
- 382.5,
- $chart->yAxis->getCoordinate( $testBoundings, 1500 ),
- 'Wrong maximum value. '
+ 1.,
+ $chart->yAxis->getCoordinate( 1500 ),
+ 'Wrong maximum value. ',
+ .05
);
}
@@ -442,34 +440,32 @@ class ezcGraphNumericAxisTest extends ezcTestCase
$chart->yAxis->position = ezcGraph::RIGHT;
$chart->render( 500, 200 );
- $testBoundings = new ezcGraphBoundings();
- $testBoundings->x0 = 50;
- $testBoundings->x1 = 400;
- $testBoundings->y0 = 75;
- $testBoundings->y1 = 330;
-
$this->assertEquals(
- 382.5,
- $chart->yAxis->getCoordinate( $testBoundings, false ),
- 'Wrong initial axis position. '
+ 1.,
+ $chart->yAxis->getCoordinate( false ),
+ 'Wrong initial axis position. ',
+ .05
);
$this->assertEquals(
- 382.5,
- $chart->yAxis->getCoordinate( $testBoundings, 1000 ),
- 'Wrong minimal value. '
+ 1.,
+ $chart->yAxis->getCoordinate( 1000 ),
+ 'Wrong minimal value. ',
+ .05
);
$this->assertEquals(
- 256.5,
- $chart->yAxis->getCoordinate( $testBoundings, 1200 ),
- 'Wrong mid value. '
+ .6,
+ $chart->yAxis->getCoordinate( 1200 ),
+ 'Wrong mid value. ',
+ .05
);
$this->assertEquals(
- 67.5,
- $chart->yAxis->getCoordinate( $testBoundings, 1500 ),
- 'Wrong maximum value. '
+ 0.,
+ $chart->yAxis->getCoordinate( 1500 ),
+ 'Wrong maximum value. ',
+ .05
);
}
@@ -480,34 +476,32 @@ class ezcGraphNumericAxisTest extends ezcTestCase
$chart->yAxis->position = ezcGraph::TOP;
$chart->render( 500, 200 );
- $testBoundings = new ezcGraphBoundings();
- $testBoundings->x0 = 50;
- $testBoundings->x1 = 400;
- $testBoundings->y0 = 75;
- $testBoundings->y1 = 330;
-
$this->assertEquals(
- 87.75,
- $chart->yAxis->getCoordinate( $testBoundings, false ),
- 'Wrong initial axis position. '
+ 0.,
+ $chart->yAxis->getCoordinate( false ),
+ 'Wrong initial axis position. ',
+ .05
);
$this->assertEquals(
- 87.75,
- $chart->yAxis->getCoordinate( $testBoundings, 1000 ),
- 'Wrong minimal value. '
+ 0.,
+ $chart->yAxis->getCoordinate( 1000 ),
+ 'Wrong minimal value. ',
+ .05
);
$this->assertEquals(
- 179.55,
- $chart->yAxis->getCoordinate( $testBoundings, 1200 ),
- 'Wrong mid value. '
+ 0.4,
+ $chart->yAxis->getCoordinate( 1200 ),
+ 'Wrong mid value. ',
+ .05
);
$this->assertEquals(
- 317.25,
- $chart->yAxis->getCoordinate( $testBoundings, 1500 ),
- 'Wrong maximum value. '
+ 1.,
+ $chart->yAxis->getCoordinate( 1500 ),
+ 'Wrong maximum value. ',
+ .05
);
}
@@ -518,34 +512,32 @@ class ezcGraphNumericAxisTest extends ezcTestCase
$chart->yAxis->position = ezcGraph::BOTTOM;
$chart->render( 500, 200 );
- $testBoundings = new ezcGraphBoundings();
- $testBoundings->x0 = 50;
- $testBoundings->x1 = 400;
- $testBoundings->y0 = 75;
- $testBoundings->y1 = 330;
-
$this->assertEquals(
- 317.25,
- $chart->yAxis->getCoordinate( $testBoundings, false ),
- 'Wrong initial axis position. '
+ 1.,
+ $chart->yAxis->getCoordinate( false ),
+ 'Wrong initial axis position. ',
+ .05
);
$this->assertEquals(
- 317.25,
- $chart->yAxis->getCoordinate( $testBoundings, 1000 ),
- 'Wrong minimal value. '
+ 1.,
+ $chart->yAxis->getCoordinate( 1000 ),
+ 'Wrong minimal value. ',
+ .05
);
$this->assertEquals(
- 225.45,
- $chart->yAxis->getCoordinate( $testBoundings, 1200 ),
- 'Wrong mid value. '
+ .6,
+ $chart->yAxis->getCoordinate( 1200 ),
+ 'Wrong mid value. ',
+ .05
);
$this->assertEquals(
- 87.75,
- $chart->yAxis->getCoordinate( $testBoundings, 1500 ),
- 'Wrong maximum value. '
+ 0.,
+ $chart->yAxis->getCoordinate( 1500 ),
+ 'Wrong maximum value. ',
+ .05
);
}
@@ -557,34 +549,32 @@ class ezcGraphNumericAxisTest extends ezcTestCase
$chart->yAxis->position = ezcGraph::LEFT;
$chart->render( 500, 200 );
- $testBoundings = new ezcGraphBoundings();
- $testBoundings->x0 = 50;
- $testBoundings->x1 = 400;
- $testBoundings->y0 = 75;
- $testBoundings->y1 = 330;
-
$this->assertEquals(
- 146.25,
- $chart->yAxis->getCoordinate( $testBoundings, false ),
- 'Wrong initial axis position. '
+ .25,
+ $chart->yAxis->getCoordinate( false ),
+ 'Wrong initial axis position. ',
+ .05
);
$this->assertEquals(
- 67.5,
- $chart->yAxis->getCoordinate( $testBoundings, -500 ),
- 'Wrong minimal value. '
+ 0.,
+ $chart->yAxis->getCoordinate( -500 ),
+ 'Wrong minimal value. ',
+ .05
);
$this->assertEquals(
- 335.25,
- $chart->yAxis->getCoordinate( $testBoundings, 1200 ),
- 'Wrong mid value. '
+ .85,
+ $chart->yAxis->getCoordinate( 1200 ),
+ 'Wrong mid value. ',
+ .05
);
$this->assertEquals(
- 382.5,
- $chart->yAxis->getCoordinate( $testBoundings, 1500 ),
- 'Wrong maximum value. '
+ 1.,
+ $chart->yAxis->getCoordinate( 1500 ),
+ 'Wrong maximum value. ',
+ .05
);
}
@@ -596,508 +586,11 @@ class ezcGraphNumericAxisTest extends ezcTestCase
$chart['evenMoreData'] = array( 'sample 1' => 300, 'sample 2' => -30, 'sample 3' => 220, 'sample 4' => 67, 'sample 5' => 450);
$chart->render( 500, 200 );
- $testBoundings = new ezcGraphBoundings();
- $testBoundings->x0 = 100;
- $testBoundings->x1 = 500;
- $testBoundings->y0 = 0;
- $testBoundings->y1 = 200;
-
- $this->assertEquals(
- 130,
- $chart->yAxis->getCoordinate( $testBoundings, false ),
- 'Wrong initial axis position. '
- );
- }
-
- public function testRenderNumericAxisBase()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 );
- $chart['sample2'] = array( 2000 => 1270, 1170, 1610, 1370 );
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawLine',
- ) );
-
- // Y-Axis
- // Base line
- $mockedRenderer
- ->expects( $this->at( 5 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 120, 200 ) ),
- $this->equalTo( new ezcGraphCoordinate( 120, 0 ) ),
- $this->equalTo( false )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderNumericAxisArrowHead()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 );
- $chart['sample2'] = array( 2000 => 1270, 1170, 1610, 1370 );
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawPolygon',
- ) );
-
- // X-Axis
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawPolygon' )
- ->with(
- $this->equalTo( array(
- new ezcGraphCoordinate( 120, 0 ),
- new ezcGraphCoordinate( 123, 5 ),
- new ezcGraphCoordinate( 118, 5 ),
- ) ),
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( true )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderNumericAxisMajor()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 );
- $chart['sample2'] = array( 2000 => 1270, 1170, 1610, 1370 );
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawLine',
- ) );
-
- // Y-Axis
- // Major step lines
- $mockedRenderer
- ->expects( $this->at( 6 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 124, 190 ) ),
- $this->equalTo( new ezcGraphCoordinate( 116, 190 ) ),
- $this->equalTo( false )
- );
- $mockedRenderer
- ->expects( $this->at( 7 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 124, 130 ) ),
- $this->equalTo( new ezcGraphCoordinate( 116, 130 ) ),
- $this->equalTo( false )
- );
- $mockedRenderer
- ->expects( $this->at( 8 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 124, 70 ) ),
- $this->equalTo( new ezcGraphCoordinate( 116, 70 ) ),
- $this->equalTo( false )
- );
- $mockedRenderer
- ->expects( $this->at( 9 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 124, 10 ) ),
- $this->equalTo( new ezcGraphCoordinate( 116, 10 ) ),
- $this->equalTo( false )
- );
-
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderNumericAxisMajorGrid()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 );
- $chart->yAxis->grid = ezcGraphColor::fromHex( '#BBBBBB' );
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawLine',
- ) );
-
- // Y-Axis
- $mockedRenderer
- ->expects( $this->at( 6 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ),
- $this->equalTo( new ezcGraphCoordinate( 100, 190 ) ),
- $this->equalTo( new ezcGraphCoordinate( 500, 190 ) ),
- $this->equalTo( false )
- );
- $mockedRenderer
- ->expects( $this->at( 8 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ),
- $this->equalTo( new ezcGraphCoordinate( 100, 154 ) ),
- $this->equalTo( new ezcGraphCoordinate( 500, 154 ) ),
- $this->equalTo( false )
- );
- $mockedRenderer
- ->expects( $this->at( 16 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ),
- $this->equalTo( new ezcGraphCoordinate( 100, 10 ) ),
- $this->equalTo( new ezcGraphCoordinate( 500, 10 ) ),
- $this->equalTo( false )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderNumericAxisMinor()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 );
- $chart['sample2'] = array( 2000 => 1270, 1170, 1610, 1370 );
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawLine',
- ) );
-
- // Y-Axis
- // Minor step lines
- $mockedRenderer
- ->expects( $this->at( 10 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 122, 190 ) ),
- $this->equalTo( new ezcGraphCoordinate( 118, 190 ) ),
- $this->equalTo( false )
- );
- $mockedRenderer
- ->expects( $this->at( 11 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 122, 178 ) ),
- $this->equalTo( new ezcGraphCoordinate( 118, 178 ) ),
- $this->equalTo( false )
- );
- $mockedRenderer
- ->expects( $this->at( 12 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 122, 166 ) ),
- $this->equalTo( new ezcGraphCoordinate( 118, 166 ) ),
- $this->equalTo( false )
- );
-
- // Last minor step
- $mockedRenderer
- ->expects( $this->at( 24 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 122, 22 ) ),
- $this->equalTo( new ezcGraphCoordinate( 118, 22 ) ),
- $this->equalTo( false )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderNumericAxisMinorGrid()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 );
- $chart->yAxis->minorGrid = '#BBBBBB';
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawLine',
- ) );
-
- // Y-Axis
- $mockedRenderer
- ->expects( $this->at( 12 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ),
- $this->equalTo( new ezcGraphCoordinate( 100, 190 ) ),
- $this->equalTo( new ezcGraphCoordinate( 500, 190 ) ),
- $this->equalTo( false )
- );
- $mockedRenderer
- ->expects( $this->at( 14 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ),
- $this->equalTo( new ezcGraphCoordinate( 100, 181 ) ),
- $this->equalTo( new ezcGraphCoordinate( 500, 181 ) ),
- $this->equalTo( false )
- );
-
- // Last minor step
- $mockedRenderer
- ->expects( $this->at( 50 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ),
- $this->equalTo( new ezcGraphCoordinate( 100, 19 ) ),
- $this->equalTo( new ezcGraphCoordinate( 500, 19 ) ),
- $this->equalTo( false )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderNumericAxisLabels()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 );
- $chart['sample2'] = array( 2000 => 1270, 1170, 1610, 1370 );
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawTextBox',
- ) );
-
- // Y-Axis
- $mockedRenderer
- ->expects( $this->at( 7 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 100, 130 ) ),
- $this->equalTo( '1000' ),
- $this->equalTo( 18 ),
- $this->equalTo( 58 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::BOTTOM )
- );
- $mockedRenderer
- ->expects( $this->at( 8 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 100, 70 ) ),
- $this->equalTo( '1250' ),
- $this->equalTo( 18 ),
- $this->equalTo( 58 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::BOTTOM )
- );
- $mockedRenderer
- ->expects( $this->at( 9 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 100, 10 ) ),
- $this->equalTo( '1500' ),
- $this->equalTo( 18 ),
- $this->equalTo( 58 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::BOTTOM )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderNumericAxisCustomLabels()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 );
- $chart['sample2'] = array( 2000 => 1270, 1170, 1610, 1370 );
- $chart->yAxis->formatString = 'test';
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawTextBox',
- ) );
-
- // Y-Axis
- $mockedRenderer
- ->expects( $this->at( 7 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 100, 130 ) ),
- $this->equalTo( 'test' ),
- $this->equalTo( 18 ),
- $this->equalTo( 58 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::BOTTOM )
- );
- $mockedRenderer
- ->expects( $this->at( 8 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 100, 70 ) ),
- $this->equalTo( 'test' ),
- $this->equalTo( 18 ),
- $this->equalTo( 58 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::BOTTOM )
- );
- $mockedRenderer
- ->expects( $this->at( 9 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 100, 10 ) ),
- $this->equalTo( 'test' ),
- $this->equalTo( 18 ),
- $this->equalTo( 58 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::BOTTOM )
- );
-
- $chart->renderer = $mockedRenderer;
-
- $chart->render( 500, 200 );
- }
-
- public function testRenderNumericXAndYAxisLabels()
- {
- $sin = array();
- for ( $i = -200; $i < 500; $i += 2 )
- {
- $sin[$i] = 25 * sin( $i / 50 );
- }
-
- $chart = ezcGraph::create( 'Line' );
- $chart->xAxis = new ezcGraphChartElementNumericAxis();
- $chart['sinus'] = $sin;
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawTextBox',
- ) );
-
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 122, 102 ) ),
- $this->equalTo( '-250' ),
- $this->equalTo( 118 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::LEFT | ezcGraph::TOP )
- );
- $mockedRenderer
- ->expects( $this->at( 2 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 242, 102 ) ),
- $this->equalTo( '0' ),
- $this->equalTo( 118 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::LEFT | ezcGraph::TOP )
- );
- $mockedRenderer
- ->expects( $this->at( 3 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 363, 102 ) ),
- $this->equalTo( '250' ),
- $this->equalTo( 118 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::LEFT | ezcGraph::TOP )
- );
- $mockedRenderer
- ->expects( $this->at( 4 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 363, 102 ) ),
- $this->equalTo( '500' ),
- $this->equalTo( 118 ),
- $this->equalTo( 8 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::TOP )
- );
-
- $chart->renderer = $mockedRenderer;
- $chart->render( 500, 200 );
- }
-
- public function testValueZeroAmplitude()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 70, 70, 70, 70 );
- $chart->render( 500, 200 );
-
- $this->assertEquals(
- 60.,
- $chart->yAxis->min,
- 'As value for: min; '
- );
-
- $this->assertEquals(
- 80.,
- $chart->yAxis->max,
- 'As value for: max; '
- );
-
- $this->assertEquals(
- 5.,
- $chart->yAxis->majorStep,
- 'As value for: majorStep; '
- );
-
- $this->assertEquals(
- 1.,
- $chart->yAxis->minorStep,
- 'As value for: minorStep; '
- );
- }
-
- public function testValueAllZero()
- {
- $chart = ezcGraph::create( 'Line' );
- $chart['sample'] = array( 2000 => 0, 0 );
- $chart->render( 500, 200 );
-
- $this->assertEquals(
- 0.,
- $chart->yAxis->min,
- 'As value for: min; '
- );
-
- $this->assertEquals(
- 1.,
- $chart->yAxis->max,
- 'As value for: max; '
- );
-
- $this->assertEquals(
- .25,
- $chart->yAxis->majorStep,
- 'As value for: majorStep; '
- );
-
$this->assertEquals(
- .05,
- $chart->yAxis->minorStep,
- 'As value for: minorStep; '
- );
- }
-
- public function testSetNumericAxis()
- {
- $chart = ezcGraph::create( 'line' );
- $chart->xAxis = new ezcGraphChartElementNumericAxis();
- $chart->yAxis = new ezcGraphChartElementNumericAxis();
-
- $this->assertTrue(
- $chart->xAxis instanceof ezcGraphChartElementNumericAxis,
- 'X axis should be numeric.'
- );
-
- $this->assertTrue(
- $chart->yAxis instanceof ezcGraphChartElementNumericAxis,
- 'Y axis should be numeric.'
+ 0.66,
+ $chart->yAxis->getCoordinate( false ),
+ 'Wrong initial axis position. ',
+ .05
);
}
}
diff --git a/tests/pie_test.php b/tests/pie_test.php
index d2005fd..c3fa240 100644
--- a/tests/pie_test.php
+++ b/tests/pie_test.php
@@ -93,6 +93,8 @@ class ezcGraphPieChartTest extends ezcTestCase
'Safari' => 987,
);
+ $chart['sample']->highlight['wget'] = true;
+
$mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
'drawPieSegment',
) );
@@ -101,375 +103,60 @@ class ezcGraphPieChartTest extends ezcTestCase
->expects( $this->at( 0 ) )
->method( 'drawPieSegment' )
->with(
+ $this->equalTo( new ezcGraphBoundings( 81, 18, 399, 182 ) ),
$this->equalTo( ezcGraphColor::fromHex( '#4E9A06' ) ),
- $this->equalTo( new ezcGraphCoordinate( 240, 100 ) ),
- $this->equalTo( 72 ),
- $this->equalTo( 0 ),
- $this->equalTo( 220.52646317558, .1 ),
- $this->equalTo( 0 )
+ $this->equalTo( 0., 1. ),
+ $this->equalTo( 220.5, .1 ),
+ $this->equalTo( 'Mozilla' ),
+ $this->equalTo( false )
);
$mockedRenderer
->expects( $this->at( 1 ) )
->method( 'drawPieSegment' )
->with(
+ $this->equalTo( new ezcGraphBoundings( 81, 18, 399, 182 ) ),
$this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 240, 100 ) ),
- $this->equalTo( 72 ),
- $this->equalTo( 220.52646317558, .1 ),
- $this->equalTo( 237.916549986, .1 ),
- $this->equalTo( 0 )
+ $this->equalTo( 220.5, .1 ),
+ $this->equalTo( 238., 1. ),
+ $this->equalTo( 'IE' ),
+ $this->equalTo( false )
);
$mockedRenderer
->expects( $this->at( 2 ) )
->method( 'drawPieSegment' )
->with(
+ $this->equalTo( new ezcGraphBoundings( 81, 18, 399, 182 ) ),
$this->equalTo( ezcGraphColor::fromHex( '#EDD400' ) ),
- $this->equalTo( new ezcGraphCoordinate( 240, 100 ) ),
- $this->equalTo( 72 ),
- $this->equalTo( 237.916549986, .1 ),
- $this->equalTo( 298.60543265192, .1 ),
- $this->equalTo( 0 )
+ $this->equalTo( 238., 1. ),
+ $this->equalTo( 298.6, 1. ),
+ $this->equalTo( 'Opera' ),
+ $this->equalTo( false )
);
$mockedRenderer
->expects( $this->at( 3 ) )
->method( 'drawPieSegment' )
->with(
+ $this->equalTo( new ezcGraphBoundings( 81, 18, 399, 182 ) ),
$this->equalTo( ezcGraphColor::fromHex( '#75505B' ) ),
- $this->equalTo( new ezcGraphCoordinate( 240, 100 ) ),
- $this->equalTo( 72 ),
- $this->equalTo( 298.60543265192, .1 ),
- $this->equalTo( 310.24922990759, .1 ),
- $this->equalTo( 0 )
+ $this->equalTo( 298.6, 1. ),
+ $this->equalTo( 310., 1. ),
+ $this->equalTo( 'wget' ),
+ $this->equalTo( true )
);
$mockedRenderer
->expects( $this->at( 4 ) )
->method( 'drawPieSegment' )
->with(
+ $this->equalTo( new ezcGraphBoundings( 81, 18, 399, 182 ) ),
$this->equalTo( ezcGraphColor::fromHex( '#F57900' ) ),
- $this->equalTo( new ezcGraphCoordinate( 240, 100 ) ),
- $this->equalTo( 72 ),
- $this->equalTo( 310.24922990759, .1 ),
- $this->equalTo( 360., .1 ),
- $this->equalTo( 0 )
- );
-
- $chart->renderer = $mockedRenderer;
- $chart->render( 400, 200 );
- }
-
- public function testPieRenderPieLables()
- {
- $chart = ezcGraph::create( 'Pie' );
- $chart['sample'] = array(
- 'Mozilla' => 4375,
- 'IE' => 345,
- 'Opera' => 1204,
- 'wget' => 231,
- 'Safari' => 987,
- );
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawTextBox',
- ) );
-
- $mockedRenderer
- ->expects( $this->at( 5 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 80, 11 ) ),
- $this->equalTo( 'Opera: 1204 (16.9%)' ),
- $this->equalTo( 118 ),
- $this->equalTo( 30 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::MIDDLE )
- );
- $mockedRenderer
- ->expects( $this->at( 6 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 80, 41 ) ),
- $this->equalTo( 'IE: 345 (4.8%)' ),
- $this->equalTo( 81 ),
- $this->equalTo( 30 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::MIDDLE )
- );
- $mockedRenderer
- ->expects( $this->at( 7 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 80, 128 ) ),
- $this->equalTo( 'Mozilla: 4375 (61.3%)' ),
- $this->equalTo( 81 ),
- $this->equalTo( 30 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::MIDDLE )
- );
- $mockedRenderer
- ->expects( $this->at( 8 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 304, 24 ) ),
- $this->equalTo( 'wget: 231 (3.2%)' ),
- $this->equalTo( 96 ),
- $this->equalTo( 30 ),
- $this->equalTo( ezcGraph::LEFT | ezcGraph::MIDDLE )
- );
- $mockedRenderer
- ->expects( $this->at( 9 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 329, 62 ) ),
- $this->equalTo( 'Safari: 987 (13.8%)' ),
- $this->equalTo( 71 ),
- $this->equalTo( 30 ),
- $this->equalTo( ezcGraph::LEFT | ezcGraph::MIDDLE )
- );
-
- $chart->renderer = $mockedRenderer;
- $chart->render( 400, 200 );
- }
-
- public function testPieRenderPieLablesWithoutSymbols()
- {
- $chart = ezcGraph::create( 'Pie' );
- $chart['sample'] = array(
- 'Mozilla' => 4375,
- 'IE' => 345,
- 'Opera' => 1204,
- 'wget' => 231,
- 'Safari' => 987,
- );
- $chart->options->showSymbol = false;
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawTextBox',
- ) );
-
- $mockedRenderer
- ->expects( $this->at( 5 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 80, 11 ) ),
- $this->equalTo( 'Opera: 1204 (16.9%)' ),
- $this->equalTo( 124 ),
- $this->equalTo( 30 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::MIDDLE )
- );
- $mockedRenderer
- ->expects( $this->at( 6 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 80, 41 ) ),
- $this->equalTo( 'IE: 345 (4.8%)' ),
- $this->equalTo( 87 ),
- $this->equalTo( 30 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::MIDDLE )
- );
- $mockedRenderer
- ->expects( $this->at( 7 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 80, 128 ) ),
- $this->equalTo( 'Mozilla: 4375 (61.3%)' ),
- $this->equalTo( 87 ),
- $this->equalTo( 30 ),
- $this->equalTo( ezcGraph::RIGHT | ezcGraph::MIDDLE )
- );
- $mockedRenderer
- ->expects( $this->at( 8 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 298, 24 ) ),
- $this->equalTo( 'wget: 231 (3.2%)' ),
- $this->equalTo( 102 ),
- $this->equalTo( 30 ),
- $this->equalTo( ezcGraph::LEFT | ezcGraph::MIDDLE )
- );
- $mockedRenderer
- ->expects( $this->at( 9 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 323, 62 ) ),
- $this->equalTo( 'Safari: 987 (13.8%)' ),
- $this->equalTo( 77 ),
- $this->equalTo( 30 ),
- $this->equalTo( ezcGraph::LEFT | ezcGraph::MIDDLE )
- );
-
- $chart->renderer = $mockedRenderer;
- $chart->render( 400, 200 );
- }
-
- public function testPieRenderPieLableIdentifiers()
- {
- $chart = ezcGraph::create( 'Pie' );
- $chart['sample'] = array(
- 'Mozilla' => 4375,
- 'IE' => 345,
- 'Opera' => 1204,
- 'wget' => 231,
- 'Safari' => 987,
- );
-
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawLine',
- 'drawSymbol',
- ) );
-
- $mockedRenderer
- ->expects( $this->at( 5 ) )
- ->method( 'drawLine' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 238, 47 ) ),
- $this->equalTo( new ezcGraphCoordinate( 204, 26 ) ),
+ $this->equalTo( 310., 1. ),
+ $this->equalTo( 360., 1. ),
+ $this->equalTo( 'Safari' ),
$this->equalTo( false )
);
- $mockedRenderer
- ->expects( $this->at( 6 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 235, 44 ) ),
- $this->equalTo( 6 ),
- $this->equalTo( 6 ),
- $this->equalTo( ezcGraph::BULLET )
- );
- $mockedRenderer
- ->expects( $this->at( 7 ) )
- ->method( 'drawSymbol' )
- ->with(
- $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
- $this->equalTo( new ezcGraphCoordinate( 201, 23 ) ),
- $this->equalTo( 6 ),
- $this->equalTo( 6 ),
- $this->equalTo( ezcGraph::BULLET )
- );
$chart->renderer = $mockedRenderer;
$chart->render( 400, 200 );
}
-
- public function testCompleteRendering()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.png';
-
- $chart = ezcGraph::create( 'Pie' );
-
- $chart['sample'] = array(
- 'Mozilla' => 4375,
- 'IE' => 345,
- 'Opera' => 1204,
- 'wget' => 231,
- 'Safari' => 987,
- );
-
- $chart->driver = new ezcGraphGdDriver();
- $chart->options->font = $this->basePath . 'font.ttf';
- $chart->render( 400, 200, $filename );
-
- $this->assertTrue(
- file_exists( $filename ),
- 'No image was generated.'
- );
-
- $this->assertEquals(
- 'dfc7af85be7a48e452c55ac1e1a84abe',
- md5_file( $filename ),
- 'Incorrect image rendered.'
- );
- }
-
- public function testCompleteRenderingWithoutLegend()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.png';
-
- $chart = ezcGraph::create( 'Pie' );
-
- $chart['sample'] = array(
- 'Mozilla' => 4375,
- 'IE' => 345,
- 'Opera' => 1204,
- 'wget' => 231,
- 'Safari' => 987,
- );
-
- $chart->legend = false;
- $chart->driver = new ezcGraphGdDriver();
- $chart->options->font = $this->basePath . 'font.ttf';
- $chart->render( 400, 200, $filename );
-
- $this->assertTrue(
- file_exists( $filename ),
- 'No image was generated.'
- );
-
- $this->assertEquals(
- 'd8186025828b208c2451333f22d9159c',
- md5_file( $filename ),
- 'Incorrect image rendered.'
- );
- }
-
- public function testCompleteRenderingWithHilight()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.png';
-
- $chart = ezcGraph::create( 'Pie' );
-
- $chart['sample'] = array(
- 'Mozilla' => 4375,
- 'IE' => 345,
- 'Opera' => 1204,
- 'wget' => 231,
- 'Safari' => 987,
- );
- $chart['sample']->highlight['Safari'] = true;
-
- $chart->driver = new ezcGraphGdDriver();
- $chart->options->font = $this->basePath . 'font.ttf';
- $chart->render( 400, 200, $filename );
-
- $this->assertTrue(
- file_exists( $filename ),
- 'No image was generated.'
- );
-
- $this->assertEquals(
- 'ea963eb0fa1549ac2f62a478e2a6225d',
- md5_file( $filename ),
- 'Incorrect image rendered.'
- );
- }
-
- public function testCompleteRenderingWithHilightWithoutSymbols()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.png';
-
- $chart = ezcGraph::create( 'Pie' );
- $chart->options->showSymbol = false;
-
- $chart['sample'] = array(
- 'Mozilla' => 4375,
- 'IE' => 345,
- 'Opera' => 1204,
- 'wget' => 231,
- 'Safari' => 987,
- );
- $chart['sample']->highlight['Safari'] = true;
-
- $chart->driver = new ezcGraphGdDriver();
- $chart->options->font = $this->basePath . 'font.ttf';
- $chart->render( 400, 200, $filename );
-
- $this->assertTrue(
- file_exists( $filename ),
- 'No image was generated.'
- );
-
- $this->assertEquals(
- '6ced9d94eb716fb5dfe8c5b1b945d42c',
- md5_file( $filename ),
- 'Incorrect image rendered.'
- );
- }
}
?>
diff --git a/tests/renderer_2d_test.php b/tests/renderer_2d_test.php
index 68a3060..49d7a39 100644
--- a/tests/renderer_2d_test.php
+++ b/tests/renderer_2d_test.php
@@ -46,6 +46,9 @@ class ezcGraphRenderer2dTest extends ezcTestCase
'drawImage',
) );
$this->renderer->setDriver( $this->driver );
+
+ $this->driver->options->width = 400;
+ $this->driver->options->height = 200;
}
/**
@@ -55,45 +58,336 @@ class ezcGraphRenderer2dTest extends ezcTestCase
*/
public function tearDown()
{
- $this->driver->verify();
}
- public function testRenderLine()
+ public function testRenderLabeledPieSegment()
{
$this->driver
- ->expects( $this->once() )
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawCircleSector' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 200, 100 ), 1. ),
+ $this->equalTo( 180, 1. ),
+ $this->equalTo( 180, 1. ),
+ $this->equalTo( 15, 1. ),
+ $this->equalTo( 156, 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawCircleSector' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 200, 100 ), 1. ),
+ $this->equalTo( 180, 1. ),
+ $this->equalTo( 180, 1. ),
+ $this->equalTo( 15, 1. ),
+ $this->equalTo( 156, 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#800000' ) ),
+ $this->equalTo( false )
+ );
+
+ $this->driver
+ ->expects( $this->at( 2 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 100, 100 ) ),
- $this->equalTo( new ezcGraphCoordinate( 113, 157 ) ),
- $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) )
+ $this->equalTo( new ezcGraphCoordinate( 205., 160. ), 1. ),
+ $this->equalTo( new ezcGraphCoordinate( 292.5, 150. ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( 1 )
+ );
+
+ $this->driver
+ ->expects( $this->at( 3 ) )
+ ->method( 'drawCircle' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 202., 157. ), 1. ),
+ $this->equalTo( 6 ),
+ $this->equalTo( 6 ),
+ $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 4 ) )
+ ->method( 'drawCircle' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 289.5, 147. ), 1. ),
+ $this->equalTo( 6 ),
+ $this->equalTo( 6 ),
+ $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( true )
+ );
+
+ $this->driver
+ ->expects( $this->at( 5 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( 'Testlabel' ),
+ $this->equalTo( new ezcGraphCoordinate( 298.5, 135. ), 1. ),
+ $this->equalTo( 101.5, 1. ),
+ $this->equalTo( 30., 1. ),
+ $this->equalTo( 36 )
+ );
+
+
+ // Render
+ $this->renderer->drawPieSegment(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ ezcGraphColor::fromHex( '#FF0000' ),
+ 15,
+ 156,
+ 'Testlabel',
+ 0
+ );
+
+ $this->renderer->render( 'foo.png' );
+ }
+
+ public function testRenderNonLabeledPieSegment()
+ {
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawCircleSector' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 200., 100. ), 1. ),
+ $this->equalTo( 180., 1. ),
+ $this->equalTo( 180., 1. ),
+ $this->equalTo( 15., 1. ),
+ $this->equalTo( 156., 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawCircleSector' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 200., 100. ), 1. ),
+ $this->equalTo( 180., 1. ),
+ $this->equalTo( 180., 1. ),
+ $this->equalTo( 15., 1. ),
+ $this->equalTo( 156., 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#800000' ) ),
+ $this->equalTo( false )
);
- $this->renderer->drawLine(
+ // Render
+ $this->renderer->drawPieSegment(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
ezcGraphColor::fromHex( '#FF0000' ),
- new ezcGraphCoordinate( 100, 100 ),
- new ezcGraphCoordinate( 113, 157 )
+ 15,
+ 156,
+ false,
+ 0
);
+
+ $this->renderer->render( 'foo.png' );
}
- public function testRenderTextBox()
+ public function testRenderNonLabeledPieSegmentMoveOut()
{
$this->driver
- ->expects( $this->once() )
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawCircleSector' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 201., 109. ), 1. ),
+ $this->equalTo( 180., 1. ),
+ $this->equalTo( 180., 1. ),
+ $this->equalTo( 15., 1. ),
+ $this->equalTo( 156., 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawCircleSector' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 201., 109. ), 1. ),
+ $this->equalTo( 180., 1. ),
+ $this->equalTo( 180., 1. ),
+ $this->equalTo( 15., 1. ),
+ $this->equalTo( 156., 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#800000' ) ),
+ $this->equalTo( false )
+ );
+
+ // Render
+ $this->renderer->drawPieSegment(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ ezcGraphColor::fromHex( '#FF0000' ),
+ 15,
+ 156,
+ false,
+ true
+ );
+
+ $this->renderer->render( 'foo.png' );
+ }
+
+ public function testRenderLotsOfLabeledPieSegments()
+ {
+ $this->driver
+ ->expects( $this->at( 13 ) )
->method( 'drawTextBox' )
->with(
- $this->equalTo( 'Drawing TextBox' ),
- $this->equalTo( new ezcGraphCoordinate( 100, 100 ) ),
- $this->equalTo( 100 ),
- $this->equalTo( 50 ),
- $this->equalTo( ezcGraph::LEFT )
+ $this->equalTo( 'Label 5' ),
+ $this->equalTo( new ezcGraphCoordinate( 0, 143. ), 1. ),
+ $this->equalTo( 106., 1. ),
+ $this->equalTo( 30., 1. ),
+ $this->equalTo( 40 )
+ );
+ $this->driver
+ ->expects( $this->at( 17 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( 'Label 1' ),
+ $this->equalTo( new ezcGraphCoordinate( 302., 42. ), 1. ),
+ $this->equalTo( 97., 1. ),
+ $this->equalTo( 30., 1. ),
+ $this->equalTo( 36 )
+ );
+ $this->driver
+ ->expects( $this->at( 21 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( 'Label 2' ),
+ $this->equalTo( new ezcGraphCoordinate( 312., 92. ), 1. ),
+ $this->equalTo( 88., 1. ),
+ $this->equalTo( 30., 1. ),
+ $this->equalTo( 36 )
+ );
+ $this->driver
+ ->expects( $this->at( 25 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( 'Label 3' ),
+ $this->equalTo( new ezcGraphCoordinate( 303., 127. ), 1. ),
+ $this->equalTo( 97., 1. ),
+ $this->equalTo( 30., 1. ),
+ $this->equalTo( 36 )
+ );
+ $this->driver
+ ->expects( $this->at( 29 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( 'Label 4' ),
+ $this->equalTo( new ezcGraphCoordinate( 281., 157. ), 1. ),
+ $this->equalTo( 119., 1. ),
+ $this->equalTo( 30., 1. ),
+ $this->equalTo( 36 )
+ );
+
+ // Render
+ $this->renderer->drawPieSegment( new ezcGraphBoundings( 0, 0, 400, 200 ), ezcGraphColor::fromHex( '#FF0000' ), 15, 27, 'Label 1', true );
+ $this->renderer->drawPieSegment( new ezcGraphBoundings( 0, 0, 400, 200 ), ezcGraphColor::fromHex( '#FF0000' ), 27, 38, 'Label 2', true );
+ $this->renderer->drawPieSegment( new ezcGraphBoundings( 0, 0, 400, 200 ), ezcGraphColor::fromHex( '#FF0000' ), 38, 45, 'Label 3', true );
+ $this->renderer->drawPieSegment( new ezcGraphBoundings( 0, 0, 400, 200 ), ezcGraphColor::fromHex( '#FF0000' ), 45, 70, 'Label 4', true );
+ $this->renderer->drawPieSegment( new ezcGraphBoundings( 0, 0, 400, 200 ), ezcGraphColor::fromHex( '#FF0000' ), 70, 119, 'Label 5', true );
+
+ $this->renderer->render( 'foo.png' );
+ }
+
+ public function testRenderDataLine()
+ {
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawLine' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 40., 160. ), 1. ),
+ $this->equalTo( new ezcGraphCoordinate( 280., 140. ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ $this->equalTo( 1 )
+ );
+
+ $this->renderer->drawDataLine(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ ezcGraphColor::fromHex( '#FF0000' ),
+ new ezcGraphCoordinate( .1, .2 ),
+ new ezcGraphCoordinate( .7, .3 )
+ );
+ }
+
+ public function testRenderFilledDataLine()
+ {
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 40., 160. ),
+ new ezcGraphCoordinate( 280., 140. ),
+ new ezcGraphCoordinate( 280., 200. ),
+ new ezcGraphCoordinate( 40., 200. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000DD' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawLine' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 40., 160. ), 1. ),
+ $this->equalTo( new ezcGraphCoordinate( 280., 140. ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ $this->equalTo( 1 )
);
- $this->renderer->drawTextBox(
- new ezcGraphCoordinate( 100, 100 ),
- 'Drawing TextBox',
- 100,
- 50
+ $this->renderer->drawDataLine(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ ezcGraphColor::fromHex( '#FF0000' ),
+ new ezcGraphCoordinate( .1, .2 ),
+ new ezcGraphCoordinate( .7, .3 ),
+ ezcGraph::NO_SYMBOL,
+ null,
+ ezcGraphColor::fromHex( '#FF0000DD' ),
+ .0
+ );
+ }
+
+ public function testRenderFilledDataLineWithIntersection()
+ {
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 40., 100. ),
+ new ezcGraphCoordinate( 40., 160. ),
+ new ezcGraphCoordinate( 148., 100. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000DD' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 280., 100. ),
+ new ezcGraphCoordinate( 280., 60. ),
+ new ezcGraphCoordinate( 148., 100. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000DD' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 2 ) )
+ ->method( 'drawLine' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 40., 160. ), 1. ),
+ $this->equalTo( new ezcGraphCoordinate( 280., 60. ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ $this->equalTo( 1 )
+ );
+
+ $this->renderer->drawDataLine(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ ezcGraphColor::fromHex( '#FF0000' ),
+ new ezcGraphCoordinate( .1, .2 ),
+ new ezcGraphCoordinate( .7, .7 ),
+ ezcGraph::NO_SYMBOL,
+ null,
+ ezcGraphColor::fromHex( '#FF0000DD' ),
+ .5
);
}
@@ -114,10 +408,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase
);
$this->renderer->drawSymbol(
- ezcGraphColor::fromHex( '#FF0000' ),
- new ezcGraphCoordinate( 100, 100 ),
- 20,
- 20
+ new ezcGraphBoundings( 100, 100, 120, 120 ),
+ ezcGraphColor::fromHex( '#FF0000' )
);
}
@@ -138,10 +430,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase
);
$this->renderer->drawSymbol(
+ new ezcGraphBoundings( 100, 100, 120, 120 ),
ezcGraphColor::fromHex( '#FF0000' ),
- new ezcGraphCoordinate( 100, 100 ),
- 20,
- 20,
ezcGraph::DIAMOND
);
}
@@ -160,10 +450,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase
);
$this->renderer->drawSymbol(
+ new ezcGraphBoundings( 100, 100, 120, 120 ),
ezcGraphColor::fromHex( '#FF0000' ),
- new ezcGraphCoordinate( 100, 100 ),
- 20,
- 20,
ezcGraph::BULLET
);
}
@@ -182,179 +470,994 @@ class ezcGraphRenderer2dTest extends ezcTestCase
);
$this->renderer->drawSymbol(
+ new ezcGraphBoundings( 100, 100, 120, 120 ),
ezcGraphColor::fromHex( '#FF0000' ),
- new ezcGraphCoordinate( 100, 100 ),
- 20,
- 20,
ezcGraph::CIRCLE
);
}
- public function testRenderRect()
+ public function testRenderFilledDataLineWithSymbolSameColor()
{
$this->driver
- ->expects( $this->once() )
+ ->expects( $this->at( 0 ) )
->method( 'drawPolygon' )
->with(
$this->equalTo( array(
- new ezcGraphCoordinate( 100, 100 ),
- new ezcGraphCoordinate( 150, 100 ),
- new ezcGraphCoordinate( 150, 150 ),
- new ezcGraphCoordinate( 100, 150 ),
- ) ),
+ new ezcGraphCoordinate( 40., 100. ),
+ new ezcGraphCoordinate( 40., 160. ),
+ new ezcGraphCoordinate( 148., 100. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000DD' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 280., 100. ),
+ new ezcGraphCoordinate( 280., 60. ),
+ new ezcGraphCoordinate( 148., 100. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000DD' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 2 ) )
+ ->method( 'drawLine' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 40., 160. ), 1. ),
+ $this->equalTo( new ezcGraphCoordinate( 280., 60. ), 1. ),
$this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( false ),
$this->equalTo( 1 )
);
+ $this->driver
+ ->expects( $this->at( 3 ) )
+ ->method( 'drawCircle' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 280, 60 ) ),
+ $this->equalTo( 6 ),
+ $this->equalTo( 6 ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ $this->equalTo( false )
+ );
- $this->renderer->drawRect(
- ezcGraphColor::fromHex( '#FF0000' ),
- new ezcGraphCoordinate( 100, 100 ),
- 50,
- 50
+ $this->renderer->drawDataLine(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ ezcGraphColor::fromHex( '#FF0000' ),
+ new ezcGraphCoordinate( .1, .2 ),
+ new ezcGraphCoordinate( .7, .7 ),
+ ezcGraph::CIRCLE,
+ null,
+ ezcGraphColor::fromHex( '#FF0000DD' ),
+ .5
);
}
- public function testRenderThickRect()
+ public function testRenderFilledDataLineWithSymbolInDifferentColorAndCustomSize()
{
$this->driver
- ->expects( $this->once() )
+ ->expects( $this->at( 0 ) )
->method( 'drawPolygon' )
->with(
$this->equalTo( array(
- new ezcGraphCoordinate( 100, 100 ),
- new ezcGraphCoordinate( 150, 100 ),
- new ezcGraphCoordinate( 150, 150 ),
- new ezcGraphCoordinate( 100, 150 ),
- ) ),
+ new ezcGraphCoordinate( 40., 100. ),
+ new ezcGraphCoordinate( 40., 160. ),
+ new ezcGraphCoordinate( 148., 100. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000DD' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 280., 100. ),
+ new ezcGraphCoordinate( 280., 60. ),
+ new ezcGraphCoordinate( 148., 100. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000DD' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 2 ) )
+ ->method( 'drawLine' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 40., 160. ), 1. ),
+ $this->equalTo( new ezcGraphCoordinate( 280., 60. ), 1. ),
$this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( false ),
- $this->equalTo( 2 )
+ $this->equalTo( 1 )
+ );
+ $this->driver
+ ->expects( $this->at( 3 ) )
+ ->method( 'drawCircle' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 280, 60 ) ),
+ $this->equalTo( 10 ),
+ $this->equalTo( 10 ),
+ $this->equalTo( ezcGraphColor::fromHex( '#00FF00' ) ),
+ $this->equalTo( true )
);
- $this->renderer->drawRect(
- ezcGraphColor::fromHex( '#FF0000' ),
- new ezcGraphCoordinate( 100, 100 ),
- 50,
- 50,
- 2
+ $this->renderer->options->symbolSize = 10;
+
+ $this->renderer->drawDataLine(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ ezcGraphColor::fromHex( '#FF0000' ),
+ new ezcGraphCoordinate( .1, .2 ),
+ new ezcGraphCoordinate( .7, .7 ),
+ ezcGraph::BULLET,
+ ezcGraphColor::fromHex( '#00FF00' ),
+ ezcGraphColor::fromHex( '#FF0000DD' ),
+ .5
);
}
- public function testRenderPieSegment()
+ public function testRenderBox()
{
$this->driver
->expects( $this->at( 0 ) )
- ->method( 'drawCircleSector' )
+ ->method( 'drawPolygon' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 100, 100 ) ),
- $this->equalTo( 200 ),
- $this->equalTo( 200 ),
- $this->equalTo( 20 ),
- $this->equalTo( 124 ),
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 1., 1. ),
+ new ezcGraphCoordinate( 399., 1. ),
+ new ezcGraphCoordinate( 399., 199. ),
+ new ezcGraphCoordinate( 1., 199. ),
+ ), 1. ),
$this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ $this->equalTo( false )
+ );
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 2., 2. ),
+ new ezcGraphCoordinate( 398., 2. ),
+ new ezcGraphCoordinate( 398., 198. ),
+ new ezcGraphCoordinate( 2., 198. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#BB0000' ) ),
$this->equalTo( true )
);
+
+ $boundings = $this->renderer->drawBox(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ ezcGraphColor::fromHex( '#BB0000' ),
+ ezcGraphColor::fromHex( '#FF0000' ),
+ 1,
+ 1,
+ 1
+ );
+
+ $this->assertEquals(
+ $boundings,
+ new ezcGraphBoundings( 3., 3., 397., 197. ),
+ 'Returned boundings are not as expected.',
+ 1.
+ );
+ }
+
+ public function testRenderBoxDifferentPadding()
+ {
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 3., 3. ),
+ new ezcGraphCoordinate( 397., 3. ),
+ new ezcGraphCoordinate( 397., 197. ),
+ new ezcGraphCoordinate( 3., 197. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ $this->equalTo( false )
+ );
$this->driver
->expects( $this->at( 1 ) )
- ->method( 'drawCircleSector' )
+ ->method( 'drawPolygon' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 100, 100 ) ),
- $this->equalTo( 200 ),
- $this->equalTo( 200 ),
- $this->equalTo( 20 ),
- $this->equalTo( 124 ),
- $this->equalTo( ezcGraphColor::fromHex( '#800000' ) ),
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 5., 5. ),
+ new ezcGraphCoordinate( 395., 5. ),
+ new ezcGraphCoordinate( 395., 195. ),
+ new ezcGraphCoordinate( 5., 195. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#BB0000' ) ),
+ $this->equalTo( true )
+ );
+
+ $boundings = $this->renderer->drawBox(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ ezcGraphColor::fromHex( '#BB0000' ),
+ ezcGraphColor::fromHex( '#FF0000' ),
+ 2,
+ 3,
+ 4
+ );
+
+ $this->assertEquals(
+ $boundings,
+ new ezcGraphBoundings( 9., 9., 391., 191. ),
+ 'Returned boundings are not as expected.',
+ 1.
+ );
+ }
+
+ public function testRenderBoxWithoutBorder()
+ {
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 1., 1. ),
+ new ezcGraphCoordinate( 399., 1. ),
+ new ezcGraphCoordinate( 399., 199. ),
+ new ezcGraphCoordinate( 1., 199. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#BB0000' ) ),
+ $this->equalTo( true )
+ );
+
+ $boundings = $this->renderer->drawBox(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ ezcGraphColor::fromHex( '#BB0000' ),
+ null,
+ 0,
+ 1,
+ 1
+ );
+
+ $this->assertEquals(
+ $boundings,
+ new ezcGraphBoundings( 2., 2., 398., 198. ),
+ 'Returned boundings are not as expected.',
+ 1.
+ );
+ }
+
+ public function testRenderBoxWithoutBackground()
+ {
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 1., 1. ),
+ new ezcGraphCoordinate( 399., 1. ),
+ new ezcGraphCoordinate( 399., 199. ),
+ new ezcGraphCoordinate( 1., 199. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
$this->equalTo( false )
);
- $this->renderer->drawPieSegment(
- ezcGraphColor::fromHex( '#FF0000' ),
- new ezcGraphCoordinate( 100, 100 ),
- 100,
- 20,
- 124
+ $boundings = $this->renderer->drawBox(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ null,
+ ezcGraphColor::fromHex( '#FF0000' ),
+ 1,
+ 1,
+ 1
+ );
+
+ $this->assertEquals(
+ $boundings,
+ new ezcGraphBoundings( 3., 3., 397., 197. ),
+ 'Returned boundings are not as expected.',
+ 1.
);
}
- public function testRenderPieSegmentMoveOut()
+ public function testRenderBoxWithTitle()
{
$this->driver
->expects( $this->at( 0 ) )
- ->method( 'drawCircleSector' )
+ ->method( 'drawPolygon' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 95, 100 ) ),
- $this->equalTo( 200 ),
- $this->equalTo( 200 ),
- $this->equalTo( 90 ),
- $this->equalTo( 270 ),
- $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) )
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 1., 1. ),
+ new ezcGraphCoordinate( 399., 1. ),
+ new ezcGraphCoordinate( 399., 199. ),
+ new ezcGraphCoordinate( 1., 199. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ $this->equalTo( false )
);
$this->driver
->expects( $this->at( 1 ) )
- ->method( 'drawCircleSector' )
+ ->method( 'drawPolygon' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 95, 100 ) ),
- $this->equalTo( 200 ),
- $this->equalTo( 200 ),
- $this->equalTo( 90 ),
- $this->equalTo( 270 ),
- $this->equalTo( ezcGraphColor::fromHex( '#800000' ) ),
- $this->equalTo( false )
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 2., 2. ),
+ new ezcGraphCoordinate( 398., 2. ),
+ new ezcGraphCoordinate( 398., 198. ),
+ new ezcGraphCoordinate( 2., 198. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#BB0000' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 2 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( 'Boxtitle' ),
+ $this->equalTo( new ezcGraphCoordinate( 3., 3. ), 1. ),
+ $this->equalTo( 394., 1. ),
+ $this->equalTo( 20., 1. ),
+ $this->equalTo( 48 )
);
- $this->renderer->drawPieSegment(
- ezcGraphColor::fromHex( '#FF0000' ),
- new ezcGraphCoordinate( 100, 100 ),
- 100,
- 90,
- 270,
- 5
+ $boundings = $this->renderer->drawBox(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ ezcGraphColor::fromHex( '#BB0000' ),
+ ezcGraphColor::fromHex( '#FF0000' ),
+ 1,
+ 1,
+ 1,
+ 'Boxtitle',
+ 20
+ );
+
+ $this->assertEquals(
+ $boundings,
+ new ezcGraphBoundings( 3., 24., 397., 176. ),
+ 'Returned boundings are not as expected.',
+ 1.
);
}
- public function testRenderBackground()
+ public function testRenderBoxWithBottomTitleAndLeftAlignement()
{
$this->driver
- ->expects( $this->once() )
+ ->expects( $this->at( 0 ) )
->method( 'drawPolygon' )
->with(
$this->equalTo( array(
- new ezcGraphCoordinate( 100, 100 ),
- new ezcGraphCoordinate( 150, 100 ),
- new ezcGraphCoordinate( 150, 150 ),
- new ezcGraphCoordinate( 100, 150 ),
- ) ),
+ new ezcGraphCoordinate( 1., 1. ),
+ new ezcGraphCoordinate( 399., 1. ),
+ new ezcGraphCoordinate( 399., 199. ),
+ new ezcGraphCoordinate( 1., 199. ),
+ ), 1. ),
$this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- true
+ $this->equalTo( false )
+ );
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 2., 2. ),
+ new ezcGraphCoordinate( 398., 2. ),
+ new ezcGraphCoordinate( 398., 198. ),
+ new ezcGraphCoordinate( 2., 198. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#BB0000' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 2 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( 'Boxtitle' ),
+ $this->equalTo( new ezcGraphCoordinate( 3., 177. ), 1. ),
+ $this->equalTo( 394., 1. ),
+ $this->equalTo( 20., 1. ),
+ $this->equalTo( 4 )
);
- $this->renderer->drawBackground(
- ezcGraphColor::fromHex( '#FF0000' ),
- new ezcGraphCoordinate( 100, 100 ),
- 50,
- 50
+ $this->renderer->options->titleAlignement = ezcGraph::LEFT;
+ $this->renderer->options->titlePosition = ezcGraph::BOTTOM;
+
+ $boundings = $this->renderer->drawBox(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ ezcGraphColor::fromHex( '#BB0000' ),
+ ezcGraphColor::fromHex( '#FF0000' ),
+ 1,
+ 1,
+ 1,
+ 'Boxtitle',
+ 20
+ );
+
+ $this->assertEquals(
+ $boundings,
+ new ezcGraphBoundings( 3., 3., 397., 176. ),
+ 'Returned boundings are not as expected.',
+ 1.
+ );
+ }
+
+ public function testRenderText()
+ {
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( 'A common test string is "foobar"' ),
+ $this->equalTo( new ezcGraphCoordinate( 0., 0. ), 1. ),
+ $this->equalTo( 400., 1. ),
+ $this->equalTo( 200., 1. ),
+ $this->equalTo( 20 )
+ );
+
+ $this->renderer->drawText(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ 'A common test string is "foobar"',
+ 20
);
}
public function testRenderBackgroundImage()
{
$this->driver
- ->expects( $this->once() )
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawImage' )
+ ->with(
+ $this->equalTo( dirname( __FILE__ ) . '/data/jpeg.jpg' ),
+ $this->equalTo( new ezcGraphCoordinate( 125., 43.5 ), 1. ),
+ $this->equalTo( 150., 1. ),
+ $this->equalTo( 113., 1. )
+ );
+
+ $this->renderer->drawBackgroundImage(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ dirname( __FILE__ ) . '/data/jpeg.jpg'
+ );
+ }
+
+ public function testRenderTopLeftBackgroundImage()
+ {
+ $this->driver
+ ->expects( $this->at( 0 ) )
->method( 'drawImage' )
->with(
- $this->equalTo( 'filename' ),
- $this->equalTo( new ezcGraphCoordinate( 100, 100 ) ),
- $this->equalTo( 50 ),
- $this->equalTo( 50 )
+ $this->equalTo( dirname( __FILE__ ) . '/data/jpeg.jpg' ),
+ $this->equalTo( new ezcGraphCoordinate( 0., 0. ), 1. ),
+ $this->equalTo( 150., 1. ),
+ $this->equalTo( 113., 1. )
);
$this->renderer->drawBackgroundImage(
- 'filename',
- new ezcGraphCoordinate( 100, 100 ),
- 50,
- 50
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ dirname( __FILE__ ) . '/data/jpeg.jpg',
+ ezcGraph::TOP | ezcGraph::LEFT
+ );
+ }
+
+ public function testRenderBottomRightBackgroundImage()
+ {
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawImage' )
+ ->with(
+ $this->equalTo( dirname( __FILE__ ) . '/data/jpeg.jpg' ),
+ $this->equalTo( new ezcGraphCoordinate( 250., 87. ), 1. ),
+ $this->equalTo( 150., 1. ),
+ $this->equalTo( 113., 1. )
+ );
+
+ $this->renderer->drawBackgroundImage(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ dirname( __FILE__ ) . '/data/jpeg.jpg',
+ ezcGraph::BOTTOM | ezcGraph::RIGHT
+ );
+ }
+
+ public function testRenderToBigBackgroundImage()
+ {
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawImage' )
+ ->with(
+ $this->equalTo( dirname( __FILE__ ) . '/data/jpeg.jpg' ),
+ $this->equalTo( new ezcGraphCoordinate( 0., 0. ), 1. ),
+ $this->equalTo( 100., 1. ),
+ $this->equalTo( 100., 1. )
+ );
+
+ $this->renderer->drawBackgroundImage(
+ new ezcGraphBoundings( 0, 0, 100, 100 ),
+ dirname( __FILE__ ) . '/data/jpeg.jpg',
+ ezcGraph::BOTTOM | ezcGraph::RIGHT
+ );
+ }
+
+ public function testRenderBackgroundImageRepeatX()
+ {
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawImage' )
+ ->with(
+ $this->equalTo( dirname( __FILE__ ) . '/data/jpeg.jpg' ),
+ $this->equalTo( new ezcGraphCoordinate( 0., 87. ), 1. ),
+ $this->equalTo( 150., 1. ),
+ $this->equalTo( 113., 1. )
+ );
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawImage' )
+ ->with(
+ $this->equalTo( dirname( __FILE__ ) . '/data/jpeg.jpg' ),
+ $this->equalTo( new ezcGraphCoordinate( 150., 87. ), 1. ),
+ $this->equalTo( 150., 1. ),
+ $this->equalTo( 113., 1. )
+ );
+ $this->driver
+ ->expects( $this->at( 2 ) )
+ ->method( 'drawImage' )
+ ->with(
+ $this->equalTo( dirname( __FILE__ ) . '/data/jpeg.jpg' ),
+ $this->equalTo( new ezcGraphCoordinate( 300., 87. ), 1. ),
+ $this->equalTo( 150., 1. ),
+ $this->equalTo( 113., 1. )
+ );
+
+ $this->renderer->drawBackgroundImage(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ dirname( __FILE__ ) . '/data/jpeg.jpg',
+ ezcGraph::BOTTOM | ezcGraph::RIGHT,
+ ezcGraph::HORIZONTAL
+ );
+ }
+
+ public function testRenderBackgroundImageRepeatY()
+ {
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawImage' )
+ ->with(
+ $this->equalTo( dirname( __FILE__ ) . '/data/jpeg.jpg' ),
+ $this->equalTo( new ezcGraphCoordinate( 250., 0. ), 1. ),
+ $this->equalTo( 150., 1. ),
+ $this->equalTo( 113., 1. )
+ );
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawImage' )
+ ->with(
+ $this->equalTo( dirname( __FILE__ ) . '/data/jpeg.jpg' ),
+ $this->equalTo( new ezcGraphCoordinate( 250., 113. ), 1. ),
+ $this->equalTo( 150., 1. ),
+ $this->equalTo( 113., 1. )
+ );
+
+ $this->renderer->drawBackgroundImage(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ dirname( __FILE__ ) . '/data/jpeg.jpg',
+ ezcGraph::BOTTOM | ezcGraph::RIGHT,
+ ezcGraph::VERTICAL
+ );
+ }
+
+ public function testRenderBackgroundImageRepeatBoth()
+ {
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawImage' )
+ ->with(
+ $this->equalTo( dirname( __FILE__ ) . '/data/jpeg.jpg' ),
+ $this->equalTo( new ezcGraphCoordinate( 0., 0. ), 1. ),
+ $this->equalTo( 150., 1. ),
+ $this->equalTo( 113., 1. )
+ );
+ $this->driver
+ ->expects( $this->at( 3 ) )
+ ->method( 'drawImage' )
+ ->with(
+ $this->equalTo( dirname( __FILE__ ) . '/data/jpeg.jpg' ),
+ $this->equalTo( new ezcGraphCoordinate( 150., 113. ), 1. ),
+ $this->equalTo( 150., 1. ),
+ $this->equalTo( 113., 1. )
+ );
+ $this->driver
+ ->expects( $this->at( 5 ) )
+ ->method( 'drawImage' )
+ ->with(
+ $this->equalTo( dirname( __FILE__ ) . '/data/jpeg.jpg' ),
+ $this->equalTo( new ezcGraphCoordinate( 300., 113. ), 1. ),
+ $this->equalTo( 150., 1. ),
+ $this->equalTo( 113., 1. )
+ );
+
+ $this->renderer->drawBackgroundImage(
+ new ezcGraphBoundings( 0, 0, 400, 200 ),
+ dirname( __FILE__ ) . '/data/jpeg.jpg',
+ ezcGraph::BOTTOM | ezcGraph::RIGHT,
+ ezcGraph::VERTICAL | ezcGraph::HORIZONTAL
+ );
+ }
+
+ public function testRenderVerticalLegendSymbols()
+ {
+ $chart = ezcGraph::create( 'Line' );
+
+ $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['sampleData']->color = '#0000FF';
+ $chart['sampleData']->symbol = ezcGraph::DIAMOND;
+ $chart['moreData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['moreData']->color = '#FF0000';
+ $chart['evenMoreData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['evenMoreData']->color = '#00FF00';
+ $chart['evenMoreData']->label = 'Even more data';
+
+ $datasets = array(
+ $chart['sampleData'],
+ $chart['moreData'],
+ $chart['evenMoreData'],
+ );
+
+ $chart->legend->generateFromDatasets( $datasets );
+
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 8., 1. ),
+ new ezcGraphCoordinate( 15., 8. ),
+ new ezcGraphCoordinate( 8., 15. ),
+ new ezcGraphCoordinate( 1., 8. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 2 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 1., 19. ),
+ new ezcGraphCoordinate( 15., 19. ),
+ new ezcGraphCoordinate( 15., 33. ),
+ new ezcGraphCoordinate( 1., 33. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 4 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 1., 37. ),
+ new ezcGraphCoordinate( 15., 37. ),
+ new ezcGraphCoordinate( 15., 51. ),
+ new ezcGraphCoordinate( 1., 51. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#00FF00' ) ),
+ $this->equalTo( true )
+ );
+
+ $this->renderer->drawLegend(
+ new ezcGraphBoundings( 0, 0, 100, 200 ),
+ $chart->legend
+ );
+ }
+
+ public function testRenderVerticalLegendText()
+ {
+ $chart = ezcGraph::create( 'Line' );
+
+ $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['sampleData']->color = '#0000FF';
+ $chart['sampleData']->symbol = ezcGraph::DIAMOND;
+ $chart['moreData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['moreData']->color = '#FF0000';
+ $chart['evenMoreData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['evenMoreData']->color = '#00FF00';
+ $chart['evenMoreData']->label = 'Even more data';
+
+ $datasets = array(
+ $chart['sampleData'],
+ $chart['moreData'],
+ $chart['evenMoreData'],
+ );
+
+ $chart->legend->generateFromDatasets( $datasets );
+
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( 'sampleData' ),
+ $this->equalTo( new ezcGraphCoordinate( 16., 1. ), 1. ),
+ $this->equalTo( 83., 1. ),
+ $this->equalTo( 14., 1. ),
+ $this->equalTo( 36 )
+ );
+ $this->driver
+ ->expects( $this->at( 3 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( 'moreData' ),
+ $this->equalTo( new ezcGraphCoordinate( 16., 19. ), 1. ),
+ $this->equalTo( 83., 1. ),
+ $this->equalTo( 14., 1. ),
+ $this->equalTo( 36 )
+ );
+ $this->driver
+ ->expects( $this->at( 5 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( 'Even more data' ),
+ $this->equalTo( new ezcGraphCoordinate( 16., 37. ), 1. ),
+ $this->equalTo( 83., 1. ),
+ $this->equalTo( 14., 1. ),
+ $this->equalTo( 36 )
+ );
+
+ $this->renderer->drawLegend(
+ new ezcGraphBoundings( 0, 0, 100, 200 ),
+ $chart->legend
+ );
+ }
+
+ public function testRenderHorizontalLegendSymbols()
+ {
+ $chart = ezcGraph::create( 'Line' );
+
+ $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['sampleData']->color = '#0000FF';
+ $chart['sampleData']->symbol = ezcGraph::DIAMOND;
+ $chart['moreData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['moreData']->color = '#FF0000';
+ $chart['evenMoreData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['evenMoreData']->color = '#00FF00';
+ $chart['evenMoreData']->label = 'Even more data';
+
+ $datasets = array(
+ $chart['sampleData'],
+ $chart['moreData'],
+ $chart['evenMoreData'],
+ );
+
+ $chart->legend->generateFromDatasets( $datasets );
+
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 8., 1. ),
+ new ezcGraphCoordinate( 15., 8. ),
+ new ezcGraphCoordinate( 8., 15. ),
+ new ezcGraphCoordinate( 1., 8. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 2 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 101., 1. ),
+ new ezcGraphCoordinate( 115., 1. ),
+ new ezcGraphCoordinate( 115., 15. ),
+ new ezcGraphCoordinate( 101., 15. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ $this->equalTo( true )
+ );
+ $this->driver
+ ->expects( $this->at( 4 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 201., 1. ),
+ new ezcGraphCoordinate( 215., 1. ),
+ new ezcGraphCoordinate( 215., 15. ),
+ new ezcGraphCoordinate( 201., 15. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#00FF00' ) ),
+ $this->equalTo( true )
+ );
+
+ $this->renderer->drawLegend(
+ new ezcGraphBoundings( 0, 0, 300, 50 ),
+ $chart->legend,
+ ezcGraph::HORIZONTAL
+ );
+ }
+
+ public function testRenderHorizontalLegendText()
+ {
+ $chart = ezcGraph::create( 'Line' );
+
+ $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['sampleData']->color = '#0000FF';
+ $chart['sampleData']->symbol = ezcGraph::DIAMOND;
+ $chart['moreData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['moreData']->color = '#FF0000';
+ $chart['evenMoreData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['evenMoreData']->color = '#00FF00';
+ $chart['evenMoreData']->label = 'Even more data';
+
+ $datasets = array(
+ $chart['sampleData'],
+ $chart['moreData'],
+ $chart['evenMoreData'],
+ );
+
+ $chart->legend->generateFromDatasets( $datasets );
+
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( 'sampleData' ),
+ $this->equalTo( new ezcGraphCoordinate( 16., 1. ), 1. ),
+ $this->equalTo( 81., 1. ),
+ $this->equalTo( 14., 1. ),
+ $this->equalTo( 36 )
+ );
+ $this->driver
+ ->expects( $this->at( 3 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( 'moreData' ),
+ $this->equalTo( new ezcGraphCoordinate( 116., 1. ), 1. ),
+ $this->equalTo( 81., 1. ),
+ $this->equalTo( 14., 1. ),
+ $this->equalTo( 36 )
+ );
+ $this->driver
+ ->expects( $this->at( 5 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( 'Even more data' ),
+ $this->equalTo( new ezcGraphCoordinate( 216., 1. ), 1. ),
+ $this->equalTo( 81., 1. ),
+ $this->equalTo( 14., 1. ),
+ $this->equalTo( 36 )
+ );
+
+ $this->renderer->drawLegend(
+ new ezcGraphBoundings( 0, 0, 300, 50 ),
+ $chart->legend,
+ ezcGraph::HORIZONTAL
+ );
+ }
+
+ public function testRenderVerticalAxis()
+ {
+ $chart = ezcGraph::create( 'line' );
+
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawLine' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 20., 200. ), 1. ),
+ $this->equalTo( new ezcGraphCoordinate( 20., 0. ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
+ $this->equalTo( 1 )
+ );
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 20., 0. ),
+ new ezcGraphCoordinate( 22.5, 5. ),
+ new ezcGraphCoordinate( 17.5, 5. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
+ $this->equalTo( true )
+ );
+
+ $this->renderer->drawAxis(
+ new ezcGraphBoundings( 0, 0, 200, 400 ),
+ new ezcGraphCoordinate( 20, 200 ),
+ new ezcGraphCoordinate( 20, 0 ),
+ $chart->yAxis
+ );
+ }
+
+ public function testRenderVerticalAxisReverse()
+ {
+ $chart = ezcGraph::create( 'line' );
+
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawLine' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 20., 0. ), 1. ),
+ $this->equalTo( new ezcGraphCoordinate( 20., 200. ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
+ $this->equalTo( 1 )
+ );
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 20., 200. ),
+ new ezcGraphCoordinate( 17.5, 195. ),
+ new ezcGraphCoordinate( 22.5, 195. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
+ $this->equalTo( true )
+ );
+
+ $this->renderer->drawAxis(
+ new ezcGraphBoundings( 0, 0, 200, 400 ),
+ new ezcGraphCoordinate( 20, 0 ),
+ new ezcGraphCoordinate( 20, 200 ),
+ $chart->yAxis
+ );
+ }
+
+ public function testRenderHorizontalAxis()
+ {
+ $chart = ezcGraph::create( 'line' );
+
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawLine' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 50., 100. ), 1. ),
+ $this->equalTo( new ezcGraphCoordinate( 350., 100. ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
+ $this->equalTo( 1 )
+ );
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 350., 100. ),
+ new ezcGraphCoordinate( 342., 96. ),
+ new ezcGraphCoordinate( 342., 104. ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
+ $this->equalTo( true )
+ );
+
+ $this->renderer->drawAxis(
+ new ezcGraphBoundings( 0, 0, 200, 400 ),
+ new ezcGraphCoordinate( 50, 100 ),
+ new ezcGraphCoordinate( 350, 100 ),
+ $chart->yAxis
+ );
+ }
+
+ public function testRenderHorizontalAxisReverse()
+ {
+ $chart = ezcGraph::create( 'line' );
+
+ $this->driver
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawLine' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 350., 100. ), 1. ),
+ $this->equalTo( new ezcGraphCoordinate( 50., 100. ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
+ $this->equalTo( 1 )
+ );
+ $this->driver
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 50., 100. ),
+ new ezcGraphCoordinate( 57., 103.5 ),
+ new ezcGraphCoordinate( 57., 96.5 ),
+ ), 1. ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
+ $this->equalTo( true )
+ );
+
+ $this->renderer->drawAxis(
+ new ezcGraphBoundings( 0, 0, 200, 400 ),
+ new ezcGraphCoordinate( 350, 100 ),
+ new ezcGraphCoordinate( 50, 100 ),
+ $chart->yAxis
);
}
}
+
?>
diff --git a/tests/suite.php b/tests/suite.php
index 3c924de..f6880cf 100644
--- a/tests/suite.php
+++ b/tests/suite.php
@@ -27,11 +27,12 @@ require_once 'text_test.php';
require_once 'numeric_axis_test.php';
require_once 'labeled_axis_test.php';
require_once 'renderer_2d_test.php';
+require_once 'axis_renderer_test.php';
require_once 'driver_gd_test.php';
require_once 'driver_svg_test.php';
require_once 'font_test.php';
require_once 'palette_test.php';
-require_once 'background_image_test.php';
+require_once 'complete_rendering_test.php';
/**
* Test suite for ImageAnalysis package.
@@ -56,12 +57,13 @@ class ezcGraphSuite extends ezcTestSuite
$this->addTest( ezcGraphNumericAxisTest::suite() );
$this->addTest( ezcGraphLabeledAxisTest::suite() );
$this->addTest( ezcGraphRenderer2dTest::suite() );
+ $this->addTest( ezcGraphAxisRendererTest::suite() );
$this->addTest( ezcGraphGdDriverTest::suite() );
$this->addTest( ezcGraphSvgDriverTest::suite() );
$this->addTest( ezcGraphFontTest::suite() );
$this->addTest( ezcGraphTextTest::suite() );
$this->addTest( ezcGraphPaletteTest::suite() );
- $this->addTest( ezcGraphBackgroundImageTest::suite() );
+ $this->addTest( ezcGraphCompleteRenderingTest::suite() );
}
public static function suite()
diff --git a/tests/text_test.php b/tests/text_test.php
index b2734a2..824b9c9 100644
--- a/tests/text_test.php
+++ b/tests/text_test.php
@@ -49,31 +49,18 @@ class ezcGraphTextTest extends ezcTestCase
$chart->title = 'Title of a chart';
$mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawTextBox',
+ 'drawText',
) );
// Y-Axis
$mockedRenderer
->expects( $this->at( 0 ) )
- ->method( 'drawTextBox' )
+ ->method( 'drawText' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 1, 1 ) ),
+ $this->equalTo( new ezcGraphBoundings( 1, 1, 499, 21 ) ),
$this->equalTo( 'Title of a chart' ),
- $this->equalTo( 498 ),
- $this->equalTo( 18 ),
$this->equalTo( ezcGraph::CENTER | ezcGraph::MIDDLE )
);
- // Test for margin
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 17, 22 ) ),
- $this->equalTo( 'sample' ),
- $this->equalTo( 81 ),
- $this->equalTo( 12 ),
- $this->equalTo( ezcGraph::LEFT | ezcGraph::MIDDLE )
- );
$chart->renderer = $mockedRenderer;
@@ -89,18 +76,16 @@ class ezcGraphTextTest extends ezcTestCase
$chart->title->position = ezcGraph::BOTTOM;
$mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawTextBox',
+ 'drawText',
) );
// Y-Axis
$mockedRenderer
->expects( $this->at( 0 ) )
- ->method( 'drawTextBox' )
+ ->method( 'drawText' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 1, 181 ) ),
+ $this->equalTo( new ezcGraphBoundings( 1, 179, 499, 199 ) ),
$this->equalTo( 'Title of a chart' ),
- $this->equalTo( 498 ),
- $this->equalTo( 18 ),
$this->equalTo( ezcGraph::CENTER | ezcGraph::MIDDLE )
);
@@ -119,32 +104,18 @@ class ezcGraphTextTest extends ezcTestCase
$chart->title->margin = 5;
$mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawTextBox',
+ 'drawText',
) );
// Y-Axis
$mockedRenderer
->expects( $this->at( 0 ) )
- ->method( 'drawTextBox' )
+ ->method( 'drawText' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 1, 1 ) ),
+ $this->equalTo( new ezcGraphBoundings( 6, 6, 494, 25 ) ),
$this->equalTo( 'Title of a chart' ),
- $this->equalTo( 498 ),
- $this->equalTo( 18 ),
$this->equalTo( ezcGraph::CENTER | ezcGraph::MIDDLE )
);
- // Test for margin
- $mockedRenderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawTextBox' )
- ->with(
- $this->equalTo( new ezcGraphCoordinate( 17, 27 ) ),
- $this->equalTo( 'sample' ),
- $this->equalTo( 81 ),
- $this->equalTo( 12 ),
- $this->equalTo( ezcGraph::LEFT | ezcGraph::MIDDLE )
- );
-
$chart->renderer = $mockedRenderer;
OpenPOWER on IntegriCloud