From 663755b520265cb1cc4bc3edf30370f54f16c86e Mon Sep 17 00:00:00 2001 From: Kore Nordmann Date: Wed, 2 Jul 2008 22:34:42 +0000 Subject: - Fixed issue #13253: Division by zero when trying to render stacked bars. --- ChangeLog | 2 +- src/charts/line.php | 3 ++- ...phLineChartTest_testStackedBarChartBug13253.svg | 2 ++ tests/line_test.php | 31 ++++++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 tests/data/compare/ezcGraphLineChartTest_testStackedBarChartBug13253.svg diff --git a/ChangeLog b/ChangeLog index 9abcc0c..8061ba1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,7 +5,7 @@ - Implemented feature #13102: Axes not extending beyond zero in line charts - Implemented feature #11981: Provide option for exact axis label renderer to put last value outside of the normal label boundings - +- Fixed issue #13253: Division by zero when trying to render stacked bars. 1.3 - Monday 16 June 2008 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/charts/line.php b/src/charts/line.php index 1c8613b..ed342e8 100644 --- a/src/charts/line.php +++ b/src/charts/line.php @@ -350,7 +350,8 @@ class ezcGraphLineChart extends ezcGraphChart } // Store stacked value for next iteration - $stacked[(int) ( $point->x * 10000 )][$point->y / abs( $point->y )] = $point; + $side = ( $point->y == 0 ? 1 : $point->y / abs( $point->y ) ); + $stacked[(int) ( $point->x * 10000 )][$side] = $point; $renderer->drawStackedBar( $boundings, diff --git a/tests/data/compare/ezcGraphLineChartTest_testStackedBarChartBug13253.svg b/tests/data/compare/ezcGraphLineChartTest_testStackedBarChartBug13253.svg new file mode 100644 index 0000000..a3b4c6a --- /dev/null +++ b/tests/data/compare/ezcGraphLineChartTest_testStackedBarChartBug13253.svg @@ -0,0 +1,2 @@ + +valuesremainsstring 1string 2string 3string 4string 50255075100 diff --git a/tests/line_test.php b/tests/line_test.php index a895da3..72ae0b8 100644 --- a/tests/line_test.php +++ b/tests/line_test.php @@ -1198,5 +1198,36 @@ class ezcGraphLineChartTest extends ezcGraphTestCase $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } + + public function testStackedBarChartBug13253() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + $graph = new ezcGraphBarChart(); + + $graph->data['values'] = new ezcGraphArrayDataSet( array( + 'string 1' => 55, + 'string 2' => 25, + 'string 3' => 10, + 'string 4' => 10, + 'string 5' => 5, + ) ); + $graph->data['remains'] = new ezcGraphArrayDataSet( array( + 'string 1' => 45, + 'string 2' => 75, + 'string 3' => 90, + 'string 4' => 90, + 'string 5' => 95, + ) ); + + $graph->palette = new ezcGraphPaletteEzRed(); + $graph->options->stackBars = true; + + $graph->render( 500, 200, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } } ?> -- cgit v1.1