Author: kn
Date: Tue Feb 5 11:25:23 2008
New Revision: 7286
Log:
- Fixed issue #12483: Average dataset does not work with a single value.
Added:
trunk/Graph/tests/data/compare/ezcGraphDataSetAverageTest_testCreateDatasetFromSingleElementDatasetRender.svg
(with props)
Modified:
trunk/Graph/ChangeLog
trunk/Graph/src/datasets/average.php
trunk/Graph/tests/dataset_average_test.php
Modified: trunk/Graph/ChangeLog
==============================================================================
--- trunk/Graph/ChangeLog [iso-8859-1] (original)
+++ trunk/Graph/ChangeLog [iso-8859-1] Tue Feb 5 11:25:23 2008
@@ -3,6 +3,7 @@
- Implemented feature #11979: Line width configurable per data set.
- Implemented feature #12382: Enhance line chart to allow invisible lines.
+- Fixed issue #12483: Average dataset does not work with a single value.
1.2.1 - Monday 21 January 2008
Modified: trunk/Graph/src/datasets/average.php
==============================================================================
--- trunk/Graph/src/datasets/average.php [iso-8859-1] (original)
+++ trunk/Graph/src/datasets/average.php [iso-8859-1] Tue Feb 5 11:25:23 2008
@@ -152,6 +152,11 @@
foreach ( $this->source as $key => $value )
{
+ if ( !is_numeric( $key ) )
+ {
+ throw new ezcGraphDatasetAverageInvalidKeysException();
+ }
+
if ( ( $this->min === false ) || ( $this->min > $key ) )
{
$this->min = (float) $key;
@@ -283,11 +288,6 @@
*/
final public function next()
{
- if ( $this->min === $this->max )
- {
- throw new ezcGraphDatasetAverageInvalidKeysException();
- }
-
if ( ++$this->position >= $this->resolution )
{
return false;
@@ -324,6 +324,12 @@
final public function valid()
{
$polynom = $this->getPolynom();
+
+ if ( $this->min >= $this->max )
+ {
+ return false;
+ }
+
return ( ( $this->getKey() >= $this->min ) && ( $this->getKey() <=
$this->max ) );
}
Added:
trunk/Graph/tests/data/compare/ezcGraphDataSetAverageTest_testCreateDatasetFromSingleElementDatasetRender.svg
==============================================================================
Binary file - no diff available.
Propchange:
trunk/Graph/tests/data/compare/ezcGraphDataSetAverageTest_testCreateDatasetFromSingleElementDatasetRender.svg
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
trunk/Graph/tests/data/compare/ezcGraphDataSetAverageTest_testCreateDatasetFromSingleElementDatasetRender.svg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: trunk/Graph/tests/dataset_average_test.php
==============================================================================
--- trunk/Graph/tests/dataset_average_test.php [iso-8859-1] (original)
+++ trunk/Graph/tests/dataset_average_test.php [iso-8859-1] Tue Feb 5 11:25:23
2008
@@ -55,6 +55,37 @@
$this->assertEquals(
'x^2',
$polynom->__toString()
+ );
+ }
+
+ public function testCreateDatasetFromSingleElementDataset()
+ {
+ $arrayDataSet = new ezcGraphArrayDataSet( array( 1 => 1 ) );
+
+ $averageDataSet = new ezcGraphDataSetAveragePolynom( $arrayDataSet );
+
+ $polynom = $averageDataSet->getPolynom();
+
+ $this->assertEquals(
+ '1',
+ $polynom->__toString()
+ );
+ }
+
+ public function testCreateDatasetFromSingleElementDatasetRender()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $chart = new ezcGraphLineChart();
+
+ $chart->data['src'] = new ezcGraphArrayDataSet( array( 1 => 1 ) );
+ $chart->data['avg'] = new ezcGraphDataSetAveragePolynom(
$chart->data['src'] );
+
+ $chart->render( 500, 200, $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ .
'.svg'
);
}
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components