VUE Echarts世界地图 中文名称显示国家

1、安装插件

npm install echarts --save

2、引入组件

  import echarts from "echarts" //引入组件
  import '../../node_modules/echarts/map/js/world.js'    //引入地图文件

3、效果图
世界地图效果4、数据连接
https://download.csdn.net/download/wanghui374/10720349
环境
VUE — 脚手架 全部代码

<template>
  <div class="echarts">
    <div :style="{height:height,width:width}" ref="myEchart"></div>
  </div>
</template>
<script>
  import echarts from "echarts" //引入组件
  import '../../node_modules/echarts/map/js/world.js'    //引入组件

  export default {
    name: "echarts",
    props: {
      width: {type: String,default: "1000px" },
      height: {type: String,default: "500px"}
    },
    data() {
      return {
        chart: null,
        data:[
          {"name": "俄罗斯","value": 1707.5},
          {"name": "加拿大","value": 997.1},
          {"name": "中国","value": 960.1},
          {"name": "美国","value": 936.4},
          //--------省略数据
        ]
      };
    },
    mounted() {
      this.initChart();
    },
    methods: {
      initChart() {
        this.chart = echarts.init(this.$refs.myEchart);
        window.onresize = echarts.init(this.$refs.myEchart).resize;
        // 把配置和数据放这里
        this.chart.setOption({
          backgroundColor: "#02AFDB",
          title: {    //地图显示标题
            text: '全球国家面积排行榜',
            subtext: 'Global ranking of country area',
            sublink: 'http://www.baidu.com',
            top:"30px",
            left: 'center',
            textStyle: {color: '#fff'}
          },
          visualMap: {   //图列显示柱
              type: 'continuous',
              min: 0,
              left:30,
              max: 2000,
              text:['大','小'],
              realtime: false,
              calculable : true,
              color: ['orangered','yellow','lightskyblue']
          },
          toolbox: {  //工具栏
              show: true,
              orient: 'vertical',
              left: 'right',
              top:50,
              itemGap:20,
              left:30,
              feature: {
                  dataView: {readOnly: false},
                  restore: {},
                  saveAsImage: {}
              }
          },
          tooltip: {  //提示框组件
            trigger: 'item',
            formatter: '{b}<br/>{c} 万平方公里'
          },
          series: [{
            name:"国家面积",
            type: 'map',
            mapType: 'world',
            roam: true,
            mapLocation: {y: 100},
            data: this.data,   //绑定数据
            nameMap:{
	          'Russia':'俄罗斯',
	          'Canada':'加拿大',
	          'China':'中国',
	          'United States':'美国',
            },
            symbolSize: 12,
            label: {
              normal: {show: false},
              emphasis: {show: false}
            },
            itemStyle: {
              emphasis: {
                borderColor: '#fff',
                borderWidth: 1
              }
            }
          }],
        });
      }
    }
  }
</script>

注意:

data 数据国家名字和nameMap映射国家名字保持一致,顺序可变化

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值