2006-11-05 Sancho Lerena <slerena@artica.es>
* images/outlimits.png: Static image for progress bar out of limits. * reporting/fgraph.php: Progress bar now show static image if there is out of limits before calculating (faster). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@249 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
9a0938766a
commit
a4afa23c8a
Binary file not shown.
After Width: | Height: | Size: 321 B |
|
@ -1376,46 +1376,53 @@ function progress_bar($progress,$width,$height) {
|
||||||
// With some adds from sdonie at lgc dot com
|
// With some adds from sdonie at lgc dot com
|
||||||
// Get from official documentation PHP.net website. Thanks guys :-)
|
// Get from official documentation PHP.net website. Thanks guys :-)
|
||||||
// Code ripped from Babel Project :-)
|
// Code ripped from Babel Project :-)
|
||||||
function drawRating($rating,$width,$height) {
|
function drawRating($rating,$width,$height) {
|
||||||
include ("../include/config.php");
|
include ("../include/config.php");
|
||||||
require ("../include/languages/language_".$language_code.".php");
|
require ("../include/languages/language_".$language_code.".php");
|
||||||
if ($width == 0) {
|
if ($width == 0) {
|
||||||
$width = 150;
|
$width = 150;
|
||||||
}
|
}
|
||||||
if ($height == 0) {
|
if ($height == 0) {
|
||||||
$height = 20;
|
$height = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
//$rating = $_GET['rating'];
|
//$rating = $_GET['rating'];
|
||||||
$ratingbar = (($rating/100)*$width)-2;
|
$ratingbar = (($rating/100)*$width)-2;
|
||||||
|
$image = imagecreate($width,$height);
|
||||||
$image = imagecreate($width,$height);
|
//colors
|
||||||
//colors
|
$back = ImageColorAllocate($image,255,255,255);
|
||||||
$back = ImageColorAllocate($image,255,255,255);
|
$border = ImageColorAllocate($image,0,0,0);
|
||||||
$border = ImageColorAllocate($image,0,0,0);
|
$red = ImageColorAllocate($image,255,60,75);
|
||||||
$red = ImageColorAllocate($image,255,60,75);
|
$fill = ImageColorAllocate($image,44,81,150);
|
||||||
$fill = ImageColorAllocate($image,44,81,150);
|
|
||||||
|
|
||||||
ImageFilledRectangle($image,0,0,$width-1,$height-1,$back);
|
ImageFilledRectangle($image,0,0,$width-1,$height-1,$back);
|
||||||
ImageRectangle($image,0,0,$width-1,$height-1,$border);
|
ImageRectangle($image,0,0,$width-1,$height-1,$border);
|
||||||
|
|
||||||
|
|
||||||
if (($rating > 100) || ($rating < 0)){
|
if (($rating > 100) || ($rating < 0)){
|
||||||
ImageFilledRectangle($image,1,1,$width-1,$height-1,$red);
|
ImageFilledRectangle($image,1,1,$width-1,$height-1,$red);
|
||||||
ImageTTFText($image, 8, 0, ($width/3)-($width/10), ($height/2)+($height/5), $back, $config_fontpath,$lang_label["out_of_limits"]);
|
ImageTTFText($image, 8, 0, ($width/3)-($width/10), ($height/2)+($height/5), $back, $config_fontpath,$lang_label["out_of_limits"]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$fill);
|
||||||
|
if ($rating > 50)
|
||||||
|
ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $back, $config_fontpath, $rating."%");
|
||||||
|
else
|
||||||
|
ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $border, $config_fontpath, $rating."%");
|
||||||
|
}
|
||||||
|
imagePNG($image);
|
||||||
|
imagedestroy($image);
|
||||||
}
|
}
|
||||||
else {
|
// Show header
|
||||||
ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$fill);
|
Header("Content-type: image/png");
|
||||||
if ($rating > 50)
|
// If progress is out limits, show static image, beware of image size!
|
||||||
ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $back, $config_fontpath, $rating."%");
|
if ($progress > 100 || $progress < 0){
|
||||||
else
|
$imgPng = imageCreateFromPng("../images/outlimits.png");
|
||||||
ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $border, $config_fontpath, $rating."%");
|
imageAlphaBlending($imgPng, true);
|
||||||
}
|
imageSaveAlpha($imgPng, true);
|
||||||
imagePNG($image);
|
imagePng($imgPng);
|
||||||
imagedestroy($image);
|
} else
|
||||||
}
|
drawRating($progress,$width,$height);
|
||||||
Header("Content-type: image/png");
|
|
||||||
drawRating($progress,$width,$height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue