为每个gird配置特定tooltip无效
One-line summary [问题简述]
应用需求是在一个图表中有多个grid,想为每个grid配置特定的tooltip,但在gird中设置tooltip却发现无效。
Version & Environment [版本及环境]
- ECharts version [ECharts 版本]: 3.5.4
- Browser version [浏览器类型和版本]: chrome 58.0.3029.110 (64-bit)
- OS Version [操作系统类型和版本]: Win7 SP1 x64
Expected behaviour [期望结果]
只有第一个gird里显示tooltip,第二个grid里不显示tooltip
ECharts option [ECharts配置项]
option = {
title: {
text: '雨量流量关系图',
x: 'center'
},
legend: {
data:['流量','降雨量'],
x: 'left'
},
grid: [{
left: 50,
right: 50,
height: '35%',
tooltip: {
trigger: 'axis',
},
}, {
left: 50,
right: 50,
top: '55%',
height: '35%'
}],
xAxis : [
{
type : 'category',
data: [1,2,3,4,5,6,7,8,9,10],
},
{
gridIndex: 1,
type : 'category',
data: [1,2,3,4,5,6,7,8,9,10],
}
],
yAxis : [
{
name : '流量(m^3/s)',
type : 'value',
},
{
gridIndex: 1,
name : '降雨量(mm)',
type : 'value',
}
],
series : [
{
name:'流量',
type:'line',
data:[12,34,56,78,24,56,78,54,34,24]
},
{
name:'降雨量',
type:'line',
xAxisIndex: 1,
yAxisIndex: 1,
data: [12,34,56,78,24,56,78,54,34,24]
}
]
};
Other comments [其他信息]
另外一个事儿挺好奇:官网的Option文档里axisPointer里有个配置选项是tiggerTooltip,只有我一个人觉得这个"tigger(跳跳虎)"是不是忘记带个r出门了么? http://echarts.baidu.com/option.html#xAxis.axisPointer.tiggerTooltip
在 option 根上要声明 tooltip 才能启用 tooltip。
option: {
tooltip: {},
...
grid: [{
tooltip: {...}
}, {
...
}],
...
}
@100pah 事实上如果在根上声明了tooltip,那么该tooltip的配置就会覆盖掉grid项里的tooltip配置。
try this:
option = {
tooltip: { },
···
grid: [{
tooltip: {
trigger: 'axis',
formatter:'{c0}'
},{
···
}],
···
}
the formatter doesn't work
请问这个问题有解决么?
@suifengfengye 暂时没找到合适的办法
今天做项目也发现了同样的问题。 @100pah grid.tooltip 的配置项会被根tooltip 覆盖掉。子类里的tooltip可能只有trigger属性是有用的。 不止是grid.tooltip,测试发现series.tooltip有时也是无效的。 感觉这是个影响面非常广的问题,希望能够重视
简单的来说,要给总的声明的那个 tooltips 加 「showContent: false 」,子类的加 「showContent:true」
option = {
color: ['#3398DB'],
tooltip : {
showContent: false //此行可以不加
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis : [
{
type : 'category',
data : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
axisTick: {
alignWithLabel: true
}
}
],
yAxis : [
{
type : 'value'
}
],
series : [
{
name:'直接访问',
type:'bar',
barWidth: '60%',
data:[10, 52, 200, 334, 390, 330, 220],
tooltip : {
showContent: true,
trigger: 'item',
formatter: function(params) {
var str = '这是我自定义的内容';
return str;
}
}
}
]
};
这个问题有解决吗
@huainanhai 后续没有跟进了,你可以参考一下 mysteryven 的方案
3年了 ,还没有解决嘛。。。 在多个gird上设置了formatter 好像没有效果, 但是在多个grid上,show属性设置不同的值有效果,可以控制显示和不显示tooltip 这个文档文档看的好费劲,还是G2的文档看的明白
This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.
This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!
这个问题依然没有解决
3年了 ,还没有解决嘛。。。 在多个gird上设置了formatter 好像没有效果, 但是在多个grid上,show属性设置不同的值有效果,可以控制显示和不显示tooltip 这个文档文档看的好费劲,还是G2的文档看的明白
2025年3月26日问题依然没解决
请问这个问题有解决么?
2025依然没解决