CODE STYLE class.pmGauge.php
This commit is contained in:
@@ -1,61 +1,64 @@
|
|||||||
<?php
|
<?php
|
||||||
class pmGauge {
|
|
||||||
|
class pmGauge
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
width
|
* width
|
||||||
*/
|
*/
|
||||||
var $w = 610;
|
var $w = 610;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
height
|
* height
|
||||||
*/
|
*/
|
||||||
var $h = 300;
|
var $h = 300;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
value of gauge
|
* value of gauge
|
||||||
*/
|
*/
|
||||||
var $value = 50;
|
var $value = 50;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
maxValue
|
* maxValue
|
||||||
*/
|
*/
|
||||||
var $maxValue = 100;
|
var $maxValue = 100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
redFrom
|
* redFrom
|
||||||
*/
|
*/
|
||||||
var $redFrom = 80;
|
var $redFrom = 80;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
redTo
|
* redTo
|
||||||
*/
|
*/
|
||||||
var $redTo = 100;
|
var $redTo = 100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
yellowFrom
|
* yellowFrom
|
||||||
*/
|
*/
|
||||||
var $yellowFrom = 60;
|
var $yellowFrom = 60;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
yellowTo
|
* yellowTo
|
||||||
*/
|
*/
|
||||||
var $yellowTo = 80;
|
var $yellowTo = 80;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
greenFrom
|
* greenFrom
|
||||||
*/
|
*/
|
||||||
var $greenFrom = 0;
|
var $greenFrom = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
greenTo
|
* greenTo
|
||||||
*/
|
*/
|
||||||
var $greenTo = 60;
|
var $greenTo = 60;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
centerLabel, the label in the middle of the gauge
|
* centerLabel, the label in the middle of the gauge
|
||||||
*/
|
*/
|
||||||
var $centerLabel = '';
|
var $centerLabel = '';
|
||||||
|
|
||||||
function render () {
|
function render ()
|
||||||
|
{
|
||||||
$this->h = $this->w / 2;
|
$this->h = $this->w / 2;
|
||||||
$im = imagecreatetruecolor( $this->w, $this->h );
|
$im = imagecreatetruecolor( $this->w, $this->h );
|
||||||
$width = $this->w;
|
$width = $this->w;
|
||||||
@@ -107,7 +110,8 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderGauge($im, $cX, $cY, $diameter) {
|
function renderGauge ($im, $cX, $cY, $diameter)
|
||||||
|
{
|
||||||
//gauge color
|
//gauge color
|
||||||
$bgcolor = ImageColorAllocate( $im, 247, 247, 247 );
|
$bgcolor = ImageColorAllocate( $im, 247, 247, 247 );
|
||||||
$extRing = ImageColorAllocate( $im, 214, 214, 214 );
|
$extRing = ImageColorAllocate( $im, 214, 214, 214 );
|
||||||
@@ -141,12 +145,18 @@
|
|||||||
imagefilledellipse( $im, $cX, $cY, $dXRing, $dYRing, $bgcolor );
|
imagefilledellipse( $im, $cX, $cY, $dXRing, $dYRing, $bgcolor );
|
||||||
|
|
||||||
//drawing the red arc
|
//drawing the red arc
|
||||||
if ( $this->redFrom > $this->maxValue ) $this->redFrom = $this->maxValue;
|
if ($this->redFrom > $this->maxValue)
|
||||||
if ( $this->redTo > $this->maxValue ) $this->redTo = $this->maxValue;
|
$this->redFrom = $this->maxValue;
|
||||||
if ( $this->yellowFrom > $this->maxValue ) $this->yellowFrom = $this->maxValue;
|
if ($this->redTo > $this->maxValue)
|
||||||
if ( $this->yellowTo > $this->maxValue ) $this->yellowTo = $this->maxValue;
|
$this->redTo = $this->maxValue;
|
||||||
if ( $this->greenFrom > $this->maxValue ) $this->greenFrom = $this->maxValue;
|
if ($this->yellowFrom > $this->maxValue)
|
||||||
if ( $this->greenTo > $this->maxValue ) $this->greenTo = $this->maxValue;
|
$this->yellowFrom = $this->maxValue;
|
||||||
|
if ($this->yellowTo > $this->maxValue)
|
||||||
|
$this->yellowTo = $this->maxValue;
|
||||||
|
if ($this->greenFrom > $this->maxValue)
|
||||||
|
$this->greenFrom = $this->maxValue;
|
||||||
|
if ($this->greenTo > $this->maxValue)
|
||||||
|
$this->greenTo = $this->maxValue;
|
||||||
|
|
||||||
$redFrom = $this->redFrom / $this->maxValue * 300 - 240;
|
$redFrom = $this->redFrom / $this->maxValue * 300 - 240;
|
||||||
$redTo = $this->redTo / $this->maxValue * 300 - 240;
|
$redTo = $this->redTo / $this->maxValue * 300 - 240;
|
||||||
@@ -184,7 +194,6 @@
|
|||||||
|
|
||||||
ImageLine( $im, $x1, $y1, $x2, $y2, $black );
|
ImageLine( $im, $x1, $y1, $x2, $y2, $black );
|
||||||
|
|
||||||
|
|
||||||
if ($min % 5 == 0) {
|
if ($min % 5 == 0) {
|
||||||
$textToDisplay = sprintf( "%d", (55 - $min) * $this->maxValue / 50 );
|
$textToDisplay = sprintf( "%d", (55 - $min) * $this->maxValue / 50 );
|
||||||
$bbox = imagettfbbox( 8, 0, $fontArial, $textToDisplay );
|
$bbox = imagettfbbox( 8, 0, $fontArial, $textToDisplay );
|
||||||
@@ -206,7 +215,6 @@
|
|||||||
imagettftext( $im, 9, 0, $cX * 0.60, $cY * 1.8, $gray, $fontArial, $this->open );
|
imagettftext( $im, 9, 0, $cX * 0.60, $cY * 1.8, $gray, $fontArial, $this->open );
|
||||||
imagettftext( $im, 9, 0, $cX * 1.40, $cY * 1.8, $gray, $fontArial, $this->completed );
|
imagettftext( $im, 9, 0, $cX * 1.40, $cY * 1.8, $gray, $fontArial, $this->completed );
|
||||||
|
|
||||||
|
|
||||||
//drawing the arrow, simple way
|
//drawing the arrow, simple way
|
||||||
$radiusX = intval( $dX * 0.35 );
|
$radiusX = intval( $dX * 0.35 );
|
||||||
$radiusY = intval( $dY * 0.35 );
|
$radiusY = intval( $dY * 0.35 );
|
||||||
@@ -264,7 +272,6 @@
|
|||||||
$centerY = $cY + $dYRing / 2 + 3 - abs( $bbox[5] );
|
$centerY = $cY + $dYRing / 2 + 3 - abs( $bbox[5] );
|
||||||
imagettftext( $im, 9, 0, $centerX, $centerY, $black, $fontArial, $textToDisplay );
|
imagettftext( $im, 9, 0, $centerX, $centerY, $black, $fontArial, $textToDisplay );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user