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

v5.x版本legend内的tooltip会继承外层的tooltip配置 #14939

Closed
DaiShengQuan opened this issue May 13, 2021 · 4 comments · Fixed by #14972
Closed

v5.x版本legend内的tooltip会继承外层的tooltip配置 #14939

DaiShengQuan opened this issue May 13, 2021 · 4 comments · Fixed by #14972
Assignees
Labels
not-a-bug pending We are not sure about whether this is a bug/new feature.
Milestone

Comments

@DaiShengQuan
Copy link

DaiShengQuan commented May 13, 2021

Version

5.0.0

Steps to reproduce

legend: {
                type: 'scroll',
                orient: 'vertical',
                formatter: function(name) {
                   name=‘Legenf’ name;
                    return name;
                },
                tooltip: {
                    show: true,
                },
            },
            tooltip: {
                trigger: 'item',
                formatter: '{b}: {c} ({d}%)',
            },

What is expected?

legend内的tooltip不应继承外层tooltip的formatter配置

What is actually happening?

这个问题会导致图例hover事件时tooltip显示的内容错误

image

@echarts-bot
Copy link

echarts-bot bot commented May 13, 2021

Hi! We've received your issue and please be patient to get responded. 🎉
The average response time is expected to be within one day for weekdays.

In the meanwhile, please make sure that it contains a minimum reproducible demo and necessary images to illustrate. Otherwise, our committers will ask you to do so.

A minimum reproducible demo should contain as little data and components as possible but can still illustrate your problem. This is the best way for us to reproduce it and solve the problem faster.

You may also check out the API and chart option to get the answer.

If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to dev@echarts.apache.org. Please attach the issue link if it's a technical question.

If you are interested in the project, you may also subscribe our mailing list.

Have a nice day! 🍵

@echarts-bot echarts-bot bot added bug pending We are not sure about whether this is a bug/new feature. waiting-for: community labels May 13, 2021
@echarts-bot
Copy link

echarts-bot bot commented May 13, 2021

@DaiShengQuan It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people, we'd like to suggest using English next time. 🤗

TRANSLATED

TITLE

The tooltip in the v5.x version of the legend will inherit the outer tooltip configuration

BODY

Version

5.0.0

Steps to reproduce

legend: {
type:'scroll',
orient:'vertical',
formatter: function(name) {
name=‘Legenf’ name;
return name;
},
tooltip: {
show: true,
},
},
tooltip: {
trigger:'item',
formatter:'{b}: {c} ({d}%)',
},

What is expected?

The tooltip in the legend should not inherit the formatter configuration of the outer tooltip

What is actually happening?

This problem will cause the tooltip to display the wrong content during the legend hover event

@pissang pissang added this to the 5.1.2 milestone May 13, 2021
@100pah 100pah added not-a-bug and removed bug labels May 15, 2021
@100pah
Copy link
Member

100pah commented May 15, 2021

That's a breaking change.

option = {
    legend: {
        type: 'scroll',
        orient: 'vertical',
        // This is the formatter of legend text,
        // not the formatter of legend tooltip.
        formatter: function(name) {
            return 'Legend ' + name;
        },
        tooltip: {
            show: true,
            // If no formatter declared, inherit the option.tooltip.formatter.
            // That is the same result as in series.
        },
    },
    tooltip: {
        trigger: 'item',
        formatter: '{b}: {c} ({d}%)',
    },
    series: {
        type: 'bar',
        label: {
            formatter: 'label{a}{b}'
        },
        tooltip: {
            // If no formatter declared, inherit the option.tooltip.formatter.
        }
    }
}

@pissang Is it reasonable for this case?

@pissang
Copy link
Contributor

pissang commented May 17, 2021

@100pah I think it's not reasonable. Component and series have different params in the formatter. They should not share one formatter config in most of the cases.

We can have default formatted in the legend component. Not using the user-set tooltip formatter.

pissang added a commit that referenced this issue May 18, 2021
fix: When component `tooltip.formatter` is not specified, use a specific default formatter, rather than use global `tooltip.formatter` as default. Fix #14939
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not-a-bug pending We are not sure about whether this is a bug/new feature.
Projects
None yet
3 participants