当前位置:网站首页>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
边栏推荐
- Bracket matching -- [implementation of one-dimensional array]
- Psychological formula for converting RGB to gray value
- thinkphp5+数据大屏展示效果
- UnhandledPromiseRejectionwarning:CastError: Cast to ObjectId failed for value
- Learn to C language fourth day
- GO語言開發天天生鮮項目第三天 案例-新聞發布系統二
- Deep analysis of C language pointer (Part I)
- UKFslam
- Addition, deletion, modification and query of advanced MySQL data (DML)
- Valueerror: invalid literal for int() with base 10 conversion error related to data type
猜你喜欢
【SQL】字符串系列2:将一个字符串根据特定字符分拆成多行
Fastdfs mind map
MySQL基础之写表(创建表)
MySQL basic collection
Google 尝试在 Chrome 中使用 Rust
CUDA, NVIDIA driver, cudnn download address and version correspondence
2021-09-02 unity project uses rider to build hot change project failure record of ilruntime
On IRP from the perspective of source code
又一款数据分析神器:Polars 真的很强大
Cmake project under vs2019: calculating binocular parallax using elas method
随机推荐
MySQL进阶之常用函数
[SQL] string series 2: split a string into multiple lines according to specific characters
3-5 obtaining cookies through XSS and the use of XSS background management system
Awk print special characters
How to configure SSH public key in code cloud
Case of the third day of go language development fresh every day project - news release system II
GSI-ECM工程建设管理数字化平台
Introduction to standardization, regularization and normalization
Unity asset import settings
MySQL进阶之数据的增删改查(DML)
Latex formula
IOT 设计与开发
Prim、Kruskal
PHP的Laravel与Composer部署项目时常见问题
Pikachuxss how to get cookie shooting range, always fail to return to the home page
缓存淘汰算法初步认识(LRU和LFU)
Go language development Daily Fresh Project Day 3 Case - Press Release System II
Unity ECS dots notes
Valueerror: invalid literal for int() with base 10 conversion error related to data type
Communication between RING3 and ring0