Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooltip 能否针对不同的gridIndex或者series来决定是否显示? #5102

Closed
zhangchenyue opened this issue Feb 19, 2017 · 4 comments
Closed
Labels
stale Inactive for a long time. Will be closed in 7 days.

Comments

@zhangchenyue
Copy link

One-line summary [问题简述]

Option中有多个Grid, 其中有个grid不希望显示tooltip, 其他的grid显示tooltip, trigger方式为axis,如何实现?

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]:
  • Browser version [浏览器类型和版本]:
  • OS Version [操作系统类型和版本]:

Expected behaviour [期望结果]

tooltip 可根据gridindex 显示或者隐藏

ECharts option [ECharts配置项]

option = {

}

Other comments [其他信息]

@pissang
Copy link
Contributor

pissang commented Feb 19, 2017

可以在 formatter 返回空字符串决定不显示

@j1ng
Copy link

j1ng commented Mar 10, 2017

@pissang 某些情况下并不能解决问题.
我遇到的问题: series属于有重叠的不同坐标轴. 简化的例子如下

//echart version: 3.4.0
function fmt(p) {
    //实测发现p总是长度为1的数组
    if (p[0].seriesIndex !== 1) return '';
    return p[0].seriesName + ': ' + p[0].value
}

option = {
    tooltip: {
        trigger: 'axis', //'item'时无此问题
        //formatter: fmt
    },
    xAxis: [{max:4},{max:4}],
    yAxis: [{max:3}],
    series : [
        {
            name: 's1',
            type: 'scatter',
            xAxisIndex: [0],
            data: [[1,1], [3,1]],
            tooltip: {show: false}, 
                //文档里没找到,但是tooltip.trigger=='item'时确实有效果
            z: 1
        }, {
            name: 's2',
            type: 'scatter',
            xAxisIndex: [1],
            data: [[2,2],[3,2]],
            z: 999  //并没有什么卵用ㄟ( ▔, ▔ )ㄏ
        }
    ]
};

两坐标轴重合. 当 trigger:'axis' 时, 属于不同坐标轴的series会分别触发formatter回调. 如上例,每次mousemove, fmt 执行两次,参数是长度为1的数组, 而不是两series合并为一个数组.

由于 fmt 被执行两次, tooltip总是显示后一次的返回值, 若后一次返回空字符串则两series都不显示tooltip. 并且我也没找到什么好方法设置这一执行顺序, zzlevel均无效, 改成手动触发(如triggerOn='none', 设置鼠标事件触发dispatchAction)也同样会执行两次 fmt ...

PS: 目前已通过避免重合回避此问题, 然而为达到同样效果需要饶很多弯. 如果能正确处理上例中的情况, 复杂度, 性能及稳定性都会得到改善. 期待大牛帮忙解决 ~

@100pah
Copy link
Member

100pah commented Apr 5, 2017

v3.5 对这个功能已支持。参见 grid.tooltip

@stale
Copy link

stale bot commented Apr 3, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Inactive for a long time. Will be closed in 7 days. label Apr 3, 2020
@stale stale bot closed this as completed Apr 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Inactive for a long time. Will be closed in 7 days.
Projects
None yet
Development

No branches or pull requests

4 participants