首页 > 其他分享 >echarts绘制地图使用dispatchAction方法高亮区域

echarts绘制地图使用dispatchAction方法高亮区域

时间:2023-06-27 16:22:26浏览次数:43  
标签:index 绘制地图 myChart dispatchAction dataIndex seriesIndex type echarts

1.高亮方法代码如下:

highlightMap(myChart){
// 高亮轮播展示
var index = 0;
this.timer = null;
this.timer = setInterval(()=>{
myChart.dispatchAction({
type: 'downplay', // 取消高亮
seriesIndex: 0
})
myChart.dispatchAction({
type: 'highlight', //高亮
seriesIndex: 0,
dataIndex: index, //数据index,要显示的区域
})
myChart.dispatchAction({
type: 'showTip', //显示提示框
seriesIndex: 0,
dataIndex: index
})
index++
if(index > mapData.length){
index = 0;
}

},3000)
}

2.绘制地图

initMap(){
let map = document.getElementById('map')
let myChart = echarts.init(map)
this.highlightMap(myChart)
let options = {
title: {},
tooltip: {},
visualMap: {},
series: [
{
label: {},
rippleEffect: {},
itemStyle: {
normal: {
areaColor: 'xx',
borderWidth: 1,
textStyle: {
color: '#fff'
},
borderColor: '地图边框颜色'
},
emphasis: {
color: '#fff',
areaColor: '#069', //高亮颜色
}
},
zoom: 1.2, //地图放大比例
data: []
}
]
}
myChart.setOption(options)
}

3.鼠标移入移出事件处理

myChart.on('mousemove',(e)=>{
clearInterval(this.timer);
myChart.dispatchAction({
type: 'downplay',
seriesIndex: 0
})
myChart.dispatchAction({
type:'highlight',
seriesIndex: 0,
dataIndex: e.dataIndex
})
myChart.dispatchAction({
type: 'showTip',
seriesIndex: 0,
dataIndex: e.dataIndex
})
})

myChart.on('mouseout',()=>{
let index = 0;
this.timer = setInterval(()=>{
myChart.dispatchAction({
type: 'downplay',
seriesIndex: 0
})
myChart.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: index
})
myChart.dispatchAction({
type:'showTip',
seriesIndex: 0,
dataIndex: index,
})
index++;
if(index > this.mapData.length){
index = 0
}

}, 3000)
})

 

 

参考链接:

     https://blog.csdn.net/yb1314111/article/details/129585093

 

标签:index,绘制地图,myChart,dispatchAction,dataIndex,seriesIndex,type,echarts
From: https://www.cnblogs.com/sunnyeve/p/17509202.html

相关文章

  • elementui admin项目中使用echarts
    1.引入依赖npminstallecharts--save2.在template中写<template>  <div>   <el-card>    <divid="mychart":style="{height:height,width:width}"></div>   </el-card>  </div></t......
  • Echarts创建中国3D地图
    Echarts创建中国3D地图客户需要做一版3D中国地图,地图要倾斜角度,然后可以支持点击省份,对地图两侧的图表数据进行切换,此外还有一些纹理,顶牌信息面板的效果,不一一赘述,末尾我会放一张成品的图片。地图数据Echarts官网迁移后,地图的json数据已经不翼而飞了,所以在开发地图图表时,要先找......
  • node服务 图片合并echarts图表,绘制方框
    效果图:环境及依赖配置node版本参考:v14.18.3npm版本参考:6.14.15环境安装Mac系统需要先将Homebrew升级到与系统匹配的版本系统命令MacOSXbrewinstallpkg-configcairopangolibpngjpeggifliblibrsvgpixmanUbuntusudoapt-getinstallbuild-essentia......
  • python数据可视化神器--pyecharts 快速入门
    大家好,我是一名来自广东的邓棋文,目前正在学习Python的开发技能。在开发过程中,数据可视化是一个非常重要的环节,帮助我们理解数据,从而作出正确的决策。今天,我将介绍一个强大的Python数据可视化库——pyecharts。pyecharts是一个用于生成ECharts图表的类库。ECharts是百度开源的一个......
  • 使用Echarts时报 Implementation of registerMap doesn't exists 错误解决办法
    最新的echarts在使用时,如果使用按需加载的方式引入依赖。在使用registerMap函数时会报错如果出现这两个错误:ImplementationofregisterMapdoesn'texists.或者Mapxxxnotexists.TheGeoJSONofthemapmustbeprovided.那么大概率是因为echarts升级后导致的不兼容问题。......
  • 解决echarts鼠标选择错位的问题
    在写echarts时遇到的问题,鼠标选择总是和图形错位,同事提供的解决方法,在这里记录一下。1.增加以下代码exportdefaultfunctionresizeEcharts(ele){letrate=1920/window.innerWidth;if(ele.style){ele.style.zoom=1*rate;ele.style.transform=`......
  • Echarts配置系列-图文并茂教你配置各种图表样式
    @Echarts配置系列说明本文列举了各种常用的图表各种常用配置信息可以通过下面链接测试你的demo配置哦https://echarts.apache.org/examples/zh/editor.html?c=area-basic渐变色面积图代码配置option={title:{text:'每天都要开心呀'}......
  • 记录--Vue3 封装 ECharts 通用组件
    这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助按需导入的配置文件配置文件这里就不再赘述,内容都是一样的,主打一个随用随取,按需导入。import*asechartsfrom"echarts/core";//引入用到的图表import{LineChart,typeLineSeriesOption}from"echarts/......
  • echarts设置散点图颜色渐变
    在echarts散点图中,可以使用系统默认的图例颜色设置散点图,也可以设置具体的颜色设置,还可以添加单个散点颜色渐变,也可以设置整个echarts散点颜色渐变1.不设置颜色在不设置颜色的情况下,echarts会使用自带的调色盘进行颜色选择默认如下。['#5470c6','#91cc75','#fac858','#ee66......
  • 点击echarts图。获取点击事件
         自动跳转复用代码:letdataIndex=param.dataIndexthis.$nextTick(()=>{this.$refs.multipleTable0.bodyWrapper.scrollTop=(this.$refs.multipleTable0.bodyWrapper.scrollHeight*(this.tableList.len......