因为在开发内部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. Saltstack数据系统

    1.grainsgrains 是在 minion(客户端)启动时收集到的一些信息,比如操作系统类型.网卡ip等.强调是minion启动时收集到的数据,所以如果改了什么硬件啥的,要重启minion才能收 ...

  2. cocos代码研究(23)Widget子类ScrollView学习笔记

    基础理论 一个能够被用户触摸滚动的一个层次型布局容器视图,允许其尺寸大于屏幕显示的物理尺寸,其内部维护有一个布局用于水平的或垂直的存放子节点.继承自 Layout,被 ListView 继承. 代码实 ...

  3. #C++初学记录(阶乘#递归)

    练习题目三 用递归进行阶乘 运行代码 #include<iostream> using namespace std; int f(int n); int n; int main() { c ...

  4. VS2010/MFC编程入门之前言

    鸡啄米的C++编程入门系列给大家讲了C++的编程入门知识,大家对C++语言在语法和设计思想上应该有了一定的了解了.但是教程中讲的例子只是一个个简单的例程,并没有可视化窗口.鸡啄米在这套VS2010/M ...

  5. Android 自定义View-字母索引表(一)

    在有些Android应用中,为了方便快速定位,经常会看到屏幕右侧有一个字母索引表,今天尝试使用自定义View的方式实现了索引表的基本布局. 字母索引表的样式如下面的示意图所示, 此时我们至少需要知道以 ...

  6. C#反射——模仿ParameterInterceptor(ashx处理程序)

    反射工具类请参见:https://www.cnblogs.com/threadj/p/10535796.html using System; using System.Collections.Gene ...

  7. Union、Union All、Intersect、Minus用法和区别

    假设我们有一个表Student,包括以下字段与数据: [c-sharp] view plain copydrop table student;    create table student  (   ...

  8. 深入理解jvm--Java中init和clinit区别完全解析(转)

    转自:http://blog.csdn.net/u013309870/article/details/72975536 init和clinit区别 ①init和clinit方法执行时机不同 init是 ...

  9. 欧几里德和扩展欧几里德详解 以及例题CodeForces 7C

    欧几里德定理: 对于整数a,b来说,gcd(a, b)==gcd(b, a%b)==d(a与b的最大公约数),又称为辗转相除法 证明: 因为a是d的倍数,b是d的倍数:所以a%d==0:b%d==0: ...

  10. exception disappear when forgot to await an async method

    https://github.com/aspnet/AspNetWebStack/issues/235 https://stackoverflow.com/questions/5383310/catc ...