Vue-cli + DataV +echarts (大屏)

一、Vue-cli + DataV +echarts (大屏)

1.创建项目,安装dataV

 vue create demo  
 npm install @jiaminghi/data-view

2.安装echarts

 npm install echarts@4

3.加载echarts(中国地图)

//按需引入DataV
 // plugs/index.js
 import Vue from "vue";
 import {  fullScreenContainer } from '@jiaminghi/data-view' //容器
 Vue.use(fullScreenContainer);

 // main.js
 import echarts from 'echarts'
 Vue.prototype.$echarts =echarts;
 import china from 'echarts/map/json/china.json' // 引入json文件
 echarts.registerMap('china', china) // 在echarts中注册使用这个文件
 ​
 new Vue({
   render: h => h(App),
   data:function(){
     return{
       ercharts1:null  
     }
   },
 }).$mount('#app')


 //App.vue
 <dv-full-screen-container class="bgc">      //容器
      <Map />  //封装组件
 </dv-full-screen-container>

 //设置配置项 (地图)
 //map.vue 组件
       let option = {
         tooltip: {
           trigger: "item",
           formatter: function (params) {
             if (params.data) {
               return params.data.name + ":  " + params.data.value;
             } else {
               return params.name + ":  " + "0"; //自行定义formatter格式
             }
           },
         },
         visualMap: {
           // 是否开启数据映射
           show:true,
           // 展示value的颜色
           color: ["#008bbd", "#32a3cb", "#9cdbf2"],
           // 范围
           symbolSize: [0, 1500]
         },
         geo: {
           map: "china",
           roam: true, //是否开启缩放和平移
           zoom: 1.1, //视角缩放比例
           label: {
             // hover前
             normal: {
               show: true,
               textStyle: {
                 color: "#fff",
                 fontSize: 15,
               },
             },
             //  hover后
             emphasis: {
               textStyle: {
                 color: "black",
               },
             },
           },
           itemStyle: {
             // hover前
             normal: {
               // 偏移量
               shadowOffsetX: 1,
               shadowOffsetY: 1,
               // 边框颜色
               borderColor: "#ACC3FA",
               // 地区边框阴影
               shadowColor: "#fff",
               // 地区颜色
               areaColor: "#0A258C",
               borderWidth: 0.6, //设置外层边框
             },
             //  hover后
             emphasis: {
               shadowOffsetX: 0,
               shadowOffsetY: 1,
               shadowBlur: 10,
               borderWidth: 1,
               //鼠标选择区域颜色
               areaColor: "#FFAA12",
             },
           },
         },
         series: [
           {
             name: "信息量",
             type: "map",
             map: "china",
             geoIndex: 0,
             data: this.dataList,
           },
         ],
       };
 ​
 //初始化
 this.$root.echarts1 = this.$echarts.init(document.getElementById('regionCharts'));
 this.$root.echarts1.setOption(option);
 this.$nextTick(()=>{
      this.$root.echarts1.resize();// 防止图表不刷新
 })

 

4.注

发websock长链接时,其中的dataList(数据)可以丢到vuex里实时更新!!

Vue-cli + DataV +echarts (大屏)icon-default.png?t=LA92https://gitee.com/nini17/datav-vue-cli-ecarts-map

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值