echarts icon indicating copy to clipboard operation
echarts copied to clipboard

关于rich中预定义样式的优化

Open Mr-Lixiaoqaing opened this issue 3 years ago • 7 comments

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?

image 这是我想象中的样子。当formatter中没有定义a时,就使用rich中的a

Mr-Lixiaoqaing avatar May 09 '22 06:05 Mr-Lixiaoqaing

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.

echarts-bot[bot] avatar May 09 '22 06:05 echarts-bot[bot]

@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?

image This is what I imagined. When a is not defined in formatter, a in rich is used

echarts-bot[bot] avatar May 09 '22 06:05 echarts-bot[bot]

In most cases, it should be sufficient to use current implementation with several styles and set the name (like "a") dynamically.

Ovilia avatar May 09 '22 07:05 Ovilia

是的,大部分场景使用预定义的样式是够用了。但是能让它更好用不是更好吗

Mr-Lixiaoqaing avatar May 10 '22 01:05 Mr-Lixiaoqaing

动态的话

formatter:(value){
     let map = {
          valueA:richA,
          valueB:richB,
          ...
     }
     return `{${map[valueA]}|${valueA}}`
}

rich:{
    richA:{},
    richB:{}
}

这样就可以吧

kitee0325 avatar May 10 '22 07:05 kitee0325

@Mr-Lixiaoqaing 你参考下楼上的做法,如果不满足的话,可以提一个 Pull Request 试试~

Ovilia avatar May 11 '22 06:05 Ovilia

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.

github-actions[bot] avatar May 10 '24 21:05 github-actions[bot]

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!

github-actions[bot] avatar May 17 '24 21:05 github-actions[bot]