当前位置:网站首页>Thinkphp5 + data large screen display effect
Thinkphp5 + data large screen display effect
2022-04-23 20:49:00 【A bone preference】
1 Controller code display :

Controller code :
// The data output after loading the page
public function index()
{
$data = Db::name('index')->limit(5)->select();
$this->assign('data',$data);
$this->display();
return view('index');
}
// Get data asynchronously
public function data(){
$list = Db::name('index')->limit(5)->select();
// Reorganize array
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)); // Convert to json Data output
}
html Code :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ECharts</title>
<!-- introduce echarts.js -->
<script src="echarts.min.js"></script>
</head>
<body>
<!-- by ECharts Prepare one with size ( Wide and high ) Of 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: ' Asynchronous data loading example '
},
tooltip: {
},
legend: {
data:[' sales ']
},
xAxis: {
// Display in the chart after loading the page X Axis information
data: [<?php foreach($data as $v){
; ?>"<?php echo $v['name'] ?>",<?php }; ?>]
},
yAxis: {
},
series: [{
name: ' sales ',
// type: 'line',// Broken line diagram
type: 'bar',// Histogram
// Display in the chart after loading the page Y Axis information
data: [<?php foreach($data as $v){
; ?>"<?php echo $v['number'] ?>",<?php }; ?>],
itemStyle:{
// Color definition
normal:{
color:'#00bc12'}
}
}]
});
// Load background data asynchronously , Through the timer to achieve
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: ' sales ',
data: json.details
}]
});
}
})
};
<!--var time = setInterval(run,3000);-->
</script>
</html>
Display effect display :

Database display :

Line chart effect :

版权声明
本文为[A bone preference]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204232047427945.html
边栏推荐
- Resolve the error - error identifier 'attr_ id‘ is not in camel case camelcase
- Solve importerror: cannot import name 'imread' from 'SciPy misc‘
- Prim、Kruskal
- Latex formula
- JSX syntax rules
- Pytorch preserves different forms of pre training models
- thinkphp5+数据大屏展示效果
- Centralized record of experimental problems
- go array
- MySQL基础合集
猜你喜欢

缓存淘汰算法初步认识(LRU和LFU)

居家第二十三天的午饭

浅谈数据库设计之三大范式

Mysql database common sense storage engine

Vulnhub DC: 1 penetration notes

High paid programmer & interview question series 91 limit 20000 loading is very slow. How to solve it? How to locate slow SQL?

Problem brushing plan -- dynamic programming (III)

Lunch on the 23rd day at home

Deep analysis of C language pointer (Part I)

Deno 1.13.2 发布
随机推荐
Realrange, reduce, repeat and einops in einops package layers. Rearrange and reduce in torch. Processing methods of high-dimensional data
go reflect
Fastdfs mind map
UKFslam
Keywords static, extern + global and local variables
Common problems in deploying projects with laravel and composer for PHP
学会打字后的思考
41. The first missing positive number
The iswow64process function determines the number of program bits
How to use PM2 management application? Come in and see
Deno 1.13.2 发布
CUDA, NVIDIA driver, cudnn download address and version correspondence
Assertionerror: invalid device ID and runtimeerror: CUDA error: invalid device ordinal
Write table of MySQL Foundation (create table)
Bracket matching -- [implementation of one-dimensional array]
Graph traversal - BFS, DFS
An error occurs when the addressable assets system project is packaged. Runtimedata is null
Case of the third day of go language development fresh every day project - news release system II
Chrome 94 引入具有争议的 Idle Detection API,苹果和Mozilla反对
GSI-ECM工程建设管理数字化平台