Note that to use this you will have to have a small (43 bytes), transparent GIF file on your Web server that is used to help properly space out the HTML table that is used to display the gauge. This image, shim.gif, can be downloaded at: http://www.developerfusion.com/images/site/shim.gif horizontal gauge test BgColor = $fgc; $this->FgColor = $bgc; $this->Width = $wid; $this->Height = $hei; $this->MinVal = $min; $this->MaxVal = $max; $this->CurVal = $cur; } // Render this into HTML as a table. function display() { // Normalize the properties. if ($this->MinVal > $this->MaxVal) { $temp_val = $this->MinVal; $this->MinVal = $this->MaxVal; $this->MaxVal = $temp_val; } if ($this->CurVal < $this->MinVal) { $this->CurVal = $this->MinVal; } elseif ($this->CurVal > $this->MaxVal) { $this->CurVal = $this->MaxVal; } // Figure out the percentage that the CurVal is within MinVal and MaxVal. $percentage_val = ($this->CurVal - $this->MinVal) / ($this->MaxVal - $this->MinVal); // Compute the first and second widths. $fg_width = Round($this->Width * $percentage_val); $bg_width = $this->Width - $fg_width; $RenderHtml = ""; if ($fg_width > 0) { $RenderHtml = $RenderHtml . ""; } if ($bg_width > 0) { $RenderHtml = $RenderHtml . ""; } $RenderHtml = $RenderHtml . "
"; print $RenderHtml; } } // Main $oGauge = new myGauge(); /* // Use method setValues to set datamembers, like: $fc = "#FFFFFF"; $bc = "#990000"; $wi = 125; $hi = 10; $mi = 0; $ma = 100; $cu = 87; $oGauge->setValues($fc, $bc, $wi, $hi, $mi, $ma, $cu); */ ?>
display(); ?>