利用JpGraph,可视化数据库中的数据
来源:互联网 发布:重庆网络审批平台 编辑:程序博客网 时间:2024/05/16 23:49
1. 数据库配置文件(创建数据库和表)dbconfig.php文件
<?phpmysql_connect('localhost', 'root', '');mysql_select_db('test');$createtb = "create table if not exists user( id int(20) primary key auto_increment, username varchar(50), password varchar(50), time int(11) )";mysql_query($createtb);?>
2. 往user 数据表中添加两条数据
3. 读取数据表中的数据,利用JpGraph进行plot, plot.php文件
<?php // content="text/plain; charset=utf-8"require_once ('../test/jpgraph/jpgraph.php');require_once ('../test/jpgraph/jpgraph_bar.php');include "dbconfig.php";$sql="select * from user order by id";$rst=mysql_query($sql);//$data1y=array(1,2);$data2y=array();while($row=mysql_fetch_assoc($rst)){ array_push($data2y,$row['id']);}// Create the graph. These two calls are always required$graph = new Graph(700,600); $graph->SetScale("textlin");$graph->SetShadow();$graph->img->SetMargin(40,30,20,40);// Create the bar plots//$b1plot = new BarPlot($data1y);//$b1plot->SetFillColor("orange");//$b1plot->value->Show();$b2plot = new BarPlot($data2y);$b2plot->SetFillColor("blue");$b2plot->value->Show();// Create the grouped bar plot//$gbplot = new AccBarPlot(array($b1plot,$b2plot));$gbplot = new AccBarPlot(array($b2plot));// ...and add it to the graPH$graph->Add($gbplot);$graph->title->Set("Accumulated bar plots");$graph->xaxis->title->Set("X-title");$graph->yaxis->title->Set("Y-title");$graph->title->SetFont(FF_FONT1,FS_BOLD);$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);// Display the graph$graph->Stroke();?>
4. 运行plot.php文件,效果如下,
5. 具体细节在另一片博客上写得很详细http://blog.csdn.net/canhui_wang/article/details/78563745
参考
http://blog.csdn.net/canhui_wang/article/details/78563745
阅读全文
0 0
- 利用JpGraph,可视化数据库中的数据
- 从数据库提取数据利用jpgraph画统计图柱形图
- 可视化中的数据
- 利用Python数据可视化工具plotly从数据库读取数据制作本地图表应用实例
- 利用ajax结合highchart和Spring实现数据可视化中的柱状图
- 可视化 DB2 中的空间数据
- 数据可视化中的图形选择
- 数据可视化中的视觉属性
- 数据挖掘中的可视化方法
- 利用Jpgraph创建折线图
- 可视化之一——利用R实现地图数据可视化
- 利用javascript实现可视化数据备份[原创]
- 利用Python可视化MINIST数据集
- 利用pandas进行数据分组及可视化
- 利用Excel进行简单的数据可视化
- 四、利用leaflet实现OSM数据可视化
- 利用R语言进行交互数据可视化
- 【Python】 利用汽车数据进行可视化分析
- 看单片机和数字电路怎么抗干扰
- String的Intern方法探析
- C小知识点 : 无符号数与有符号数运算
- Python SMTP 发送带附件电子邮件
- idea快捷键
- 利用JpGraph,可视化数据库中的数据
- 配置maven环境
- DX(DevExpress)RichEditControl 控件 生成导航栏,点击定位到文本
- Mysql在大型网站的应用架构演变
- java实现解压缩工具方法
- Eclipse 中设置JVM 内存及JVM监控调优
- RDB和AOF持久化对比
- mysql配置版安装使用说明,mysql-5.7.20
- java如何实现让程序暂停1s再继续执行?