Author: Kore Nordmann
Date: 2006-06-19 16:48:30 +0200 (Mon, 19 Jun 2006)
New Revision: 3144

Log:
- Fixed division by zero with zero values and filled lines

Modified:
   trunk/Graph/src/charts/line.php
   trunk/Graph/tests/line_test.php

Modified: trunk/Graph/src/charts/line.php
===================================================================
--- trunk/Graph/src/charts/line.php     2006-06-19 14:13:21 UTC (rev 3143)
+++ trunk/Graph/src/charts/line.php     2006-06-19 14:48:30 UTC (rev 3144)
@@ -42,7 +42,7 @@
     public function __set( $propertyName, $propertyValue ) 
     {
         switch ( $propertyName ) {
-            case 'X_Axis':
+            case 'xAxis':
                 if ( $propertyValue instanceof ezcGraphChartElementAxis )
                 {
                     $this->addElement( 'xAxis', $propertyValue );
@@ -53,7 +53,7 @@
                     throw new ezcBaseValueException( $propertyName, 
$propertyValue, 'ezcGraphChartElementAxis' );
                 }
                 break;
-            case 'Y_Axis':
+            case 'yAxis':
                 if ( $propertyValue instanceof ezcGraphChartElementAxis )
                 {
                     $this->addElement( 'yAxis', $propertyValue );
@@ -103,7 +103,9 @@
                         $axisPosition
                     );
 
-                    if ( $value / abs( $value ) == $lastValue / abs( 
$lastValue ) )
+                    if ( ( $value == 0 ) ||
+                         ( $lastValue == 0 ) ||
+                         ( $value / abs( $value ) == $lastValue / abs( 
$lastValue ) ) )
                     {
                         // Values have the same sign, so that the line do not 
cross any axes
                         $renderer->drawPolygon(

Modified: trunk/Graph/tests/line_test.php
===================================================================
--- trunk/Graph/tests/line_test.php     2006-06-19 14:13:21 UTC (rev 3143)
+++ trunk/Graph/tests/line_test.php     2006-06-19 14:48:30 UTC (rev 3144)
@@ -227,6 +227,37 @@
         $chart->render( 500, 200 );
     }
 
+
+    public function testRenderChartFilledLinesZero()
+    {
+        $chart = ezcGraph::create( 'Line' );
+        $chart->sampleData = array( 'sample 1' => 0, 'sample 2' => 0 );
+        $chart->palette = 'Black';
+        $chart->options->fillLines = 100;
+
+        $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+            'drawPolygon',
+        ) );
+
+        $mockedRenderer
+            ->expects( $this->at( 2 ) )
+            ->method( 'drawPolygon' )
+            ->with(
+                $this->equalTo( array( 
+                    new ezcGraphCoordinate( 120, 190 ),
+                    new ezcGraphCoordinate( 480, 190 ),
+                    new ezcGraphCoordinate( 480, 190 ),
+                    new ezcGraphCoordinate( 120, 190 ),
+                ) ),
+                $this->equalTo( ezcGraphColor::fromHex( '#3465A464' ) ),
+                $this->equalTo( true )
+            );
+        
+        $chart->renderer = $mockedRenderer;
+
+        $chart->render( 500, 200 );
+    }
+
     public function testRenderChartLinesModifiedThickness()
     {
         $chart = ezcGraph::create( 'Line' );

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

Reply via email to