ホームページ  >  記事  >  バックエンド開発  >  折れ線グラフを作成するPHP関数_PHPチュートリアル

折れ線グラフを作成するPHP関数_PHPチュートリアル

WBOY
WBOYオリジナル
2016-07-13 17:23:05730ブラウズ

折れ線グラフを作成するPHP関数

キーワード: PHP

/*
関数の説明
$data:y軸データ(配列)
$graphdata:y軸データ--パーセンテージ(配列)
$label:x軸データ (配列) 配列)
$height: 画像の高さ
$width: 画像の幅
$font: フォント サイズ
$dot: ドットのサイズを決定
$bg: 背景色
$line: 線の色
$text:文字の色
$dotcolor: ドットの色
$file: 出力画像ファイル名
*/

function qximage($data ,
$graphdata,
$label ,
$height,
$width ,
$font,
$dot ,
$bg,
$ line,
$text,
$dotcolor,
$file)
{
$jc=$height/100;
$fontwidth= imagefontwidth ($font);
$fontheight=imagefontheight($font );

$image= imagecreate ($width,$height+20);
$bg= imagecolorallocate($image,$bg[0],$bg[1],$bg[2]);
$line= imagecolorallocate($image,$line [0],$line[1],$line[2]);
$text=imagecolorallocate($image,$text[0],$text[1],$text[2] );
$dotcolor=imagecolorallocate ($image,$dotcolor[0],$dotcolor[1],$$dotcolor[2]);
imageline ($image,0,0,0,$height,$line);
imageline($image,0 ,$height,$width,$height,$line);


for ($i=1;$i{
imagedashedline($image) ,0,$height - $ jc*$i*10 ,$width ,$height -$jc*$i*10 ,$line );
imagestring ($image,$font,0,$height-$jc*$ i*10,$i* 10,$text);
}
for ($i=0;$i {
#echo $tmp."
";
$x1=(($width-50)/count( $data))*($ i)+40;
#echo $x1 ."
";
$y1=$height-$graphdata[$i]*$jc;
$x2=$x1;
$y2= $y1+$graphdata[$i ]*$jc;
#echo $y1."
";
imagestring($image,$font,$x1,$y1-2*$fontheight,$graphdata[$i]." %(".$data[ $i].")",$text);
imagearc ($image,$x1,$y1,$dot,$dot,0,360,$dotcolor);
imagefilltoborder ($image,$ x1,$y1,$dotcolor ,$dotcolor);
imagestring ($image,$font,$x1,$y2,$label[$i],$text);
if ($i>0)
{
imageline ($image,$tmpx1, $tmpy1,$x1,$y1,$line);
}
$tmpx1=$x1;$tmpy1=$y1;
}
imagegif ($image,$file);
}
?>

www.bkjia.comtru​​ehttp://www.bkjia.com/PHPjc/532262.html技術記事折れ線グラフを作成するための PHP 関数キーワード: PHP /* 関数の説明 $data: Y 軸データ (配列) $graphdata: Y 軸データ -- パーセンテージ (配列) $label: X 軸データ (配列) $height: image身長..
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。