From ebaaaabd9fd74aef2000ac4c3025df19ff1d3db3 Mon Sep 17 00:00:00 2001 From: juanmanuelr Date: Thu, 31 May 2012 14:37:34 +0000 Subject: [PATCH] 2012-05-31 Juan Manuel Ramon * include/graphs/functions_pchart.php include/graphs/pChart/pDraw.class.php: Graphs with all data equal to zero are displayed correctly. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6390 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 ++++++ pandora_console/include/graphs/functions_pchart.php | 8 +++++++- pandora_console/include/graphs/pChart/pDraw.class.php | 8 +++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 49c3e5e184..60bb7566cc 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2012-05-31 Juan Manuel Ramon + + * include/graphs/functions_pchart.php + include/graphs/pChart/pDraw.class.php: Graphs with all data equal + to zero are displayed correctly. + 2012-05-31 Juan Manuel Ramon * godmode/reporting/reporting_builder.php: Fixed error updating diff --git a/pandora_console/include/graphs/functions_pchart.php b/pandora_console/include/graphs/functions_pchart.php index d94c9a4c1d..bfe1d3953c 100755 --- a/pandora_console/include/graphs/functions_pchart.php +++ b/pandora_console/include/graphs/functions_pchart.php @@ -707,11 +707,16 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, // Get the max number of scale $max_all = 0; + + $serie_ne_zero = false; foreach($data as $serie) { $max_this_serie = max($serie); if($max_this_serie > $max_all) { $max_all = $max_this_serie; } + // Detect if all serie is equal to zero or not + if ($serie != 0) + $serie_ne_zero = true; } // Get the number of digits of the scale @@ -722,7 +727,8 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, } // If the number is less than 1 we count the decimals - if($digits_left == 0){ + // Also check if the serie is not all equal to zero (!$serie_ne_zero) + if($digits_left == 0 and !$serie_ne_zero) { while($max_all < 1) { $digits_left ++; $max_all *= 10; diff --git a/pandora_console/include/graphs/pChart/pDraw.class.php b/pandora_console/include/graphs/pChart/pDraw.class.php index f0ba37965b..0b2a46e4b0 100755 --- a/pandora_console/include/graphs/pChart/pDraw.class.php +++ b/pandora_console/include/graphs/pChart/pDraw.class.php @@ -1808,7 +1808,13 @@ $AutoMargin = (($AxisMax-$AxisMin)/100)*$XReleasePercent; $Data["Axis"][$AxisID]["Min"] = $AxisMin-$AutoMargin; $Data["Axis"][$AxisID]["Max"] = $AxisMax+$AutoMargin; - if ( $Mode == SCALE_MODE_START0 ) { $Data["Axis"][$AxisID]["Min"] = 0; } + if ( $Mode == SCALE_MODE_START0 ) { + $Data["Axis"][$AxisID]["Min"] = 0; + // Hack: When max and min graph values are equal to zero then force max = 1 + if($Data["Axis"][$AxisID]["Max"] == 0) { + $Data["Axis"][$AxisID]["Max"] = 1; + } + } } elseif ( $Mode == SCALE_MODE_MANUAL ) {