-
Notifications
You must be signed in to change notification settings - Fork 19.7k
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自定义背景色后,文字颜色无法修改 #13905
Comments
Hi! We've received your issue and please be patient to get responded. 🎉 In the meanwhile, please make sure that you have posted enough image to demo your request. 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 [email protected]. 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! 🍵 |
Seems #13848 will fix it |
@plainheart 🙏,官方文档里面没看到有这项配置。 |
@realeve 抱歉,文档暂时还没有加上,后面会完善。 |
@plainheart 测试用例: https://echarts.apache.org/next/examples/zh/editor.html?c=line-simplevar style=`.echarts-tooltip {
background-color: rgba(48, 54, 64, 0.8);
color: rgb(224, 224, 227);
font-size: 12px ;
line-height: 18px;
font-family: 'Unica One', -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
'Noto Color Emoji';
padding: 12px;
box-shadow: rgba(0, 0, 0, 0.5) 0px 2px 4px;
border-radius: 3px;
border: none;
backdrop-filter: saturate(180%) blur(20px);
}
`;
/* 注入style */
const appendStyle = (style)=>{
var ele=document.createElement("style");
ele.innerHTML=style;
document.getElementsByTagName('head')[0].appendChild(ele)
}
appendStyle(style);
option = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [{
data: [150, 230, 224, 218, 135, 147, 260],
type: 'line'
}],
tooltip:{
className:'echarts-tooltip'
}
}; |
style 的优先级确实要比 class 要高。 |
@plainheart 就是这意思,目前看来关键的属性(背景/字号/行距/边距/边框)等都被强制指定了,如果className无法控制这些属性,干脆就用 extraCssText 来指定,注入给 tooltip 的style中了. |
Version
5.0.0
Steps to reproduce
tooltip自定义文字颜色无法生效
What is expected?
测试

What is actually happening?
在tooltip生成的dom结点,文字颜色被固定为了:#6E7079 ,
对应源码中的:https://github.com/apache/incubator-echarts/blob/master/src/component/tooltip/tooltipMarkup.ts#L406
导致用户在extraCSStext或者 textStyle中定义的内容无法生效;
建议
能否给tooltip加一个css,如 .echarts-tooltip,这样方便在css层自定义样式;
The text was updated successfully, but these errors were encountered: