From ccc75f9a0f37cf808a4dda2dc68b731e0be177ef Mon Sep 17 00:00:00 2001 From: Kore Nordmann Date: Mon, 7 Jan 2008 09:59:44 +0000 Subject: - Fixed issue #11777: Optionally independent axis font configuration --- ChangeLog | 1 + src/options/renderer.php | 7 +++- src/renderer/2d.php | 7 ++++ src/renderer/3d.php | 7 ++++ ...aphLineChartTest_testLineChartUnsyncedFonts.svg | 2 + ...hLineChartTest_testLineChartUnsyncedFonts3d.svg | 2 + tests/line_test.php | 49 ++++++++++++++++++++++ tests/renderer_2d_test.php | 29 +++++++++++++ 8 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 tests/data/compare/ezcGraphLineChartTest_testLineChartUnsyncedFonts.svg create mode 100644 tests/data/compare/ezcGraphLineChartTest_testLineChartUnsyncedFonts3d.svg diff --git a/ChangeLog b/ChangeLog index e0327f0..180066f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ - Fixed issue #12254: Bad property-check for strokeLineJoin in SVG driver - Fixed issue #12295: Broken automatic scaling with manually set min value, not divisible by major step +- Fixed issue #11777: Optionally independent axis font configuration 1.2 - Monday 17 December 2007 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/options/renderer.php b/src/options/renderer.php index 18f6635..c8465dc 100644 --- a/src/options/renderer.php +++ b/src/options/renderer.php @@ -73,6 +73,9 @@ * Color used for gleam on pie charts. * @property float $pieChartGleamBorder * Do not draw gleam on an outer border of this size. + * @property bool $syncAxisFonts + * Synchronize fonts of axis. With the defaut true value, the only + * the fonts of the yAxis will be used. * * @version //autogentag// * @package Graph @@ -107,6 +110,7 @@ class ezcGraphRendererOptions extends ezcGraphChartOptions $this->properties['legendSymbolGleamColor'] = ezcGraphColor::fromHex( '#FFFFFF' ); $this->properties['pieVerticalSize'] = .5; $this->properties['pieHorizontalSize'] = .25; + $this->properties['syncAxisFonts'] = true; parent::__construct( $options ); } @@ -174,11 +178,12 @@ class ezcGraphRendererOptions extends ezcGraphChartOptions break; case 'showSymbol': + case 'syncAxisFonts': if ( !is_bool( $propertyValue ) ) { throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' ); } - $this->properties['showSymbol'] = (bool) $propertyValue; + $this->properties[$propertyName] = (bool) $propertyValue; break; case 'pieChartOffset': diff --git a/src/renderer/2d.php b/src/renderer/2d.php index 929dbdd..58d68bf 100644 --- a/src/renderer/2d.php +++ b/src/renderer/2d.php @@ -1440,6 +1440,13 @@ class ezcGraphRenderer2d { foreach ( $this->axisLabels as $nr => $axisLabel ) { + // If font should not be synchronized, use font configuration from + // each axis + if ( $this->options->syncAxisFonts === false ) + { + $this->driver->options->font = $axisLabel['axis']->font; + } + $start = $axisLabel['start']; $end = $axisLabel['end']; diff --git a/src/renderer/3d.php b/src/renderer/3d.php index 01c763b..0a39e50 100644 --- a/src/renderer/3d.php +++ b/src/renderer/3d.php @@ -2225,6 +2225,13 @@ class ezcGraphRenderer3d { foreach ( $this->axisLabels as $axisLabel ) { + // If font should not be synchronized, use font configuration from + // each axis + if ( $this->options->syncAxisFonts === false ) + { + $this->driver->options->font = $axisLabel['axis']->font; + } + switch ( $axisLabel['axis']->position ) { case ezcGraph::RIGHT: diff --git a/tests/data/compare/ezcGraphLineChartTest_testLineChartUnsyncedFonts.svg b/tests/data/compare/ezcGraphLineChartTest_testLineChartUnsyncedFonts.svg new file mode 100644 index 0000000..a147df8 --- /dev/null +++ b/tests/data/compare/ezcGraphLineChartTest_testLineChartUnsyncedFonts.svg @@ -0,0 +1,2 @@ + +sampleIEOperawgetSafari010002000300040005000 diff --git a/tests/data/compare/ezcGraphLineChartTest_testLineChartUnsyncedFonts3d.svg b/tests/data/compare/ezcGraphLineChartTest_testLineChartUnsyncedFonts3d.svg new file mode 100644 index 0000000..86befdb --- /dev/null +++ b/tests/data/compare/ezcGraphLineChartTest_testLineChartUnsyncedFonts3d.svg @@ -0,0 +1,2 @@ + +sampleIEOperawgetSafari010002000300040005000 diff --git a/tests/line_test.php b/tests/line_test.php index 48d1052..432bd9f 100644 --- a/tests/line_test.php +++ b/tests/line_test.php @@ -956,6 +956,55 @@ class ezcGraphLineChartTest extends ezcGraphTestCase ); } + public function testLineChartUnsyncedFonts() + { + $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->renderer->options->syncAxisFonts = false; + + $chart->driver = new ezcGraphSvgDriver(); + $chart->render( 500, 200, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + + public function testLineChartUnsyncedFonts3d() + { + $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->renderer = new ezcGraphRenderer3d(); + $chart->renderer->options->syncAxisFonts = false; + + $chart->driver = new ezcGraphSvgDriver(); + $chart->render( 500, 200, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + public function testStackedBarChart() { $filename = $this->tempDir . __FUNCTION__ . '.svg'; diff --git a/tests/renderer_2d_test.php b/tests/renderer_2d_test.php index 892faa8..16d8508 100644 --- a/tests/renderer_2d_test.php +++ b/tests/renderer_2d_test.php @@ -2191,6 +2191,35 @@ class ezcGraphRenderer2dTest extends ezcGraphTestCase $this->fail( 'Expected ezcBaseValueException.' ); } + public function testRendererOptionsPropertySyncAxisFonts() + { + $options = new ezcGraphRendererOptions(); + + $this->assertSame( + true, + $options->syncAxisFonts, + 'Wrong default value for property syncAxisFonts in class ezcGraphRendererOptions' + ); + + $options->syncAxisFonts = false; + $this->assertSame( + false, + $options->syncAxisFonts, + 'Setting property value did not work for property syncAxisFonts in class ezcGraphRendererOptions' + ); + + try + { + $options->syncAxisFonts = 42; + } + catch ( ezcBaseValueException $e ) + { + return true; + } + + $this->fail( 'Expected ezcBaseValueException.' ); + } + public function testRendererOptionsPropertySymbolSize() { $options = new ezcGraphRendererOptions(); -- cgit v1.1