Revision 1, 0.7 KB
(checked in by andrewgunn, 14 years ago)
|
Added original EVE-Killboard.net source code.
|
Rev | Line | |
---|
[1] | 1 | <? |
---|
| 2 | |
---|
| 3 | class BarGraph |
---|
| 4 | { |
---|
| 5 | function BarGraph( $value = 0, $max = 100, $width = 75, $text = "" ) |
---|
| 6 | { |
---|
| 7 | $this->value_ = $value; |
---|
| 8 | $this->width_ = $width; |
---|
| 9 | $this->text_ = $text; |
---|
| 10 | $this->max_ = $max; |
---|
| 11 | |
---|
| 12 | $this->class_ = "bar"; |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | function generate() |
---|
| 16 | { |
---|
| 17 | if ( $this->text_ == "" ) $this->text_ = " "; |
---|
| 18 | if ( $this->value_ ) |
---|
| 19 | $width = $this->width_ / ( $this->max_ / $this->value_ ); |
---|
| 20 | else |
---|
| 21 | $width = 0; |
---|
| 22 | $html = "<div class=".$this->class_." style=\"width: ".$width."px;\">".$this->text_."</div>"; |
---|
| 23 | return $html; |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | function setLow( $low, $class ) |
---|
| 27 | { |
---|
| 28 | if ( $this->value_ <= $low ) |
---|
| 29 | $this->class_ = "bar-".$class; |
---|
| 30 | } |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | ?> |
---|