웹마스터 팁
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
php에서 GD를 이용한 3차원 막대 그래프 입니다.
2002.06.22 09:45
미리보기 : http://sjbiz.net/house/a.php
phpschool에서 어떤분이 3차원 그래프를 올려 놓으셨길래 함 따라해 봤어여 ^^;
( 그분이 소스를 안 올려 주셔서 ㅡ.ㅜ )
디자인은 그분꺼 그대루...
이거 근데 생각보다 디게 노가대 네여
무려 8시간이나 ㅡ.,ㅡ;;
내용은 매월 수익과 지출을 그래프로 나타낸 겁니다.
디비와 연결 없이 for 로 난수를 적용하여 그래프 만든겁니다 ^^;
그럼...
<?
header("Content-Type : image/png");
function printPolygon($num, $color, $x1,$y1,$x2,$y2,$x3=0,$y3=0,$x4=0,$y4=0,$x5=0,$y5=0,$x6=0,$y6=0){
global $im;
$points[0]=$x1; $points[1]=$y1;
$points[2]=$x2; $points[3]=$y2;
$points[4]=$x3; $points[5]=$y3;
$points[6]=$x4; $points[7]=$y4;
$points[8]=$x5; $points[9]=$y5;
$points[10]=$x6; $points[11]=$y6;
ImageFilledPolygon($im,$points,$num,$color);
}
$im=ImageCreate(663,403);
$black=ImageColorAllocate($im,0,0,0);
$white=ImageColorAllocate($im,255,255,255);
$fb1=ImageColorAllocate($im,192,192,192);
$fb2=ImageColorAllocate($im,130,130,130);
$fb3=ImageColorAllocate($im,240,240,240);
$g1=ImageColorAllocate($im,0,153,51);
$g2=ImageColorAllocate($im,0,115,39);
$g3=ImageColorAllocate($im,0,77,26);
$gr1=ImageColorAllocate($im,153,0,0);
$gr2=ImageColorAllocate($im,115,0,0);
$gr3=ImageColorAllocate($im,77,0,0);
printPolygon(4,$white,2,2,657,2,657,397,2,397); //배경 만들기
imagefilledrectangle($im,0,400,5,403,$white); //왼쪽 아래 조그만 흰색 사각형
imagefilledrectangle($im,660,0,663,5,$white); //오른쪽 상단 조그만 흰색 사각형
//실제 그래프 모양 만들기
printPolygon(6,$fb1,65,25,630,25,630,265,610,285,45,285,45,45); //배경 다각형
printPolygon(6,$fb2,630,25,630,265,610,285,610,277,625,261,625,30); //오른쪽 모서리 다각형
printPolygon(6,$fb3,45,45,51,45,51,277,610,277,610,285,45,285); //축 배경
printPolygon(4,$fb2,52,45,67,29,67,262,52,276); //Y축 배경 안쪽
printPolygon(4,$fb3,68,30,624,30,624,261,68,261); //배경 다각형 안쪽 배경
//축 기준 값들 (점선)
for ($i=52; $i<242; $i+=21) imageLine($im,68,$i,624,$i,$black);
for ($i=52; $i<242; $i+=21) imageLine($im,52,$i+15,67,$i,$fb3);
for ($i=68; $i<258; $i+=21) imageLine($im,45,$i,50,$i,$black);
for ($i=20; $i<466; $i+=15){
if(!$j)$j=1;
imageLine($im,$i+93,277,$i+93,285,$black);
$y=rand(100,276);
imagefilledrectangle($im,$i+80,$y,$i+90,276,$g1); //값 표면
printPolygon(4,$g2,$i+80,$y,$i+95,$y-15,$i+105,$y-15,$i+90,$y); //값 안쪽
printPolygon(4,$g3,$i+90,$y,$i+105,$y-15,$i+105,261,$i+90,276); //값 오른쪽
$y=rand(100,276);
$i+=15;
imagefilledrectangle($im,$i+80,$y,$i+90,276,$gr1); //값 표면
printPolygon(4,$gr2,$i+80,$y,$i+95,$y-15,$i+105,$y-15,$i+90,$y); //값 안쪽
printPolygon(4,$gr3,$i+90,$y,$i+105,$y-15,$i+105,261,$i+90,276); //값 오른쪽
$i+=10;
Imagestring($im,2,$i+66,286,$j,$black);
$j++;
}
imagefilledrectangle($im,440,320,632,372,$fb2); //주석 상자 테두리
imagefilledrectangle($im,442,322,630,370,$white); //주석 상자
imagefilledrectangle($im,450,332,460,342,$g1); //수입 상자
imagefilledrectangle($im,450,352,460,362,$gr1); //지출 상자
Imagestring($im,2,470,330,': the amount of imports.'+ ',$black);
Imagestring($im,2,470,350,': the amount disbursed.',$black);
Imagestring($im,5,150,7,'2002 Year, monthly expenses graph.',$black); //타이틀 적기
$file="per_day.png";
ImageInterlace($im,1);
Imagepng($im);
//Imagepng($im,$file);
ImageDestroy($im);
?>
phpschool에서 어떤분이 3차원 그래프를 올려 놓으셨길래 함 따라해 봤어여 ^^;
( 그분이 소스를 안 올려 주셔서 ㅡ.ㅜ )
디자인은 그분꺼 그대루...
이거 근데 생각보다 디게 노가대 네여
무려 8시간이나 ㅡ.,ㅡ;;
내용은 매월 수익과 지출을 그래프로 나타낸 겁니다.
디비와 연결 없이 for 로 난수를 적용하여 그래프 만든겁니다 ^^;
그럼...
<?
header("Content-Type : image/png");
function printPolygon($num, $color, $x1,$y1,$x2,$y2,$x3=0,$y3=0,$x4=0,$y4=0,$x5=0,$y5=0,$x6=0,$y6=0){
global $im;
$points[0]=$x1; $points[1]=$y1;
$points[2]=$x2; $points[3]=$y2;
$points[4]=$x3; $points[5]=$y3;
$points[6]=$x4; $points[7]=$y4;
$points[8]=$x5; $points[9]=$y5;
$points[10]=$x6; $points[11]=$y6;
ImageFilledPolygon($im,$points,$num,$color);
}
$im=ImageCreate(663,403);
$black=ImageColorAllocate($im,0,0,0);
$white=ImageColorAllocate($im,255,255,255);
$fb1=ImageColorAllocate($im,192,192,192);
$fb2=ImageColorAllocate($im,130,130,130);
$fb3=ImageColorAllocate($im,240,240,240);
$g1=ImageColorAllocate($im,0,153,51);
$g2=ImageColorAllocate($im,0,115,39);
$g3=ImageColorAllocate($im,0,77,26);
$gr1=ImageColorAllocate($im,153,0,0);
$gr2=ImageColorAllocate($im,115,0,0);
$gr3=ImageColorAllocate($im,77,0,0);
printPolygon(4,$white,2,2,657,2,657,397,2,397); //배경 만들기
imagefilledrectangle($im,0,400,5,403,$white); //왼쪽 아래 조그만 흰색 사각형
imagefilledrectangle($im,660,0,663,5,$white); //오른쪽 상단 조그만 흰색 사각형
//실제 그래프 모양 만들기
printPolygon(6,$fb1,65,25,630,25,630,265,610,285,45,285,45,45); //배경 다각형
printPolygon(6,$fb2,630,25,630,265,610,285,610,277,625,261,625,30); //오른쪽 모서리 다각형
printPolygon(6,$fb3,45,45,51,45,51,277,610,277,610,285,45,285); //축 배경
printPolygon(4,$fb2,52,45,67,29,67,262,52,276); //Y축 배경 안쪽
printPolygon(4,$fb3,68,30,624,30,624,261,68,261); //배경 다각형 안쪽 배경
//축 기준 값들 (점선)
for ($i=52; $i<242; $i+=21) imageLine($im,68,$i,624,$i,$black);
for ($i=52; $i<242; $i+=21) imageLine($im,52,$i+15,67,$i,$fb3);
for ($i=68; $i<258; $i+=21) imageLine($im,45,$i,50,$i,$black);
for ($i=20; $i<466; $i+=15){
if(!$j)$j=1;
imageLine($im,$i+93,277,$i+93,285,$black);
$y=rand(100,276);
imagefilledrectangle($im,$i+80,$y,$i+90,276,$g1); //값 표면
printPolygon(4,$g2,$i+80,$y,$i+95,$y-15,$i+105,$y-15,$i+90,$y); //값 안쪽
printPolygon(4,$g3,$i+90,$y,$i+105,$y-15,$i+105,261,$i+90,276); //값 오른쪽
$y=rand(100,276);
$i+=15;
imagefilledrectangle($im,$i+80,$y,$i+90,276,$gr1); //값 표면
printPolygon(4,$gr2,$i+80,$y,$i+95,$y-15,$i+105,$y-15,$i+90,$y); //값 안쪽
printPolygon(4,$gr3,$i+90,$y,$i+105,$y-15,$i+105,261,$i+90,276); //값 오른쪽
$i+=10;
Imagestring($im,2,$i+66,286,$j,$black);
$j++;
}
imagefilledrectangle($im,440,320,632,372,$fb2); //주석 상자 테두리
imagefilledrectangle($im,442,322,630,370,$white); //주석 상자
imagefilledrectangle($im,450,332,460,342,$g1); //수입 상자
imagefilledrectangle($im,450,352,460,362,$gr1); //지출 상자
Imagestring($im,2,470,330,': the amount of imports.'+ ',$black);
Imagestring($im,2,470,350,': the amount disbursed.',$black);
Imagestring($im,5,150,7,'2002 Year, monthly expenses graph.',$black); //타이틀 적기
$file="per_day.png";
ImageInterlace($im,1);
Imagepng($im);
//Imagepng($im,$file);
ImageDestroy($im);
?>
댓글 4
제목 | 글쓴이 | 날짜 |
---|---|---|
초보분들을 위한 연산자 총정리 [6] | TheMics | 2002.01.29 |
이제 PHP에 ?id=가나다라 같은것을 넣자! [12] | 담배를끊으면복이옴과 | 2002.01.30 |
이제 홈페이지 업데이트 안하는 수모를 겪지 말자! [7] | 담배를끊으면복이옴과 | 2002.02.02 |
md5() 알고리듬 [8] | 양창민 | 2002.02.05 |
원고지 함수;; [3] | 디쓰 | 2002.02.07 |
한글 필터링 정확히 하기 [1] | mini | 2002.02.09 |
필터링조금 다른거.. [7] | 두기두바 | 2002.02.10 |
좋은 난수값을 얻기위한 시드배정 방법 mt_srand(), srand() | 차카게살자 | 2002.02.21 |
제로보드 분석 -1- [4] | 제키드+_+)/ | 2002.02.21 |
PHP 소스 보이게 하기; [5] | Topy | 2002.02.21 |
in_array 함수이용한 업로드금지 [3] | 김승제 | 2002.02.21 |
date 함수의 매개 변수 | Topy | 2002.02.22 |
제로보드 분석 -2- [2] | 제키드+_+)/ | 2002.02.22 |
복잡해? 줄여! [3] | 제키드+_+)/ | 2002.02.22 |
[lib] fun 문자열속의 url에 링크를 거는 함수 [2] | Topy | 2002.02.22 |
[lib] fun. alert message (경고 메시지) [1] | Topy | 2002.02.22 |
for 문에 대한 이해, 구구단 만들어 보기. [3] | Topy | 2002.02.22 |
http://홈주소/?mode=xxx 하는방법 :) [5] | 제니 | 2002.02.23 |
[re | 씽크식 PHP] 많고 많은 페이지들을 하나로 줄이자! [2] | John Sync. | 2002.02.24 |
많고 많은 페이지들을 하나로 줄이자! [7] | 제키드+_+)/ | 2002.02.23 |