-
- class ImageReport{
- var $X;//이미지 크기 X축
- var $Y; / /사진 크기 Y축
- var $R;//뒷면 색상 R 값
- var $G;//...G.
- var $B;//...B.
- var $TRANSPARENT;//투명 여부 1 또는 0
- var $IMAGE;//이미지 개체
- //-------------------
- var $ARRAYSPLIT;//값을 구분하는 데 사용되는 기호 지정
- var $ITEMARRAY;//값
- var $REPORTTYPE;//차트 유형, 1은 세로 열, 2는 가로 열, 3은 폴리라인
- var $BORDER;//거리
- //------
- var $FONTSIZE;//글꼴 크기
- var $FONTCOLOR ; //글꼴 색상
-
- var $numX = 1; //X축 시작 스케일 값
- var $stepX = 1; //X축 각 스케일 간격 값
-
- // --------파라미터 설정 함수
- function setImage($SizeX,$SizeY,$R,$G,$B,$Transparent){
- $this->X=$SizeX ;
- $this->Y=$SizeY
- $this->R=$R
- $this->B= $B ; $this->TRANSPARENT=$Transparent;
- }
- function setItem($ArraySplit,$ItemArray,$ReportType,$Border){
- $this->ARRAYSPLIT=$ ArraySplit;
- $this->ITEMARRAY=$ItemArray;
- $this->BORDER=$Border;
- }
- 함수 ($ FontSize){
- $this->FONTSIZE=$FontSize;
- }
- //X축 스케일 값 설정
- function setX($numX = 1, $stepX = 1){
- $this->numX = $numX;
- $this->stepX = $stepX;
- }
- //--------------- -Body
- function PrintReport(){
- //캔버스 크기 생성
- $this->IMAGE=ImageCreate($this->X,$this->Y)
- // 캔버스 배경색 설정
- $Background=ImageColorAllocate($this->IMAGE,$this->R,$this->G,$this->B)
- if($this-> ;TRANSPARENT ==="1"){
- //배경은 투명합니다
- Imagecolortransparent($this->IMAGE,$Background)
- }else{
- //채울 수 있습니다. 투명하게 하고 싶지 않은 경우 배경색
- ImageFilledRectangle($this->IMAGE,0,0,$this->X,$this->Y,$Background)
- }
- //글꼴 크기 및 색상 매개변수
- $this->FONTCOLOR=ImageColorAllocate($this->IMAGE,255-$this->R,255-$this->G,255-$ this->B);
- 스위치( $this->REPORTTYPE){
- 케이스 "0":
- 중단
- 케이스 "1":
- $this->imageColumnS ();
- 중단;
- 사례 "2":
- $this->imageColumnH()
- 중단
- 사례 "3":
- $this->imageLine ();
- 중단;
- 사례 "4":
- $this->imageCircle()
- 중단
- }
- $this->printXY(); 🎜> $this->printAll();
- }
- //---------XY 좌표축 인쇄
- function printXY(){
- $rulerY = $ ruleX = "";
- //XY 좌표축 그리기*/
- $color=ImageColorAllocate($this->IMAGE,255-$this->R,255-$this->G,255 -$this->B)
- $xx=$this->X/10
- $yy=$this->Y-$this->Y/10;
- ImageLine ($this->IMAGE,$this->BORDER,$this->BORDER,$this->BORDER,$this->Y-$this->BORDER,$color);//X -축
- ImageLine($this->IMAGE ,$this->BORDER,$this->Y-$this->BORDER,$this->X-$this->BORDER,$ this->Y-$this->BORDER, $color);//y축
- imagestring($this->IMAGE, $this->FONTSIZE, $this->BORDER-2, $this->Y-$this->BORDER 5 , "0", $color);
- //Y축 크기 조정
- $rulerY=$this->Y-$this-> BORDER;
- $i = 0;
- while ($rulerY>$this->BORDER*2){
- $rulerY=$rulerY-$this->BORDER; this->IMAGE,$this->BORDER,$ 눈금자Y,$this->BORDER-2,$rulerY,$color)
-
- if($this->REPORTTYPE == 2) {//가로 막대형 차트
- imagestring($this- >IMAGE, $this->FONTSIZE, $this->BORDER-10, $rulerY-2-$this->BORDER*($i . 5), $this->numX, $color)
- $this->numX = $this->stepX;
- }
- $i ;
- }
- // X축 크기 조정
- $rulerX=$rulerX $this ->BORDER
- $i = 0;
- while($rulerX<($this->X-$this-> BORDER*2)){
- $rulerX=$rulerX $this ->BORDER
- //ImageLine($this->IMAGE,$this->BORDER,10,$this->BORDER; 10,10,$color)
- ImageLine($this- >IMAGE,$rulerX,$this->Y-$this->BORDER,$rulerX,$this->Y-$this- >BORDER 2,$color);
-
- / /Scale 값
- if($this->REPORTTYPE == 1){//세로 막대형 차트
- imagestring($this-> IMAGE, $this->FONTSIZE, $rulerX-2 $this- >BORDER*($i .5), $this->Y-$this->BORDER 5, $this->numX, $ color);
- $this->numX = $this- >stepX;
- }else if($this->REPORTTYPE == 3){//折线图
- imagestring($this->IMAGE, $this->FONTSIZE, $rulerX-2, $this->Y-$ this->BORDER 5, $this->numX, $color);
- $this->numX = $this->stepX;
- }
- $i ;
- }
- }
-
- //--------------- 종 모양 그림
- function imageColumnS(){
- $item_array=Split($this-> ARRAYSPLIT,$this->ITEMARRAY);
- $num=개수($item_array);
- $item_max=0;
- for ($i=0;$i<$num;$i ){
- $item_max=Max($item_max,$item_array[$i]);
- }
- $xx=$ this->BORDER*2;
- //형식 그림
- for ($i=0;$i<$num;$i ){
- srand((double)microtime()*1000000);
- if($ this->R!=255 && $this->G!=255 && $this->B!=255){
- $R=Rand($this->R,200);
- $G=Rand($this->G,200);
- $B=Rand($this->B,200);
- }else{
- $R=Rand(50,200);
- $G=랜드(50,200);
- $B=랜드(50,200);
- }
- $color=ImageColorAllocate($this->IMAGE,$R,$G,$B);
- //모양의 높이
- $height=($this->Y-$this->BORDER)-($this->Y-$this->BORDER*2)*($ item_array[$i]/$item_max);
- ImageFilledRectangle($this->IMAGE,$xx,$height,$xx $this->BORDER,$this->Y-$this->BORDER,$color);
- ImageString($this->IMAGE,$this->FONTSIZE,$xx,$height-$this->BORDER,$item_array[$i],$this->FONTCOLOR);
- //사용于间隔
- $xx=$xx $this->BORDER*2;
- }
- }
- //------------ 모양 그림
- function imageColumnH(){
- $item_array=Split($this->ARRAYSPLIT ,$this->ITEMARRAY);
- $num=개수($item_array);
- $item_max=0;
- for ($i=0;$i<$num;$i ){
- $item_max=Max($item_max,$item_array[$i]);
- }
- $yy=$ this->Y-$this->BORDER*2;
- //형식 그림
- for ($i=0;$i<$num;$i ){
- srand((double)microtime()*1000000);
- if($ this->R!=255 && $this->G!=255 && $this->B!=255){
- $R=Rand($this->R,200);
- $G=Rand($this->G,200);
- $B=Rand($this->B,200);
- }else{
- $R=Rand(50,200);
- $G=랜드(50,200);
- $B=랜드(50,200);
- }
- $color=ImageColorAllocate($this->IMAGE,$R,$G,$B);
- //형태의 크기
- $leight=($this->X-$this->BORDER*2)*($item_array[$i]/$item_max);
- $leight = $leight < $this->BORDER ? $this->BORDER : $leight;
- ImageFilledRectangle($this->IMAGE,$this->BORDER,$yy-$this->BORDER,$leight,$yy,$color);
- ImageString($this->IMAGE,$this->FONTSIZE,$leight 2,$yy-$this->BORDER,$item_array[$i],$this->FONTCOLOR);
- //사용于间隔
- $yy=$yy-$this->BORDER*2;
- }
- }
- //--------------- 折线图
- function imageLine(){
- $item_array=Split($this-> ARRAYSPLIT,$this->ITEMARRAY);
- $num=개수($item_array);
- $item_max=0;
- for ($i=0;$i<$num;$i ){
- $item_max=Max($item_max,$item_array[$i]);
- }
- $xx=$ this->BORDER;
- //형식 그림
- for ($i=0;$i<$num;$i ){
- srand((double)microtime()*1000000);
- if($ this->R!=255 && $this->G!=255 && $this->B!=255){
- $R=Rand($this->R,200);
- $G=Rand($this->G,200);
- $B=Rand($this->B,200);
- }else{
- $R=Rand(50,200);
- $G=랜드(50,200);
- $B=랜드(50,200);
- }
- $color=ImageColorAllocate($this->IMAGE,$R,$G,$B);
- //모양의 높이
- $height_now=($this->Y-$this->BORDER)-($this->Y-$this->BORDER*2)*($ item_array[$i]/$item_max);
- if($i!="0")
- ImageLine($this->IMAGE,$xx-$this->BORDER,$height_next,$xx,$height_now,$color);
-
- ImageString($this->IMAGE,$this->FONTSIZE,$xx 2,$height_now-$this->BORDER/2,$item_array[$i],$this-> 글꼴 색상);
- $height_next=$height_now;
- //사용于间隔
- $xx=$xx $this->BORDER;
- }
- }
- //---------------饼状图
- function imageCircle(){
- $total = 0;
- $ item_array=분할($this->ARRAYSPLIT,$this->ITEMARRAY);
- $num=개수($item_array);
- $item_max=0;
- for ($i=0;$i<$num;$i ){
- $item_max=Max($item_max,$item_array[$i]);
- $total = $item_array[$i ];
- }
- $yy=$this->Y-$this->BORDER*2;
-
- //画饼状图的阴影부분분
- $e=0;
- for ($i=0;$i<$num;$i ){
- srand((double )microtime()*1000000);
- if($this->R!=255 && $this->G!=255 && $this->B!=255){
- $R= 랜드($this->R,200);
- $G=Rand($this->G,200);
- $B=Rand($this->B,200);
- }else{
- $R=Rand(50,200);
- $G=랜드(50,200);
- $B=랜드(50,200);
- }
- $s=$e;
- $leight=$item_array[$i]/$total*360;
- $e=$s $leight;
- $color=ImageColorAllocate( $this->IMAGE,$R,$G,$B);
- $colorarray[$i]=$color;
- //画圆
- for ($j = 90; $j > 70; $j--) imagefilledarc($this->IMAGE, 110, $j, 200, 100, $s, $ e, $color, IMG_ARC_PIE);
- //imagefilledarc($this->IMAGE, 110, 70, 200, 100, $s, $e, $color, IMG_ARC_PIE);
- //ImageFilledRectangle($this->IMAGE,$this->BORDER,$yy-$this->BORDER,$leight,$yy,$color);
- //ImageString($this->IMAGE,$this->FONTSIZE,$leight 2,$yy-$this->BORDER,$item_array[$i],$this->FONTCOLOR);
- //사용于间隔
- $yy=$yy-$this->BORDER*2;
- }
-
- //画饼状图的表면부분
- $e=0;
- for ($i=0;$i<$num;$i ){
- srand((double)microtime()*1000000);
- if($this->R!=255 && $this->G!=255 && $this->B!=255){
- $R=Rand($this->R,200);
- $G=Rand($this->G,200);
- $B=Rand($this->B,200);
- }else{
- $R=Rand(50,200);
- $G=랜드(50,200);
- $B=랜드(50,200);
- }
- $s=$e;
- $leight=$item_array[$i]/$total*360;
- $e=$s $leight;
- //$color= $colorarray[$i];
- $color=ImageColorAllocate($this->IMAGE,$R,$G,$B);
- //画圆
- //for ($j = 90; $j > 70; $j--) imagefilledarc($this->IMAGE, 110, $j, 200, 100, $s , $e, $color, IMG_ARC_PIE);
- imagefilledarc($this->IMAGE, 110, 70, 200, 100, $s, $e, $color, IMG_ARC_PIE);
- }
- }
- //---------------完成打印图shape
- function printAll(){
- ImagePNG($this->IMAGE) ;
- ImageDestroy($this->IMAGE);
- }
- //-------------调试
- function debug(){
- echo "X:".$this->X."< ;br/>Y:".$this->Y;
- echo "
BORDER:".$this->BORDER;
- $item_array=split($this->ARRAYSPLIT,$this->ITEMARRAY);
- $num=개수($item_array);
- echo "
数值个数:".$num." 数值:";
- for ($i=0;$i<$num;$i ){
- echo "
".$item_array[$i];
- }
- }
- }
- //$report->debug();//调式之用
- /*
- Header( "콘텐츠 유형:이미지/png" );
- $report=new ImageReport;
- $report->setImage(600,500,255,255,255,1);//参数(长,高,背影colorR,G,B,是否透明1或0)
- >符号,数值变weight,样式1为竖柱图2为横柱图3为折线图4为饼图,距离)
- $report->setFont(1);//字体大小1-10
- / /$report->setX(1,1);//设置X轴刻degree值(起始刻島值=1,刻島间隔值=1)
- $report->PrintReport();
- * /
- ?>
-
复代码
|