|
4141 - in trunk/Graph: . src src/charts src/exceptions tests [eZComponents:: msg#00314web.ezcomponents.cvs
Author: Kore Nordmann Date: 2006-11-30 10:29:35 +0100 (Thu, 30 Nov 2006) New Revision: 4141 Log: - Fixed bug #9568: (Devision by zero warning) Added: trunk/Graph/src/exceptions/no_data.php Modified: trunk/Graph/ChangeLog trunk/Graph/src/charts/line.php trunk/Graph/src/charts/pie.php trunk/Graph/src/graph_autoload.php trunk/Graph/tests/chart_test.php Modified: trunk/Graph/ChangeLog =================================================================== --- trunk/Graph/ChangeLog 2006-11-30 09:28:23 UTC (rev 4140) +++ trunk/Graph/ChangeLog 2006-11-30 09:29:35 UTC (rev 4141) @@ -5,6 +5,7 @@ - Renamed pie chart options percentTreshHold to percentThreshold and absoluteTreshHold to absoluteThreshold +- Fixed issue #9568: Devision by zero warning - Fixed issue #9655: pieChartOffset and highlight do not work together in 2d renderer - Fixed issue #9586: No data rendered with string keys on date axis. Modified: trunk/Graph/src/charts/line.php =================================================================== --- trunk/Graph/src/charts/line.php 2006-11-30 09:28:23 UTC (rev 4140) +++ trunk/Graph/src/charts/line.php 2006-11-30 09:29:35 UTC (rev 4141) @@ -290,6 +290,11 @@ */ public function render( $width, $height, $file = null ) { + if ( !count( $this->data ) ) + { + throw new ezcGraphNoDataException(); + } + // Set image properties in driver $this->driver->options->width = $width; $this->driver->options->height = $height; Modified: trunk/Graph/src/charts/pie.php =================================================================== --- trunk/Graph/src/charts/pie.php 2006-11-30 09:28:23 UTC (rev 4140) +++ trunk/Graph/src/charts/pie.php 2006-11-30 09:29:35 UTC (rev 4141) @@ -182,6 +182,11 @@ */ public function render( $width, $height, $file = null ) { + if ( !count( $this->data ) ) + { + throw new ezcGraphNoDataException(); + } + // Set image properties in driver $this->driver->options->width = $width; $this->driver->options->height = $height; Added: trunk/Graph/src/exceptions/no_data.php =================================================================== --- trunk/Graph/src/exceptions/no_data.php 2006-11-30 09:28:23 UTC (rev 4140) +++ trunk/Graph/src/exceptions/no_data.php 2006-11-30 09:29:35 UTC (rev 4141) @@ -0,0 +1,24 @@ +<?php +/** + * File containing the ezcGraphNoDataException class + * + * @package Graph + * @version //autogen// + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ +/** + * Exception shown, when trying to render a chart without assigning any data. + * + * @package Graph + * @version //autogen// + */ +class ezcGraphNoDataException extends ezcGraphException +{ + public function __construct() + { + parent::__construct( "No data sets assigned to chart." ); + } +} + +?> Property changes on: trunk/Graph/src/exceptions/no_data.php ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/Graph/src/graph_autoload.php =================================================================== --- trunk/Graph/src/graph_autoload.php 2006-11-30 09:28:23 UTC (rev 4140) +++ trunk/Graph/src/graph_autoload.php 2006-11-30 09:29:35 UTC (rev 4141) @@ -70,6 +70,7 @@ 'ezcGraphChartElement' => 'Graph/interfaces/element.php', 'ezcGraphNoSuchElementException' => 'Graph/exceptions/no_such_element.php', + 'ezcGraphNoDataException' => 'Graph/exceptions/no_data.php', 'ezcGraphFontOptions' => 'Graph/options/font.php', 'ezcGraphChartElementText' => 'Graph/element/text.php', 'ezcGraphChartElementLegend' => 'Graph/element/legend.php', Modified: trunk/Graph/tests/chart_test.php =================================================================== --- trunk/Graph/tests/chart_test.php 2006-11-30 09:28:23 UTC (rev 4140) +++ trunk/Graph/tests/chart_test.php 2006-11-30 09:29:35 UTC (rev 4141) @@ -182,5 +182,31 @@ $this->fail( 'Expected ezcGraphInvalidDriverException' ); } + + public function testPieChartWithoutData() + { + try + { + $pieChart = new ezcGraphPieChart(); + $pieChart->render( 400, 200 ); + } + catch ( ezcGraphNoDataException $e ) + { + return true; + } + } + + public function testBarChartWithoutData() + { + try + { + $pieChart = new ezcGraphPieChart(); + $pieChart->render( 400, 200 ); + } + catch ( ezcGraphNoDataException $e ) + { + return true; + } + } } ?> |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | 4140 - in trunk/Template: src/parsers/tst/implementations tests [eZComponents: Trunk]: 00314, Raymond Bosman |
|---|---|
| Next by Date: | 4142 - trunk/Template/tests [eZComponents: Trunk]: 00314, Raymond Bosman |
| Previous by Thread: | 4140 - in trunk/Template: src/parsers/tst/implementations tests [eZComponents: Trunk]i: 00314, Raymond Bosman |
| Next by Thread: | 4142 - trunk/Template/tests [eZComponents: Trunk]: 00314, Raymond Bosman |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |