Author: Kore Nordmann
Date: 2006-06-12 14:13:32 +0200 (Mon, 12 Jun 2006)
New Revision: 3120

Log:
- Added possibility to highlight datasets and dataset elements

Added:
   trunk/Graph/src/datasets/property/boolean.php
Modified:
   trunk/Graph/src/datasets/base.php
   trunk/Graph/src/graph_autoload.php
   trunk/Graph/tests/dataset_test.php

Modified: trunk/Graph/src/datasets/base.php
===================================================================
--- trunk/Graph/src/datasets/base.php   2006-06-12 11:44:21 UTC (rev 3119)
+++ trunk/Graph/src/datasets/base.php   2006-06-12 12:13:32 UTC (rev 3120)
@@ -15,16 +15,55 @@
 class ezcGraphDataset implements ArrayAccess, Iterator
 {
 
+    /**
+     * labels for dataset and dataset elements
+     * 
+     * @var ezcGraphDatasetStringProperty
+     */
     protected $label;
 
+    /**
+     * Colors for dataset elements
+     * 
+     * @var ezcGraphDatasetColorProperty
+     */
     protected $color;
 
+    /**
+     * Symbols for dataset elements
+     * 
+     * @var ezcGraphDatasetIntProperty
+     */
     protected $symbol;
 
+    /**
+     * Status if dataset element is hilighted
+     * 
+     * @var ezcGraphDatasetBooleanProperty
+     * @access protected
+     */
+    protected $highlight;
+
+    /**
+     * Array which contains the data of the dataset
+     * 
+     * @var array
+     */
     protected $data;
 
+    /**
+     * Current dataset element
+     * needed for iteration over dataset with ArrayAccess
+     * 
+     * @var mixed
+     */
     protected $current;
 
+    /**
+     * Color palette used for dataset colorization
+     * 
+     * @var ezcGraphPalette
+     */
     protected $pallet;
 
     public function __construct()
@@ -32,6 +71,9 @@
         $this->label = new ezcGraphDatasetStringProperty( $this );
         $this->color = new ezcGraphDatasetColorProperty( $this );
         $this->symbol = new ezcGraphDatasetIntProperty( $this );
+        $this->highlight = new ezcGraphDatasetBooleanProperty( $this );
+
+        $this->highlight->default = false;
     }
 
     /**
@@ -65,6 +107,10 @@
             case 'symbol':
                 $this->symbol->default = $propertyValue;
                 break;
+            case 'highlight':
+            case 'hilight':
+                $this->highlight->default = $propertyValue;
+                break;
             case 'palette':
                 $this->palette = $propertyValue;
                 $this->color->default = $this->palette->dataSetColor;

Added: trunk/Graph/src/datasets/property/boolean.php
===================================================================
--- trunk/Graph/src/datasets/property/boolean.php       2006-06-12 11:44:21 UTC 
(rev 3119)
+++ trunk/Graph/src/datasets/property/boolean.php       2006-06-12 12:13:32 UTC 
(rev 3120)
@@ -0,0 +1,30 @@
+<?php
+/**
+ * File containing the abstract ezcGraphDatasetBooleanProperty class
+ *
+ * @package Graph
+ * @version //autogentag//
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * Class for integer properties of datasets
+ *
+ * @package Graph
+ */
+class ezcGraphDatasetBooleanProperty extends ezcGraphDatasetProperty
+{
+    /**
+     * Converts value to an ezcGraphColor object
+     * 
+     * @param & $value 
+     * @return void
+     */
+    protected function checkValue( &$value )
+    {
+        $value = (bool) $value;
+        return true;
+    }
+}
+
+?>


Property changes on: trunk/Graph/src/datasets/property/boolean.php
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/Graph/src/graph_autoload.php
===================================================================
--- trunk/Graph/src/graph_autoload.php  2006-06-12 11:44:21 UTC (rev 3119)
+++ trunk/Graph/src/graph_autoload.php  2006-06-12 12:13:32 UTC (rev 3120)
@@ -57,6 +57,7 @@
     'ezcGraphDatasetColorProperty'              => 
'Graph/datasets/property/color.php',
     'ezcGraphDatasetStringProperty'             => 
'Graph/datasets/property/string.php',
     'ezcGraphDatasetIntProperty'                => 
'Graph/datasets/property/integer.php',
+    'ezcGraphDatasetBooleanProperty'            => 
'Graph/datasets/property/boolean.php',
     'ezcGraphNoSuchDataException'               => 
'Graph/exceptions/no_such_data.php',
     'ezcGraphNoSuchDatasetException'            => 
'Graph/exceptions/no_such_dataset.php',
     'ezcGraphTooManyDatasetsExceptions'         => 
'Graph/exceptions/too_many_datasets.php',

Modified: trunk/Graph/tests/dataset_test.php
===================================================================
--- trunk/Graph/tests/dataset_test.php  2006-06-12 11:44:21 UTC (rev 3119)
+++ trunk/Graph/tests/dataset_test.php  2006-06-12 12:13:32 UTC (rev 3120)
@@ -149,18 +149,51 @@
         );
     }
 
-    public function testDatasetSetSymbol()
+    public function testDatasetSetHighlight()
     {
         $chart = ezcGraph::create( 'Pie' );
         $chart->income = array( 2000 => 2345.2, 2456.3, 2567.4 );
-        $chart->income->symbol = ezcGraph::DIAMOND;
+        $chart->income->highlight = true;
 
         $this->assertEquals(
-            ezcGraph::DIAMOND,
-            $chart->income->symbol->default
+            true,
+            $chart->income->highlight->default
         );
     }
 
+    public function testDatasetGetHighlight()
+    {
+        $chart = ezcGraph::create( 'Pie' );
+        $chart->income = array( 2000 => 2345.2, 2456.3, 2567.4 );
+
+        $this->assertEquals(
+            false,
+            $chart->income->highlight[2001]
+        );
+
+        $this->assertEquals(
+            false,
+            $chart->income->highlight->default
+        );
+    }
+
+    public function testDatasetSetHighlightSingle()
+    {
+        $chart = ezcGraph::create( 'Pie' );
+        $chart->income = array( 2000 => 2345.2, 2456.3, 2567.4 );
+        $chart->income->highlight[2001] = true;
+
+        $this->assertEquals(
+            false,
+            $chart->income->highlight[2000]
+        );
+
+        $this->assertEquals(
+            true,
+            $chart->income->highlight[2001]
+        );
+    }
+
     public function testDatasetSetSingleColor()
     {
         $chart = ezcGraph::create( 'Pie' );

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

Reply via email to