php报表 jpgraph柱状图实例
发布:smiling 来源: PHP粉丝网 添加日期:2014-08-19 10:15:30 浏览: 评论:0
jpgraph是php中一个非常非常强大的第三方报表工具,据说能完成一切你想要的图形…新手初识jpgraph肯定会遇到各种各样的问题,比如乱码什么的,本案例是jpgraph3.0.7制作,也经过本人的多次实验,解决乱码问题.
php报表 jpgraph柱状图实例代码如下:
- <?php$
- datay=array(); //纵坐标数据
- $datax=array(); //横坐标数据
- foreach ($usernums as $key => $value){
- $datay[] = $value;
- $datax[] = $userids[$key];
- }
- require_once (‘jpgraph-3.0.7/jpgraph/jpgraph.php’);
- require_once (‘jpgraph-3.0.7/jpgraph/jpgraph_bar.php’);
- // Create the graph. These two calls are always required
- $graph = new Graph(800,600); //图像高宽
- $graph->SetScale(“textlin”);
- $graph->xaxis->SetTickLabels($datax);
- $graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
- $graph->xaxis->SetLabelAngle(30);
- $graph->yaxis->scale->SetGrace(20);
- $graph->xaxis->scale->SetGrace(20);// Add a drop shadow
- $graph->SetShadow();// Adjust the margin a bit to make more room for titles
- $graph->img->SetMargin(40,30,20,40);// Create a bar pot
- $bplot = new BarPlot($datay);// Adjust fill color
- $bplot->SetFillColor(‘orange’);
- $bplot->value->Show();$bplot->value->SetFont(FF_ARIAL,FS_BOLD,10);//开源代码phpfensi.com
- $bplot->value->SetAngle(45);
- $bplot->value->SetFormat(‘%d’);
- $graph->Add($bplot);// Setup the titles
- $graph->title->Set(iconv(“UTF-8″, “gb2312″,”用户消费报表图”));
- $graph->xaxis->title->Set(iconv(“UTF-8″, “gb2312″,”用户姓名”));
- $graph->yaxis->title->Set(iconv(“UTF-8″, “gb2312″,”用户订单数量”));
- $graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
- $graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
- $graph->title->SetFont(FF_SIMSUN,FS_BOLD);// Display the graph
- $graph->Stroke();
- ?>
Tags: php报表 jpgraph 柱状图实例
- 上一篇:php 创建等比例图片代码
- 下一篇:php等比例生成缩略图程序
相关文章
- ·jpgraph 生成类型数据以图表走势图的形式表现出来(2014-08-19)
- ·jpgraph柱状图的使用方法详解(2015-04-08)
- ·PHP图形操作之Jpgraph学习笔记(2021-07-01)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)