Hi !
Displaying [no data] in graphs is a bit useless and takes place when using templates. For example, I have a template with 20 network interfaces and a graph with the in/out bandwidth of all interfaces. When applied to a host with only 4 interfaces, I get many [no data] in the legend. Here is a patch removing them :
Displaying [no data] in graphs is a bit useless and takes place when using templates. For example, I have a template with 20 network interfaces and a graph with the in/out bandwidth of all interfaces. When applied to a host with only 4 interfaces, I get many [no data] in the legend. Here is a patch removing them :
Code:
From: Vincent Bernat <[email protected]> Date: Tue, 27 Feb 2007 11:38:02 +0000 (+0100) Subject: Disable "no data" in graphs. X-Git-Url: http://localhost/cgi-bin/gitweb.cgi?p=zabbix-wallix-1.1.6.git;a=commitdiff_plain;h=d862c73f406010bb7ce7633bd997ed4e8ffc81f7 Disable "no data" in graphs. --- diff --git a/frontends/php/include/classes/graph.inc.php b/frontends/php/include/classes/graph.inc.php index ee7c51a..cc32956 100644 --- a/frontends/php/include/classes/graph.inc.php +++ b/frontends/php/include/classes/graph.inc.php @@ -559,6 +559,7 @@ if(strlen($this->items[$i]["description"])>$max_desc_len) $max_desc_len=strlen($this->items[$i]["description"]); } + $j=0; for($i=0;$i<$this->num;$i++) { if($this->items[$i]["calc_type"] == GRAPH_ITEM_AGGREGATED) @@ -589,22 +590,18 @@ convert_units(min($data->min),$this->items[$i]["units"]), convert_units(max($data->max),$this->items[$i]["units"]), convert_units($this->getLastValue($i),$this->items[$i]["units"])); - } - else - { - $str=sprintf("%s: %s [ no data ]", - str_pad($this->items[$i]["host"],$max_host_len," "), - str_pad($this->items[$i]["description"],$max_desc_len," ")); + + ImageFilledRectangle($this->im,$this->shiftXleft,$this->sizeY+$this->shiftY+62+12*$j,$this->shiftXleft+5,$this->sizeY+$this->shiftY+5+62+12*$j,$color); + ImageRectangle($this->im,$this->shiftXleft,$this->sizeY+$this->shiftY+62+12*$j,$this->shiftXleft+5,$this->sizeY+$this->shiftY+5+62+12*$j,$this->colors["Black No Alpha"]); + + ImageString($this->im, 2, + $this->shiftXleft+9, + $this->sizeY+$this->shiftY+(62-5)+12*$j, + $str, + $this->colors["Black No Alpha"]); + $j++; } - ImageFilledRectangle($this->im,$this->shiftXleft,$this->sizeY+$this->shiftY+62+12*$i,$this->shiftXleft+5,$this->sizeY+$this->shiftY+5+62+12*$i,$color); - ImageRectangle($this->im,$this->shiftXleft,$this->sizeY+$this->shiftY+62+12*$i,$this->shiftXleft+5,$this->sizeY+$this->shiftY+5+62+12*$i,$this->colors["Black No Alpha"]); - - ImageString($this->im, 2, - $this->shiftXleft+9, - $this->sizeY+$this->shiftY+(62-5)+12*$i, - $str, - $this->colors["Black No Alpha"]); } if($this->sizeY < 120) return; @@ -613,14 +610,14 @@ { ImageFilledEllipse($this->im, $this->shiftXleft + 2, - $this->sizeY+$this->shiftY+2+62+12*$i, + $this->sizeY+$this->shiftY+2+62+12*$j, 6, 6, $this->colors[$trigger["color"]]); ImageEllipse($this->im, $this->shiftXleft + 2, - $this->sizeY+$this->shiftY+2+62+12*$i, + $this->sizeY+$this->shiftY+2+62+12*$j, 6, 6, $this->colors["Black No Alpha"]); @@ -629,10 +626,10 @@ $this->im, 2, $this->shiftXleft+9, - $this->sizeY+$this->shiftY+(62-5)+12*$i, + $this->sizeY+$this->shiftY+(62-5)+12*$j, $trigger['description'], $this->colors["Black No Alpha"]); - ++$i; + ++$j; } } @@ -900,6 +897,17 @@ } } + function countUsefulItems() + { + $j=0; + for($i=0;$i<$this->num;$i++) + { + $data = &$this->data[$this->items[$i]["itemid"]][$this->items[$i]["calc_type"]]; + if(isset($data)&&isset($data->min)) $j++; + } + return $j; + } + function selectData() { global $DB_TYPE; @@ -1160,7 +1168,7 @@ $this->calcTriggers(); $this->fullSizeX = $this->sizeX+$this->shiftXleft+$this->shiftXright+1; - $this->fullSizeY = $this->sizeY+$this->shiftY+62+12*($this->num+ (($this->sizeY < 120) ? 0 : count($this->triggers)))+8; + $this->fullSizeY = $this->sizeY+$this->shiftY+62+12*($this->countUsefulItems()+ (($this->sizeY < 120) ? 0 : count($this->triggers)))+8; if(function_exists("ImageColorExactAlpha")&&function_exists("ImageCreateTrueColor")&&@imagecreatetruecolor(1,1)) $this->im = ImageCreateTrueColor($this->fullSizeX,$this->fullSizeY);
Comment