Author: Kore Nordmann
Date: 2006-06-12 14:44:10 +0200 (Mon, 12 Jun 2006)
New Revision: 3121

Log:
- Move pie chart elements out of the middle on highlight

Modified:
   trunk/Graph/src/charts/pie.php
   trunk/Graph/src/options/pie_chart.php
   trunk/Graph/tests/pie_test.php

Modified: trunk/Graph/src/charts/pie.php
===================================================================
--- trunk/Graph/src/charts/pie.php      2006-06-12 12:13:32 UTC (rev 3120)
+++ trunk/Graph/src/charts/pie.php      2006-06-12 12:44:10 UTC (rev 3121)
@@ -82,10 +82,10 @@
             $renderer->drawPieSegment(
                 $dataset->color[$label],
                 $center,
-                $radius,
+                $radius * ( 1 - $this->options->moveOut ),
                 $angle,
                 $endAngle = $angle + $value / $sum * 360,
-                0
+                ( $dataset->highlight[$label] ? $radius * 
$this->options->moveOut : 0 )
             );
 
             // Determine position of label

Modified: trunk/Graph/src/options/pie_chart.php
===================================================================
--- trunk/Graph/src/options/pie_chart.php       2006-06-12 12:13:32 UTC (rev 
3120)
+++ trunk/Graph/src/options/pie_chart.php       2006-06-12 12:44:10 UTC (rev 
3121)
@@ -42,6 +42,14 @@
     protected $symbolSize = 6;
 
     /**
+     * Percent to move pie chart elements out of the middle on highlight
+     * 
+     * @var float
+     * @access protected
+     */
+    protected $moveOut = .1;
+
+    /**
      * Set an option value
      * 
      * @param string $propertyName 
@@ -63,6 +71,9 @@
             case 'symbolSize':
                 $this->symbolSize = (int) $propertyValue;
                 break;
+            case 'moveOut':
+                $this->moveOut = min( 1, max( 0, (float) $propertyValue ) );
+                break;
             default:
                 return parent::__set( $propertyName, $propertyValue );
         }

Modified: trunk/Graph/tests/pie_test.php
===================================================================
--- trunk/Graph/tests/pie_test.php      2006-06-12 12:13:32 UTC (rev 3120)
+++ trunk/Graph/tests/pie_test.php      2006-06-12 12:44:10 UTC (rev 3121)
@@ -269,10 +269,41 @@
         );
 
         $this->assertEquals(
-            'b1de7ecb51784885c11d86091489d12d',
+            'c12df5fe4632d7a4b6bd3406bf395514',
             md5_file( $filename ),
             'Incorrect image rendered.'
         );
     }
+
+    public function testCompleteRenderingWithHilight()
+    {
+        $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+        $chart = ezcGraph::create( 'Pie' );
+
+        $chart->sample = array(
+            'Mozilla' => 4375,
+            'IE' => 345,
+            'Opera' => 1204,
+            'wget' => 231,
+            'Safari' => 987,
+        );
+        $chart->sample->highlight['Safari'] = true;
+
+        $chart->driver = new ezcGraphGdDriver();
+        $chart->options->font = $this->basePath . 'font.ttf';
+        $chart->render( 400, 200, $filename );
+
+        $this->assertTrue(
+            file_exists( $filename ),
+            'No image was generated.'
+        );
+
+        $this->assertEquals(
+            '016c82f3a51c8b35c36323360ab4f40b',
+            md5_file( $filename ),
+            'Incorrect image rendered.'
+        );
+    }
 }
 ?>

-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to