diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2004-08-25 19:12:58 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2004-08-25 19:12:58 +0000 |
| commit | afd9f9f5ef1d002ac92f3cc8e2a733fac69c2c20 (patch) | |
| tree | 84aa824aedb5e1bfa0ca7a451699387f4685f0ff /frontends/php/include | |
| parent | 93248e9b70106966ef70e752a32d2528e46435b3 (diff) | |
- added support for customised Y axis for graphs (Alexei)
- added columns graphs.(yaxistype|yaxismin|yaxismax) (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@1405 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/classes.inc.php | 136 | ||||
| -rw-r--r-- | frontends/php/include/config.inc.php | 8 | ||||
| -rw-r--r-- | frontends/php/include/defines.inc.php | 3 | ||||
| -rw-r--r-- | frontends/php/include/forms.inc.php | 84 | ||||
| -rw-r--r-- | frontends/php/include/local_en.inc.php | 5 |
5 files changed, 184 insertions, 52 deletions
diff --git a/frontends/php/include/classes.inc.php b/frontends/php/include/classes.inc.php index 1ecc3af4..28fa4287 100644 --- a/frontends/php/include/classes.inc.php +++ b/frontends/php/include/classes.inc.php @@ -30,6 +30,10 @@ var $shiftY; var $border; + var $yaxistype; + var $yaxismin; + var $yaxismax; + // items[num].data.min[max|avg] var $items; // $idnum[$num] is itemid @@ -103,6 +107,7 @@ $this->border=1; $this->num=0; $this->nodata=1; + $this->yaxistype=GRAPH_YAXIS_TYPE_CALCULATED; $this->count=array(); $this->min=array(); @@ -149,6 +154,21 @@ $this->period=$period; } + function setYAxisMin($yaxismin) + { + $this->yaxismin=$yaxismin; + } + + function setYAxisMax($yaxismax) + { + $this->yaxismax=$yaxismax; + } + + function setYAxisType($yaxistype) + { + $this->yaxistype=$yaxistype; + } + function setSTime($stime) { if($stime>200000000000 && $stime<220000000000) @@ -390,65 +410,85 @@ } // Calculation of maximum Y - function calculateMaxY() + function calculateMinY() { - unset($maxY); - for($i=0;$i<$this->num;$i++) + if($this->yaxistype==GRAPH_YAXIS_TYPE_FIXED) { - if(!isset($maxY)) - { - if(count($this->max[$i])>0) - { - $maxY=max($this->max[$i]); - } - } - else - { - $maxY=@iif($maxY<max($this->max[$i]),max($this->max[$i]),$maxY); - } - } - - if($maxY>0) - { - $exp = floor(log10($maxY)); - $mant = $maxY/pow(10,$exp); + return $this->yaxismin; } else { - $exp=0; - $mant=0; + return 0; } + } - $mant=(floor($mant*1.1*10/6)+1)*6/10; - -/* if($mant<1.5) - { - $mant=1.5; - } - elseif($mant<2) - { - $mant=2; - } - elseif($mant<3) - { - $mant=3; - } - elseif($mant<5) - { - $mant=5; - } - elseif($mant<8) +// Calculation of maximum Y + function calculateMaxY() + { + if($this->yaxistype==GRAPH_YAXIS_TYPE_FIXED) { - $mant=8; + return $this->yaxismax; } else { - $mant=10; + unset($maxY); + for($i=0;$i<$this->num;$i++) + { + if(!isset($maxY)) + { + if(count($this->max[$i])>0) + { + $maxY=max($this->max[$i]); + } + } + else + { + $maxY=@iif($maxY<max($this->max[$i]),max($this->max[$i]),$maxY); + } + } + + if($maxY>0) + { + $exp = floor(log10($maxY)); + $mant = $maxY/pow(10,$exp); + } + else + { + $exp=0; + $mant=0; + } + + $mant=(floor($mant*1.1*10/6)+1)*6/10; + + /* if($mant<1.5) + { + $mant=1.5; + } + elseif($mant<2) + { + $mant=2; + } + elseif($mant<3) + { + $mant=3; + } + elseif($mant<5) + { + $mant=5; + } + elseif($mant<8) + { + $mant=8; + } + else + { + $mant=10; + } + */ + $maxY = $mant*pow(10,$exp); + + return $maxY; } -*/ - $maxY = $mant*pow(10,$exp); - - return $maxY; } function selectData() @@ -539,7 +579,7 @@ $maxX=900; $minX=0; - $minY=0; + $minY=$this->calculateMinY(); $maxY=$this->calculateMaxY(); for($item=0;$item<$this->num;$item++) diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 66e614b1..0bb1f90b 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -2646,7 +2646,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; # Update Graph - function update_graph($graphid,$name,$width,$height) + function update_graph($graphid,$name,$width,$height,$yaxistype,$yaxismin,$yaxismax) { global $ERROR_MSG; @@ -2656,7 +2656,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; return 0; } - $sql="update graphs set name='$name',width=$width,height=$height where graphid=$graphid"; + $sql="update graphs set name='$name',width=$width,height=$height,yaxistype=$yaxistype,yaxismin=$yaxismin,yaxismax=$yaxismax where graphid=$graphid"; return DBexecute($sql); } @@ -2678,7 +2678,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; # Add Graph - function add_graph($name,$width,$height) + function add_graph($name,$width,$height,$yaxistype,$yaxismin,$yaxismax) { global $ERROR_MSG; @@ -2688,7 +2688,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; return 0; } - $sql="insert into graphs (name,width,height) values ('$name',$width,$height)"; + $sql="insert into graphs (name,width,height,yaxistype,yaxismin,yaxismax) values ('$name',$width,$height,$yaxistype,$yaxismin,$yaxismax)"; return DBexecute($sql); } diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index 8d8169e6..97f0eac4 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -31,6 +31,9 @@ define("GRAPH_DRAW_TYPE_DOT",3); define("GRAPH_DRAW_TYPE_DASHEDLINE",4); + define("GRAPH_YAXIS_TYPE_CALCULATED",0); + define("GRAPH_YAXIS_TYPE_FIXED",1); + define("ITEM_VALUE_TYPE_FLOAT",0); define("ITEM_VALUE_TYPE_STR",1); diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 675de396..864111f5 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -737,4 +737,88 @@ echo "</form>"; show_table2_header_end(); } + + function insert_graph_form() + { + global $_GET; + + $name=@iif(isset($_GET["name"]),$_GET["name"],""); + $width=@iif(isset($_GET["width"]),$_GET["width"],900); + $height=@iif(isset($_GET["height"]),$_GET["height"],200); + $yaxistype=@iif(isset($_GET["yaxistype"]),$_GET["yaxistype"],GRAPH_YAXIS_TYPE_CALCULATED); + $yaxismin=@iif(isset($_GET["yaxismin"]),$_GET["yaxismin"],0.00); + $yaxismax=@iif(isset($_GET["yaxismax"]),$_GET["yaxismax"],100.00); + + if(isset($_GET["graphid"])&&!isset($_GET["name"])) + { + $result=DBselect("select g.graphid,g.name,g.width,g.height,g.yaxistype,g.yaxismin,g.yaxismax from graphs g where graphid=".$_GET["graphid"]); + $row=DBfetch($result); + $name=$row["name"]; + $width=$row["width"]; + $height=$row["height"]; + $yaxistype=$row["yaxistype"]; + $yaxismin=$row["yaxismin"]; + $yaxismax=$row["yaxismax"]; + } + + echo "<br>"; + show_table2_header_begin(); + echo S_GRAPH; + + show_table2_v_delimiter(); + echo "<form method=\"get\" action=\"graphs.php\">"; + if(isset($_GET["graphid"])) + { + echo "<input class=\"biginput\" name=\"graphid\" type=\"hidden\" value=".$_GET["graphid"].">"; + } + echo S_NAME; + show_table2_h_delimiter(); + echo "<input class=\"biginput\" name=\"name\" value=\"$name\" size=32>"; + + show_table2_v_delimiter(); + echo S_WIDTH; + show_table2_h_delimiter(); + echo "<input class=\"biginput\" name=\"width\" size=5 value=\"$width\">"; + + show_table2_v_delimiter(); + echo S_HEIGHT; + show_table2_h_delimiter(); + echo "<input class=\"biginput\" name=\"height\" size=5 value=\"$height\">"; + + show_table2_v_delimiter(); + echo S_YAXIS_TYPE; + show_table2_h_delimiter(); + echo "<SELECT class=\"biginput\" NAME=\"yaxistype\" size=\"1\" onChange=\"submit()\">"; + echo "<OPTION VALUE=\"0\" "; if($yaxistype==GRAPH_YAXIS_TYPE_CALCULATED) echo "SELECTED"; echo ">".S_CALCULATED; + echo "<OPTION VALUE=\"1\" "; if($yaxistype==GRAPH_YAXIS_TYPE_FIXED) echo "SELECTED"; echo ">".S_FIXED; + echo "</SELECT>"; + + if($yaxistype == GRAPH_YAXIS_TYPE_FIXED) + { + show_table2_v_delimiter(); + echo S_YAXIS_MIN_VALUE; + show_table2_h_delimiter(); + echo "<input class=\"biginput\" name=\"yaxismin\" size=5 value=\"$yaxismin\">"; + + show_table2_v_delimiter(); + echo S_YAXIS_MAX_VALUE; + show_table2_h_delimiter(); + echo "<input class=\"biginput\" name=\"yaxismax\" size=5 value=\"$yaxismax\">"; + } + else + { + echo "<input class=\"biginput\" name=\"yaxismin\" type=hidden value=\"$yaxismin\">"; + echo "<input class=\"biginput\" name=\"yaxismax\" type=hidden value=\"$yaxismax\">"; + } + + show_table2_v_delimiter2(); + echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"add\">"; + if(isset($_GET["graphid"])) + { + echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"update\">"; + echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"delete\" onClick=\"return Confirm('".S_DELETE_GRAPH_Q."');\">"; + } + + show_table2_header_end(); + } ?> diff --git a/frontends/php/include/local_en.inc.php b/frontends/php/include/local_en.inc.php index e2f72bcb..0db93818 100644 --- a/frontends/php/include/local_en.inc.php +++ b/frontends/php/include/local_en.inc.php @@ -199,6 +199,11 @@ define("S_ID", "Id"); define("S_NO_GRAPHS_DEFINED", "No graphs defined"); define("S_DELETE_GRAPH_Q", "Delete graph?"); + define("S_YAXIS_TYPE", "Y axis type"); + define("S_YAXIS_MIN_VALUE", "Y axis MIN value"); + define("S_YAXIS_MAX_VALUE", "Y axis MAX value"); + define("S_CALCULATED", "Calculated"); + define("S_FIXED", "Fixed"); // history.php define("S_LAST_HOUR_GRAPH", "Last hour graph"); |
