2012-07-27 110 views
3

爲什麼我在我的GD餅圖中看到這個奇怪的線?爲什麼我在我的GD餅圖中看到這個奇怪的線?

pie graph

這裏的PHP:

<?php 
$ratio = $_GET['ratio']; 
$height = intval(isset($_GET['size']) ? $_GET['size'] : 200); 
$width = intval(isset($_GET['size']) ? $_GET['size'] : 200); 
$startDegree = 270; 
$ratiodeg = $ratio * 360; 
$image = imagecreatetruecolor($width,$height); 
imagealphablending($image,false); 
imagesavealpha($image,true); 
$color = imagecolorallocate($image,127,26,40); 
$grey = imagecolorallocate($image,200,200,200); 
$transparent = imagecolorallocatealpha($image,255,255,255,127); 
imagefilledrectangle($image,0,0,$width,$height,$transparent); 
if($ratio > 0){ 
    if($ratio < 1){ 
     imagefilledarc($image,$width/2,$height/2,$width,$height,$ratiodeg + $startDegree,$startDegree,$grey,IMG_ARC_PIE); 
    } 
    imagefilledarc($image,$width/2,$height/2,$width,$height,$startDegree,$ratiodeg + $startDegree,$color,IMG_ARC_PIE); 
} 
else{ 
    imagefilledarc($image,$width/2,$height/2,$width,$height,$startDegree,360 + $startDegree,$grey,IMG_ARC_PIE); 
} 
imagefilledellipse($image,$width/2,$height/2,$width * 0.95,$height * 0.95,$transparent); 
header("Content-type: image/png"); 
imagepng($image); 
imagedestroy($image); 
?> 

回答

1

My output

我跑你的代碼,並得到了這個形象..

這裏是我的PHP細節

版本: 5.4.3

GD:捆綁(2.0.34兼容)

你通過了什麼比例?我使用了1,4,4.65(圈出了一個有點缺失的圈),但我從來沒有這樣做過!

+0

該比例是一個浮點數,但我嘗試了這些值以及相同的結果。我使用5.2.some沒有捆綁GD(至少,我不這麼認爲 - 我沒有捆綁的imageantialias,所以可能不會)。它可能是我的發行版中的錯誤嗎? – iLoch 2012-07-27 05:50:46

+0

創建一個名爲phpinfo.php的新php文件,並將其放入它中。<?php phpinfo(); ?>然後運行它..它會給你很多有關你的php的細節,你可能希望儘快刪除它,雖然它不是你的服務器上最安全的頁面! – Dale 2012-07-27 06:31:06

相關問題