关于 echarts 使用 geo 制作地图 tooltip 不显示问题(转)

原文地址

我之前遇到过这问题,单独设置 tooltip 没效果,geo 下面也有 tooltip 属性,但是也不管用,网上查了一下说 geo 不支持 tooltip 提示框显示,就自己根据 echarts 配置项试了试,弄出两种方法

第一种就是 tooltip 全局设置一个,geo 下面 tooltip 在设置一个,两个都设置才管用,单独设置没效果,

代码附上

const option = {

title: {

text: ""

 },

tooltip: {

trigger: "item",

show: true,

formatter: function(params) {

let city = params.name + "市";

let res = "";

sswlist.map(item => {

if (item.properties.name == city) {

res = item.properties.info;

 }

 });

return res;

 },

padding: 2,

textStyle: {

fontSize: 8,

lineHeight: 10,

align: "left"

 }

 },

geo: {

map: "yns",

zlevel: 10,

show: true,

layoutCenter: ["50%", "48%"],

roam: false,

layoutSize: "150%",

zoom: 1,

label: {

normal: {

show: true,

textStyle: {

fontSize: 12,

color: "#43D0D6"

 }

 }

 },

itemStyle: {

normal: {

color: "#062031",

borderWidth: 1.1,

borderColor: "#43D0D6"

 }

 },

emphasis: {

areaColor: "#FFB800",

label: {

show: false

 }

 },

tooltip: {

trigger: "item",

show: true,

formatter: function(params) {

let city = params.name + "市";

let res = "";

sswlist.map(item => {

if (item.properties.name == city) {

res = item.properties.info;

 }

 });

return res;

 },

padding: 2,

textStyle: {

fontSize: 8,

lineHeight: 10,

align: "left"

 }
第二种就是 label  通过更改 label 下的 formatter 属性来实现,formatter 和 tooltip 下的 formatterz 作用一样,如果想让鼠标点击或划过显示的话通过 emphasis 下的 label 实现例如:
折叠

emphasis:{
label:
{formatter:{}
}

posted on   嘘嘘乖乖  阅读(2574)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示