summaryrefslogtreecommitdiffstats
path: root/src/charts
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2007-05-24 12:29:24 +0000
committerKore Nordmann <github@kore-nordmann.de>2007-05-24 12:29:24 +0000
commitaa49d9ec7aaa79cc42043224386ffc30bf7c7b0f (patch)
treefd09d73e08ca90ee14e46a76a78095cffeaa0e19 /src/charts
parent4029d5db40e0cc0c59647d1be98ead6602800d9a (diff)
downloadzetacomponents-graph-aa49d9ec7aaa79cc42043224386ffc30bf7c7b0f.zip
zetacomponents-graph-aa49d9ec7aaa79cc42043224386ffc30bf7c7b0f.tar.gz
- Fixed issue #10842: Pie charts fatal error with datasets with value sum <= 0
Diffstat (limited to 'src/charts')
-rw-r--r--src/charts/pie.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/charts/pie.php b/src/charts/pie.php
index 782ad32..4d616c8 100644
--- a/src/charts/pie.php
+++ b/src/charts/pie.php
@@ -86,8 +86,13 @@ class ezcGraphPieChart extends ezcGraphChart
// Calculate sum of all values to be able to calculate percentage
$sum = 0;
- foreach ( $dataset as $value )
+ foreach ( $dataset as $name => $value )
{
+ if ( $value <= 0 )
+ {
+ throw new ezcGraphInvalidDataException( "Values > 0 required, '$name' => '$value'." );
+ }
+
$sum += $value;
}
if ( $this->options->sum !== false )
@@ -95,6 +100,11 @@ class ezcGraphPieChart extends ezcGraphChart
$sum = max( $sum, $this->options->sum );
}
+ if ( $sum <= 0 )
+ {
+ throw new ezcGraphInvalidDataException( "Pie charts require a value sum > 0, your value: '$sum'." );
+ }
+
$angle = 0;
foreach ( $dataset as $label => $value )
{
OpenPOWER on IntegriCloud