最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php下實(shí)現(xiàn)折線圖效果的代碼

 更新時(shí)間:2007年04月28日 00:00:00   作者:  
<?php
  Class ImageReport{ 
var $X;//圖片大小X軸 
var $Y;//圖片大小Y軸 
var $R;//背影色R值 
var $G;//...G. 
var $B;//...B. 
var $TRANSPARENT;//是否透明1或0 
var $IMAGE;//圖片對(duì)像 
//------------------- 
var $ARRAYSPLIT;//指定用于分隔數(shù)值的符號(hào) 
var $ITEMARRAY;//數(shù)值 
var $REPORTTYPE;//圖表類型,1為豎柱形2為橫柱形3為折線形 
var $BORDER;//距離 
//------------------- 
var $FONTSIZE;//字體大小 
var $FONTCOLOR;//字體顏色 
//--------參數(shù)設(shè)置函數(shù) 
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);  
//設(shè)定畫布背景色  
$background=ImageColorAllocate($this->IMAGE,$this->R,$this->G,$this->B);  
if($this->TRANSPARENT=="1"){  
//背影透明  
Imagecolortransparent($this->IMAGE,$background);  
}else{  
//如不要透明時(shí)可填充背景色  
ImageFilledRectangle($this->IMAGE,0,0,$this->X,$this->Y,$background);  
}  
//參數(shù)字體文小及顏色  
$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坐標(biāo)軸  
function printXY(){  
//畫XY坐標(biāo)軸*/  
$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($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);  
}  
}  

//--------------豎柱形圖  
function imageColumnS(){  
$item_array=Split($this->ARRAYSPLIT,$this->ITEMARRAY);  
$num=Count($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=Rand(50,200);  
$B=Rand(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=Count($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=Rand(50,200);  
$B=Rand(50,200);  
}  
$color=ImageColorAllocate($this->IMAGE,$R,$G,$B);  
//柱形長(zhǎng)度  
$leight=($this->X-$this->BORDER*2)*($item_array[$i]/$item_max);  
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=Count($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=Rand(50,200);  
$B=Rand(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,$height_next,$xx+$this->BORDER,$height_now,$color);  
}  
ImageString($this->IMAGE,$this->FONTSIZE,$xx+$this->BORDER,$height_now-$this->BORDER/2,$item_array[$i],$this->FONTCOLOR);  
$height_next=$height_now;  
//用于間隔  
$xx=$xx+$this->BORDER;  
}  
}  

//--------------完成打印圖形http://knowsky.com  
function printAll(){  
ImageGIF($this->IMAGE);  
ImageDestroy($this->IMAGE);  
}  
//--------------調(diào)試  
function debug(){  
echo "X:".$this->X."
Y:".$this->Y;  
echo "
BORDER:".$this->BORDER;  
$item_array=split($this->ARRAYSPLIT,$this->ITEMARRAY);  
$num=Count($item_array);  
echo "
數(shù)值個(gè)數(shù):".$num."
數(shù)值:";  
for ($i=0;$i<$num;$i++){ 
echo "
".$item_array[$i];  
}  
}  
}  

$report=new ImageReport;  
$report->setImage(600,300,255,255,255,1);//參數(shù)(長(zhǎng),寬,背影色R,G,B,是否透明1或0)  
$temparray="50,25,100,250,180,200,150,220,200,150,50,25,100,250,180,200,150,220,200,150";//數(shù)值,用指定符號(hào)隔開  
$report->setItem(',',$temparray,3,20);//參數(shù)(分隔數(shù)值的指定符號(hào),數(shù)值變量,樣式1為豎柱圖2為橫柱圖3為折線圖,距離)  
$report->setFont(1);//字體大小1-10  
$report->PrintReport();  
//$report->debug();//調(diào)式之用  
?>

相關(guān)文章

  • PHP實(shí)現(xiàn)讀取一個(gè)1G的文件大小

    PHP實(shí)現(xiàn)讀取一個(gè)1G的文件大小

    以下是對(duì)使用PHP實(shí)現(xiàn)讀取一個(gè)1G文件大小的方法進(jìn)行了詳細(xì)的介紹,需要的朋友可以過來參考下
    2013-08-08
  • 又十個(gè)超級(jí)有用的PHP代碼片段

    又十個(gè)超級(jí)有用的PHP代碼片段

    這篇文章又介紹了十個(gè)超級(jí)有用的PHP代碼片段,每一個(gè)都很精彩,每一個(gè)都值得收藏,感興趣的小伙伴們可以參考一下
    2015-09-09
  • PHP編程函數(shù)安全篇

    PHP編程函數(shù)安全篇

    關(guān)于腳本安全這個(gè)話題好像永遠(yuǎn)沒完沒了,如果你經(jīng)常到國外的各種各樣的bugtraq上,你會(huì)發(fā)現(xiàn)有一半以上都和腳本相關(guān),諸如SQL injection,XSS,Path Disclosure,Remote commands execution這樣的字眼比比皆是,我們看了之后的用途難道僅僅是抓肉雞?
    2013-01-01
  • 用PHP去掉文件頭的Unicode簽名(BOM)方法

    用PHP去掉文件頭的Unicode簽名(BOM)方法

    下面小編就為大家?guī)硪黄肞HP去掉文件頭的Unicode簽名(BOM)方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-06-06
  • Ajax+PHP 邊學(xué)邊練之四 表單

    Ajax+PHP 邊學(xué)邊練之四 表單

    通過上一篇文章已經(jīng)了解到如何利用Ajax和PHP對(duì)數(shù)據(jù)庫進(jìn)行數(shù)據(jù)讀取,這樣可以動(dòng)態(tài)的獲取到數(shù)據(jù)庫的最新數(shù)據(jù)。本篇?jiǎng)t繼續(xù)介紹通過表單(Form)向數(shù)據(jù)庫中寫入數(shù)據(jù)。
    2009-11-11
  • 解析如何修改phpmyadmin中的默認(rèn)登陸超時(shí)時(shí)間

    解析如何修改phpmyadmin中的默認(rèn)登陸超時(shí)時(shí)間

    本篇文章是對(duì)修改phpmyadmin中的默認(rèn)登陸超時(shí)時(shí)間的解決方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06
  • 解析PHP觀察者模式Observer

    解析PHP觀察者模式Observer

    Observer,首先要有一個(gè)被觀察的角色,但它是【唯一的】。雖然"表演者"只有一個(gè)但是"觀眾"有很多,既一群"人"圍觀一個(gè)"人"。既然有無數(shù)個(gè)觀察者,那么我們需要知道都有哪一些"人"。所以我們需要一個(gè)“容器”來記錄這些"人",一個(gè)類似于數(shù)組一樣來儲(chǔ)存所有觀察者的容器。
    2021-05-05
  • Android AsyncTack 異步任務(wù)實(shí)例詳解

    Android AsyncTack 異步任務(wù)實(shí)例詳解

    這篇文章主要介紹了Android AsyncTack 異步任務(wù)實(shí)例詳解的相關(guān)資料,并附簡(jiǎn)單實(shí)例代碼,和實(shí)現(xiàn)效果圖,需要的朋友可以參考下
    2016-11-11
  • 學(xué)習(xí)php設(shè)計(jì)模式 php實(shí)現(xiàn)策略模式(strategy)

    學(xué)習(xí)php設(shè)計(jì)模式 php實(shí)現(xiàn)策略模式(strategy)

    這篇文章主要介紹了php設(shè)計(jì)模式中的適配器模式,使用php實(shí)現(xiàn)適配器模式,感興趣的小伙伴們可以參考一下
    2015-12-12
  • php的GD庫imagettftext函數(shù)解決中文亂碼問題

    php的GD庫imagettftext函數(shù)解決中文亂碼問題

    這篇文章主要介紹了php的GD庫imagettftext函數(shù)解決中文亂碼問題,可通過將中文字符串轉(zhuǎn)為utf-8格式來解決,需要的朋友可以參考下
    2015-01-01

最新評(píng)論

察隅县| 上杭县| 当雄县| 阿勒泰市| 铁岭县| 东明县| 张家界市| 南郑县| 观塘区| 平凉市| 三台县| 正蓝旗| 祁阳县| 闽侯县| 辽源市| 天等县| 洛南县| 陵水| 郯城县| 永新县| 江山市| 玛曲县| 托里县| 潜山县| 潍坊市| 沧源| 商河县| 大田县| 乾安县| 湘阴县| 锡林郭勒盟| 六安市| 永顺县| 沐川县| 抚顺县| 南陵县| 麟游县| 济源市| 通化市| 张家港市| 宜兴市|