summaryrefslogtreecommitdiffstats
path: root/tests/line_test.php
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2007-09-06 12:45:09 +0000
committerKore Nordmann <github@kore-nordmann.de>2007-09-06 12:45:09 +0000
commita3a7f0b264223ec011b46fd4e0ce2674af7e0087 (patch)
tree345bb747e3c8311795c154f9849bbc30aca8ee0b /tests/line_test.php
parentc87432c04b6b68d8a1e210947acb3f260f013707 (diff)
downloadzetacomponents-graph-a3a7f0b264223ec011b46fd4e0ce2674af7e0087.zip
zetacomponents-graph-a3a7f0b264223ec011b46fd4e0ce2674af7e0087.tar.gz
- Implemented feature #10978: Add support for stacked bar charts
Diffstat (limited to 'tests/line_test.php')
-rw-r--r--tests/line_test.php172
1 files changed, 172 insertions, 0 deletions
diff --git a/tests/line_test.php b/tests/line_test.php
index 002af62..10243b5 100644
--- a/tests/line_test.php
+++ b/tests/line_test.php
@@ -548,6 +548,97 @@ class ezcGraphLineChartTest extends ezcGraphTestCase
$chart->render( 500, 200 );
}
+ public function testRenderChartStackedBars()
+ {
+ $chart = new ezcGraphBarChart();
+
+ $chart->options->stackBars = true;
+
+ $chart->data['sampleData'] = new ezcGraphArrayDataSet( array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => -324, 'sample 4' => 120, 'sample 5' => -16 ) );
+ $chart->data['sampleData']->color = '#CC0000';
+ $chart->data['moreData'] = new ezcGraphArrayDataSet( array( 'sample 1' => 234, 'sample 2' => -21, 'sample 3' => 324, 'sample 4' => 220, 'sample 5' => -34 ) );
+ $chart->data['moreData']->color = '#0000CC';
+
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
+ 'drawStackedBar',
+ ) );
+
+ $mockedRenderer
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawStackedBar' )
+ ->with(
+ $this->equalTo( new ezcGraphBoundings( 140., 20., 460., 180. ), 1. ),
+ $this->equalTo( new ezcGraphContext( 'sampleData', 'sample 1' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .1, .5 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( .1, .266 ), .05 )
+ );
+ $mockedRenderer
+ ->expects( $this->at( 4 ) )
+ ->method( 'drawStackedBar' )
+ ->with(
+ $this->equalTo( new ezcGraphBoundings( 140., 20., 460., 180. ), 1. ),
+ $this->equalTo( new ezcGraphContext( 'sampleData', 'sample 5' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .9, .5 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( .9, .516 ), .05 )
+ );
+ $mockedRenderer
+ ->expects( $this->at( 5 ) )
+ ->method( 'drawStackedBar' )
+ ->with(
+ $this->equalTo( new ezcGraphBoundings( 140., 20., 460., 180. ), 1. ),
+ $this->equalTo( new ezcGraphContext( 'moreData', 'sample 1' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#0000CC' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .1, .266 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( .1, .032 ), .05 )
+ );
+ $mockedRenderer
+ ->expects( $this->at( 6 ) )
+ ->method( 'drawStackedBar' )
+ ->with(
+ $this->equalTo( new ezcGraphBoundings( 140., 20., 460., 180. ), 1. ),
+ $this->equalTo( new ezcGraphContext( 'moreData', 'sample 2' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#0000CC' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .3, .5 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( .3, .521 ), .05 )
+ );
+ $mockedRenderer
+ ->expects( $this->at( 7 ) )
+ ->method( 'drawStackedBar' )
+ ->with(
+ $this->equalTo( new ezcGraphBoundings( 140., 20., 460., 180. ), 1. ),
+ $this->equalTo( new ezcGraphContext( 'moreData', 'sample 3' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#0000CC' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .5, .5 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( .5, .176 ), .05 )
+ );
+ $mockedRenderer
+ ->expects( $this->at( 8 ) )
+ ->method( 'drawStackedBar' )
+ ->with(
+ $this->equalTo( new ezcGraphBoundings( 140., 20., 460., 180. ), 1. ),
+ $this->equalTo( new ezcGraphContext( 'moreData', 'sample 4' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#0000CC' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .7, .38 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( .7, .16 ), .05 )
+ );
+ $mockedRenderer
+ ->expects( $this->at( 9 ) )
+ ->method( 'drawStackedBar' )
+ ->with(
+ $this->equalTo( new ezcGraphBoundings( 140., 20., 460., 180. ), 1. ),
+ $this->equalTo( new ezcGraphContext( 'moreData', 'sample 5' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#0000CC' ) ),
+ $this->equalTo( new ezcGraphCoordinate( .9, .516 ), .05 ),
+ $this->equalTo( new ezcGraphCoordinate( .9, .55 ), .05 )
+ );
+
+ $chart->renderer = $mockedRenderer;
+
+ $chart->render( 500, 200 );
+ }
+
public function testRenderChartFilledLines()
{
$chart = new ezcGraphLineChart();
@@ -817,5 +908,86 @@ class ezcGraphLineChartTest extends ezcGraphTestCase
$this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
);
}
+
+ public function testStackedBarChart()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $chart = new ezcGraphBarChart();
+
+ $chart->options->stackBars = true;
+
+ $chart->data['sample'] = new ezcGraphArrayDataSet( array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ ) );
+
+ $chart->data['sample 2'] = new ezcGraphArrayDataSet( array(
+ 'Mozilla' => 4352,
+ 'IE' => 745,
+ 'Opera' => 204,
+ 'wget' => 2231,
+ 'Safari' => 487,
+ ) );
+
+ $chart->data['sample 3'] = new ezcGraphArrayDataSet( array(
+ 'Mozilla' => 234,
+ 'IE' => 100,
+ 'Opera' => 0,
+ 'wget' => -934,
+ 'Safari' => 2043,
+ ) );
+
+ $chart->render( 500, 200, $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
+
+ public function testStackedBarChart3d()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $chart = new ezcGraphBarChart();
+
+ $chart->options->stackBars = true;
+
+ $chart->data['sample'] = new ezcGraphArrayDataSet( array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ ) );
+
+ $chart->data['sample 2'] = new ezcGraphArrayDataSet( array(
+ 'Mozilla' => 4352,
+ 'IE' => 745,
+ 'Opera' => 204,
+ 'wget' => 2231,
+ 'Safari' => 487,
+ ) );
+
+ $chart->data['sample 3'] = new ezcGraphArrayDataSet( array(
+ 'Mozilla' => 234,
+ 'IE' => 100,
+ 'Opera' => 0,
+ 'wget' => -934,
+ 'Safari' => 2043,
+ ) );
+
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->render( 500, 200, $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
}
?>
OpenPOWER on IntegriCloud