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并没有把你的路径字符串当做路径来处理,而是直接 ...
随机推荐
- LeetCode刷题系列——Add Two Numbers
题目链接 这个题目很简单,归并而已,好久没练编程,居然忘了在使用自定义类型前,要进行初始化(new操作). class ListNode{ int val; ListNode next; ListNo ...
- Win SDK 标准程序
//-Registering window class. //-Creating window. //-Creating message loop. //-Implement WndProc func ...
- Hadoop ->> HDFS(Hadoop Distributed File System)
HDFS全称是Hadoop Distributed File System.作为分布式文件系统,具有高容错性的特点.它放宽了POSIX对于操作系统接口的要求,可以直接以流(Stream)的形式访问文件 ...
- 离线安装wxpython
离线安装wxpython 前言 由于工作环境,我的工作机是在离线环境下的,没法连接外网.但是自己又想学习一下wxpython,只好自己手动离线安装,本来以为很简单的,但是实际上...一言难尽. 基本环 ...
- bind 详解
请看我的有道云笔记: http://note.youdao.com/noteshare?id=eaf4194473cf4294776fbc263ffe6b89&sub=5CB214C594E0 ...
- tensorflow报错 tensorflow Resource exhausted: OOM when allocating tensor with shape
在使用tensorflow的object detection时,出现以下报错 tensorflow Resource exhausted: OOM when allocating tensor wit ...
- Scrum _GoodJob
作为长大的大三老腊肉,我们已经在长大生活了两年多,对于什么是长大人最想完善的校园需求.最想拥有的校园服务媒介也有了更加深切的体会. 于是,GoodJob小团队blingbling闪现啦!! GoodJ ...
- Jerry的CRM Middleware(中间件)文章合集
我在SAP成都研究院做过的CRM中间件的项目其实并不是很多: 1. 2013年下半年和2014年上半年曾经支持过中联重科和蒙牛的CRM项目相关的中间件问题; 2. 2014年上半年做过一个CRM物料主 ...
- 关于 org.hibernate.TransientObjectException 异常
在Hibernate的关联关系中,如果一个对象A 持有 对象 B 的引用,如果先保存 A ,再保存B,那么会出现 org.hibernate.TransientObjectException 异常. ...
- 超简单,快速修改Oracle10g的默认8080端口
因为Oracle数据库默认的端口是8080,这也是tomcat服务器的默认端口. 为了避免端口冲突,我们通常会修改掉其中一个. 这里我们选择修改Oracle数据库的端口. 第一步:以管理员身份运行cm ...