前言

🚀 基于 Echarts 实现可视化数据大屏响应式展示效果的源码,,基于html+css+javascript+echarts制作, 可以在此基础上重新开发。

本项目中使用的是echarts图表库,ECharts 提供了常规的折线图、柱状图、散点图、饼图、K线图,用于统计的盒形图,用于地理数据可视化的地图、热力图、线图,用于关系数据可视化的关系图、treemap、旭日图,多维数据可视化的平行坐标,还有用于 BI 的漏斗图,仪表盘,并且支持图与图之间的混搭。



文章目录

  • ​​前言​​
  • ​​一、Echart是什么​​
  • ​​二、ECharts入门教程​​
  • ​​三、作品演示​​
  • ​​四、代码实现​​
  • ​​1.HTML​​
  • ​​2.CSS​​
  • ​​3.JavaScript​​
  • ​​4.Echarts​​
  • ​​五、更多干货​​

一、Echart是什么

ECharts是一个使用 JavaScript 实现的开源可视化库,可以流畅的运行在 PC 和移动设备上,兼容当前绝大部分浏览器(IE8/9/10/11,Chrome,Firefox,Safari等),底层依赖矢量图形库 ZRender,提供直观,交互丰富,可高度个性化定制的数据可视化图表。

二、ECharts入门教程

5 分钟上手ECharts


三、作品演示

基于Echarts实现可视化数据大屏车辆类型統计_echarts


四、代码实现

1.HTML


<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>详情-复杂</title>
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="css/tail.css">
</head>

<body class="body1">

<header class="header left">
<div class="left nav">
<ul>
<li><i class="nav_1"></i><a href="index.html">数据概览</a> </li>
<li><i class="nav_2"></i><a href="carContrl.html">车辆监控</a> </li>
<li><i class="nav_3"></i><a href="map.html">地图界面</a> </li>
</ul>
</div>
<div class="header_center left">
<h2><strong>xx区智慧旅游综合服务平台</strong></h2>
<p class="color_font"><small>Comprehensive service platform for smart tourism</small></p>
</div>
<div class="right nav text_right">
<ul>
<li><i class="nav_7"></i><a href="static.html">查询统计</a> </li>
<li class="nav_active"><i class="nav_8"></i><a href="message.html">信息录入</a> </li>
<li><i class="nav_4"></i><a href="table1.html">表格界面</a> </li>
</ul>
</div>















</header>
<section class="sm_section left" style="width: 100%;">
<form>
<fieldset class="message_fieldset">
<legend>基本信息</legend>
<div class="message_con"><label>新闻标题:</label><input type="text" class="message_input"><span
class="must">*</span>
<p>新闻标题可以输入任一字符,但长度不能小于1大有大于200!</p>
</div>
<div class="message_con"><label>新闻类型:</label><select class="message_select">
<option>全部类型</option>
</select><span class="must">*</span>
<p>新闻标题可以输入任一字符,但长度不能小于1大有大于200!</p>
</div>
<div class="message_con"><label>是否需要审核:</label><input type="radio" name="ref" checked><span
class="font_color">是</span><input type="radio" name="ref"><span class="font_color">否</span>
</div>
<div class="message_con inputfile_div"><label>附件上传:</label><input type="file"
class="message_input input_file"><span class="must">*</span>
<div><input type="text"><button>选择文件</button></div>
<p>新闻标题可以输入任一字符,但长度不能小于1大有大于200!</p>
</div>
</fieldset>
<fieldset class="message_fieldset">
<legend>详情信息</legend>
<div class="message_con"><label>新闻格式:</label><input type="checkbox" name="ref" checked><span
class="font_color">格式一</span><input type="checkbox" name="ref"><span
class="font_color">格式二</span><input type="checkbox" name="ref"><span
class="font_color">格式三</span></div>
<div class="message_con"><label>新闻详情:</label>
<textarea id="editor" style="width: 100%;height:"></textarea>
</div>
</fieldset>
<div class="message_footer"><button class="bule">保存</button><button class="orgen">取消</button></div>
</form>
</section>
<script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script>
</body>

</html>


2.CSS


* {
margin: 0;
padding: 0;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.body {
background-color: #081832b5;
}

.body1 {
background-color: #081832;
}

.sm_section {
margin: 10px auto;
}

.left {
float: left;
}

.right {
float: right;
}

.tail_div {
padding: 10px 1%;
font-size: 13px;
}

.tail_div input[type=checkbox],
.tail_div input[type=radio] {
width: 14px;
height: 14px;
margin-right: 3px;
margin-left: 10px;
position: relative;
top: 2px;
}

.tail_div span {
color: #d1cbcb;
}

.tail_div label {
display: inline-block;
text-align: right;
color: #bcd4e9;
font-weight: bold;
height: 26px;
background-color: #eeeeee3b;
border: 1px solid #cccccc;
line-height: 25px;
width: 100px;
}

.noLable {
background-color: transparent !important;
border: none !important;
}

.tail_div input[type=text],
.tail_div input[type=date],
.tail_div input[type=tel],
.tail_div input[type=number],
.tail_div input[type=url],
.tail_div input[type=email],
.tail_div textarea {
border: 1px solid #cccccc;
text-indent: 1em;
}

.tail_div_min {
width: 49%;
margin-top: 10px;
}

.tail_div_min input[type=text],
.tail_div_min input[type=number],
.tail_div_min input[type=tel],
.tail_div_min input[type=date] {
width: 70%;
height: 26px;
}

.tail_div_min input[type=date] {
position: relative;
top: 1px;
}

.tail_div_min select {
width: 70%;
height: 28px;
}

.tail_div_max {
width: 98%;
margin-top: 10px;
}

.tail_div_max input[type=text],
.tail_div_max input[type=number],
.tail_div_max input[type=tel],
.tail_div_max input[type=date],
.tail_div_max input[type=url] {
width: 84.8%;
height: 26px;
}

.tail_div_max input[type=date] {
position: relative;
top: 1px;
}

.tail_div_max textarea {
width: 85.8%;
height: 100px;
resize: none;
position: relative;
left: -1%;
}

.max_textarea_lable {
height: 100px !important;
line-height: 100px !important;
position: relative;
top: -47px;
left: -1%;
}

.tail_div_xm {
width: 33%;
margin-top: 10px;
}

.div_foot {
position: fixed;
bottom: 0px;
height: 40px;
background-color: #eeeeee;
width: 100%;
}

.div_foot button {
width: 60px;
height: 30px;
border: none;
border-radius: 5px;
margin-left: 10px;
margin-top: 5px;
color: #FFFFff;
}

.save_but {
background-color: #00B83F;
}

.close_but {
background-color: orangered;
}

.base_div {
width: 98%;
margin: 0 auto;
}

.base_table {
width: 100%;
border-collapse: collapse;
border: 1px solid #cccccc;
}

.base_table td {
padding: 5px;
border: 1px solid #cccccc;
}

.label_td {
background-color: #eeeeee3b;
color: #bcd4e9;
font-weight: 600;
width: 15%;
text-align: right;
font-size: 13px;
}

.label_td span {
color: red;
position: relative;
top: 3px;
width: 12px;
height: 12px;
display: inline-block;
}

.base_input {
width: 69%;
height: 26px;
border: 1px solid rgba(26, 55, 132, 0.52);
border-radius: 3px;
}

.base_area {
height: 60px;
border: 1px solid rgba(26, 55, 132, 0.52);
border-radius: 3px;
width: 90%;
resize: none;
}

.base_input_lg {
width: 90%;
!important;
}

.base_note {
font-size: 13px;
color: #999999;
margin-left: 5px;
}

.more_div {
width: 98%;
margin: 10px auto;
border: 1px solid #cccccc;
border-radius: 5px;
}

.more_div .more_tit {
width: 100%;
height: 30px;
/*background-color: rgba(46, 141, 237, 0.22);*/
border-bottom: 1px solid #cccccc;
}

.more_tit a {
line-height: 30px;
display: inline-block;
padding: 0 25px;
background-color: #eeeeee;
text-decoration: none;
font-size: 13px;
color: #2b542c;
border-right: 1px solid #cccccc;
}

.more_active {
background-color: #2e8ded !important;
color: #FFFFff !important;
}

.more_con {
width: 98%;
margin: 10px auto;
}

.more_con_div {
width: 100%;
display: none;
position: relative;
}

.input_span {
color: #666666;
font-size: 13px;
}

.input_checkbox {
width: 14px;
height: 14px;
position: relative;
top: 3px;
margin-right: 3px;
margin-left: 8px;
}

.td_img {
width: 250px;
height: 300px;
}

.td_img img {
width: 100%;
height: 100%;
}

.tail_left {
width: 20%;
height: 100%;
border-right: 1px solid #cccccc;
}

.tail_right {
width: 79%;
height: 100%;
}

.tail_ul {
list-style: none;
width: 98%;
margin: 10px auto;
text-align: center;
}

.tail_ul li {
display: inline-block;
width: 47%;
border: 1px solid #cccccc;
padding: 5px;
border-radius: 3px;
margin-right: 2%;
margin-top: 6px;
}

.tail_left_img {
width: 80px;
height: 80px;
margin-right: 6px;
}

.tail_left_img img {
width: 100%;
height: 100%;
border-radius: 50%;
}

.tail_left_tit {
padding: 5px;
}

.tail_left_con {
color: #999999;
font-size: 13px;
}

.message_fieldset {
width: 98%;
margin: 10px auto;
border-radius: 5px;
border: 1px solid #cccccc;
}

.message_fieldset legend {
color: #c6e5f6b8;
font-size: 14px;
}

.message_fieldset .message_con {
width: 98%;
margin-left: 1%;
margin-top: 10px;
margin-bottom: 10px;
}

.message_fieldset .message_con label {
font-size: 13px;
font-weight: 600;
width: 10%;
display: inline-block;
text-align: right;
color: #eeeeee;
}

.message_con p {
padding-left: 10%;
font-size: 13px;
padding-top: 10px;
padding-bottom: 10px;
color: #b98129;
}

.message_con .message_input {
width: 80%;
height: 30px;
border: 1px solid #4b8df8;
border-radius: 5px;
outline: none;
}

.message_con .message_select {
width: 80%;
height: 32px;
border: 1px solid #4b8df8;
border-radius: 5px;
outline: none;
}

.message_con .must {
color: red;
margin-left: 5px;
position: relative;
display: inline-block;
top: 3px;
}

.message_con input[type=radio] {
width: 14px;
height: 14px;
position: relative;
top: 3px;
margin-left: 25px;
margin-right: 5px;
}

.message_con input[type=checkbox] {
width: 14px;
height: 14px;
position: relative;
top: 3px;
margin-left: 25px;
margin-right: 5px;
}

.font_color {
color: #eeeeee;
font-size: 13px;
}

.input_file {
opacity: 0;
position: relative;
z-index: 999;
}

.inputfile_div {
position: relative;
}

.inputfile_div div {
position: absolute;
left: 10%;
width: 80%;
height: 32px;
top: 0px;
}

.inputfile_div div>input {
width: 90%;
height: 30px;
border: 1px solid #4b8df8;
border-bottom-left-radius: 5px;
border-top-left-radius: 5px;
outline: none;
}

.inputfile_div div>button {
width: 9%;
height: 31px;
border: none;
background-color: #4b8df8;
color: #FFFFff;
}

.message_con .edui-default .edui-editor {
width: 80% !important;
height: 300px;
border: 1px solid #4b8df8;
border-radius: 5px;
outline: none;
left: 10%;
}

.edui-default .edui-editor-bottomContainer {
display: none;
}

.edui-default .edui-editor-iframeholder {
width: 100% !important;
}

.message_footer {
text-align: center;
}

.message_footer button {
margin-right: 10px;
padding: 4px 15px;
border: none;
border-radius: 3px;
color: #FFFFff;
}

.bule {
background-color: #4b8df8;
}

.orgen {
background-color: #ff6b29;
}


3.JavaScript


/**
* Created by 30947 on 2018/7/20.
*/
$(function() {
getHt();
initMap();
})
//获取div的高度
function getHt() {
var all_height = $(window).height();
var div_height = all_height - 84;
$("#car_control").css("height", div_height + "px");


}
//加载地图
function initMap() {
// 百度地图API功能
var map = new BMap.Map("map"); // 创建Map实例
map.centerAndZoom(new BMap.Point(116.404, 39.915), 11); // 初始化地图,设置中心点坐标和地图级别
//添加地图类型控件
var size1 = new BMap.Size(10, 50);
map.addControl(new BMap.MapTypeControl({
offset: size1,
mapTypes: [
BMAP_NORMAL_MAP,
BMAP_HYBRID_MAP,

]
}));
// 编写自定义函数,创建标注
function addMarker(point) {
var marker = new BMap.Marker(point);
map.addOverlay(marker);
}
// 随机向地图添加25个标注
var bounds = map.getBounds();
var sw = bounds.getSouthWest();
var ne = bounds.getNorthEast();
var lngSpan = Math.abs(sw.lng - ne.lng);
var latSpan = Math.abs(ne.lat - sw.lat);
for (var i = 0; i < 25; i++) {
var point = new BMap.Point(sw.lng + lngSpan * (Math.random() * 0.7), ne.lat - latSpan * (Math.random() * 0.7));
addMarker(point);
};

map.setCurrentCity("北京"); // 设置地图显示的城市 此项是必须设置的
map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
设备地图颜色
//var mapStyle={
// style:"midnight"
//};
//map.setMapStyle(mapStyle);





//加载城市控件
var size = new BMap.Size(10, 50);
map.addControl(new BMap.CityListControl({
anchor: BMAP_ANCHOR_TOP_LEFT,
offset: size,


}));
}


4.Echarts


/**
* Created by 30947 on 2018/7/18.
*/
$(function() {

char1();
char2();
char3();
char4();
char5();
})

//统计分析图
function char1() {

var myChart = echarts.init($("#char1")[0]);

option = {
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: {
orient: 'vertical',
x: 'right',
textStyle: {
color: '#ffffff',

},
data: ['客运车', '危险品车', '网约车', '学生校车']
},

calculable: false,
series: [{
name: '车类型',
type: 'pie',
radius: ['40%', '70%'],
itemStyle: {
normal: {
label: {
show: false
},
labelLine: {
show: false
}
},
emphasis: {
label: {
show: true,
position: 'center',
textStyle: {
fontSize: '20',
fontWeight: 'bold'
}
}
}
},
data: [{
value: 335,
name: '客运车'
},
{
value: 310,
name: '危险品车'
},
{
value: 234,
name: '网约车'
},
{
value: 135,
name: '学生校车'
}

]
}]
};

myChart.setOption(option);
window.addEventListener('resize', function() {
myChart.resize();
})

}

function char2() {

var myChart = echarts.init($("#char2")[0]);

option = {
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
grid: {
show: 'true',
borderWidth: '0'
},
legend: {
data: ['行驶', '停车', '熄火', '离线'],
textStyle: {
color: '#ffffff',

}
},

calculable: false,
xAxis: [{
type: 'value',
axisLabel: {
show: true,
textStyle: {
color: '#fff'
}
},
splitLine: {
lineStyle: {
color: ['#f2f2f2'],
width: 0,
type: 'solid'
}
}

}],
yAxis: [{
type: 'category',
data: ['客运车', '危险品车', '网约车', '学生校车'],
axisLabel: {
show: true,
textStyle: {
color: '#fff'
}
},
splitLine: {
lineStyle: {
width: 0,
type: 'solid'
}
}
}],
series: [{
name: '行驶',
type: 'bar',
stack: '总量',
itemStyle: {
normal: {
label: {
show: true,
position: 'insideRight'
}
}
},
data: [320, 302, 301, 334]
},
{
name: '停车',
type: 'bar',
stack: '总量',
itemStyle: {
normal: {
label: {
show: true,
position: 'insideRight'
}
}
},
data: [120, 132, 101, 134]
},
{
name: '熄火',
type: 'bar',
stack: '总量',
itemStyle: {
normal: {
label: {
show: true,
position: 'insideRight'
}
}
},
data: [220, 182, 191, 234]
},
{
name: '离线',
type: 'bar',
stack: '总量',
itemStyle: {
normal: {
label: {
show: true,
position: 'insideRight'
}
}
},
data: [150, 212, 201, 154]
}

]
};

myChart.setOption(option);
window.addEventListener('resize', function() {
myChart.resize();
})

}

function char3() {

var myChart = echarts.init($("#char3")[0]);

option = {
legend: {
data: ['车辆行驶数量'],
textStyle: {
color: '#ffffff',

}
},
grid: {
show: 'true',
borderWidth: '0'
},

calculable: false,
tooltip: {
trigger: 'axis',
formatter: "Temperature : <br/>{b}km : {c}°C"
},
xAxis: [{
type: 'value',
axisLabel: {
formatter: '{value}',
textStyle: {
color: '#fff'
}
},

splitLine: {
lineStyle: {
width: 0,
type: 'solid'
}
}
}],
yAxis: [{
type: 'category',
axisLine: {
onZero: false
},
axisLabel: {
formatter: '{value} km',
textStyle: {
color: '#fff'
}
},
splitLine: {
lineStyle: {
width: 0,
type: 'solid'
}
},
boundaryGap: false,
data: ['0', '10', '20', '30', '40', '50', '60', '70', '80']
}],
series: [{
name: '车辆行驶数量',
type: 'line',
smooth: true,
itemStyle: {
normal: {
lineStyle: {
shadowColor: 'rgba(0,0,0,0.4)'
}
}
},
data: [15, 0, 20, 45, 22.1, 25, 70, 55, 76]
}]
};

myChart.setOption(option);
window.addEventListener('resize', function() {
myChart.resize();
})

}

function char4() {

var myChart = echarts.init($("#char4")[0]);

option = {
grid: {
show: 'true',
borderWidth: '0'
},
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
},

formatter: function(params) {
var tar = params[0];
return tar.name + '<br/>' + tar.seriesName + ' : ' + tar.value;
}
},

xAxis: [{
type: 'category',
splitLine: {
show: false
},
data: ['客运车', '危险品车', '网约车', '学生校车'],
axisLabel: {
show: true,
textStyle: {
color: '#fff'
}
}

}],
yAxis: [{
type: 'value',
splitLine: {
show: false
},
axisLabel: {
show: true,
textStyle: {
color: '#fff'
}
}
}],
series: [

{
name: '报警数量',
type: 'bar',
stack: '总量',
itemStyle: {
normal: {
label: {
show: true,
position: 'inside'
}
}
},
data: [2900, 1200, 300, 200, 900, 300]
}
]
};

myChart.setOption(option);
window.addEventListener('resize', function() {
myChart.resize();
})

}

function char5() {

var myChart = echarts.init($("#char5")[0]);

option = {
grid: {
show: 'true',
borderWidth: '0'
},
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
},

formatter: function(params) {
var tar = params[0];
return tar.name + '<br/>' + tar.seriesName + ' : ' + tar.value;
}
},

xAxis: [{
type: 'category',
splitLine: {
show: false
},
data: ['客运车', '危险品车', '网约车', '学生校车'],
axisLabel: {
show: true,
textStyle: {
color: '#fff'
}
}

}],
yAxis: [{
type: 'value',
splitLine: {
show: false
},
axisLabel: {
show: true,
textStyle: {
color: '#fff'
}
}
}],
series: [

{
name: '报警数量',
type: 'bar',
stack: '总量',
itemStyle: {
normal: {
label: {
show: true,
position: 'inside'
}
}
},
data: [2900, 1200, 300, 200, 900, 300]
}
]
};

myChart.setOption(option);
window.addEventListener('resize', function() {
myChart.resize();
})

}