echart实现大数据可视化看板大屏看板效果

代码语言:html

所属分类:布局界面

代码描述:echart实现大数据可视化看板大屏看板效果

代码标签: 数据 可视化 看板 大屏 看板 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新能源车联网综合大数据平台</title>
<style>
    /*css 初始化 */
html, body, ul, li, ol, dl, dd, dt, p, h1, h2, h3, h4, h5, h6, form, fieldset, legend, img {
    margin: 0;
    padding: 0;
}

/*将标签原有的默认内外边距去掉*/

fieldset, img, input, button {
    border: none; /*去掉边框*/
    padding: 0;
    margin: 0;
    outline-style: none; /*去掉环绕边框*/
}

ul, ol {
    list-style: none; /*去掉原样式中的小黑点*/
    /*ctrl+alt+l*/
}

input {
    padding-top: 0;
    padding-bottom: 0;

}

select, input {
    vertical-align: middle; /*输入字居中显示*/
}

select, input, textarea {
    font-size: 14px;
    margin: 0;
}

/**/
textarea {
    resize: none; /*防止拖动*/
}

img {
    border: 0;
    vertical-align: middle; /*  去掉图片底部默认的3像素空白缝隙*/
}

table {
    border-collapse: collapse; /*合并外边线*/
}

body {
    font-family:  Microsoft YaHei, Arial, "\5b8b\4f53";
}

.clearfix:before, .clearfix:after {
    content: "";
    display: table;
}

.clearfix:after {
    clear: both;
}

.clearfix {
    *zoom: 1; /*IE/7/6*/
    /*兼容IE6下的写法*/
}

h1, h2, h3, h4, h5, h6 {
    text-decoration: none; /**/
    font-weight: normal; /*不加粗*/
    font-size: 100%;
}
a{
    text-decoration: none;
}
s, i, em {
    /*一般起装饰作用*/
    font-style: normal; /*将字体变成正常字体*/
    text-decoration: none; /*去掉中划线*/
}
.fl{
    float: left;
}
.fr{
    float: right;
}


html,body{
    height: 100%;
    width: 100%;
}
.data{
    width: 100%;
    height: 100%;
    background: url('http://repo.bfw.wiki/bfwrepo/image/5eec59613702c.png') center;
    min-width: 1366px;
}
.data>.data-title{
    width: 100%;
    height: 105px;
    padding: 30px 0 35px 0;
    box-sizing: border-box;
}
.data>.data-title>.title-center{
    width: 440px;
    height: 40px;
    box-sizing: border-box;
    border-right: 5px solid #0089ff;
    border-left: 5px solid #0089ff;
    
}
.data>.data-title>.title-left,
.data>.data-title>.title-right{
    width:calc(50% - 220px);
    height: 3px;
    background: #0089ff;
    margin-top: 18px;
}

.data>.data-content{
    width: 100%;
    height:calc(100% - 105px);
    padding:0 20px 20px 20px ;
    box-sizing: border-box;
}
.data>.data-content>.con-left{
    width: 23.4375%;
    height: 100%;
}
.data>.data-content>.con-left>.left-top{
    width: 100%;
    height:calc(75% - 20px);
    margin-bottom: 20px;
    position: relative;
}

.data>.data-content>.con-left>.left-top>.info{
    height:62%;
    width: 100%;
    border: 1px solid #20558b;
    /*border-radius: 4px;*/
    box-sizing: border-box;
    position: relative;
}

.data>.data-content>.con-left>.left-top>.info>.info-title{
    width: 158px;
    height: 43px;
    background: url('../img/info-title.png') no-repeat;
    position: absolute;
    top: -22px;
    left:50%;
    margin-left: -74px;
    color:#fff;
    font-size: 18px;
    font-weight: 600;
    line-height: 43px;
    text-align: center;
}
.data>.data-content>.con-left>.left-top>.info>.info-main{
    width: 100%;
    height: 80% ;
}
.data>.data-content>.con-left>.left-top>.info>.info-main>div{
    width: 275px;
    height: 25%;
    background: url('../img/info-text.png') no-repeat;
    margin: 8px auto;
}
.data>.data-content>.con-left>.left-top>.info>.info-main>div.info-1{
    margin-top: 40px;
}
.data>.data-content>.con-left>.left-top>.info>.info-main .info-img{
    width: 100px;
    height: 60px;
    position: relative;
}
.data>.data-content>.con-left>.left-top>.info>.info-main .info-img>img{
    position: absolute;
    top: 50%;
    left: 50%;
    margin-left: -24px;
    margin-top: -24px;
}
.data>.data-content>.con-left>.left-top>.info>.info-main .info-text{
    width: 175px;
    height: 70px;
    padding-left: 30px;
    padding-top: 16px;
    box-sizing: border-box;
}
.data>.data-content>.con-left>.left-top>.info>.info-main .info-text>p:nth-child(1){
    color:#fff;
    font-weight: 600;
    font-size: 14px;
}
.data>.data-content>.con-left>.left-top>.info>.info-main>.info-1> .info-text>p:nth-child(2){
    font-weight: 600;
    color:#ffff44;
    font-size: 22px;
}
.data>.data-content>.con-left>.left-top>.info>.info-main>.info-2> .info-text>p:nth-child(2){
    font-weight: 600;
    color:#25f3e6;
    font-size: 22px;
}
.data>.data-content>.con-left>.left-top>.info>.info-main>.info-3> .info-text>p:nth-child(2){
    font-weight: 600;
    color:#f84a4a;
    font-size: 22px;
}
.data>.data-content>.con-left>.left-top>.info>.info-main>.info-4> .info-text>p:nth-child(2){
    font-weight: 600;
    color:#f5c847;
    font-size: 22px;
}

.data>.data-content>.con-left>.left-top>.top-bottom{
    height:calc(38% - 20px);
    width: 100%;
    background-color: rgba(0,24,106,0.5);
    margin-top: 20px;
    border: 1px solid #20558b;
    box-sizing: border-box;
    position: relative;
}



.data>.data-content>.con-left>.left-bottom{
    width: 100%;
    height: 25%;
    background-color: rgba(0,24,106,0.5);
    border: 1px solid #20558b;
    box-sizing: border-box;
    position: relative;
}
.data>.data-content>.con-center{
    width: 53.125%;
    height: 100%;
    padding:0 20px;
    box-sizing: border-box;
    position: relative;
}
.data>.data-content>.con-center>.map-num{
    width: 500px;
    height: 120px;
    position: absolute;
    top: 15px;
    left:50px;
    z-index: 1000;
}
.data>.data-content>.con-center>.map-num>p{
    font-size: 18px;
    font-weight: 600;
    color:#fff;
}
.data>.data-content>.con-center>.map-num span{
    display: inline-block;
    width: 45px;
    height: 65px;
    text-align: center;
    line-height: 65px;

    color:#fff;
    font-size: 68px;
    font-weight: 600;
    font-family: "LcdD";
    margin-top: 15px;
}
.data>.data-content>.con-center>.map-num span:nth-child(2),
.data>.data-content>.con-center>.map-num span:nth-child(6){
    background-color: transparent;
    width: 30px;
}

.data>.data-content>.con-center>.cen-top{
    width: 100%;
    height:calc(75% - 20px);
    margin-bottom: 20px;
    /*background-color: rgba(0,24,106,0.3);*/
    /*border: 1px solid #0089ff;*/
    /*border-radius: 4px;*/
    /*box-sizing: border-box;*/
}


.data>.data-content>.con-center>.cen-bottom{
    width: 100%;
    height: 25%;
    background-color: rgba(0,24,106,0.5);
    border: 1px solid #20558b;
    box-sizing: border-box;
    position: relative;
}

.data>.data-content>.con-right{
    width: 23.4375%;
    height: 100%;
}
.data>.data-content>.con-right>.right-top{
    width: 100%;
    height: 32%;
    background-color: rgba(0,24,106,0.5);
    border: 1px solid #20558b;
    box-sizing: border-box;
    position: relative;
}
.data>.data-content>.con-right>.right-center{
    width: 100%;
    height:calc(36% - 40px);
    margin: 20px 0;
    background-color: rgba(0,24,106,0.5);
    border: 1px solid #20558b;
    box-sizing: border-box;
    position: relative;
}
.data>.data-content>.con-right>.right-bottom{
    width: 100%;
    height:32%;
    background-color: rgba(0,24,106,0.5);
    border: 1px solid #20558b;
    box-sizing: border-box;
    position: relative;
}

.data>.data-content .title{
    height: 35px;
    line-height: 35px;
    width: 100%;
    color:#fff;
    font-weight: 600;
    padding-left: 15px;
    box-sizing: border-box;
}
.data>.data-content .charts{
    width: 100%;
    height:calc(100% - 35px);
}

.data>.data-content img.bj-1{
    position: absolute;
    left:-1px;
    top:-1px;
}
.data>.data-content img.bj-2{
    position: absolute;
    right:-1px;
    top:-1px;
}
.data>.data-content img.bj-3{
    position: absolute;
    right:-1px;
    bottom:-1px;
}
.data>.data-content img.bj-4{
    position: absolute;
    left:-1px;
    bottom:-1px;
}
</style>
</head>
<body>
<div class="data">

    <div class="data-title">
        <div class="title-left fl"></div>
        <div class="title-center fl" style="color:white;text-align:center;font-size:26px;">新能源车联网综合大数据平台</div>
        <div class="title-right fr"></div>
    </div>
    <div class="data-content">
        <div class="con-left fl">
            <div class="left-top">
                <div class="info">
                    <div class="info-title">实时统计</div>
                  
                    <div class="info-main">
                        <div class="info-1">
                            <div class="info-img fl">
                              <img src="http://repo.bfw.wiki/bfwrepo/icon/5da6d2ab95449.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_48,h_48,/quality,q_90" />
                            </div>
                            <div class="info-text fl">
                                <p>车辆总数(辆)</p>
                                <p>12,457</p>
                            </div>
                        </div>
                        <div class="info-2">
                            <div class="info-img fl">
                               <img src="http://repo.bfw.wiki/bfwrepo/icon/5da6d2ab95449.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_48,h_48,/quality,q_90" />
                            </div>
                            <div class="info-text fl">
                                <p>当前在线数(辆)</p>
                                <p>12,457</p>
                            </div>
                        </div>
                        <div class="info-3">
                            <div class="info-img fl">
                               <img src="http://repo.bfw.wiki/bfwrepo/icon/5da6d2ab95449.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_48,h_48,/quality,q_90" />
                            </div>
                            <div class="info-text fl">
                                <p>今日活跃数(辆)</p>
                                <p>12,457</p>
                            </div>
                        </div>
                    
                    </div>
                </div>
                <div class="top-bottom">
                    <div class="title">行业分类</div>
                
                    <div id="echarts_1" class="charts"></div>
                </div>
            </div>
            <div class="left-bottom">
                <div class="title">车型分类</div>
               
                <div id="echarts_2" class="charts"></div>
            </div>
        </div>
        <div class="con-center fl">
            <div class="map-num">
                <p>实时行驶车辆(辆)</p>
                <div class="num">
                    <span>1</span>
                    <span>,</span>
                    <span>2</span>
                    <span>3</span>
                    <span>4</span>
                    <span>,</span>
                    <span>5</span>
                    <span>6</span>
                    <span>7</span>
                </div>
            </div>
            <div class="cen-top" id="map"></div>
            <div class="cen-bottom">
                <div class="title">车辆充电高峰时间</div>
               
                <div id="echarts_3" class="charts"></div>
            </div>
        </div>
        <div class="con-right fr">
            <div class="right-top">
                <div class="title">本月行驶里程TOP5</div>
               
                <div id="echarts_4" class="charts"></div>
            </div>
            <div class="right-center">
                <div class="title">报警车辆TOP5</div>
               
                <div id="echarts_5" class="charts"></div>
            </div>
            <div class="right-bottom">
                <div class="title">电池报警车辆TOP10</div>
               
                <div id="echarts_6" class="charts"></div>
            </div>
        </div>
    </div>
</div>

</body>
<script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/echarts.js"></script>
<script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/echart-china.js"></script>
<script >
    
$(function () {

    echarts_1();
    echarts_2();
    map();
    echarts_3();
    echarts_4();
    echarts_5();
    echarts_6();

    function echarts_1() {
        // 基于准备好的dom,初始化echarts实例
        var myChart = echarts.init(document.getElementById('echarts_1'));

        var data = [
            {value: 12,name: '行业一'},
            {value: 13,name: '行业二'},
            {value: 70,name: '行业三'},
            {value: 52,name: '行业四'},
            {value: 35,name: '行业五'}
        ];

        option = {
            backgroundColor: 'rgba(0,0,0,0)',
            tooltip: {
                trigger: 'item',
                formatter: "{b}: <br/>{c} ({d}%)"
            },
            color: ['#af89d6', '#4ac7f5', '#0089ff', '#f36f8a', '#f5c847'],
            legend: { //图例组件,颜色和名字
                x: '70%',
                y: 'center',
                orient: 'vertical',
                itemGap: 12, //图例每项之间的间隔
                itemWidth: 10,
                itemHeight: 10,
                icon: 'rect',
                data: ['行业一', '行业二', '行业三', '行业四', '行业五'],
                textStyle: {
                    color: [],
                    fontStyle: 'normal',
                    fontFamily: '微软雅黑',
                    fontSize: 12,
                }
            },
            series: [{
                name: '行业占比',
                type: 'pie',
                clockwise: false, //饼图的扇区是否是顺时针排布
                minAngle: 20, //最小的扇区角度(0 ~ 360)
                center: ['35%', '50%'], //饼图的中心(圆心)坐标
                radius: [50, 75], //饼图的半径
                avoidLabelOverlap: true, ////是否启用防止标签重叠
                itemStyle: { //图形样式
                    normal: {
                        borderColor: '#1e2239',
                        borderWidth: 2,
                    },
                },
                label: { //标签的位置
                    normal: {
                        show: true,
                        position: 'inside', //标签的位置
                        formatter: "{d}%",
                        textStyle: {
                            color: '#fff',
                        }
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontWeight: 'bold'
                        }
                    }
                },
                data: data
            }, {
                name: '',
                type: 'pie',
                clockwise: false,
                silent: true,
                minAngle: 20, //最小的扇区角度(0 ~ 360)
                center: ['35%', '50%'], //饼图的中心(圆心)坐标
                radius: [0, 40], //饼图的半径
                itemStyle: { //图形样式
                    normal: {
                        borderColor: '#1e2239',
                        borderWidth: 1.5,
                        opacity: 0.21,
                    }
                },
                label: { //标签的位置
                    normal: {
                        show: false,
                    }
                },
                data: data
            }]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    }
    function echarts_2() {
        // 基于准备好的dom,初始化echarts实例
        var myChart = echarts.init(document.getElementById('echarts_2'));

        option = {
            backgroundColor: 'rgba(0,0,0,0)',
            tooltip: {
                trigger: 'item',
                formatter: "{b}  <br/>{c}辆"
            },
            legend: {
                x: 'center',
                y: '2%',
                data: ['车型一', '车型二', '车型三', '车型四', '车型五'],
                icon: 'circle',
                textStyle: {
                    color: '#fff',
                }
            },
            calculable: true,
            series: [{
                name: '车型',
                type: 'pie',
                //起始角度,支持范围[0, 360]
                startAngle: 0,
                //饼图的半径,数组的第一项是内半径,第二项是外半径
                radius: [41, 110],
                //支持设置成百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度
                center: ['50%', '20%'],
                //是否展示成南丁格尔图,通过半径区分数据大小。可选择两种模式:
                // 'radius' 面积展现数据的百分比,半径展现数据的大小。
                //  'area' 所有扇区面积相同,仅通过半径展现数据大小
                roseType: 'area',
                //是否启用防止标签重叠策略,默认开启,圆环图这个例子中需要强制所有标签放在中心位置,可以将该值设为 false。
                avoidLabelOverlap: false,
                label: {
                    normal: {
                        show: true,
                        formatter: '{c}辆'
                    },
                    emphasis: {
                        show: true
                    }
                },
                labelLine: {
                    normal: {
                        show: true,
                        length2: 1,
                    },
                    emphasis: {
                        show: true
                    }
                },
                data: [{
                    value: 600,
                    name: '车型一',
                    itemStyle: {
                        normal: {
                            color: '#f845f1'
                        }
                    }
                },
                    {
                        value: 1100,
                        name: '车型二',
                        itemStyle: {
                            normal: {
                                color: '#ad46f3'
                            }
                        }
                    },
                    {
                        value: 1200,
                        name: '车型三',
                        itemStyle: {
                            normal: {
                                color: '#5045f6'
                            }
                        }
                    },
                    {
                        value: 1300,
                        name: '车型四',
                        itemStyle: {
                            normal: {
                                color: '#4777f5'
                            }
                        }
                    },
                    {
                        value: 1400,
                        name: '车型五',
                        itemStyle: {
                            normal: {
                                color: '#44aff0'
                            }
                        }
                    },

                    {
                        value: 0,
                        name: "",
                        label: {
                            show: false
                        },
                        labelLine: {
                            show: false
                        }
                    },
                    {
                        value: 0,
                        name: "",
                        label: {
                            show: false
                        },
                        labelLine: {
                            show: false
                        }
                    },
                    {
                        value: 0,
                        name: "",
                        label: {
                            show: false
                        },
                        labelLine: {
                            show: false
                        }
                    },
                    {
                        value: 0,
                        name: "",
                        label: {
                            show: false
                        },
                        labelLine: {
                            show: false
                        }
                    },
                    {
                        value: 0,
                        name: "",
                        label: {
                            show: false
                        },
                        labelLine: {
                            show: false
                        }
                    }
                ]
            }]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    }
    function map() {
        // 基于准备好的dom,初始化echarts实例
        var myChart = echarts.init(document.getElementById('map'));

        var nameColor = " rgb(55, 75, 113)"
        var name_fontFamily = '宋体'
        var name_fontSize = 35
        var mapName = 'china'
        var data = []
        var geoCoordMap = {};
        var toolTipData = [];

        /*获取地图数据*/
        myChart.showLoading();
        var mapFeatures = echarts.getMap(mapName).geoJson.features;
        myChart.hideLoading();
        mapFeatures.forEach(function(v) {
            // 地区名称
            var name = v.properties.name;
            // 地区经纬度
            geoCoordMap[name] = v.properties.cp;
            data.push({
                name: name,
                value: Math.round(Math.random() * 100 + 10)
            })
            toolTipData.push({
                name: name,
                value: [{
                    name: "车型一",
                    value: Math.round(Math.random() * 100 + 10) + '辆'
                },
                    {
                        name: "车型二",
                        value: Math.round(Math.random() * 100 + 10)+ '辆'
                    },
                    {
                        name: "车型三",
                        value: Math.round(Math.random() * 100 + 10)+ '辆'
                    },
                    {
                        name: "车型四",
                        value: Math.round(Math.random() * 100 + 10)+ '辆'
                    }
                ]
            })
        });

        var max = 480,
            min = 9; // todo
        var maxSize4Pin = 50,
            minSize4Pin = 20;

        var convertData = function(data) {
            var res = [];
            for (var i = 0; i < data.length; i++) {
                var geoCoord = geoCoordMap[data[i].name];
                if (geoCoord) {
                    res.push({
                        name: data[i].name,
                        value: geoCoord.concat(data[i].value),
                    });
                }
            }
            return res;
        };

        option = {



            tooltip: {
                trigger: 'item',
                formatter: function(params) {
                    if (typeof(params.value)[2] == "undefined") {
                        var toolTiphtml = ''
                        for(var i = 0;i<toolTipData.length;i++){
                            if(params.name==toolTipData[i].name){
                                toolTiphtml += toolTipData[i].name+':<br>'
                                for(var j = 0;j<toolTipData[i].value.length;j++){
                                    toolTiphtml+=toolTipData[i].value[j].name+':'+toolTipData[i].value[j].value+"<br>"
                                }
                            }
                        }
                        console.log(toolTiphtml)
                        // console.log(convertData(data))
                        return toolTiphtml;
                    } else {
                        var toolTiphtml = ''
                        for(var i = 0;i<toolTipData.length;i++){
                            if(params.name==toolTipData[i].name){
                                toolTiphtml += toolTipData[i].name+':<br>'
                                for(var j = 0;j<toolTipData[i].value.length;j++){
                                    toolTiphtml+=toolTipData[i].value[j].name+':'+toolTipData[i].value[j].value+"<br>"
                                }
                            }
                        }
                        console.log(toolTiphtml)
                        // console.log(convertData(data))
                        return toolTiphtml;
                    }
                }
            },
            legend: {
                orient: 'vertical',
                y: 'bottom',
                x: 'right',
                data: ['credit_pm2.5'],
                textStyle: {
                    color: '#fff'
                }
            },
            visualMap: {
                show: false,
                min: 0,
                max: 600,
                left: 'left',
                top: 'bottom',
                text: ['高', '低'], // 文本,默认为数值文本
                calculable: true,
                seriesIndex: [1],
                inRange: {
                    // color: ['#3B5077', '#031525'] // 蓝黑
                    // color: ['#ffc0cb', '#800080'] // 红紫
                    // color: ['#3C3B3F', '#605C3C'] // 黑绿
                    //  color: ['#0f0c29', '#302b63', '#24243e'] // 黑紫黑
                    // color: ['#23074d', '#cc5333'] // 紫红
                    //   color: ['#00467F', '#A5CC82'] // 蓝绿
                    // color: ['#1488CC', '#2B32B2'] // 浅蓝
                    // color: ['#00467F', '#A5CC82','#ffc0cb'] // 蓝绿红
                    // color: ['#00467F', '#A5CC82'] // 蓝绿
                    // color: ['#00467F', '#A5CC82'] // 蓝绿
                    // color: ['#00467F', '#A5CC82'] // 蓝绿
                    color: ['#22e5e8', '#0035f9','#22e5e8'] // 蓝绿

                }
            },
            /*工具按钮组*/
            toolbox: {
                show: false,
                orient: 'vertical',
                left: 'right',
                top: 'center',
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0