Blame view

src/views/home/wgsl.vue 3.71 KB
任超 committed
1 2
<template>
    <div class="wgsl">
任超 committed
3 4
        <div class="title">陕西省不动产信息接入</div>
        <div class="map-box" ref="mapContainProvince" />
任超 committed
5 6
    </div>
</template>
任超 committed
7
 
任超 committed
8 9 10
<script>
export default {
    data () {
任超 committed
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
        return {
            provinceName: "shanxi1",
            mapName: "陕西",
            listArr: [{
                name: '西安市',
                value: '6000'
            },
            {
                name: '宝鸡市',
                value: '8000'
            },
            {
                name: '咸阳市',
                value: '3000'
            },
            {
                name: '铜川市',
                value: '7000'
            },
            {
                name: '渭南市',
                value: '1000'
            },
            {
                name: '延安市',
                value: '2000'
            },
            {
                name: '榆林市',
                value: '600'
            },
            {
                name: '汉中市',
                value: '3000'
            },
            {
                name: '安康市',
                value: '1000'
            },
            {
                name: '商洛市',
                value: '1000'
            }], //城市json
            max: "9000", //最大value值
            min: "500", // 最小value值
        };
任超 committed
57 58
    },
    methods: {
任超 committed
59 60 61
        drawProvinceMap (provinceName, mapName) {
            this.provinceName = provinceName;
            this.mapName = mapName;
任超 committed
62
            // 引入区域数据
任超 committed
63 64
            require(`./map/${this.provinceName}.js`);
            let _this = this;
任超 committed
65
            let myChart8 = this.$echarts.init(this.$refs.mapContainProvince);
任超 committed
66 67 68 69 70 71 72 73 74
            const option = {
                visualMap: {
                    min: _this.min,
                    max: _this.max,
                    show: false,
                    inRange: {
                        color: ["lightskyblue"],
                    },
                },
任超 committed
75
                // 数据移入显示
任超 committed
76 77 78 79 80
                tooltip: {
                    trigger: "item",
                    formatter: function (params) {
                        return params.value ? params.name + ':' + params.value + '件' : params.name + ':' + '0件'
                    },
任超 committed
81
                    // 边框颜色
任超 committed
82
                    borderColor: "#CB000C",
任超 committed
83
                    // 边框宽度
任超 committed
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
                    borderWidth: "1",
                },
                series: [
                    {
                        type: "map",
                        map: this.mapName,
                        itemStyle: {
                            normal: {  //正常状态
                                label: {
                                    show: true,
                                    formatter: '{b}',   //地图上显示的数据,分别对应data中的name和value
                                    color: '#fff',
                                },
                                areaColor: '#409EFF'   //地图区域的颜色
                            },
                            emphasis: {
                                label: { show: true },
                                areaColor: "#67C23A", //鼠标进入时的颜色
                            },
                        },
                        data: _this.listArr,
                    },
                ],
            };
            myChart8.setOption(option);
        },
任超 committed
110
    },
任超 committed
111
    mounted () {
任超 committed
112
        // 初始化数据
任超 committed
113 114 115
        this.drawProvinceMap("shanxi1", "陕西");
    }
}
任超 committed
116
</script>
任超 committed
117
<style scoped>
任超 committed
118 119
.wgsl {
    width: 100%;
任超 committed
120
}
任超 committed
121

任超 committed
122 123 124 125 126 127 128 129 130
.title {
    text-align: center;
    line-height: 36px;
    font-size: 26px;
}

.map-box {
    display: inline-block;
    width: 100%;
任超 committed
131
    height: 75vh;
任超 committed
132
}
任超 committed
133
</style>