php柱状图多系列动态实现
时间:2018-12-10
本文章向大家介绍php柱状图多系列动态实现,主要包括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();
本篇为博主原创文章,如需转载请注明出处,谢谢!
- demo1 动态显示view或弹框 动态隐藏view或弹框
- 从零开始的Spring Security Oauth2(一)
- 细说Android事件传递
- swift基础_ set get方法 理解
- 高仿今日头条(2)
- ios tableview 上加 textfiled
- Spring Cloud实战小贴士:Feign的继承特性(伪RPC模式)
- 仿淘宝购买详情页购买缩小动画
- 高仿今日头条(1)
- android Native堆
- Spring Boot中Web应用的统一异常处理
- android bitmap的内存分配和优化
- Gitflow工作流程
- Android学习第一弹:Android通过用代码画虚线椭圆边框背景来学习一下shape的用法
- php概述
- php教程
- php环境搭建
- PHP书写格式
- php变量
- php常量
- PHP注释
- php数组
- php字符串 string
- PHP整型 integer
- PHP浮点型 float
- php布尔型
- php数据类型之数组
- php数据类型之对象
- php数据类型之null
- php数据类型之间的转换
- php运算符
- php表达式
- PHP循环控制
- PHP流程控制
- php函数
- php全局变量
- PHP魔术变量
- php命名空间
- php 日期
- PHP包含文件
- php文件
- PHP 文件上传
- php Cookies
- php Sessions
- php email
- php安全email
- php错误处理
- PHP异常处理
- php过滤器
- PHP 高级过滤器
- php json
- php 表单
- PHP MySQL 简介
- PHP 连接 MySQL
- php创建数据库
- php 创建表
- php mysq 插入数据
- PHP MySQL 插入多条数据
- PHP MySQL 预处理语句
- php mysql 读取数据
- php mysql where
- PHP MySQL Order By
- PHP MySQL Update
- PHP MySQL Delete
- php ODBC
- 发布 Angular 应用至生产环境
- 在 NHibernate 中使用 Snow Flake ID
- 在 Angular 应用中创建包含组件
- PostgreSQL 数据库中的窗口函数
- 代码整洁的 JavaScript
- Script 标记的 defer 和 async 属性说明
- 百行代码轻松爬取视频
- WebLogic coherence UniversalExtractor 反序列化 (CVE-2020-14645) 漏洞分析
- equals和hashCode你学会了么?
- 15 张精美动图全面讲解 CORS
- Rasa X 安装之Docker Compose 模式
- 使用Vue写个首页,原来这么简单
- 5分钟内搭建你的第一个Python聊天机器人
- dotnet 获取进程命令行参数的工具
- SpringFramework之ViewResolver优化