mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
2011-11-28 Sergio Martin <sergio.martin@artica.es>
* include/graphs/functions_gd.php: Fixed rounded corners graphs when the progress is less than 30% git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5182 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f872f9e239
commit
eef37e9185
@ -1,3 +1,8 @@
|
|||||||
|
2011-11-28 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
|
* include/graphs/functions_gd.php: Fixed rounded corners
|
||||||
|
graphs when the progress is less than 30%
|
||||||
|
|
||||||
2011-11-28 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
2011-11-28 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||||
|
|
||||||
* operation/agentes/status_monitor.php: Added variable
|
* operation/agentes/status_monitor.php: Added variable
|
||||||
|
@ -182,6 +182,7 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim
|
|||||||
|
|
||||||
//$rating = $_GET['rating'];
|
//$rating = $_GET['rating'];
|
||||||
$ratingbar = (($rating/100)*$width)-2;
|
$ratingbar = (($rating/100)*$width)-2;
|
||||||
|
$ratingbar30 = ((30/100)*$width)-2;
|
||||||
|
|
||||||
$image = imagecreate($width,$height);
|
$image = imagecreate($width,$height);
|
||||||
|
|
||||||
@ -189,7 +190,7 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim
|
|||||||
//colors
|
//colors
|
||||||
$back = ImageColorAllocate($image,255,255,255);
|
$back = ImageColorAllocate($image,255,255,255);
|
||||||
imagecolortransparent ($image, $back);
|
imagecolortransparent ($image, $back);
|
||||||
$border = ImageColorAllocate($image,174,174,174);
|
$bordercolor = ImageColorAllocate($image,174,174,174);
|
||||||
$text = ImageColorAllocate($image,74,74,74);
|
$text = ImageColorAllocate($image,74,74,74);
|
||||||
$red = ImageColorAllocate($image,255,60,75);
|
$red = ImageColorAllocate($image,255,60,75);
|
||||||
$green = ImageColorAllocate($image,50,205,50);
|
$green = ImageColorAllocate($image,50,205,50);
|
||||||
@ -201,26 +202,35 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim
|
|||||||
$other_red = ImageColorAllocate($image,238, 0, 0);
|
$other_red = ImageColorAllocate($image,238, 0, 0);
|
||||||
|
|
||||||
ImageRectangleWithRoundedCorners($image,0,0,$width-1,$height-1,$radius,$back,false);
|
ImageRectangleWithRoundedCorners($image,0,0,$width-1,$height-1,$radius,$back,false);
|
||||||
|
|
||||||
|
$x1 = 1;
|
||||||
|
$y1 = 1;
|
||||||
|
$x2 = $ratingbar;
|
||||||
|
$y2 = $height - 1;
|
||||||
|
|
||||||
switch ($mode)
|
switch ($mode)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if ($rating > 70)
|
if ($rating > 70)
|
||||||
ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $soft_green, $border);
|
ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius, $soft_green);
|
||||||
elseif ($rating > 50)
|
elseif ($rating > 50)
|
||||||
ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $soft_yellow, $border);
|
ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius, $soft_yellow);
|
||||||
elseif ($rating > 30)
|
elseif ($rating > 30)
|
||||||
ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $soft_red, $border);
|
ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius, $soft_red);
|
||||||
else
|
else if($rating > 0) {
|
||||||
ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $other_red, $border);
|
if($radius != 0) {
|
||||||
|
$x2 = $ratingbar30;
|
||||||
|
}
|
||||||
|
ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius, $other_red);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if ($rating > 100)
|
if ($rating > 100)
|
||||||
ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1,$radius,$red, $border);
|
ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius,$red);
|
||||||
elseif ($rating == 100)
|
elseif ($rating == 100)
|
||||||
ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1,$radius,$green, $border);
|
ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius,$green);
|
||||||
else
|
else
|
||||||
ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1,$radius,$blue, $border);
|
ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius,$blue);
|
||||||
|
|
||||||
|
|
||||||
if ($rating > 50)
|
if ($rating > 50)
|
||||||
@ -233,20 +243,33 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if ($rating > 70)
|
if ($rating > 70)
|
||||||
ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $other_red, $border);
|
ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius, $other_red);
|
||||||
elseif ($rating > 50)
|
elseif ($rating > 50)
|
||||||
ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $soft_red, $border);
|
ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius, $soft_red);
|
||||||
elseif ($rating > 30)
|
elseif ($rating > 30)
|
||||||
ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $soft_yellow, $border);
|
ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius, $soft_yellow);
|
||||||
else
|
else if($rating > 0) {
|
||||||
ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $soft_green, $border);
|
if($radius != 0) {
|
||||||
|
$x2 = $ratingbar30;
|
||||||
|
}
|
||||||
|
ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius, $soft_green);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if($bordercolor !== false) {
|
||||||
ImageRectangle($image,0,0,$width-1,$height-1,$border);
|
$x1-=1;
|
||||||
*/
|
$x2 = $width-2;
|
||||||
|
imageline($image, $x1+$radius, $y1, $x2-$radius, $y1, $bordercolor);
|
||||||
|
imageline($image, $x1+$radius, $y2, $x2-$radius, $y2, $bordercolor);
|
||||||
|
imageline($image, $x1, $y1+$radius, $x1, $y2-$radius, $bordercolor);
|
||||||
|
imageline($image, $x2, $y1+$radius, $x2, $y2-$radius, $bordercolor);
|
||||||
|
|
||||||
|
imagearc($image,$x1+$radius, $y1+$radius, $radius*2, $radius*2, 180 , 270, $bordercolor);
|
||||||
|
imagearc($image,$x2-$radius, $y1+$radius, $radius*2, $radius*2, 270 , 360, $bordercolor);
|
||||||
|
imagearc($image,$x1+$radius, $y2-$radius, $radius*2, $radius*2, 90 , 180, $bordercolor);
|
||||||
|
imagearc($image,$x2-$radius, $y2-$radius, $radius*2, $radius*2, 360 , 90, $bordercolor);
|
||||||
|
}
|
||||||
|
|
||||||
imagePNG($image);
|
imagePNG($image);
|
||||||
imagedestroy($image);
|
imagedestroy($image);
|
||||||
@ -254,31 +277,17 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function ImageRectangleWithRoundedCorners(&$im, $x1, $y1, $x2, $y2, $radius, $color, $bordercolor)
|
function ImageRectangleWithRoundedCorners(&$im, $x1, $y1, $x2, $y2, $radius, $color)
|
||||||
{
|
{
|
||||||
// Draw rectangle without corners
|
// Draw rectangle without corners
|
||||||
ImageFilledRectangle($im, $x1+$radius, $y1, $x2-$radius, $y2, $color);
|
ImageFilledRectangle($im, $x1+$radius, $y1, $x2-$radius, $y2, $color);
|
||||||
ImageFilledRectangle($im, $x1, $y1+$radius, $x2, $y2-$radius, $color);
|
ImageFilledRectangle($im, $x1, $y1+$radius, $x2, $y2-$radius, $color);
|
||||||
|
|
||||||
// Draw circled corners
|
// Draw circled corners
|
||||||
ImageFilledEllipse($im, $x1+$radius, $y1+$radius, $radius*2, $radius*2, $color);
|
ImageFilledEllipse($im, $x1+$radius, $y1+$radius, $radius*2, $radius*2, $color);
|
||||||
ImageFilledEllipse($im, $x2-$radius, $y1+$radius, $radius*2, $radius*2, $color);
|
ImageFilledEllipse($im, $x2-$radius, $y1+$radius, $radius*2, $radius*2, $color);
|
||||||
ImageFilledEllipse($im, $x1+$radius, $y2-$radius, $radius*2, $radius*2, $color);
|
ImageFilledEllipse($im, $x1+$radius, $y2-$radius, $radius*2, $radius*2, $color);
|
||||||
ImageFilledEllipse($im, $x2-$radius, $y2-$radius, $radius*2, $radius*2, $color);
|
ImageFilledEllipse($im, $x2-$radius, $y2-$radius, $radius*2, $radius*2, $color);
|
||||||
|
|
||||||
if($bordercolor !== false) {
|
|
||||||
$x1--;
|
|
||||||
$y1--;
|
|
||||||
$x2++;
|
|
||||||
imageline($im, $x1+$radius, $y1, $x2-$radius, $y1, $bordercolor);
|
|
||||||
imageline($im, $x1+$radius, $y2, $x2-$radius, $y2, $bordercolor);
|
|
||||||
imageline($im, $x1, $y1+$radius, $x1, $y2-$radius, $bordercolor);
|
|
||||||
imageline($im, $x2, $y1+$radius, $x2, $y2-$radius, $bordercolor);
|
|
||||||
|
|
||||||
imagearc($im,$x1+$radius, $y1+$radius, $radius*2, $radius*2, 180 , 270, $bordercolor);
|
|
||||||
imagearc($im,$x2-$radius, $y1+$radius, $radius*2, $radius*2, 270 , 360, $bordercolor);
|
|
||||||
imagearc($im,$x1+$radius, $y2-$radius, $radius*2, $radius*2, 90 , 180, $bordercolor);
|
|
||||||
imagearc($im,$x2-$radius, $y2-$radius, $radius*2, $radius*2, 360 , 90, $bordercolor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Header("Content-type: image/png");
|
Header("Content-type: image/png");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user