用GD图库生成横竖柱状图折线图的类_PHP教程

WBOY
Freigeben: 2016-07-13 17:32:27
Original
886 Leute haben es durchsucht

最近写的一个GD图库用以生成横竖柱状图和折线图的类库,算是一个教学例程吧 
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;//字体颜色
//--------参数设置函数
function setImage($SizeX,$SizeY,$R,$G,$B,$Transparent){
$this->X=$SizeX; 
$this->Y=$SizeY; 
$this->R=$R; 
$this->G=$G; 
$this->B=$B; 
$this->TRANSPARENT=$Transparent; 

function setItem($ArraySplit,$ItemArray,$ReportType,$Border){ 
$this->ARRAYSPLIT=$ArraySplit; 
$this->ITEMARRAY=$ItemArray; 
$this->REPORTTYPE=$ReportType; 
$this->BORDER=$Border; 

function setFont($FontSize){ 
$this->FONTSIZE=$FontSize; 

//----------------主体 
function PrintReport(){ 
Header( "Content-type: image/gif"); 
//建立画布大小 
$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); 
Switch ($this->REPORTTYPE){ 
case "0": 
break; 
case "1": 
$this->imageColumnS(); 
break; 
case "2": 
$this->imageColumnH(); 
break; 
case "3": 
$this->imageLine(); 
break; 

$this->printXY(); 
$this->printAll(); 

//-----------打印XY坐标轴 
function printXY(){ 
//画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轴 
//Y轴上刻度 
$rulerY=$this->Y-$this->BORDER; 
while($rulerY>$this->BORDER*2){ 
$rulerY=$rulerY-$this->BORDER; 
ImageLine($this->IMAGE,$this->BORDER,$rulerY,$this->BORDER-2,$rulerY,$color); 

//X轴上刻度 
$rulerX=$rulerX+$this->BORDER; 
while($rulerXX-$this->BORDER*2)){ 
$rulerX=$rulerX+$this->BORDER; 
//ImageLine($this->IMAGE,$this->BORDER,10,$this->BORDER+10,10,$color); 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/508716.htmlTechArticle最近写的一个GD图库用以生成横竖柱状图和折线图的类库,算是一个教学例程吧 Class ImageReport var X;//图片大小X轴 var Y;//图片大小Y轴 var R;//背...
Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage