웹마스터 팁
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
-
주여리
2002.06.23 23:38
대단하군 -_-; 요런것을 생각해 낼수 있다니..... 근데 이거 어케 써먹냐? -
용가리
2002.06.24 15:35
그래프 쓸일이 엄냐? ㅡ.,ㅡ;;
보통 통계낼때 많이 쓰잖어... (난 가계부 만들어서 일별, 월별, 년별 수입, 지출 통계낼때 쓴다..)
사용법은 fot 문에 난수부분에 값을 대입하면 되지..
글구 클래스로 만들어서 쓰면 더 낳겠지.. (난 클래스로 만들어서 쓰구 있어..) -
유기노
2002.06.24 17:24
for 문에 난수 부분에 값을 대입하라고 하셨는데요. 어느 for 문에 어느 난수를 변경하면 이용
할수 있는 건가요?
쪼매 알려주세요...^^ -
용가리
2002.06.24 18:43
for ($i=20; $i<466; $i+=15){
.
.
} 이 부분이요.. 여기가 데이타 입력하는 부분이에여..
제목 | 글쓴이 | 날짜 |
---|---|---|
php소스를 윈도우 실행파일로 만드는 컴파일러 있나요? [2] | 소우리 | 2002.07.08 |
배경그림과 글자색상,배경색상을 지정해주는 php스크립트 [2] | ZipShin | 2002.07.07 |
echo를 처음사용하시는 초보들에게... [10] | ZipShin | 2002.07.06 |
HTML 태그 메일 전송하기 [2] | ZipShin | 2002.07.06 |
EMail 주소 검사하기 [6] | ZipShin | 2002.07.06 |
트리뷰를 흉내낸 클래스 입니다.^^;; | 용가리 | 2002.06.24 |
위 짜가리 클래스 활용 1 (FTP 디렉토리 트리뷰) | 용가리 | 2002.06.24 |
위 짜가리 클래스 활용 1 (디렉토리 트리뷰) | 용가리 | 2002.06.24 |
트리뷰를 흉내낸 클래스 사용법 입니다.^^;; | 용가리 | 2002.06.24 |
리스트뷰를 흉내낸 클래스 입니다.^^;; [2] | 용가리 | 2002.06.22 |
위의 리스트뷰 흉내낸 클래스 활용법 입니다.^^; [1] | 용가리 | 2002.06.22 |
위의 리스트뷰 흉내낸 클래스 사용법 입니다.^^; | 용가리 | 2002.06.22 |
php에서 GD를 이용한 3차원 막대 그래프 입니다. [4] | 용가리 | 2002.06.22 |
리눅스로 쉘 프로그래밍 할때 [1] | OsE= | 2002.06.19 |
[mysql] 하나 더 추가요. 역시 별로 쓸대 없는거... | 불티나 | 2002.06.18 |
[mysql] 별로 쓸대는 없지만..그래도.. | 불티나 | 2002.06.18 |
만들어보자~ PortScan For PHP [5] | OsE= | 2002.06.16 |
Flush() [2] | OsE= | 2002.06.16 |
[책에서 퍼옴] html과 php의 결합 혹은 분리 [7] | 박민호 | 2002.06.13 |
php 와 flash 의 연동을 이용한 제로보드 최근글 추출...(소스)
![]() | 주현석 | 2002.06.05 |