<?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柱状图多系列动态实现的更多相关文章

  1. C#进阶系列——动态Lamada(二:优化)

    前言:前几天写了一篇动态Lamada的文章C#进阶系列——动态Lamada,受园友xiao99的启发,今天打算来重新优化下这个动态Lamada的工具类.在此做个笔记,以免以后忘了. 一.原理分析 上篇 ...

  2. 【转载】C#进阶系列——动态Lamada(二:优化)

    前言:前几天写了一篇动态Lamada的文章C#进阶系列——动态Lamada,受园友xiao99的启发,今天打算来重新优化下这个动态Lamada的工具类.在此做个笔记,以免以后忘了. 一.原理分析 上篇 ...

  3. 柱状图多系列php动态实现(ec)

    <?php require_once 'data.php'; $arr1=$a->sum('answer','ask_id=1'); $arr2=$a->sum('answer',' ...

  4. C#进阶系列——动态Lamada

    前言:在DDD系列文章里面,我们在后台仓储里面封装了传递Lamada表达式的通用方法,类似这样: public virtual IQueryable<TEntity> Find(Expre ...

  5. 【转载】C#进阶系列——动态Lamada

    前言:在DDD系列文章里面,我们在后台仓储里面封装了传递Lamada表达式的通用方法,类似这样: public virtual IQueryable<TEntity> Find(Expre ...

  6. SpringBoot系列——动态定时任务

    前言 定时器是我们项目中经常会用到的,SpringBoot使用@Scheduled注解可以快速启用一个简单的定时器(详情请看我们之前的博客<SpringBoot系列--定时器>),然而这种 ...

  7. objective-c系列-动态类型和动态绑定

    /* 静态类型: 变量的类型在编译之时就被确定下来. 动态类型: 对象的类型由对象的内存里的某个结构数据来决定它是什么类型, 而不是在编译之时就被确定下来的数据类型. 对象的类型只有在运行时才知道. ...

  8. [Flex] Accordion系列-动态添加或删除Accordion容器中项目

    <?xml version="1.0" encoding="utf-8"?> <!--Flex中如何使用addChild()和removeCh ...

  9. Vue系列——动态设置img标签的src属性

    声明 本文转自:vue动态设置img的src路径 正文 相信开发的小伙伴已经遇到这个问题了,动态切换img标签的src时,写的路径就是不生效,原因是vue并没有把你的路径字符串当做路径来处理,而是直接 ...

随机推荐

  1. 14_synchronized深入

    [脏读] 对于对象同步和异步的方法,我们在设计程序的时候,一定要考虑问题的整体,不然会出现不一致的错误,最经典的错误的就是脏读(dirty read). [实例代码] package com.higg ...

  2. laravel5.4学习笔记

    1.安装laravel可以直接用composer安装,然后用laravel new xxx来新建项目 服务器上安装了composer(php包管理工具)以后, composer global requ ...

  3. WAKE-SPM-综述

    1,SPM 1,1source paper:http://lear.inrialpes.fr/pubs/2007/ZMLS07/ZhangMarszalekLazebnikSchmid-IJCV07- ...

  4. ORA-07445: exception encountered: core dump [kglpin()+527]

    此报错在MOS上查到了相关信息:APPLIES TO: Oracle Database - Enterprise Edition - Version 11.2.0.4 and laterInforma ...

  5. Locust性能测试2 分布式运行

    locust分布式可以是本机多进程,也可以是本机作为master,其他机器作slave. 试一下本机的多进程运行: 1  控制台输入 locust -f 脚本路径 --master 2  打开另一个控 ...

  6. 面条代码 vs. 馄沌代码

    转载自:https://blog.csdn.net/godsme_yuan/article/details/6594013

  7. Android(java)学习笔记57:PC and Phone 通信程序

    1. 首先我写的程序代码如下: package com.himi.udpsend; import java.net.DatagramPacket; import java.net.DatagramSo ...

  8. 昨天刚看了Handler和HandlerThread这个东西,不明白为什么要用这么复杂的东西,而且Handler直接post的话好像还不是子线程运行。那我再开发的时候直接用Thread行不行?两个有什么区别?

    Handler就是android中一个机制,主要是考虑到线程安全的! Handler是可以实现线程间通信的,LZ知道Android的UI线程不安全的吧,也就是说不可以在UI线程以外的其他线程对UI进行 ...

  9. sougou输入法无法正常输入汉字

    删除~/.config目录下的SougouPY SogouPY.users sogou-qimpanel文件夹,然后重启搜狗输入法即可

  10. markdown的常用高级操作。

    符号 说明 对应编码(使用时去掉空格) 英文怎么说 & AND 符号 & amp; ampersand < 小于 & lt; little 大于 & gt; gr ...