效果图:
源码gitHub上的地址:
在线效果:https://wanghongzheng.github.io/visualizationChart/visualizedCharts.html
源码:https://wanghongzheng.github.io/visualizationChart/visualizationChart-master.zip
CSDN下载地址:https://download.csdn.net/download/yb305/18697862
参考别人的截图做的。
一、页面布局
1.页面总体布局,先将界面分成header(头部)和container(内容)两个部分,头部显示标题和当前时间,container(内容)显示可视化的echarts图表
<html>
<body class="contains">
<div class="header">
<div class = "title" >数据可视化-Echarts</div>
<div class = "time" >当前时间:<label>2020-05-27 08:36:58</label></div>
</div>
<div class="container">
内容部分
</div>
</body>
</html>
2.container(内容)部分采用百分比布局,填充除去头部高度的剩余空间,用height:calc(100vh - 80px)来设置高度的。
<html>
<head>
<style>
.contains{background:#000a2d;height:100%;width:100%;font-size:12px;margin:0px;padding:0px;}
.header{height:80px;background:red;margin:0px;padding:0px;}
.header .title{display:flex;justify-content:center;color:#fff;font-weight:bold;font-size:2.8rem;align-items: center;height: 100%;}
.time{margin-right: 10px;font-size: 1.8rem;margin-top: -4rem;color: #fff;float: right;}
.time .label{font-weight:300}
.container{height:calc(100vh - 80px);width:100%;color:#fff;text-align:center;font-size:30px;}
</style>
</head>
<body class="contains">
<div class="header">
<div class = "title" >数据可视化-Echarts</div>
<div class = "time" >当前时间:<label>2020-05-27 08:36:58</label></div>
</div>
<div class="container">
内容部分
</div>
</body>
</html>
3.利用bootstrap栅格化布局,将container(内容)部分分成三列
<html>
<head>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<style>
.contains{background:#000a2d;height:100%;width:100%;font-size:12px;margin:0px;padding:0px;}
.header{height:80px;background:red;margin:0px;padding:0px;}
.header .title{display:flex;justify-content:center;color:#fff;font-weight:bold;font-size:2.8rem;align-items: center;height: 100%;}
.time{margin-right: 10px;font-size: 1.8rem;margin-top: -4rem;color: #fff;float: right;}
.time .label{font-weight:300}
.container{height:calc(100vh - 80px);width:100%;color:#fff;text-align:center;font-size:30px;}
.item_left,.item_center,.item_right{height:100%;}
.item_left{background:green;}
.item_center{background:gray;}
.item_right{background:blue;}
</style>
</head>
<body class="contains">
<div class="header">
<div class = "title" >数据可视化-Echarts</div>
<div class = "time" >当前时间:<label>2020-05-27 08:36:58</label></div>
</div>
<div class="container">
<div class="container">
<div class="row">
<div class="col-md-4 item_left">
一列
</div>
<div class="col-md-4 item_center">
二列
</div>
<div class="col-md-4 item_right">
三列
</div>
</div>
</div>
</div>
</body>
</html>
4.将第一列分成三行,其他列的布局实现类似。
<html>
<head>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<style>
.contains{background:#000a2d;height:100%;width:100%;font-size:12px;margin:0px;padding:0px;}
.header{height:80px;background:red;margin:0px;padding:0px;}
.header .title{display:flex;justify-content:center;color:#fff;font-weight:bold;font-size:2.8rem;align-items: center;height: 100%;}
.time{margin-right: 10px;font-size: 1.8rem;margin-top: -4rem;color: #fff;float: right;}
.time .label{font-weight:300}
.container{height:calc(100vh - 80px);width:100%;color:#fff;text-align:center;font-size:30px;}
.item_left,.item_center,.item_right{height:100%;}
.item_left{background:green;;display: flex;}
.item_center{background:gray;;display: flex;}
.item_right{background:blue;;display: flex;}
.c1{display: flex;flex-direction: column;align-content: stretch;justify-content: stretch;width: 100%;}
.industryChartDiv,.changeChartDiv,.ageChartDiv{flex:1;margin: 10px 0px;background:#fff;color:#000;}
</style>
</head>
<body class="contains">
<div class="header">
<div class = "title" >数据可视化-Echarts</div>
<div class = "time" >当前时间:<label>2020-05-27 08:36:58</label></div>
</div>
<div class="container">
<div class="container">
<div class="row">
<div class="col-md-4 item_left">
<div class="c1">
<div class="industryChartDiv">
<div class="border">
一
</div>
</div>
<div class="changeChartDiv" >
<div class="border">
二
</div>
</div>
<div class="ageChartDiv">
<div class="border">
三
</div>
</div>
</div>
</div>
<div class="col-md-4 item_center">
二列
</div>
<div class="col-md-4 item_right">
三列
</div>
</div>
</div>
</div>
</body>
</html>
5.添加边框效果后,整体布局效果图
<html>
<head>
<meta chartset="utf-8">
<title>可视化echarts图表</title>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.contains{background:#000a2d;height:100%;width:100%;}
.header{height:80px;background-size: cover;background:url('./images/headerbg.png');background-repeat:no-repeat;background-position:center;}
.header .title{display:flex;justify-content:center;color:#fff;font-weight:bold;font-size:2.8rem;align-items: center;height: 100%;}
.time{margin-right: 10px;font-size: 1.8rem;margin-top: -4rem;color: #fff;float: right;}
.time .label{font-weight:300}
.container{height:calc(100vh - 80px);width:100%;}
.item_left,.item_center,.item_right{height:100%; padding-right: 10px;padding-left: 10px;display: flex;}
.c1,.c2,.c3{display: flex;flex-direction: column;align-content: stretch;justify-content: stretch;width: 100%;}
.industryChartDiv,.changeChartDiv,.ageChartDiv,.powerChartDiv,.playChatDiv,.areaChartDiv{flex:1;margin: 10px 0px;}
.totalInfoDiv{flex: 1;margin: 10px 0px;background: #0c1a50;}
.moveMapDiv{flex:4;margin: 10px 0px;}
.border{
border: 2px solid #02a6b5;
width: 100%;
height: 100%;
position: relative;
margin: auto;
}
.border:before{
content: '';
position: absolute;
width: 88%;
bottom: -2px;
top: -2px;
left: 6%;
border-bottom: 2px solid #0b3146;
border-top: 2px solid #0b3146;
}
.border:after{
content: '';
position: absolute;
height: 76%;
left: -2px;
right: -2px;
top: 12%;
border-left: 2px solid #0b3146;
border-right: 2px solid #0b3146;
}
</style>
</head>
<body class="contains">
<div class="header">
<div class = "title" >数据可视化-Echarts</div>
<div class = "time" >当前时间:<label>2020-05-27 08:36:58</label></div>
</div>
<div class="container">
<div class="row">
<div class="col-md-4 item_left">
<div class="c1">
<div class="industryChartDiv">
<div class="border">
</div>
</div>
<div class="changeChartDiv" >
<div class="border"></div>
</div>
<div class="ageChartDiv">
<div class="border"></div>
</div>
</div>
</div>
<div class="col-md-4 item_center">
<div class="c2">
<div class="totalInfoDiv">
</div>
<div class="moveMapDiv">
</div>
</div>
</div>
<div class="col-md-4 item_right">
<div class="c3">
<div class="powerChartDiv">
<div class="border"></div>
</div>
<div class="playChatDiv">
<div class="border"></div>
</div>
<div class="areaChartDiv">
<div class="border"></div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
边框处理:
<style>
.border{border: 2px solid #02a6b5;width: 100%;height: 100%;position: relative;margin: auto;}
.border:before{content: '';position: absolute;width: 88%;bottom: -2px;top: -2px;left: 6%;border-bottom: 2px solid #0b3146;border-top: 2px solid #0b3146;}
.border:after{content: '';position: absolute;height: 76%;left: -2px;right: -2px;top: 12%;border-left: 2px solid #0b3146;border-right: 2px solid #0b3146;}
.myDiv{height:300px;width:400px;background:#000a2d;padding:20px;}
</style>
<div class="myDiv">
<div class="border"></div>
</div>
二、可视化echarts图表部分,echarts图表的具体使用参照echarts官网https://echarts.apache.org/examples/zh/index.html,扩展使用参照echarts社区https://gallery.echartsjs.com/explore.html#sort=rank~timeframe=all~author=all