php图形jpgraph操作实例分析

本文实例讲述了PHP图形jpgraph操作。分享给大家供大家参考,具体如下:

rush:PHP;"> 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.柱形图和饼状图举例

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,"auto"); $graph1->SetScale("textlin"); $graph1->SetShadow(); $graph1->title->setFont(FF_SimsUN,FS_BOLD); $graph1->title->set("用户文章饼形图"); $graph1->setMargin(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程序设计有所帮助。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


服务器优化必备:深入了解PHP8底层开发原理
Golang的网络编程:如何快速构建高性能的网络应用?
Golang和其他编程语言的对比:为什么它的开发效率更高?
PHP8底层开发原理揭秘:如何利用新特性创建出色的Web应用
将字符重新排列以形成回文(如果可能)在C++中
掌握PHP8底层开发原理和新特性:创建高效可扩展的应用程序
服务器性能优化必学:掌握PHP8底层开发原理
PHP8新特性和底层开发原理详解:优化应用性能的终极指南
将 C/C++ 代码转换为汇编语言
深入研究PHP8底层开发原理:创建高效可扩展的应用程序
C++程序查找法向量和迹
PHP8底层开发原理实战指南:提升服务器效能
重排数组,使得当 i 为偶数时,arr[i] >= arr[j],当 i 为奇数时,arr[i] <= arr[j],其中 j < i,使用 C++ 语言实现
Golang的垃圾回收:为什么它可以减少开发人员的负担?
C++程序:将一个数组的所有元素复制到另一个数组中
Golang:构建智能系统的基石
为什么AI开发者应该关注Golang?
在C和C++中,逗号(comma)的用法是用来分隔表达式或语句
PHP8底层开发原理解析及新特性应用实例
利用PHP8底层开发原理解析新特性:如何构建出色的Web应用