From 7a117ebaf97c5387d5da544d5bb385fc014364f9 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Thu, 31 Mar 2011 12:13:23 +0000 Subject: [PATCH] 2011-03-31 Sergio Martin * include/graphs/pChart/pDraw.class.php: Added to library an option to avoid draw zeros in area charts git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4155 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 ++++++ pandora_console/include/graphs/pChart/pDraw.class.php | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 5716be96d6..d94c153644 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2011-03-31 Sergio Martin + + * include/graphs/pChart/pDraw.class.php: Added to + library an option to avoid draw zeros in area + charts + 2011-03-31 Sergio Martin * include/graphs/pChart/pDraw.class.php: Fixed diff --git a/pandora_console/include/graphs/pChart/pDraw.class.php b/pandora_console/include/graphs/pChart/pDraw.class.php index 5656daf973..3742897fc4 100755 --- a/pandora_console/include/graphs/pChart/pDraw.class.php +++ b/pandora_console/include/graphs/pChart/pDraw.class.php @@ -3660,6 +3660,7 @@ function drawAreaChart($Format=NULL) { $DisplayValues = isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE; + $DisplayZeros = isset($Format["DisplayZeros"]) ? $Format["DisplayZeros"] : TRUE; $DisplayOffset = isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2; $DisplayColor = isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL; $DisplayR = isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0; @@ -3700,8 +3701,16 @@ $X = $this->GraphAreaX1 + $XMargin; $LastX = NULL; $LastY = NULL; if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; } + $lastKey = 0; foreach($PosArray as $Key => $Y) { + // Hack to avoid draw zero values + debugPrint($Serie["Data"][$Key]." - ".$lastKey, '/tmp/logo'); + if(!$DisplayZeros && $Serie["Data"][$Key] == 0 && $lastKey == 0) { + $Y = VOID; + } + $lastKey = $Serie["Data"][$Key]; + if ( $DisplayValues && $Serie["Data"][$Key] != VOID ) { if ( $Serie["Data"][$Key] > 0 ) { $Align = TEXT_ALIGN_BOTTOMMIDDLE; $Offset = $DisplayOffset; } else { $Align = TEXT_ALIGN_TOPMIDDLE; $Offset = -$DisplayOffset; }