当前位置:网站首页>thinkphp5+数据大屏展示效果
thinkphp5+数据大屏展示效果
2022-04-23 14:48:00 【游戏编程】
1控制器代码展示:

控制器代码:
// 加载页面后输出的数据 public function index() { $data = Db::name('index')->limit(5)->select(); $this->assign('data',$data); $this->display(); return view('index'); } // 异步获取数据 public function data(){ $list = Db::name('index')->limit(5)->select(); // 重组数组 foreach ($list as $key => $value) { $arr['id'][] = $value['id']; $arr['name'][] = $value['name']; $arr['number'][] = $value['number']; $arr['details'][] = $value['details']; $arr['create_time'][] = $value['create_time']; } die(json_encode($arr)); //转换为json数据输出 }
html代码:
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>ECharts</title> <!-- 引入 echarts.js --> <script src="echarts.min.js"></script></head><body><!-- 为ECharts准备一个具备大小(宽高)的Dom --><div id="main" style="width: 600px;height:400px;"></div></body><script src="http://code.jquery.com/jquery-2.2.1.min.js"></script><script type="text/javascript"> var myChart; myChart = echarts.init(document.getElementById('main')); myChart.setOption({ title: { text: '异步数据加载示例' }, tooltip: {}, legend: { data:['销量'] }, xAxis: { // 加载页面后显示在图表中的X轴信息 data: [<?php foreach($data as $v){; ?>"<?php echo $v['name'] ?>",<?php }; ?>] }, yAxis: {}, series: [{ name: '销量', // type: 'line',// 折线图 type: 'bar',//柱状图 // 加载页面后显示在图表中的Y轴信息 data: [<?php foreach($data as $v){; ?>"<?php echo $v['number'] ?>",<?php }; ?>], itemStyle:{ // 颜色定义 normal:{color:'#00bc12'} } }] }); // 异步加载后台数据,通过定时器在实现 var i = 0; function run() { i++; $.ajax({ url: "{:url('index/index/data')}", type: 'POST', dataType: 'JSON', data:{page:i}, success:function(json){ if(json.datetime.length != 5){ clearInterval(time); return; } myChart.setOption({ xAxis: { data: json.create_time }, series: [{ name: '销量', data: json.details }] }); } }) }; <!--var time = setInterval(run,3000);--></script></html>
显示效果展示:

数据库展示:

折线图效果:

作者:骨子里的偏爱
游戏编程 ️,一个游戏开发收藏夹~
如果图片长时间未显示,请使用Chrome内核浏览器。
版权声明
本文为[游戏编程]所创,转载请带上原文链接,感谢
https://www.233tw.com/php/118838
边栏推荐
- [servlet] detailed explanation of servlet (use + principle)
- 555 timer + 74 series chip to build eight way responder, 30s countdown, proteus simulation, etc
- 科技的成就(二十一)
- Matrix exchange row and column
- 如何打开Win10启动文件夹?
- OpenFaaS实战之四:模板操作(template)
- 冰冰学习笔记:一步一步带你实现顺序表
- Outsourcing for four years, abandoned
- UML project example -- UML diagram description of tiktok
- 剑指 Offer II 019. 最多删除一个字符得到回文(简单)
猜你喜欢
线程同步、生命周期
一个月把字节,腾讯,阿里都面了,写点面经总结……
Explanation and example application of the principle of logistic regression in machine learning
Svn detailed use tutorial
外包幹了四年,廢了...
抑郁症治疗的进展
1 - first knowledge of go language
Provided by Chengdu control panel design_ It's detailed_ Introduction to the definition, compilation and quotation of single chip microcomputer program header file
555 timer + 74 series chip to build eight way responder, 30s countdown, proteus simulation, etc
Programming philosophy - automatic loading, dependency injection and control inversion
随机推荐
Frame synchronization implementation
Programming philosophy - automatic loading, dependency injection and control inversion
AT89C52 MCU frequency meter (1Hz ~ 20MHz) design, LCD1602 display, including simulation, schematic diagram, PCB and code, etc
Introduction to Arduino for esp8266 serial port function
2-GO variable operation
QT interface optimization: double click effect
Mq-2 and DS18B20 fire temperature smoke alarm system design, 51 single chip microcomputer, with simulation, C code, schematic diagram, PCB, etc
Vous ne connaissez pas encore les scénarios d'utilisation du modèle de chaîne de responsabilité?
A blog allows you to learn how to write markdown on vscode
8.4 循环神经网络从零实现
Model location setting in GIS data processing -cesium
Outsourcing for four years, abandoned
[NLP] HMM hidden Markov + Viterbi word segmentation
Mds55-16-asemi rectifier module mds55-16
A good tool: aardio
We reference My97DatePicker to realize the use of time plug-in
想要成为架构师?夯实基础最重要
select 同时接收普通数据 和 带外数据
利用 MATLAB 编程实现最速下降法求解无约束最优化问题
详解TCP的三次握手