From 315ef1f26d86d573a2443d6c23dbbdf6e699ebbb Mon Sep 17 00:00:00 2001 From: Kore Nordmann Date: Wed, 25 Feb 2009 13:23:01 +0000 Subject: - Implemented feature #14400: Add shortcut to set background color --- ChangeLog | 6 +++ src/interfaces/chart.php | 3 ++ tests/background_test.php | 49 +++++++++++++++++++++- ..._testRenderLineChartBackgroundColorShortcut.svg | 2 + ...t_testRenderPieChartBackgroundColorShortcut.svg | 2 + 5 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 tests/data/compare/ezcGraphBackgroundTest_testRenderLineChartBackgroundColorShortcut.svg create mode 100644 tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartBackgroundColorShortcut.svg diff --git a/ChangeLog b/ChangeLog index a349af5..46eabf4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +1.5-alpha1 - [RELEASEDATE] +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Implemented feature #14400: Add shortcut to set background color + + 1.4.1 - Monday 09 February 2009 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/interfaces/chart.php b/src/interfaces/chart.php index a67e104..3c3088d 100644 --- a/src/interfaces/chart.php +++ b/src/interfaces/chart.php @@ -136,6 +136,9 @@ abstract class ezcGraphChart $this->elements[$propertyName]->title = $propertyValue; $this->renderElement[$propertyName] = true; break; + case 'background': + $this->elements[$propertyName]->color = $propertyValue; + break; case 'legend': if ( !is_bool( $propertyValue ) ) { diff --git a/tests/background_test.php b/tests/background_test.php index 3d3f815..69dd5c5 100644 --- a/tests/background_test.php +++ b/tests/background_test.php @@ -101,11 +101,11 @@ class ezcGraphBackgroundTest extends ezcGraphTestCase public function testSetOptionsBorderLineChart() { $lineChart = new ezcGraphLineChart(); - $lineChart->background->border = '#FF0000'; + $lineChart->background = '#FF0000'; $this->assertEquals( ezcGraphColor::fromHex( 'FF0000' ), - $lineChart->background->border + $lineChart->background->color ); } @@ -353,5 +353,50 @@ class ezcGraphBackgroundTest extends ezcGraphTestCase ); } + public function testRenderPieChartBackgroundColorShortcut() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $chart = new ezcGraphPieChart(); + $chart->data['sample'] = new ezcGraphArrayDataSet( array( + 'Mozilla' => 4375, + 'IE' => 345, + 'Opera' => 1204, + 'wget' => 231, + 'Safari' => 987, + ) ); + + $chart->background = '#2e3436'; + + $chart->render( 500, 200, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + + public function testRenderLineChartBackgroundColorShortcut() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $chart = new ezcGraphLineChart(); + $chart->data['sample'] = new ezcGraphArrayDataSet( array( + 'Mozilla' => 4375, + 'IE' => 345, + 'Opera' => 1204, + 'wget' => 231, + 'Safari' => 987, + ) ); + + $chart->background = '#2e3436'; + + $chart->render( 500, 200, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } } ?> diff --git a/tests/data/compare/ezcGraphBackgroundTest_testRenderLineChartBackgroundColorShortcut.svg b/tests/data/compare/ezcGraphBackgroundTest_testRenderLineChartBackgroundColorShortcut.svg new file mode 100644 index 0000000..8579890 --- /dev/null +++ b/tests/data/compare/ezcGraphBackgroundTest_testRenderLineChartBackgroundColorShortcut.svg @@ -0,0 +1,2 @@ + +sampleIEOperawgetSafari010002000300040005000 diff --git a/tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartBackgroundColorShortcut.svg b/tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartBackgroundColorShortcut.svg new file mode 100644 index 0000000..d2297d4 --- /dev/null +++ b/tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartBackgroundColorShortcut.svg @@ -0,0 +1,2 @@ + +MozillaIEOperawgetSafariOpera: 1204 (16.9%)IE: 345 (4.8%)Mozilla: 4375 (61.3%)wget: 231 (3.2%)Safari: 987 (13.8%) -- cgit v1.1