关于rich中预定义样式的优化
What problem does this feature solve?
formatter中使用rich,只能先在rich中定义好富文本对象,再在formatter中去使用(比如'{a|这段文本能使用a样式}')。 希望能在formatter中使用一个计算出来的样式对象,比如 '{a|这段文本能使用a样式}' 这个a不再是预定义在rich中的对象,而是可以在formatter函数中定义的一个对象。这样在使用一些动态的字体颜色、背景色等会方便很多
What does the proposed API look like?
这是我想象中的样子。当formatter中没有定义a时,就使用rich中的a
I'm sorry to close this issue for it lacks the necessary title. Please provide a descriptive and as concise as possible title to describe your problems or requests and then the maintainers or I will reopen this issue.
Every good bug report or feature request starts with a title. Your issue title is a critical element as it's the first thing maintainers see.
A good issue title makes it easier for maintainers to understand what the issue is, easily locate it, and know what steps they'll need to take to fix it.
Moreover, it's better to include keywords, as this makes it easier to find the issue self and similar issues in searches.
@Mr-Lixiaoqaing It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗
TRANSLATED
TITLE
About the optimization of predefined styles in rich
BODY
What problem does this feature solve?
The rich can only be used in the formatter to define a rich text object in rich and then use it in format (e.g. '{a| this text can use a style}'). It is desirable to use a computed style object in formatter, such as '{a| this text can use a style}' This a is no longer an object predefined in rich, but an object that can be defined in the formatr function. This will be much more convenient in using some dynamic font colors, background colors, etc
What does the proposed API look like?
This is what I imagined. When a is not defined in formatter, a in rich is used
In most cases, it should be sufficient to use current implementation with several styles and set the name (like "a") dynamically.
是的,大部分场景使用预定义的样式是够用了。但是能让它更好用不是更好吗
动态的话
formatter:(value){
let map = {
valueA:richA,
valueB:richB,
...
}
return `{${map[valueA]}|${valueA}}`
}
rich:{
richA:{},
richB:{}
}
这样就可以吧
@Mr-Lixiaoqaing 你参考下楼上的做法,如果不满足的话,可以提一个 Pull Request 试试~
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!