国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

php圖形jpgraph操作實例分析

2024-05-04 23:55:23
字體:
來源:轉載
供稿:網友

本文實例講述了php圖形jpgraph操作。分享給大家供大家參考,具體如下:

<?phpinclude ("src/jpgraph.php");include("src/jpgraph_bar.php");include ("src/jpgraph_line.php");//設置顯示的數據數組;//調用類庫//設置圖像的大小$graph = new Graph(400,200,"auto");$graph->SetScale("textlin");//設置圖形的邊距$graph->img->SetMargin(40,180,40,40);//設置圖形的背景圖片,填充方式有:BGIMG_FILLPLOT, BGIMG_FILLFRAME, BGIMG_COPY$graph->SetBackgroundImage("abc.jpg",BGIMG_FILLPLOT);$graph->img->SetAngle(45); //設置圖形在圖像中的角度//設置背景圖片的對比度,must be between -1 <= x <= 1, (0,0)=original image$graph->AdjBackgroundImage(0,0);//設置投影;//$graph->SetShadow();//設置標題$graph->title->Set("test image");//設置標題字體樣式$graph->title->SetFont(FF_FONT1,FS_BOLD);//設置標題的邊距$graph->title->SetMargin(3);//設置圖列的位置$graph->legend->Pos(0.05,0.5,"right","center");//設置圖列的投影,顏色$graph->legend->SetShadow('darkgray@0.1');$graph->legend->SetFillColor('lightblue@0.3');//設置x軸的標記$graph->xaxis->SetTickLabels($label_x);//設置X軸的顯示值的角度;$graph->xaxis->SetLabelAngle(30);//設置x軸標題和字體顏色$graph->xaxis->title->Set('Year 2006');$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);$graph->xaxis->title->SetColor('white');//設置x軸的字體和顏色$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);$graph->xaxis->SetColor('yellow');//設置y軸的字體和顏色$graph->yaxis->SetFont(FF_FONT1,FS_BOLD);$graph->yaxis->SetColor('yellow');//設置是否顯示格子。默認為顯示;//$graph->ygrid->Show(false);//設置格子的顏色和粗細。值越小,格子越粗。$graph->ygrid->SetColor('yellow@0.5');//設置y軸更優美一些$graph->yaxis->scale->SetGrace(20);//設置圖列的數據$bplot1 = new BarPlot($datay1);$bplot2 = new BarPlot($datay2);//設置圖列的填充顏色$bplot1->SetFillColor('orange@0.4');$bplot2->SetFillColor('brown@0.4');//設置值的格式$bplot1->value->SetFormat('%d');//設置圖列標簽$bplot1->SetLegend('Label 1');$bplot2->SetLegend('Label 2');//設置圖列在圖中的陰影$bplot1->SetShadow('black@0.4');$bplot2->SetShadow('black@0.4');//生成圖列$gbarplot = new GroupBarPlot(array($bplot1,$bplot2));$gbarplot->SetWidth(0.9);$graph->Add($gbarplot);//生成圖形$graph->Stroke();//上面所說的時在生成柱形圖,當生成線性圖時用下面的方法$p1 = new LinePlot($datay);$p1->mark->SetType(MARK_FILLEDCIRCLE);$p1->mark->SetFillColor("red");$p1->mark->SetWidth(4);$p1->SetColor("blue");$p1->SetCenter();$p1->SetLegend("Triumph Tiger -98");$graph->Add($p1);$p2 = new LinePlot($data2y);$p2->mark->SetType(MARK_STAR);$p2->mark->SetFillColor("red");$p2->mark->SetWidth(4);$p2->SetColor("red");$p2->SetCenter();$p2->SetLegend("New tiger -99");$graph->Add($p2);// Style can also be specified as SetStyle([1|2|3|4]) or// SetStyle("solid"|"dotted"|"dashed"|"lobgdashed")$lineplot->SetStyle("dashed");//設置線的樣式$graph->yaxis->scale->SetGrace(20); //設置y軸更優美一些?>

2.柱形圖和餅狀圖舉例

if($tag == 1){$graph = new Graph(600,400,"auto");$graph->SetScale("textlin");$graph->setMarginColor('lightblue');$graph->SetShadow();$graph->setMargin(30,100,30,60);//設置標題;$graph->title->set("文章分類匯總");$graph->title->SetMargin(3);$graph->title->setfont(FF_SIMSUN,FS_BOLD);$graph->title->setcolor('black@0.5');$graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD);$graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD);$graph->xaxis->SetFont(FF_SIMSUN,FS_NORMAL);$graph->xaxis->SetColor('darkblue','black');$graph->xaxis->SetTickLabels($name);$graph->xaxis->SetLabelAngle(30);$bplot = new BarPlot($article_num);$bplot->SetFillColor("orange");$bplot->value->SetFormat('%d');$bplot->SetShadow('darkgray');$bplot->value->show();$graph->legend->SetFont(FF_SIMSUN,FS_BOLD);$bplot->SetLegend("文章數");$graph->Add($bplot);$graph->Stroke();}else{$graph1 = new PieGraph(600,400,"auto");$graph1->SetScale("textlin");$graph1->SetShadow();$graph1->title->setFont(FF_SIMSUN,FS_BOLD);$graph1->title->set("用戶文章餅形圖");$graph1->setMargin(30,100,30,60);$p1 = new pieplot3d($article_num);$p1->setAngle(80);$p1->setsize(0.5);$p1->setShadow();$p1->ExplodeSlice(2);$p1->SetCenter(0.4);$graph1->legend->SetFont(FF_SIMSUN,FS_NORMAL);$graph1->legend->setshadow();$p1->SetLegends($name);$graph1->Add($p1);$graph1->Stroke();}//生成本地圖片$graph->Stroke("路徑/文件名.png");

希望本文所述對大家PHP程序設計有所幫助。


注:相關教程知識閱讀請移步到PHP教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 巴林左旗| 宝兴县| 固始县| 汉源县| 德惠市| 来凤县| 永平县| 孝感市| 藁城市| 勐海县| 卓资县| 郑州市| 英德市| 定远县| 马关县| 德钦县| 长葛市| 浦东新区| 福安市| 穆棱市| 柏乡县| 明溪县| 静海县| 木兰县| 谢通门县| 云阳县| 南开区| 建始县| 崇阳县| 通海县| 溆浦县| 三台县| 闽侯县| 滕州市| 宝山区| 宜兰县| 宜阳县| 高唐县| 清河县| 泸定县| 平凉市|