ECharts(中国地图篇)的使用

一、
网址:            https://www.cnblogs.com/ldlx-mars/p/9242250.html
点击:            无区域显示的中国地图
下载文件:        必须引入china.js

网址:            https://www.cnblogs.com/xianwen/p/6045454.html
点击:            高亮颜色中国地图(有区域显示)
下载文件:       必须引入china.js

 

安装:npm install echart --saver

组件必须引入:

import echarts from 'echarts'
import '../../node_modules/echarts/map/js/china.js'
 



二、代码示例

复制代码
<template>
       <div id="chart_example"></div>
</template>
<style lang="stylus" scoped>
#chart_example {
width: 50%;
height: 500px;
border: 1px solid red;
margin: 0 auto;
}

</style>
<script>
import $ from 'jquery'
import echarts from 'echarts'
import '../../node_modules/echarts/map/js/china.js'

export default {
data(){
return{

}
},
methods:{

},
mounted(){
//无区域的地图显示
 let myChart = echarts.init(document.getElementById('chart_example'));
 let option = {
 series: [{
 type: 'map',
// // mapType: 'china'// mapType或者map都可以
 map: 'china',
 }]
 };
 myChart.setOption(option);
//无区域的地图显示


//有区域的地图显示
var myChart = echarts.init(document.getElementById('chart_example'));
var option = {
tooltip: {
// show: false //不显示提示标签
formatter: '{b}', //提示标签格式
backgroundColor:"#ff7f50",//提示标签背景颜色
textStyle:{color:"#fff"} //提示标签字体颜色
},
series: [{
type: 'map',
mapType: 'china',
label: {
normal: {
show: true,//显示省份标签
textStyle:{color:"#c71585"}//省份标签字体颜色
},
emphasis: {//对应的鼠标悬浮效果
show: true,
textStyle:{color:"#800080"}
}
},
itemStyle: {
normal: {
borderWidth: .5,//区域边框宽度
borderColor: '#009fe8',//区域边框颜色
areaColor:"#ffefd5",//区域颜色
},
emphasis: {
borderWidth: .5,
borderColor: '#4b0082',
areaColor:"#ffdead",
}
},
data:[
{name:'福建', selected:true}//福建为选中状态
]
}],
};
 
myChart.setOption(option);
myChart.on('mouseover', function (params) {
var dataIndex = params.dataIndex;
console.log(params);
});
}
}
</script>
复制代码

 

三、效果图


四、修改省份标签位置:
打开china.js文件,修改"properties":{"cp":[X坐标,Y坐标],...}

转载于:https://www.cnblogs.com/cjj123456/p/11192845.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值