因为在开发内部BI系统中需要画出统计图表,我选了Jpgraph 开源绘图工具实现需求。

之前实现过需求,没想到这次又花了很多时间回忆,各种搜索,真的是好记性不如烂笔头,

不会总结的人没有未来啊。

常用的三种图表样式:

|———— 3D饼图:

include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_pie.php");
include ("jpgraph/jpgraph_pie3d.php");
$data = array(218,100);
$datatitle = array('男','女');
$title = "男女占比";
 
$width = 490;
$height = 350;
$graph = new PieGraph($width,$height,'auto');
 
$graph->SetShadow();
 
$graph->title->Set($title);
 
$graph->title->SetFont(FF_SIMSUN,FS_BOLD,12);
 
$p1 = new PiePlot3D($data);//创建3D饼形图对象
 
$p1->ExplodeSlice(1); //分割线
$p1->SetCenter(0.45);
 
$graph->legend->SetFont(FF_SIMSUN,FS_BOLD,10); //设置旁注字体
$graph->legend->Pos(0.89,0.9,'center','bottom');//设置旁注位置
$graph->legend->SetFrameWeight(0); //图例文字外框边框border设置为0
$graph->legend->SetFillColor('#FFFFFF'); //图例文字框内的填充颜色
$graph->legend->SetShadow('#C8C8C8', 0);
$graph->legend->SetLayout(LEGEND_VERT);//旁注摆放形式[竖直]
 
$p1->SetLegends($datatitle);
 
$graph->Add($p1);
$graph->Stroke();


|—————普通圆形图:

include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_pie.php");
$data = array(218,100);
$datatitle = array('男','女');
$title = "男女占比";
 
$width = 490;
$height = 350;
$graph = new PieGraph($width,$height,'auto');
 
$graph->SetShadow();
 
$graph->title->Set($title);
 
$graph->title->SetFont(FF_SIMSUN,FS_BOLD,12);
 
$graph->legend->SetFont(FF_SIMSUN,FS_BOLD,10); //设置旁注字体
$graph->legend->Pos(0.89,0.9,'center','bottom');//设置旁注位置
$graph->legend->SetFrameWeight(0); //图例文字外框边框border设置为0
$graph->legend->SetFillColor('#FFFFFF'); //图例文字框内的填充颜色
$graph->legend->SetShadow('#C8C8C8', 0);
$graph->legend->SetLayout(LEGEND_VERT);//旁注摆放形式[竖直]
 
// Create pie plot
$p1 = new PiePlot($data);
$p1->SetCenter(0.5,0.55);
$p1->SetSize(0.3);
 
// Enable and set policy for guide-lines. Make labels line up vertically
$p1->SetGuideLines(true,false);
$p1->SetGuideLinesAdjust(1.1);
$p1->SetLegends($datatitle);
 
// Setup the labels
$p1->SetLabelType(PIE_VALUE_PER);
$p1->value->Show();
$p1->value->SetFont(FF_ARIAL,FS_NORMAL,9);
$p1->value->SetFormat('%2.1f%%');
 
$graph->legend->SetLayout(LEGEND_VERT);
 
$graph->Add($p1);
$graph->Stroke();
 
 


|————柱状图:

require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
 
$datay = array('23','12','4','67','9');
$datax = array('0-10','11-50','51-100','101-500','500+');
$title = "综合排名";
 
$width=520;
$height=380;
 
// Set the basic parameters of the graph
$graph = new Graph($width,$height,'auto');
$graph->SetScale("textlin");
 
$top = 50;
$bottom = 80;
$left = 80;
$right = 25;
$graph->Set90AndMargin($left,$right,$top,$bottom);
 
$graph->xaxis->SetPos('min');
 
// Nice shadow
$graph->SetShadow();
 
// Setup title
$graph->title->Set($title);
$graph->title->SetFont(FF_SIMSUN,FS_BOLD,10);
 
// Setup X-axis
$graph->xaxis->SetTickLabels($datax);
//
$graph->xaxis->SetFont(FF_SIMSUN,FS_BOLD,12);
 
 
// Some extra margin looks nicer
$graph->xaxis->SetLabelMargin(5);
 
// Label align for X-axis
$graph->xaxis->SetLabelAlign('right','center');
 
// Add some grace to y-axis so the bars doesn't go
// all the way to the end of the plot area
$graph->yaxis->scale->SetGrace(20);
 
// Setup the Y-axis to be displayed in the bottom of the
// graph. We also finetune the exact layout of the title,
// ticks and labels to make them look nice.
$graph->yaxis->SetPos('max');
 
// First make the labels look right
$graph->yaxis->SetLabelAlign('center','top');
$graph->yaxis->SetLabelFormat('%d');
$graph->yaxis->SetLabelSide(SIDE_RIGHT);
 
// The fix the tick marks
$graph->yaxis->SetTickSide(SIDE_LEFT);
 
// Finally setup the title
$graph->yaxis->SetTitleSide(SIDE_RIGHT);
$graph->yaxis->SetTitleMargin(35);
 
// Now create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor("orange");
$bplot->SetShadow();
 
//You can change the width of the bars if you like
//$bplot->SetWidth(0.5);
 
// We want to display the value of each bar at the top
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL,FS_BOLD,12);
$bplot->value->SetAlign('left','center');
$bplot->value->SetColor("black","darkred");
$bplot->value->SetFormat('%.1f mkr');
 
// Add the bar to the graph
$graph->Add($bplot);
$graph->Stroke();


以上为常用的图表及对应的后端实现:给自己记忆和需要人的便捷;

 

BI系统之统计图表的绘制[后端实现]的更多相关文章

  1. 国内经典BI系统架构分析

    谈起商业智能BI,也许大家并不陌生,但你是否了解国内的各类BI系统架构? 自国内商业智能发展以来,就系统结构方面已经历了多次优化性的变革.目前国内商业智能BI系统的经典架构的模式包括数据层.业务层和应 ...

  2. BI系统与KPI指标的整合分析

    今天我们要说的是信息化时代下关于企业运营的两个热词:BI系统和KPI指标.一直到现在,企业运营的方方面面都在被数据化,成为庞大信息流的一部分,这一庞大的信息流,正以我们自己都尚未完全意识到的速度和规模 ...

  3. BI系统的应用组织思路与数据分析模式

    BI商业智能软件一般都会提供若干数据整合.数据查询.分析与评价.数据可视化及数据分享的手段,但是在BI项目的构建与实施过程中,如果不按照一定的应用组织思路.数据分析模式及分析流程使用这些工具或手段,呈 ...

  4. 企业BI系统应用的切入点及五大策略

    从技术的角度来看,BI的技术正在走向成熟,处于一个发展的阶段,但它促使了BI的应用在成本方面开始逐步的降低,越来越多的企业在BI应用方面取得了成功.从实施的角度来出发,实施商业智能系统是一项复杂的系统 ...

  5. 大数据时代的新BI系统架构发展趋势

    商业智能(BI,Business Intelligence).它是一套完整的解决方式,用来将企业中现有的数据进行有效的整合,高速准确的提供报表并提出决策根据.帮助企业做出明智的业务经营决策.     ...

  6. BI系统要自研还是采购?这篇文章告诉你

    首先说一下目前市面上的BI工具都有哪些吧.总体上,其实分为免费和付费两大阵营.免费阵营里,为首的当然是GA(也就是谷歌分析).PowerBI,但是由于有墙的限制,很多公司没法使用前者.付费阵营里,近两 ...

  7. 想上BI系统,原来的Excel优秀模板都丢弃吗?

    我们公司之前一直都用Excel来存储数据,展示数据,Excel本身拥有强大的公式可以帮助我们的数据进行再加工计算,Excel的图形我们可以可以直接拿来展示数据,Excel本身还有数据透视表帮助我们的分 ...

  8. 大数据BI系统搭建对企业经营的作用有哪些

    随着数据化时代的到来,企业为了适应高速发展的业务.维持自身更好的发展,纷纷开始寻求适合自身企业发展的BI系统.为什么BI系统会受到企业如此的青睐?BI系统对企业经营究竟有哪些方面的作用呢? 下面,小编 ...

  9. 大数据BI系统是怎么助力企业长久发展的

    多元化集团企业在发展到一定阶段后,往往会遇到业务与财务分离.管理缺乏系统决策支持等管理问题.财务决策支持系统建设实施BI是管理升级的内在要求. 1996年,加特纳集团提出了商业智能(Businesin ...

随机推荐

  1. 单机部署PXC

    在一台机器上安装PXC Linux:centos 7     IP:192.168.30.221 PXC版本:Percona-XtraDB-Cluster-5.7.17-rel13-29.20.3.L ...

  2. http之状态码含义

    状态代码有三位数字组成,第一个数字定义了响应的类别,共分五种类别: 1xx:指示信息--表示请求已接收,继续处理 2xx:成功--表示请求已被成功接收.理解.接受 3xx:重定向--要完成请求必须进行 ...

  3. Flask Web 开发 错误页面自定义

    如果要自定义错误画面,无法大多数情况是自定义404和500的情况 首先,要在路由中设置 通过app.error_handler这个装饰器来绑定响应函数 @main.errorhandler(404) ...

  4. spring AOP的注解实例

    上一篇写了spring AOP 的两种代理,这里开始AOP的实现了,个人喜欢用注解方式,原因是相对于XML方式注解方式更灵活,更强大,更可扩展.所以XML方式的AOP实现就被我抛弃了. 实现Sprin ...

  5. Errors occurred during the build. Errors running builder 'DeploymentBuilder' on project

    本文转自:http://www.phperz.com/article/14/1205/39544.html 本文向大家讲解了Myeclipse错误:Errors occurred during the ...

  6. CentOS7搭建Gitlab详细过程

    1.参见Gitlab官网说明 原文地址:https://about.gitlab.com/install/#centos-7   1.安装并配置必要的依赖项 在CentOS 7(和RedHat / O ...

  7. kotlin 学习感受

    目录 kotlin 学习感受 特点 优点 屎一样的缺点 总结 kotlin 学习感受 直白的说..很不好,像屎一样,本来对此抱有很大的期望和好感度,但经过一整天的学习,完全失望了,这门语言中间有各种的 ...

  8. JS实现焦点图轮播效果

    大家平时逛淘宝网的时候,在首页就能看到焦点图轮播的效果,就是这个样子的: PS:想起每每打开淘宝,总会被这个玩意先夺眼球,偶尔还去点进去溜溜,幸好我定力好,总能控制住自己的购买欲望,为自己不用剁手感到 ...

  9. git clone,push,pull,fetch命令详解

    源自 Git是目前最流行的版本管理系统,学会Git几乎成了开发者的必备技能. Git有很多优势,其中之一就是远程操作非常简便.本文详细介绍5个Git命令,它们的概念和用法,理解了这些内容,你就会完全掌 ...

  10. ubinize的用法

    1.ubinize支持哪些选项 Usage: ubinize [options] <ini-file> Generate UBI images. An UBI image may cont ...