<?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. SQL Server数据类型一览表

    数据类型 类型 描             述 bit 整型 bit 数据类型是整型,其值只能是0.1或空值.这种数据类型用于存储只有两种可能值的数据,如Yes 或No.True 或Fa lse .O ...

  2. Web测试中定位bug方法

    在web测试过程中,经常会遇到页面中内容或数据显示错误,甚至不显示,第一反应就是BUG,没错,确实是BUG.进一步了解这个BUG的问题出在那里,是测试人员需要掌握的,可以简单的使用浏览器自带开发者工具 ...

  3. CodeMirror教程,CodeMirrorAPI中文信息

    <html> <head>     <link rel="stylesheet" href="codemirror.css"> ...

  4. import模块后查找模块的绝对路径

    >>> import bsddb3>>> bsddb3.__file__'/usr/local/lib/python2.6/site-packages/bsddb3 ...

  5. python加解密

    from Crypto.Cipher import AES import base64 secret_key = '1234567890123456' # 密匙 msg_text = 'test so ...

  6. day011-网络编程

    1. 网络编程概述 1.1  网络编程三要素 地址.端口.协议 1.1.1 IP地址:网络中设备的唯一标识. IPV4格式:xxx.xxx.xxx.xxx由四段数字组成,每一段数字由八位二进制数字组成 ...

  7. 配置karma支持Chrome浏览器

    准备:项目中已搭建好了karma. 前言:利用vue-cli初始化创建vue项目时,已经搭建好了测试框架 karma+mocha,但是此时karma默认启动的浏览器是 phantomjs,而我想用 C ...

  8. A full JDK must be specified

    当你开发就了,你就发现,你遇到了各种奇葩的问题,结果,自己奇葩了. 背景:由于项目需要做安全恢复测试,然后,就搭一个新的库环境去测试: 配置jboss的运行jdk时,结果,蹦出个:A full JDK ...

  9. May 18th 2017 Week 20th Thursday

    The greater the struggle, the more glorious the triumph. 挑战愈艰巨,胜利愈辉煌. Sometimes it would be better t ...

  10. datatable 动态显示/隐藏列

    这个例子演示了 column().visible()方法来隐藏显示列,通过点击列按钮动态切换 <table id="example" class="display& ...