-
Notifications
You must be signed in to change notification settings - Fork 19.8k
fix(label): fix label rich style does not inherit the plain label style #20977
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some thoughts:
Do we need to simplify it to only support
richInheritPlainLabelon the global model?(I'm not sure)
richInheritPlainLabelis when users upgrade to echarts v6, and find that some text style is broken. They can simply setrichInheritPlainLabel: falseon the global option to revert it, without being bothered by debugging. But if they have decided to not to userichInheritPlainLabel: falseand fix the broken style one by one, they can also just modify the text styles directly, but not necessarily setrichInheritPlainLabel: falseon some specific style option (such as,axisLable,series[i].label, ...).richInheritPlainLabelon the global model, that can be declared intypes.ts#ECUnitOption. On the contrary, if supportingrichInheritPlainLabelevery text style, it seems not easy to make a uniform TS declaration. ThetextStyleModelin this function has been declared asModel<any>, that makestextStyleModel.get('richInheritPlainLabel')return ananytype, and pass TS check by chance, but not quite correct.ecModelis not necessarily exist in this function, tho in most cases it exists. Is it appropriate to just ignore the cases thatecModeldoes not exist? I meanif (ecModel) { ecModel.get('richInheritPlainLabel') } else { /* just treat it as richInheritPlainLabel: true */ }.richInheritPlainLabel: false?But since no ideal approach, it's also fine to use the current implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sake of migration, I think supporting the global
richInheritPlainLabeloption makes sense, and the type is easy to define. But I hope to also support therichInheritPlainLabeloption inlabelstyle, but keep it undocumented until it is required by developers.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that after this changing,
test/pie-label-alignTo-adjust.htmlthrows JS Error in zrender.The root cause of that Error is related to zr incorrect impl (I'm fixing it.), but not caused by this PR.
However, this PR changes the inheritance behavior, causing the rich style to inherit
widthfrom the outermost label style, which trigger the bug code in zr.Through this case, I realized that:
width,height,padding,margin,tag,backgroundColor,borderColor,borderWidth,borderRadius,shadowColor,shadowBlur,shadowOffsetX,shadowOffsetY(inTextStylePropsPart), are inappropriate to inherit.static defaultOption = ...) has props (such as,alignverticalAlign, and inGauseSeries), we change the inheritance behavior, that may cause a breaking change. Also need to consider that some default style is set in emphasis state. And users have to reset them in each rich style to correct the style - that might cause the config more complicated than no inheritance.Thus should we only conservatively only allow inheritance in
TEXT_PROPS_WITH_GLOBAL, i.e.,'fontStyle', 'fontWeight', 'fontSize', 'fontFamily', 'textShadowColor', 'textShadowBlur', 'textShadowOffsetX', 'textShadowOffsetY'- they are meant to be inheritable (has been inheritable from global option).Moreover, I found that it's not a correct way to implements the inheritance by
See
test/pie-dataView.html, that breaks the rich text in pie, because in that case thetextStyleModelis the model of each item and therichshould be fetched from the originaltextStyleModel.parent.Regarding impl, because in another branch I encountered this issue, I just try to fix that in this way:
#21016