<?php
function createImage($data,$twidth,$tspace,$height){
            $dataName = array();
            $dataValue = array();
            $i = 0;
            $j = 0;
            $k = 0;
            $num = sizeof($data);
            
             foreach($data as $key => $val){
                    $dataName[] = $key;
                    $dataValue[] = $val;
                 }
    
            $maxnum = max($data);
			$tempmun=ceil($maxnum/$height)*10;
            $width = ($twidth + $tspace) * $num + 4;//image's width
            $im = imagecreate($width + 40,$height+20);
            $lineColor = imagecolorallocate($im,12,12,12);
            $bgColor = imagecolorallocate($im,255,255,255);
            $tColor = imagecolorallocate($im,123,200,56);
            imagefill($im,0,0,$bgColor);
            imageline ( $im, 30, 0, 30, $height - 2, $lineColor);
            imageline ( $im, 30, $height -2, $width + 30 -2 , $height -2,$lineColor);
             while($i < $num){
                imagefilledrectangle ( $im, $i * ($tspace+$twidth) + 40, ceil($height-$height*($dataValue[$i]/($tempmun*40))), $i * ($tspace+$twidth) + 40 + $twidth, $height - 3, $tColor);
			   // imagefilledrectangle ( $im, $i * ($tspace+$twidth) + 40, $height - $dataValue[$i], $i * ($tspace+$twidth) + 40 + $twidth, $height - 3, $tColor);
               // imagestring ( $im, 4, $i * ($tspace+$twidth) + $twidth/2 + 30, $height - $dataValue[$i], $dataName[$i]."(".$dataValue[$i].")", $lineColor);
				imagestring ( $im, 4, $i * ($tspace+$twidth) + $twidth/2 + 20, ceil($height-$height*($dataValue[$i]/($tempmun*40))), $dataValue[$i], $lineColor);
				imagestring ( $im, 3, $i * ($tspace+$twidth) + $twidth/2+15, $height , $dataName[$i], $lineColor);
                $i++;
             }
             while($j <= ($height/10)){
			 
                imagestringup ( $im, 4, 2, $height - $j * 10 + 40, $j * $tempmun, $lineColor);
                $j = $j + 8;
             }
             while($k <= ($height/10)){
                 if($k != 0)
                imageline ( $im, 28, $height - $k * 10, 32 , $height - $k * 10,$lineColor);
                $k = $k + 8;
             }
            imagepng($im);
         }

header("content-type:image/png");
/*include('checkstate.php');
$id=$_GET['id'];
$sql="select languageid,counts from website where comid=$id";
		$result=mysql_query($sql);
		while($row=mysql_fetch_array($result)){
			//$file="http://jsq.etwun.com:8080/all_count.php?id=".$row['jsqid'];
			//$counts=file_get_contents($file);
			$counts=$row['counts'];
			$language=getdomain($row['languageid']);
			$data[$language]=$counts;
		}*/
//$data=array("French" => 20772, "English" => 44414); 
$data = array("法语1" => 100, "法语2" => 260,"法语3" => 320,"法语5" => 250,"法语32" => 150,"法语3d" => 220);
createImage($data,40,35,400);

?>