indexLeft.vue 6.32 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
<template>
    <div class="app-container home">
      <div style="width: 100%;height: 250px;border: 1px solid #dbdada;">
        <div style="width: 50%;height: 100%;text-align: center;line-height: 50px;float: left;">
            <p>企业人员数量</p>
            <div class="tz">
                <span style="font-family: 'UnidreamLED'; color: #fff;font-size: 35px;">135</span>
            </div>
        </div>
        <div style="width: 50%;height: 100%;text-align: center;line-height: 50px;float: right;">
            <p>特种作业人员数量</p>
            <div class="tz">
                <!-- <img src="../../assets/images/group1.png" alt="" width="100%"> -->
                <span style="font-family: 'UnidreamLED';color: #fff;font-size: 35px;">53</span>
            </div>
        </div>
      </div>
      <div style="width: 100%;height: 300px;border: 1px solid #dbdada;margin-top: 5px;">
        <p style="padding-left: 20px;">感知设备</p>
        <div id="myChartone" :style="{ width: '100%', height: '240px' }"></div>
      </div>
    </div>
  </template>
  <script>
    // 引入基本模板
    import * as echarts from 'echarts';
    export default {
      data() {
        return {
          
        };
      },
      mounted() {
        this.drawLine();
      },
      methods: {
        drawLine() {
          // 基于准备好的dom,初始化echarts实例
          let myChart1 = this.$echarts.init(document.getElementById("myChartone"));
          // 绘制图表
          myChart1.setOption({
            legend: {},
            grid: {
              top: "14%",
              left: "5%",
              right: "7%",
              bottom: "5%",
              containLabel: true,
            },
            tooltip: {},
            dataset: {
                source: [
                    ['product', '在线数量', '离线数量'],
                    ['气体报警器', 89, 23],
                    ['摄像头', 55, 12],
                    ['用电探测器', 77, 12],
                    ['压力探测器', 66, 16],
                    ['温度探测器', 90, 20]
                ]
            },
            xAxis: { 
                type: 'category',
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: "#6AB7EB",
                        width: 1,
                        type: "solid"
                    }
                },
                axisLabel: {//x轴文字的配置
                    show: true,
                    interval: 0,
                    rotate: 20,
                    fontSize: 12,
                    textStyle: {
                        color: "#334D6E ",
                    }
                },
             },
            yAxis: {
                axisLine: {//y轴线的颜色以及宽度
                    show: true,
                    lineStyle: {
                        color: "#6AB7EB ",
                        width: 1,
                        type: "solid"
                    },
                },
                axisLabel: {//x轴文字的配置
                    show: true,
                    textStyle: {
                        color: "#334D6E ",
                    }
                },
                splitLine:{
                    //设置条纹显示 柱状图默认yAxis(true)
                    show:true,
                    //设置lineStyle即可写入样式即可
                    lineStyle:{
                        color:'#c7e8ff',
                        type:'dashed'
                    }
                }
            },
            series: [
                { 
                    type: 'bar' ,
                    barWidth: 18,
                    itemStyle: {
                        normal: {
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#0098FF '
                                }, {
                                offset: 1,
                                color: '#fff'
                            }]),
                            label: {
                            // show: true, //开启显示
                            position: "top", //在上方显示
                            // textStyle: {
                            //     //数值样式
                            //     color: "#688AB6",
                            //     fontSize: 12,
                            // },
                            },
                            barBorderRadius: [5, 5, 0, 0], //每个柱子的颜色即为colorList数组里的每一项,如果柱子数目多于colorList的长度,则柱子颜色循环使用该数组
                        },
                    }
                }, 
                { 
                    type: 'bar' ,
                    barWidth: 18,
                    itemStyle: {
                        normal: {
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#CBB700'
                                }, {
                                offset: 1,
                                color: '#fff'
                            }]),
                            label: {
                            // show: true, //开启显示
                            position: "top", //在上方显示
                            // textStyle: {
                            //     //数值样式
                            //     color: "#688AB6",
                            //     fontSize: 12,
                            // },
                            },
                            barBorderRadius: [5, 5, 0, 0], //每个柱子的颜色即为colorList数组里的每一项,如果柱子数目多于colorList的长度,则柱子颜色循环使用该数组
                        },
                    }
                }
            ]
            
          });
        },
      },
    };
    </script>
  <style scoped lang="scss">
    .home{
      padding: 20px 5px 0px 20px;
    }
    .tz{
        background: url('../../assets/images/group1.png');
        background-size: 100% 100%;
        background-repeat: no-repeat;
        width: 130px;
        text-align: center;
        height: 130px;
        position: relative;
        margin-left: 15%;
        line-height: 130px;
    }
    </style>