66 lines
2.1 KiB
HTML
66 lines
2.1 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html lang="zh-CN">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
<title>学前教育数据测试</title>
|
||
|
<link rel="stylesheet" href="css/style.css">
|
||
|
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
|
||
|
<script src="js/jquery-3.7.1.min.js"></script>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="container">
|
||
|
<h1>学前教育招生人数统计</h1>
|
||
|
<div id="preschoolChart" style="width: 100%; height: 600px;"></div>
|
||
|
<div id="message" class="message"></div>
|
||
|
</div>
|
||
|
|
||
|
<script>
|
||
|
// 初始化图表
|
||
|
var preschoolChart = echarts.init(document.getElementById('preschoolChart'));
|
||
|
|
||
|
// 显示加载状态
|
||
|
function showLoading() {
|
||
|
preschoolChart.showLoading();
|
||
|
$('#message').text('数据加载中...');
|
||
|
}
|
||
|
|
||
|
// 隐藏加载状态
|
||
|
function hideLoading() {
|
||
|
preschoolChart.hideLoading();
|
||
|
}
|
||
|
|
||
|
// 显示错误信息
|
||
|
function showError(message) {
|
||
|
$('#message').text('错误: ' + message);
|
||
|
console.error(message);
|
||
|
}
|
||
|
|
||
|
// 加载学前教育数据
|
||
|
function loadPreschoolData() {
|
||
|
showLoading();
|
||
|
$.getJSON('/bigscreen/school/preschool/chart')
|
||
|
.done(function(data) {
|
||
|
preschoolChart.setOption(data);
|
||
|
$('#message').text('数据加载成功');
|
||
|
})
|
||
|
.fail(function(jqXHR, textStatus, errorThrown) {
|
||
|
showError(errorThrown || '获取数据失败,请检查接口是否正常');
|
||
|
})
|
||
|
.always(function() {
|
||
|
hideLoading();
|
||
|
});
|
||
|
}
|
||
|
|
||
|
// 页面加载时加载数据
|
||
|
$(document).ready(function() {
|
||
|
loadPreschoolData();
|
||
|
});
|
||
|
|
||
|
// 窗口大小变化时调整图表
|
||
|
$(window).resize(function() {
|
||
|
preschoolChart.resize();
|
||
|
});
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|