summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-08-08 12:09:04 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-08-08 12:09:04 +0000
commit5e6c1783d9ecbbf9ae8b1e0ff8c39c0d1fb91ffa (patch)
tree9a45ec6f551ba54c08266469df433f1de92069ef
parent950007a0594912ad27b923ef1ff54c533af654d9 (diff)
downloadzetacomponents-graph-5e6c1783d9ecbbf9ae8b1e0ff8c39c0d1fb91ffa.zip
zetacomponents-graph-5e6c1783d9ecbbf9ae8b1e0ff8c39c0d1fb91ffa.tar.gz
- Fixed calculation of title boundings to respect margin of title element
- Made ezcGraphChartElementText::maxHeight accessible
-rw-r--r--src/element/text.php26
-rw-r--r--tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChartBigMaxFontSize.pngbin0 -> 92166 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChartSmallMaxFontSize.pngbin0 -> 91388 bytes
-rw-r--r--tests/renderer_3d_test.php53
4 files changed, 78 insertions, 1 deletions
diff --git a/src/element/text.php b/src/element/text.php
index e08b482..dfe1a55 100644
--- a/src/element/text.php
+++ b/src/element/text.php
@@ -23,6 +23,30 @@ class ezcGraphChartElementText extends ezcGraphChartElement
protected $maxHeight = .1;
/**
+ * __set
+ *
+ * @param mixed $propertyName
+ * @param mixed $propertyValue
+ * @throws ezcBaseValueException
+ * If a submitted parameter was out of range or type.
+ * @throws ezcBasePropertyNotFoundException
+ * If a the value for the property options is not an instance of
+ * @return void
+ */
+ public function __set( $propertyName, $propertyValue )
+ {
+ switch ( $propertyName )
+ {
+ case 'maxHeight':
+ $this->maxHeight = min( 1, max( 0, (float) $propertyValue ) );
+ break;
+ default:
+ parent::__set( $propertyName, $propertyValue );
+ break;
+ }
+ }
+
+ /**
* Render a legend
*
* @param ezcGraphRenderer $renderer
@@ -39,7 +63,7 @@ class ezcGraphChartElementText extends ezcGraphChartElement
$height = (int) min(
round( $this->maxHeight * ( $boundings->y1 - $boundings->y0 ) ),
- $this->font->maxFontSize + $this->padding * 2
+ $this->font->maxFontSize + $this->padding * 2 + $this->margin * 2
);
switch ( $this->position )
diff --git a/tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChartBigMaxFontSize.png b/tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChartBigMaxFontSize.png
new file mode 100644
index 0000000..c0b2f87
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChartBigMaxFontSize.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChartSmallMaxFontSize.png b/tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChartSmallMaxFontSize.png
new file mode 100644
index 0000000..8115cb6
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChartSmallMaxFontSize.png
Binary files differ
diff --git a/tests/renderer_3d_test.php b/tests/renderer_3d_test.php
index eeb8678..b9c5588 100644
--- a/tests/renderer_3d_test.php
+++ b/tests/renderer_3d_test.php
@@ -341,6 +341,59 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
);
}
+ public function testRender3dLineChartSmallMaxFontSize()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = new ezcGraphLineChart();
+ $chart->palette = new ezcGraphPaletteBlack();
+
+ $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->title = 'Line chart title';
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->title->font->maxFontSize = 8;
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testRender3dLineChartBigMaxFontSize()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = new ezcGraphLineChart();
+ $chart->palette = new ezcGraphPaletteBlack();
+
+ $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->title = 'Line chart title';
+ $chart->title->maxHeight = .2;
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->title->font->maxFontSize = 32;
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
public function testRender3dFilledLineChart()
{
$filename = $this->tempDir . __FUNCTION__ . '.png';
OpenPOWER on IntegriCloud