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 ...
随机推荐
- php5.6安装gd库
rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -Uvh ht ...
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
一.什么是跨域访问 举个栗子:在A网站中,我们希望使用Ajax来获得B网站中的特定内容.如果A网站与B网站不在同一个域中,那么就出现了跨域访问问题.你可以理解为两个域名之间不能跨过域名来发送请求或者请 ...
- 5.5 Components -- Customizing A Compnent's Element
一.概述 默认的,每一个组件都基于一个<div>元素.如果你在开发者工具中查看一个渲染的组件,你将会看到一个像这样的DOM表示: <div id="ember180&quo ...
- (5)调度器(scheduler)
继承关系 原理介绍 Cocos2d-x调度器为游戏提供定时事件和定时调用服务.所有Node对象都知道如何调度和取消调度事件,使用调度器有几个好处: 每当Node不再可见或已从场景中移除时,调度器会停止 ...
- macbook 蓝牙关闭按钮灰色的
PRAM重置:1.关机,拔掉所有外设,只连接电源线2.按开机键,接着马上同时按住 command+option+p+r 键,按住后听到三次dang的开机音后放开3.电脑会自行启动,进到登录页面后点关机 ...
- ACM ICPC, Amman Collegiate Programming Contest (2018) Solution
Solution A:Careful Thief 题意:给出n个区间,每个区间的每个位置的权值都是v,然后找长度为k的区间,使得这个区间的所有位置的权值加起来最大,输出最大权值, 所有区间不重叠 思路 ...
- 2018-2019 ICPC, NEERC, Northern Eurasia Finals (Unrated, Online Mirror, ICPC Rules, Teams Preferred) Solution
A. Alice the Fan Solved. 题意: 两个人打网球,要求teamA 的得分与其他队伍拉开尽量大 输出合法的方案 思路: $dp[i][j][k][l] 表示 A 赢i局,其他队伍赢 ...
- Python:执行精确的浮点数运算
需要对浮点数执行精确的计算操作,并且不希望有任何小误差的出现. 浮点数的一个普遍问题是它们并不能精确的表示十进制数.并且,即使是最简单的数学运算也会产生小的误差,比如: >>> a ...
- Hopper Disassembler v4 ( The macOS Disassembler, Decompiler and Debugger)
Hopper Disassembler v4 ( The macOS Disassembler, Decompiler and Debugger) Reveal13 (UI) 两个好东西..不知道的自 ...
- linux第七周
可执行程序的装载 一.预处理.编译.链接和目标文件的格式 可执行文件的创建——预处理.编译和链接 cd Code vi hello.c gcc -E -o hello.cpp hello.c -m32 ...