Module: nagvis
Branch: master
Commit: f3fd859cfefb47c73baa2d92efcf92baa10b947f
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=f3fd859cfefb47c73baa2d92efcf92baa10b947f

Author: Lars Michelsen <[email protected]>
Date:   Tue Oct  5 21:06:17 2010 +0200

Fixed negative value handling in speedometer gadgets

---

 share/userfiles/gadgets/gadgets_core.php     |    6 +++---
 share/userfiles/gadgets/std_speedometer.php  |   20 ++++++++++----------
 share/userfiles/gadgets/std_speedometer2.php |   10 +++++-----
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/share/userfiles/gadgets/gadgets_core.php 
b/share/userfiles/gadgets/gadgets_core.php
index 5c893ad..c9fec03 100644
--- a/share/userfiles/gadgets/gadgets_core.php
+++ b/share/userfiles/gadgets/gadgets_core.php
@@ -172,7 +172,7 @@ function errorBox($msg) {
 
 /* Now read the parameters */
 
-$aOpts = Array('name1', 'name2', 'state', 'stateType', 'perfdata');
+$aOpts = Array();
 $aPerfdata = Array();
 
 /**
@@ -204,8 +204,8 @@ elseif(!isset($_GET['opts']) || strpos($_GET['opts'], 
'no_perf') === false)
        errorBox('ERROR: The needed parameter "perfdata" is missing.');
 
 /* Now parse the perfdata */
-if(isset($_GET['opts']) && ($_GET['opts'] != ''))
-       if(strpos($_GET['opts'],'no_perf') === false)
+if(isset($_GET['opts']) && $_GET['opts'] != '')
+       if(strpos($_GET['opts'], 'no_perf') === false)
                $aPerfdata = parsePerfdata($aOpts['perfdata']);
 else
        $aPerfdata = parsePerfdata($aOpts['perfdata']);
diff --git a/share/userfiles/gadgets/std_speedometer.php 
b/share/userfiles/gadgets/std_speedometer.php
index 6f1f1e0..4eec393 100644
--- a/share/userfiles/gadgets/std_speedometer.php
+++ b/share/userfiles/gadgets/std_speedometer.php
@@ -85,10 +85,12 @@ if($value == null) {
        }
 }
 
-// If there is no max value given set it critical value
-if(intval($max) == 0 || $max == '') {
-       $max = $crit + 1;
-}
+// If there is no max value given set it critical or warning value
+if(intval($max) == 0 || $max == '')
+       if(intval($crit) == 0 || $crit != '')
+               $max = $crit + 1;
+       else
+               $max = $warn + 1;
 
 //================
 // Calculate degrees of value, warn, critical
@@ -145,13 +147,11 @@ imagecolortransparent($img, $oBackground);
 imagefilledarc($img,$centerx, $centery, $outerdia, $outerdia, 180, 0, $oGreen, 
IMG_ARC_EDGED);
 
 // Warning
-if($warn && $warnp <= -1) {
-       imagefilledarc($img, $centerx, $centery, $outerdia, $outerdia, $warnp, 
0, $oYellow, IMG_ARC_EDGED);
-}
+if($warn && $warnp <= -1)
+       imagefilledarc($img, $centerx, $centery, $outerdia, $outerdia, 360 + 
$warnp, 0, $oYellow, IMG_ARC_EDGED);
 // Critical
-if($crit && $critp <= -1) {
-       imagefilledarc($img,$centerx, $centery, $outerdia, $outerdia, $critp, 
0, $oRed, IMG_ARC_EDGED);
-}
+if($crit && $critp <= -1)
+       imagefilledarc($img,$centerx, $centery, $outerdia, $outerdia, 360 + 
$critp, 0, $oRed, IMG_ARC_EDGED);
 
 // Borders
 imagearc($img, $centerx, $centery+1, $outerdia+2, $outerdia+2, 180, 0, 
$oBlack);
diff --git a/share/userfiles/gadgets/std_speedometer2.php 
b/share/userfiles/gadgets/std_speedometer2.php
index fd696be..c6293bf 100644
--- a/share/userfiles/gadgets/std_speedometer2.php
+++ b/share/userfiles/gadgets/std_speedometer2.php
@@ -240,17 +240,17 @@ for ($i=0; $i < $pdc; $i++){
                // Warning
                if($warn && $warnp <= -1) {
                        if ($warn < $crit) {
-                               imagefilledarc($img, $centerx, $centery, 
$outerdia, $outerdia, $warnp, 0, $oYellow, IMG_ARC_EDGED);
+                               imagefilledarc($img, $centerx, $centery, 
$outerdia, $outerdia, 360 + $warnp, 0, $oYellow, IMG_ARC_EDGED);
                        } else {
-                               imagefilledarc($img, $centerx, $centery, 
$outerdia, $outerdia, 180, $warnp, $oYellow, IMG_ARC_EDGED);
+                               imagefilledarc($img, $centerx, $centery, 
$outerdia, $outerdia, 180, 360 + $warnp, $oYellow, IMG_ARC_EDGED);
                        }
                }
                // Critical
                if($crit && $critp <= -1) {
                        if ($warn < $crit) {
-                               imagefilledarc($img,$centerx, $centery, 
$outerdia, $outerdia, $critp, 0, $oRed, IMG_ARC_EDGED);
-                       } else {
-                               imagefilledarc($img,$centerx, $centery, 
$outerdia, $outerdia, 180, $critp, $oRed, IMG_ARC_EDGED);
+                               imagefilledarc($img,$centerx, $centery, 
$outerdia, $outerdia, 360 + $critp, 0, $oRed, IMG_ARC_EDGED);
+                       } else
+                               imagefilledarc($img,$centerx, $centery, 
$outerdia, $outerdia, 180, 360 + $critp, $oRed, IMG_ARC_EDGED);
                        }
                }
                


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to