BI系统之统计图表的绘制[后端实现]
因为在开发内部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系统之统计图表的绘制[后端实现]的更多相关文章
- 国内经典BI系统架构分析
谈起商业智能BI,也许大家并不陌生,但你是否了解国内的各类BI系统架构? 自国内商业智能发展以来,就系统结构方面已经历了多次优化性的变革.目前国内商业智能BI系统的经典架构的模式包括数据层.业务层和应 ...
- BI系统与KPI指标的整合分析
今天我们要说的是信息化时代下关于企业运营的两个热词:BI系统和KPI指标.一直到现在,企业运营的方方面面都在被数据化,成为庞大信息流的一部分,这一庞大的信息流,正以我们自己都尚未完全意识到的速度和规模 ...
- BI系统的应用组织思路与数据分析模式
BI商业智能软件一般都会提供若干数据整合.数据查询.分析与评价.数据可视化及数据分享的手段,但是在BI项目的构建与实施过程中,如果不按照一定的应用组织思路.数据分析模式及分析流程使用这些工具或手段,呈 ...
- 企业BI系统应用的切入点及五大策略
从技术的角度来看,BI的技术正在走向成熟,处于一个发展的阶段,但它促使了BI的应用在成本方面开始逐步的降低,越来越多的企业在BI应用方面取得了成功.从实施的角度来出发,实施商业智能系统是一项复杂的系统 ...
- 大数据时代的新BI系统架构发展趋势
商业智能(BI,Business Intelligence).它是一套完整的解决方式,用来将企业中现有的数据进行有效的整合,高速准确的提供报表并提出决策根据.帮助企业做出明智的业务经营决策. ...
- BI系统要自研还是采购?这篇文章告诉你
首先说一下目前市面上的BI工具都有哪些吧.总体上,其实分为免费和付费两大阵营.免费阵营里,为首的当然是GA(也就是谷歌分析).PowerBI,但是由于有墙的限制,很多公司没法使用前者.付费阵营里,近两 ...
- 想上BI系统,原来的Excel优秀模板都丢弃吗?
我们公司之前一直都用Excel来存储数据,展示数据,Excel本身拥有强大的公式可以帮助我们的数据进行再加工计算,Excel的图形我们可以可以直接拿来展示数据,Excel本身还有数据透视表帮助我们的分 ...
- 大数据BI系统搭建对企业经营的作用有哪些
随着数据化时代的到来,企业为了适应高速发展的业务.维持自身更好的发展,纷纷开始寻求适合自身企业发展的BI系统.为什么BI系统会受到企业如此的青睐?BI系统对企业经营究竟有哪些方面的作用呢? 下面,小编 ...
- 大数据BI系统是怎么助力企业长久发展的
多元化集团企业在发展到一定阶段后,往往会遇到业务与财务分离.管理缺乏系统决策支持等管理问题.财务决策支持系统建设实施BI是管理升级的内在要求. 1996年,加特纳集团提出了商业智能(Businesin ...
随机推荐
- Android初体验之Monkey和MonkeyRunner
原文地址https://blog.csdn.net/mad1989/article/details/38087737 Monkey 什么是Monkey Monkey是Android中的一个命令行工具, ...
- flask jinja的宏
form中关于表单的定义 class AreaListForm(Form): area1 = BooleanField(u'1区', default=False) area2 = BooleanFie ...
- Apache HttpClient4使用教程
基于HttpClient 4.5.2 执行GET请求 CloseableHttpClient httpClient = HttpClients.custom() .build(); Closeable ...
- Linux 中各个文件夹的作用
/ 根目录 包含了几乎所的文件目录.相当于中央系统.进入的最简单方法是:cd /. /boot 引导程序,内核等存放的目录 这个目录,包括了在引导过程中所必需的文件.在最开始的启动阶段,通过引导程 ...
- Tensorflow源码编译,解决tf提示未使用SSE4.1 SSE4.2 AVX警告【转】
本文转载自:https://blog.csdn.net/iTaacy/article/details/72799833 版权声明:欢迎转载,转载请注明出处! https://blog.csdn.net ...
- Python学习札记(三十) 面向对象编程 Object Oriented Program 1
参考:OOP NOTE 1.面向对象编程--Object Oriented Programming,简称OOP,是一种程序设计思想.OOP把对象作为程序的基本单元,一个对象包含了数据和操作数据的函数. ...
- Mininet实验 自定义拓扑结构
参考:MiniNet实验2 通过Mininet学习可视化操作,可以在界面上方便的构建拓扑结构. 最新的Mininet 2.2.0内置了一个mininet可视化工具miniedit.miniedit在/ ...
- spring boot2 基于百度云apiface实现人脸检测与认证1
原理介绍: 基于百度云的人脸资料库(用户上传),调用本地摄像头抓拍的图像,与百度云的用户图像做比对,实现人脸认证. 主要步骤如下: 1. 创建百度去账号 2. 在百度云控制台中创建人脸识别的应用,并记 ...
- BZOJ 2333 【SCOI2011】 棘手的操作
题目链接:棘手的操作 网上的题解大部分都是在线用可并堆艹……但是树高严格\(\log\)的可并堆我不会啊……还是离线大法好…… 我们可以先把所有的合并操作用并查集给处理好,把得到的森林记录下来.然后, ...
- 例子.ZC简单.JSP和session
1.环境: Win7x64.E:\ZC_IDE\Eclipse\Windows\eclipse-jee-mars-R-win32__apk__20180122_1457\eclipse.exe.E:\ ...