summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2007-05-29 09:10:48 +0000
committerKore Nordmann <github@kore-nordmann.de>2007-05-29 09:10:48 +0000
commitf7e1b8683290c347a00e80c0b3779e05892842e1 (patch)
treefbf927864ae5c80d6bbf9bd14c658bc8d9be5c8b
parente9f7f66fef8d66865eae4cf731bf502c19dc948e (diff)
downloadzetacomponents-graph-f7e1b8683290c347a00e80c0b3779e05892842e1.zip
zetacomponents-graph-f7e1b8683290c347a00e80c0b3779e05892842e1.tar.gz
- Fixed issue #10861 Circle sector size reducement failes for very big angles.
-rw-r--r--ChangeLog1
-rw-r--r--src/interfaces/driver.php31
-rw-r--r--tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorBorderReducementWithReallyBigAngle.svg2
-rw-r--r--tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorBorderReducementWithReallyBigAngle2.svg2
-rw-r--r--tests/driver_svg_test.php66
5 files changed, 96 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 95946a6..8aa9390 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,7 @@
- Fixed issue #10852: Fixed radar chart documentation
- Fixed issue #10830: Automatically shorten labels if not enough space is
available
+- Fixed issue #10861 Circle sector size reducement failes for very big angles.
1.1beta1 - Monday 07 May 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/interfaces/driver.php b/src/interfaces/driver.php
index b9a55dd..69aa161 100644
--- a/src/interfaces/driver.php
+++ b/src/interfaces/driver.php
@@ -264,6 +264,7 @@ abstract class ezcGraphDriver
);
// We always need radian values..
+ $degAngle = abs( $endAngle - $startAngle );
$startAngle = deg2rad( $startAngle );
$endAngle = deg2rad( $endAngle );
@@ -300,8 +301,17 @@ abstract class ezcGraphDriver
( $newCenter->y < ( $center->y - $height ) ) ||
( $newCenter->y > ( $center->y + $height ) ) )
{
- // Quick bounding box check
- throw new ezcGraphReducementFailedException();
+ // Quick outer boundings check
+ if ( $degAngle > 180 )
+ {
+ // Use old center for very big angles
+ $newCenter = clone $center;
+ }
+ else
+ {
+ // Do not draw for very small angles
+ throw new ezcGraphReducementFailedException();
+ }
}
else
{
@@ -317,14 +327,23 @@ abstract class ezcGraphDriver
$angle = $direction->angle( new ezcGraphVector( 0, 1 ) );
$outerPoint = new ezcGraphVector(
- sin( $angle ) * $width,
- cos( $angle ) * $height
+ sin( $angle ) * $width / 2,
+ cos( $angle ) * $height / 2
);
// Point is not in ellipse any more
- if ( $distance->x > $outerPoint->x )
+ if ( abs( $distance->x ) > abs( $outerPoint->x ) )
{
- throw new ezcGraphReducementFailedException();
+ if ( $degAngle > 180 )
+ {
+ // Use old center for very big angles
+ $newCenter = clone $center;
+ }
+ else
+ {
+ // Do not draw for very small angles
+ throw new ezcGraphReducementFailedException();
+ }
}
}
diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorBorderReducementWithReallyBigAngle.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorBorderReducementWithReallyBigAngle.svg
new file mode 100644
index 0000000..1c112d7
--- /dev/null
+++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorBorderReducementWithReallyBigAngle.svg
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="ezcGraphChart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d="M 100.00,50.00 L 139.50,50.50 A 39.50,19.50 0 1,1 139.48,49.22 z" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 0.50; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphCircleSector_1"/></g></svg>
diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorBorderReducementWithReallyBigAngle2.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorBorderReducementWithReallyBigAngle2.svg
new file mode 100644
index 0000000..3148a9c
--- /dev/null
+++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorBorderReducementWithReallyBigAngle2.svg
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="ezcGraphChart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d="M 100.00,50.00 L 139.50,50.50 A 39.50,19.50 0 1,1 139.50,49.43 z" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 0.50; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphCircleSector_1"/></g></svg>
diff --git a/tests/driver_svg_test.php b/tests/driver_svg_test.php
index e9dffa8..5adb9d3 100644
--- a/tests/driver_svg_test.php
+++ b/tests/driver_svg_test.php
@@ -305,6 +305,72 @@ class ezcGraphSvgDriverTest extends ezcGraphTestCase
);
}
+ public function testDrawCircleSectorBorderReducementWithBiggerAngle()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawCircleSector(
+ new ezcGraphCoordinate( 100, 50 ),
+ 80,
+ 40,
+ 10,
+ 10.8,
+ ezcGraphColor::fromHex( '#3465A480' ),
+ false
+ );
+
+ $this->driver->render( $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/empty.svg'
+ );
+ }
+
+ public function testDrawCircleSectorBorderReducementWithReallyBigAngle()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawCircleSector(
+ new ezcGraphCoordinate( 100, 50 ),
+ 80,
+ 40,
+ 0,
+ 359.2,
+ ezcGraphColor::fromHex( '#3465A480' ),
+ false
+ );
+
+ $this->driver->render( $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
+
+ public function testDrawCircleSectorBorderReducementWithReallyBigAngle2()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawCircleSector(
+ new ezcGraphCoordinate( 100, 50 ),
+ 80,
+ 40,
+ 0,
+ 359.8,
+ ezcGraphColor::fromHex( '#3465A480' ),
+ false
+ );
+
+ $this->driver->render( $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
+
public function testDrawPolygonBorderReducementWithShortEdge()
{
$filename = $this->tempDir . __FUNCTION__ . '.svg';
OpenPOWER on IntegriCloud