[Rt-commit] rt branch, 4.2/chart-divide-zero, created. rt-4.2.12-158-g84ec669
Shawn Moore
shawn at bestpractical.com
Thu Jul 7 15:45:16 EDT 2016
The branch, 4.2/chart-divide-zero has been created
at 84ec669470f5b550fc5bfc8175393e644e7c2870 (commit)
- Log -----------------------------------------------------------------
commit 84ec669470f5b550fc5bfc8175393e644e7c2870
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Jul 7 19:45:07 2016 +0000
Avoid divide-by-zero in charts with no data
Fixes: I#32143
diff --git a/share/html/Search/Chart b/share/html/Search/Chart
index 8e26bcc..55528b9 100644
--- a/share/html/Search/Chart
+++ b/share/html/Search/Chart
@@ -371,8 +371,14 @@ if ($chart_class eq "GD::Graph::bars") {
if ( $width > $x_space_for_label ) {
$can{'horizontal, one line'} = 0;
}
- my $y_space_for_label = $Height * 0.6
- *( 1 - ($args{'element'}-$min_value)/($max_value-$min_value) );
+ my $y_space_for_label;
+ if ($max_value == $min_value) {
+ $y_space_for_label = 0;
+ }
+ else {
+ $y_space_for_label = $Height * 0.6
+ *( 1 - ($args{'element'}-$min_value)/($max_value-$min_value) );
+ }
if ( $width > $y_space_for_label ) {
$can{'vertical, one line'} = 0;
}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list