Author: kn
Date: Fri Nov 23 13:40:39 2007
New Revision: 6796

Log:
- Fixed some first issues in Graph

Modified:
    trunk/Graph/review.txt
    trunk/Graph/src/charts/odometer.php
    trunk/Graph/src/graph_autoload.php
    trunk/Graph/tests/odometer_test.php

Modified: trunk/Graph/review.txt
==============================================================================
--- trunk/Graph/review.txt [iso-8859-1] (original)
+++ trunk/Graph/review.txt [iso-8859-1] Fri Nov 23 13:40:39 2007
@@ -1,7 +1,7 @@
 Some issues in Graph (Alexandru, 22-11-2007)
 ============================================
 
-[ ] If using a 3D renderer with Radar and Odometer (usually nobody does this)
+[x] If using a 3D renderer with Radar and Odometer (usually nobody does this)
     you get 2 different errors:
 
 Radar: ezcBaseValueException: The value 'O:18:"ezcGraphRenderer3d":16:{s:19:"
@@ -10,18 +10,24 @@
 Odometer: Fatal error: Call to undefined method 
ezcGraphRenderer3d::drawOdometer()
           in /home/as/dev/ezcomponents/trunk/Graph/src/charts/odometer.php on 
line 137
 
-[ ] ezcGraphOdometerChart has no class doc-block - most likely will end up
+[x] ezcGraphOdometerChart has no class doc-block - most likely will end up
     in the NoPackageName section on 
http://ezcomponents.org/docs/api/trunk/elementindex.html
     (same with some classes in Webdav). It should also be marked as @mainclass.
 
 [ ] Odometer chart linear gradient looks different in Flash and Svg (more 
green on
     the left side in Svg and almost no green in Flash, using the default 
palette).
 
-[ ] Odometer chart does not do gradient colors in Gd (but probably this is 
documented).
+[x] Odometer chart does not do gradient colors in Gd (but probably this is 
documented).
+ 
+    # GD can't draw any gradients (in a reasonable time), so yes, it is
+       # documented.
 
 [ ] ezcGraphOdometerChart has some white space issues (eg. in foreach).
 
-[ ] graph_autoload.php: src/math/term.php is missing (and docanalysis.php tool 
does
+[x] graph_autoload.php: src/math/term.php is missing (and docanalysis.php tool 
does
     not work).
 
+       # This class is not used anywhere yet, and automatically included. 
Removed
+       # from autoload file.
+
 [ ] Some more doc block issues are revealed after running docanalysis.php.

Modified: trunk/Graph/src/charts/odometer.php
==============================================================================
--- trunk/Graph/src/charts/odometer.php [iso-8859-1] (original)
+++ trunk/Graph/src/charts/odometer.php [iso-8859-1] Fri Nov 23 13:40:39 2007
@@ -7,7 +7,67 @@
  * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
  * @license http://ez.no/licenses/new_bsd New BSD License
  */
-
+/**
+ * Class for odometer charts. Can only use one dataset which will be dispalyed
+ * as a odometer chart.
+ *
+ * <code>
+ *  $graph = new ezcGraphOdometerChart();
+ *  $graph->title = 'Custom odometer';
+ *  
+ *  $graph->data['data'] = new ezcGraphArrayDataSet(
+ *      array( 87 )
+ *  );
+ *  
+ *  // Set the marker color
+ *  $graph->data['data']->color[0]  = '#A0000055';
+ *  
+ *  // Set colors for the background gradient
+ *  $graph->options->startColor     = '#2E3436';
+ *  $graph->options->endColor       = '#EEEEEC';
+ *  
+ *  // Define a border for the odometer
+ *  $graph->options->borderWidth    = 2;
+ *  $graph->options->borderColor    = '#BABDB6';
+ *  
+ *  // Set marker width
+ *  $graph->options->markerWidth    = 5;
+ *  
+ *  // Set space, which the odometer may consume
+ *  $graph->options->odometerHeight = .7;
+ *  
+ *  // Set axis span and label
+ *  $graph->axis->min               = 0;
+ *  $graph->axis->max               = 100;
+ *  $graph->axis->label             = 'Coverage  ';
+ *  
+ *  $graph->render( 400, 150, 'custom_odometer_chart.svg' );
+ * </code>
+ *
+ * Each chart consists of several chart elements which represents logical parts
+ * of the chart and can be formatted independently. The odometer chart consists
+ * of:
+ *  - title ( [EMAIL PROTECTED] ezcGraphChartElementText} )
+ *  - background ( [EMAIL PROTECTED] ezcGraphChartElementBackground} )
+ *
+ * All elements can be configured by accessing them as properties of the chart:
+ *
+ * <code>
+ *  $chart->title->position = ezcGraph::BOTTOM;
+ * </code>
+ *
+ * The chart itself also offers several options to configure the appearance.
+ * The extended configure options are available in 
+ * [EMAIL PROTECTED] ezcGraphOdometerChartOptions} extending the [EMAIL 
PROTECTED]
+ * ezcGraphChartOptions}.
+ *
+ * @property ezcGraphOdometerChartOptions $options
+ *           Chart options class
+ *
+ * @version //autogentag//
+ * @package Graph
+ * @mainclass
+ */
 class ezcGraphOdometerChart extends ezcGraphChart
 {
 
@@ -31,6 +91,50 @@
         $this->elements['axis']->axisLabelRenderer->showZeroValue = true;
         $this->elements['axis']->position  = ezcGraph::LEFT;
         $this->elements['axis']->axisSpace = .05;
+    }
+
+    /**
+     * Property write access
+     * 
+     * @throws ezcBasePropertyNotFoundException
+     *          If Option could not be found
+     * @throws ezcBaseValueException
+     *          If value is out of range
+     * @param string $propertyName Option name
+     * @param mixed $propertyValue Option value;
+     * @return void
+     * @ignore
+     */
+    public function __set( $propertyName, $propertyValue ) 
+    {
+        switch ( $propertyName ) {
+            case 'axis':
+                if ( $propertyValue instanceof ezcGraphChartElementAxis )
+                {
+                    $this->addElement( 'axis', $propertyValue );
+                    $this->elements['axis']->axisLabelRenderer = new 
ezcGraphAxisCenteredLabelRenderer();
+                    $this->elements['axis']->axisLabelRenderer->showZeroValue 
= true;
+                    $this->elements['axis']->position  = ezcGraph::LEFT;
+                    $this->elements['axis']->axisSpace = .05;
+                }
+                else
+                {
+                    throw new ezcBaseValueException( $propertyName, 
$propertyValue, 'ezcGraphChartElementAxis' );
+                }
+                break;
+            case 'renderer':
+                if ( $propertyValue instanceof ezcGraphOdometerRenderer )
+                {
+                    parent::__set( $propertyName, $propertyValue );
+                }
+                else 
+                {
+                    throw new ezcBaseValueException( $propertyName, 
$propertyValue, 'ezcGraphOdometerRenderer' );
+                }
+                break;
+            default:
+                parent::__set( $propertyName, $propertyValue );
+        }
     }
 
     /**

Modified: trunk/Graph/src/graph_autoload.php
==============================================================================
--- trunk/Graph/src/graph_autoload.php [iso-8859-1] (original)
+++ trunk/Graph/src/graph_autoload.php [iso-8859-1] Fri Nov 23 13:40:39 2007
@@ -115,7 +115,6 @@
     'ezcGraphRotation'                              => 
'Graph/math/rotation.php',
     'ezcGraphSvgDriver'                             => 'Graph/driver/svg.php',
     'ezcGraphSvgDriverOptions'                      => 
'Graph/options/svg_driver.php',
-    'ezcGraphTerm'                                  => 'Graph/math/term.php',
     'ezcGraphTools'                                 => 'Graph/tools.php',
     'ezcGraphTranslation'                           => 
'Graph/math/translation.php',
     'ezcGraphVector'                                => 'Graph/math/vector.php',

Modified: trunk/Graph/tests/odometer_test.php
==============================================================================
--- trunk/Graph/tests/odometer_test.php [iso-8859-1] (original)
+++ trunk/Graph/tests/odometer_test.php [iso-8859-1] Fri Nov 23 13:40:39 2007
@@ -212,6 +212,33 @@
         try
         {
             $options->odometerHeight = 1.2;
+        }
+        catch ( ezcBaseValueException $e )
+        {
+            return true;
+        }
+
+        $this->fail( 'Expected ezcBaseValueException.' );
+    }
+
+    public function testOdometerChartPropertyAxis()
+    {
+        $chart = new ezcGraphOdometerChart();
+
+        $this->assertTrue(
+            $chart->axis instanceof ezcGraphChartElementNumericAxis,
+            'Wrong default value for property axis in class 
ezcGraphOdometerChart'
+        );
+
+        $chart->axis = new ezcGraphChartElementLabeledAxis();
+        $this->assertTrue(
+            $chart->axis instanceof ezcGraphChartElementLabeledAxis,
+            'Setting property value did not work for property axis in class 
ezcGraphOdometerChart'
+        );
+
+        try
+        {
+            $chart->axis = true;
         }
         catch ( ezcBaseValueException $e )
         {
@@ -329,6 +356,24 @@
         $this->fail( 'Expected ezcGraphNoDataException.' );
     }
 
+    public function testIncompatibleRenderer()
+    {
+        $chart = new ezcGraphOdometerChart();
+        $chart->data['sampleData'] = new ezcGraphArrayDataSet( array( 'sample 
1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 1, 'sample 5' => 
120 ) );
+
+        try
+        {
+            $chart->renderer = new ezcGraphRenderer3d();
+            $chart->render( 500, 200 );
+        }
+        catch ( ezcBaseValueException $e )
+        {
+            return;
+        }
+
+        $this->fail( 'Expected ezcBaseValueException.' );
+    }
+
     public function testRenderCompleteOdometer()
     {
         $filename = $this->tempDir . __FUNCTION__ . '.svg';


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to