vue echarts 地图使用

在这里插入图片描述
1.首先安装echart
2.引用
import echarts from ‘echarts’
Vue.prototype.$echarts = echarts;
3.引入地图数据 import worldJson from ‘echarts/map/json/world.json’
注意:name与你引入的echart库的map下word.js,保持一致
{ name: ‘United States’, value: 12247.116, selected: true},
遇到两个
{ name: ‘United States of America’, value: 12247.116, selected: true}

<template>
    <div class="echart">
        <div ref="worldDiv" style="width: 900px;height: 600px;"></div>
    </div>
</template>
<script>
    import worldJson from 'echarts/map/json/world.json'
    export default {
        name: 'World',
        data() {
            return {
                option: {
                    title: {
                        text: 'World Population (2020)',
                        subtext: 'from United Nations, Total population, both sexes combined, as of 1 July (thousands)',
                        sublink: 'http://esa.un.org/wpp/Excel-Data/population.htm',
                        x: 'center',
                        y: 'top'
                    },
                    tooltip: {
                        trigger: 'item',
                        // formatter: function (params) {
                        //     var value = (params.value + '').split('.');
                        //     console.log('params',value)
                        //      console.log('value', value)
                        //     value = value[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g, '$1,')
                        //         + '.' + value[1];
                        //     return params.seriesName + '<br/>' + params.name + ' : ' + value;
                        // }
                    },
                    toolbox: {
                        show: true,
                        orient: 'vertical',
                        x: 'right',
                        y: 'center',
                        feature: {
                            mark: { show: true },
                            dataView: { show: true, readOnly: false },
                            restore: { show: true },
                            saveAsImage: { show: true }
                        }
                    },
                    // dataRange: {
                    //     min: 0,
                    //     max: 1000000,
                    //     text: ['High', 'Low'],
                    //     realtime: false,
                    //     calculable: true,
                    //     color: ['orangered', 'yellow', 'lightskyblue']
                    // },
                    series: [
                        {
                            name: 'World Population (2010)',
                            type: 'map',
                            mapType: 'world',
                            roam: true,
                            mapLocation: {
                                y: 60
                            },
                            itemStyle: {
                                normal: {
                                    label: {
                                        show: false
                                    },
                                    areaColor: '#0D62AA',
                                    borderColor: '#41c7db ',
                                    borderWidth: 0,
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值