#声明
- 单纯记录学习计算机当中所遇到的问题
- 把解决问题的方法分享给大家
- 希望大佬不要喷我这个小白
#根据自己的想法完成的可视化面板,没有后端数据。
#面板配置信息
- 省地图模块(可参考我的另一篇文章)
echarts.registerMap('henan', henan); var myEcharts = echarts.init(document.getElementById("map")); var mapOption = { tooltip: { trigger: 'item', backgroundColor: "white", formatter: '地区:{b}<br/>确诊人数:{c}' }, visualMap: {//视觉映射组件 bootom: 'bootom', left: 'left', min: 100, max: 1000, text: ['High', 'Low'], realtime: false, calculable: true, textStyle: { color: '#fff' }, inRange: { color: ['#F9DCD1', '#F2AD92', '#E55B25', '#C64918', '#8A3310'] } }, series: [ { type: 'map', map: 'henan', roam: false, zoom: 1.25, itemStyle: { normal: { areaColor: "rgba(43, 196, 243, 0.42)", borderColor: "rgba(43, 196, 243, 1)", borderWidth: 1, label: { show: true, textStyle: { color: "white" } } }, }, data: [ { name: '郑州市', value: 2658 }, { name: '开封市', value: 150 }, { name: '洛阳市', value: 1865 }, { name: '平顶山市', value: 160 }, { name: '安阳市', value: 450 }, { name: '鹤壁市', value: 205 }, { name: '新乡市', value: 265 }, { name: '焦作市', value: 224 }, { name: '濮阳市', value: 216 }, { name: '许昌市', value: 250 }, { name: '漯河市', value: 270 }, { name: '三门峡市', value: 1258 }, { name: '南阳市', value: 295 }, { name: '商丘市', value: 310 }, { name: '周口市', value: 325 }, { name: '驻马店市', value: 365 }, { name: '信阳市', value: 652 }, ] }, ], }; myEcharts.setOption(mapOption);
- 折线图
var myChart = echarts.init(document.getElementById('polyline')); var polylineOption = { textStyle: { color: '#fff' }, tooltip: { trigger: 'axis', axisPointer: { type: 'cross', label: { backgroundColor: '#6a7985' } } }, legend: { data: ['新增人数', '治愈人数'], textStyle: { color: '#fff' } }, xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, series: [ { name: '治愈人数', type: 'line', color: 'green', data: [10, 15, 30, 60, 80, 150, 240] }, { name: '新增人数', type: 'line', color: 'red', data: [220, 182, 191, 234, 80, 40, 100] } ] }; myChart.setOption(polylineOption);
- 柱状图
var coloumChart = echarts.init(document.getElementById('coloum')); var coloumOption = { textStyle: { color: '#fff' }, tooltip: { trigger: 'axis', axisPointer: { type: 'cross', label: { backgroundColor: '#6a7985' } } }, xAxis: { type: 'category', data: ['郑州市', '洛阳市', '三门峡市', '信阳市', '安阳市'] }, yAxis: { type: 'value' }, series: [ { data: [2658, 1865, 1258, 652, 450], type: 'bar' } ] }; coloumChart.setOption(coloumOption);
- 政策
var policyList = [ { text: '河南发布暑期师生出行健康提醒:假期可在省内有序流动,跨省前往低风险地区的需提前报备', time: '2022-06-23' }, { text: '暑期防疫措施来了:在疫情形势平稳可控下,全省师生可省内有序流动', time: '2022-06-13' }, { text: '交通运输行业十条措施助企纾困 涉及财税、金融、车辆年审等多方面', time: '2022-05-31' }, { text: '事关暑期来返豫,热点问题解答!', time: '2022-05-26' }, { text: '省疫情防控指挥部发布通知 有序做好暑期来豫返豫人员健康管理和服务', time: '2022-05-25' }, { text: '河南开展常态化核酸检测,河南人将隔一天做一次核酸', time: '2022-05-22' }, { text: '河南省加快构建15分钟核酸检测“采样圈”', time: '2022-05-14' } ] policyList.forEach(item => { let str = `<li class="polocy_item"> <p class="text">${item.text}</p> <div class="time">${item.time}</div> </li>` $('.list').append(str) })
- 南丁格尔玫瑰图
var pieChart = echarts.init(document.getElementById('pie')); var pieOption = { legend: { top: 'bottom' }, series: [ { name: 'Nightingale Chart', type: 'pie', radius: [10, 100], center: ['50%', '45%'], roseType: 'area', itemStyle: { borderRadius: 3, }, data: [ { value: 20, name: '婴幼儿' }, { value: 20, name: '少儿' }, { value: 32, name: '青少年' }, { value: 30, name: '青年' }, { value: 50, name: '中年' }, { value: 60, name: '老年' } ] } ] }; pieChart.setOption(pieOption);
#完整代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>主页</title>
<link rel="stylesheet" href="css/rest.css">
<link rel="stylesheet" href="css/common.css">
<link rel="stylesheet" href="css/index.css">
<script src="./js/jquery.js"></script>
<script src="./js/echarts.js"></script>
<script src="./js/henan.js"></script>
</head>
<body>
<div id="wrapper">
<!-- 头部信息栏 -->
<header>
<div class="head_l"></div>
<div class="head_m">
<h1>河南省疫情可视化面板</h1>
</div>
<div class="head_r">当前时间:2022年6月17-0时54分14秒</div>
</header>
<div class="content">
<!-- 左小图区 -->
<section class="content_l">
<div class="item bor">
<h2>河南7天内新增情况</h2>
<div id="polyline"></div>
</div>
<div class="item bor">
<h2>河南省内高风险地区Top5</h2>
<div id="coloum"></div>
</div>
</section>
<!-- 中大图区域 -->
<section class="content_m">
<div class="total_num bor">
<div class="totalConfirm">现有确诊人数:7805</div>
<div class="totalCure">现有治愈人数:3685</div>
</div>
<div id="map"></div>
</section>
<!-- 右小图区域 -->
<section class="content_r">
<div id="policy" class="bor item">
<h2 class="policy_title">河南省内最新出行政策</h2>
<ul class="list">
</ul>
</div>
<div class="item bor">
<h2>感染人口年龄分布情况</h2>
<div id="pie"></div>
</div>
</section>
</div>
<!-- 底部信息栏 -->
<footer></footer>
<script>
var timer = null;
timer = setTimeout(time, 1000);
function time() {
clearTimeout(timer);
date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hour = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var str = "当前时间:"+year +"年" +month +"月" +day +"-" +hour +"时" +minutes +"分" +seconds +"秒";
$('.head_r').html(str)
timer= setTimeout(time, 1000);
}
var policyList = [
{
text: '河南发布暑期师生出行健康提醒:假期可在省内有序流动,跨省前往低风险地区的需提前报备',
time: '2022-06-23'
},
{
text: '暑期防疫措施来了:在疫情形势平稳可控下,全省师生可省内有序流动',
time: '2022-06-13'
},
{
text: '交通运输行业十条措施助企纾困 涉及财税、金融、车辆年审等多方面',
time: '2022-05-31'
}, {
text: '事关暑期来返豫,热点问题解答!',
time: '2022-05-26'
}, {
text: '省疫情防控指挥部发布通知 有序做好暑期来豫返豫人员健康管理和服务',
time: '2022-05-25'
}, {
text: '河南开展常态化核酸检测,河南人将隔一天做一次核酸',
time: '2022-05-22'
}, {
text: '河南省加快构建15分钟核酸检测“采样圈”',
time: '2022-05-14'
}
]
policyList.forEach(item => {
let str = `<li class="polocy_item">
<p class="text">${item.text}</p>
<div class="time">${item.time}</div>
</li>`
$('.list').append(str)
})
// 初始化echarts实例
echarts.registerMap('henan', henan);
var myEcharts = echarts.init(document.getElementById("map"));
var mapOption = {
tooltip: {
trigger: 'item',
backgroundColor: "white",
formatter: '地区:{b}<br/>确诊人数:{c}'
},
visualMap: {//视觉映射组件
bootom: 'bootom',
left: 'left',
min: 100,
max: 1000,
text: ['High', 'Low'],
realtime: false,
calculable: true,
textStyle: {
color: '#fff'
},
inRange: {
color: ['#F9DCD1', '#F2AD92', '#E55B25', '#C64918', '#8A3310']
}
},
series: [
{
type: 'map',
map: 'henan',
roam: false,
zoom: 1.25,
itemStyle: {
normal: {
areaColor: "rgba(43, 196, 243, 0.42)",
borderColor: "rgba(43, 196, 243, 1)",
borderWidth: 1,
label: {
show: true,
textStyle: {
color: "white"
}
}
},
},
data: [
{ name: '郑州市', value: 2658 },
{ name: '开封市', value: 150 },
{ name: '洛阳市', value: 1865 },
{ name: '平顶山市', value: 160 },
{ name: '安阳市', value: 450 },
{ name: '鹤壁市', value: 205 },
{ name: '新乡市', value: 265 },
{ name: '焦作市', value: 224 },
{ name: '濮阳市', value: 216 },
{ name: '许昌市', value: 250 },
{ name: '漯河市', value: 270 },
{ name: '三门峡市', value: 1258 },
{ name: '南阳市', value: 295 },
{ name: '商丘市', value: 310 },
{ name: '周口市', value: 325 },
{ name: '驻马店市', value: 365 },
{ name: '信阳市', value: 652 },
]
},
],
};
myEcharts.setOption(mapOption);
var myChart = echarts.init(document.getElementById('polyline'));
var polylineOption = {
textStyle: {
color: '#fff'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
legend: {
data: ['新增人数', '治愈人数'],
textStyle: {
color: '#fff'
}
},
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
name: '治愈人数',
type: 'line',
color: 'green',
data: [10, 15, 30, 60, 80, 150, 240]
},
{
name: '新增人数',
type: 'line',
color: 'red',
data: [220, 182, 191, 234, 80, 40, 100]
}
]
};
myChart.setOption(polylineOption);
var coloumChart = echarts.init(document.getElementById('coloum'));
var coloumOption = {
textStyle: {
color: '#fff'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
xAxis: {
type: 'category',
data: ['郑州市', '洛阳市', '三门峡市', '信阳市', '安阳市']
},
yAxis: {
type: 'value'
},
series: [
{
data: [2658, 1865, 1258, 652, 450],
type: 'bar'
}
]
};
coloumChart.setOption(coloumOption);
var pieChart = echarts.init(document.getElementById('pie'));
var pieOption = {
legend: {
top: 'bottom'
},
series: [
{
name: 'Nightingale Chart',
type: 'pie',
radius: [10, 100],
center: ['50%', '45%'],
roseType: 'area',
itemStyle: {
borderRadius: 3,
},
data: [
{ value: 20, name: '婴幼儿' },
{ value: 20, name: '少儿' },
{ value: 32, name: '青少年' },
{ value: 30, name: '青年' },
{ value: 50, name: '中年' },
{ value: 60, name: '老年' }
]
}
]
};
pieChart.setOption(pieOption);
</script>
</div>