php柱状图多系列动态实现
<?php
require_once 'data.php';
require_once 'jpgraph/src/jpgraph.php';
require_once"jpgraph/src/jpgraph_bar.php";
$arr1=$a->sum('answer','answer_id=1');
$arr2=$a->sum('answer','answer_id=2');
$arr3=$a->sum('answer','answer_id=3');
$arr4=$a->sum('answer','answer_id=4');
$arr5=$a->sum('answer','answer_id=5');
$arr6=$a->sum('answer','answer_id=6');
for($i=0;$i<10;$i++){
$datay1[$i]=$arr1[$i]['numbers'];
$datay2[$i]=$arr2[$i]['numbers'];
$datay3[$i]=$arr3[$i]['numbers'];
$datay4[$i]=$arr4[$i]['numbers'];
$datay5[$i]=$arr5[$i]['numbers'];
$datay6[$i]=$arr6[$i]['numbers'];
}
//设置显示的数据数组;
//调用类库
$x = array("1","2","3","4","5","6","7","8","9","10");
//设置图像的大小
$graph = new Graph(1000,500); //创建新的Graph对象
$graph->SetScale("textlin"); //刻度样式
$graph->SetShadow(); //设置阴影
$graph->img->SetMargin(40,30,40,50); //设置边距
$graph->graph_theme = null; //设置主题为null,否则value->Show(); 无效
$ybplot1 = new BarPlot($datay1); //创建BarPlot对象
$ybplot2 = new BarPlot($datay2);
$ybplot3 = new BarPlot($datay3);
$ybplot4 = new BarPlot($datay4);
$ybplot5 = new BarPlot($datay5);
$ybplot6 = new BarPlot($datay6);
$barplot = new GroupBarPlot(array($ybplot1,$ybplot2,$ybplot3,$ybplot4,$ybplot5,$ybplot6));
$ybplot1->SetFillColor('red'); //设置颜色
$ybplot2->SetFillColor('blue'); //设置颜色
$ybplot3->SetFillColor('green'); //设置颜色
$ybplot4->SetFillColor('gray'); //设置颜色
$ybplot5->SetFillColor('orange');
$ybplot6->SetFillColor('#000');
$ybplot1->value->Show(); //设置显示数字
$ybplot2->value->Show(); //设置显示数字
$ybplot3->value->Show(); //设置显示数字
$ybplot4->value->Show(); //设置显示数字
//$ybplot5->value->show();
//$ybplot6->value->show();
$graph->Add($barplot); //将柱形图添加到图像中
$graph->title->Set("统计");
$graph->xaxis->title->Set("题目"); //设置标题和X-Y轴标题
$graph->yaxis->title->Set("人数(个人)");
$graph->title->SetColor("black");
$graph->title->SetMargin(10);
$graph->xaxis->title->SetMargin(3);
$graph->yaxis->title->SetMargin(-5);
$graph->xaxis->SetTickLabels($x);
$graph->title->SetFont(FF_SIMSUN,FS_BOLD); //设置字体
$graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
$graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
$graph->xaxis->SetFont(FF_SIMSUN,FS_BOLD);
$graph->Stroke();
本篇为博主原创文章,如需转载请注明出处,谢谢!
php柱状图多系列动态实现的更多相关文章
- C#进阶系列——动态Lamada(二:优化)
前言:前几天写了一篇动态Lamada的文章C#进阶系列——动态Lamada,受园友xiao99的启发,今天打算来重新优化下这个动态Lamada的工具类.在此做个笔记,以免以后忘了. 一.原理分析 上篇 ...
- 【转载】C#进阶系列——动态Lamada(二:优化)
前言:前几天写了一篇动态Lamada的文章C#进阶系列——动态Lamada,受园友xiao99的启发,今天打算来重新优化下这个动态Lamada的工具类.在此做个笔记,以免以后忘了. 一.原理分析 上篇 ...
- 柱状图多系列php动态实现(ec)
<?php require_once 'data.php'; $arr1=$a->sum('answer','ask_id=1'); $arr2=$a->sum('answer',' ...
- C#进阶系列——动态Lamada
前言:在DDD系列文章里面,我们在后台仓储里面封装了传递Lamada表达式的通用方法,类似这样: public virtual IQueryable<TEntity> Find(Expre ...
- 【转载】C#进阶系列——动态Lamada
前言:在DDD系列文章里面,我们在后台仓储里面封装了传递Lamada表达式的通用方法,类似这样: public virtual IQueryable<TEntity> Find(Expre ...
- SpringBoot系列——动态定时任务
前言 定时器是我们项目中经常会用到的,SpringBoot使用@Scheduled注解可以快速启用一个简单的定时器(详情请看我们之前的博客<SpringBoot系列--定时器>),然而这种 ...
- objective-c系列-动态类型和动态绑定
/* 静态类型: 变量的类型在编译之时就被确定下来. 动态类型: 对象的类型由对象的内存里的某个结构数据来决定它是什么类型, 而不是在编译之时就被确定下来的数据类型. 对象的类型只有在运行时才知道. ...
- [Flex] Accordion系列-动态添加或删除Accordion容器中项目
<?xml version="1.0" encoding="utf-8"?> <!--Flex中如何使用addChild()和removeCh ...
- Vue系列——动态设置img标签的src属性
声明 本文转自:vue动态设置img的src路径 正文 相信开发的小伙伴已经遇到这个问题了,动态切换img标签的src时,写的路径就是不生效,原因是vue并没有把你的路径字符串当做路径来处理,而是直接 ...
随机推荐
- windows RT开发笔记:WinRT DLL及其调用研究
一. 几个概念: WinRT : Windows Runtime, windows运行时.创建Windows运行时(WinRT)是为了在Windows上给用户提供一种流畅且安全的应用体验.WinRT会 ...
- C#程序集
我的理解: 程序集是一个物理上的概念,一个项目生成的exe或者dll都可以叫做一个程序集,internal修饰的内容可以在程序集内可见.
- CSS和文档流
1. CSS的定位机制有3种:普通流.浮动和定位. 2. 文档流:从上到下,从左到右,一个挨一个的简单或者叫正常布局. 3. 定位:(position) Static:保持文档流. Relati ...
- Java应用程序
示例: public class HelloWorld { public static void main(String[] args) { System.out.println("Hell ...
- 深入Python(1): 字典排序 关于sort()、reversed()、sorted()
http://www.cnblogs.com/BeginMan/p/3193081.html 一.Python的排序 1.reversed() 这个很好理解,reversed英文意思就是:adj. 颠 ...
- Kubernetes JSONpath Support
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=test-nginx,ap ...
- Facebook 新开源了 2 个东西,一个语音识别系统(wav2letter++)和一个机器学习库(flashlight)
Open sourcing wav2letter++, the fastest state-of-the-art speech system, and flashlight, an ML librar ...
- php文件编程
一:文件常见操作 流的概念:当数据从程序(内存)->文件(磁盘),我们称为输出流,当数据从文件(磁盘)->程序(内存),我们称为输入流 1,获取文件信息 <?php //打开文件 f ...
- ORA-07445: exception encountered: core dump [kglpin()+527]
此报错在MOS上查到了相关信息:APPLIES TO: Oracle Database - Enterprise Edition - Version 11.2.0.4 and laterInforma ...
- 一种不通过UI给C4C自定义BO创建测试数据的方式
假设我在Cloud Studio里创建了如下一个非常简单的自定义BO: 我想生成一些该BO的实例.以前我采用的做法是给这个自定义BO创建编辑用的UI.然后使用这些UI创建BO实例.这种方式很花费时间. ...