No way to set global style for chart series
- Dominant language
- TypeScript
- Stars
- 67.3k
- Forks
- 19.8k
- Avg merge
- 11d 14h
- Merged PRs (30d)
- 8
Description
### What problem does this feature solve?
Currently there is no way to apply a consistent theme to, for example, all lines of a line chart. That is, if a chart wants 10 line series all drawn in the same style, then the style must be expressed 10 times over (copy and paste). If the style is only expressed once, only the first series will adopt the specified style and all other series will receive the default style (the ECharts library default).
We see this even in the official examples, where multiple series are drawn with custom style, that custom style is expressed multiple times, either [verbatim declarative](https://echarts.apache.org/examples/en/editor.html?c=area-stack-gradient) or [programmatically in a loop](https://echarts.apache.org/examples/en/editor.html?c=line-race).
Since ECharts options are normally expressed declaratively, a simple declarative approach to consistent chart styling for multiple series should be provided. In particular, whilst it is fairly simple to copy and paste the same styles repeatedly for each series when the number of series is fixed and known, it is much more difficult to declaratively specify style options when the number of series is variable and thus not known. Even in the case that the number of series is fixed, repeating the theme options is a maintenance burden and an inelegant approach.
Aside, the documentation page titled [_Customized Chart Styles_](https://echarts.apache.org/en/tutorial.html#Customized%20Chart%20Styles) claims:
>Apache EChartsTM provides a rich amount of configurable items, which can be set in global, series, and data three different levels.
However, this is the only reference in that document to the notion of a *global level* of configuration for styles. The rest of the document never mentions the three different levels again, and in particular, never makes any reference to *global level* again or gives any examples of setting global style, so I presume such facility does not exist since I cannot find any reference documentation or examples that showcase it.
### What does the proposed API look like?
I suppose the reason there is no such feature at present to specify global style is because style options depend on the series type; that is, theme options are different between line and pie charts. However, it should be possible to specify defaults for each series type, i.e. specify defaults for all line series.
If there *are* options common to all series types, there should also be a way to specify these styles globally that would affect all series types, too.
Contributor guide
Assessment
This issue has not been assessed yet.