summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2007-11-23 12:40:39 +0000
committerKore Nordmann <github@kore-nordmann.de>2007-11-23 12:40:39 +0000
commitaa6990d330fd354477f767adb22cc4c02b18c76e (patch)
tree8260423701712d11299a25a4bba1f6083e421f16
parent4b6f409dd6023baee2f89454e868d4286709092c (diff)
downloadzetacomponents-graph-aa6990d330fd354477f767adb22cc4c02b18c76e.zip
zetacomponents-graph-aa6990d330fd354477f767adb22cc4c02b18c76e.tar.gz
- Fixed some first issues in Graph
-rw-r--r--review.txt14
-rw-r--r--src/charts/odometer.php106
-rw-r--r--src/graph_autoload.php1
-rw-r--r--tests/odometer_test.php45
4 files changed, 160 insertions, 6 deletions
diff --git a/review.txt b/review.txt
index 8e261e5..dd9dc0b 100644
--- a/review.txt
+++ b/review.txt
@@ -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 @@ Radar: ezcBaseValueException: The value 'O:18:"ezcGraphRenderer3d":16:{s:19:"
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.
diff --git a/src/charts/odometer.php b/src/charts/odometer.php
index 101db8b..554c2a9 100644
--- a/src/charts/odometer.php
+++ b/src/charts/odometer.php
@@ -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 ( {@link ezcGraphChartElementText} )
+ * - background ( {@link 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
+ * {@link ezcGraphOdometerChartOptions} extending the {@link
+ * ezcGraphChartOptions}.
+ *
+ * @property ezcGraphOdometerChartOptions $options
+ * Chart options class
+ *
+ * @version //autogentag//
+ * @package Graph
+ * @mainclass
+ */
class ezcGraphOdometerChart extends ezcGraphChart
{
@@ -34,6 +94,50 @@ class ezcGraphOdometerChart extends ezcGraphChart
}
/**
+ * 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 );
+ }
+ }
+
+ /**
* Render the assigned data
*
* Will renderer all charts data in the remaining boundings after drawing
diff --git a/src/graph_autoload.php b/src/graph_autoload.php
index 9c54a17..0f7efa2 100644
--- a/src/graph_autoload.php
+++ b/src/graph_autoload.php
@@ -115,7 +115,6 @@ return array(
'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',
diff --git a/tests/odometer_test.php b/tests/odometer_test.php
index 73cae07..27c23ae 100644
--- a/tests/odometer_test.php
+++ b/tests/odometer_test.php
@@ -221,6 +221,33 @@ class ezcGraphOdometerChartTest extends ezcGraphTestCase
$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 )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
public function testRenderOdometer()
{
$chart = new ezcGraphOdometerChart();
@@ -329,6 +356,24 @@ class ezcGraphOdometerChartTest extends ezcGraphTestCase
$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';
OpenPOWER on IntegriCloud