You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2021/04/14 12:07:04 UTC

[GitHub] [echarts] Bilge opened a new issue #14675: No way to set global style for chart series

Bilge opened a new issue #14675:
URL: https://github.com/apache/echarts/issues/14675


   ### 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, a chart has 10 lines series and all lines should be drawn in the same style, then the style must be expressed 10 times over (copy and paste). If the style is only expressed once, then only the first series will adopt the specified style and the 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.
   
   <!-- This issue is generated by echarts-issue-helper. DO NOT REMOVE -->
   <!-- This issue is in English. DO NOT REMOVE -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang commented on issue #14675: No way to set global style for chart series

Posted by GitBox <gi...@apache.org>.
pissang commented on issue #14675:
URL: https://github.com/apache/echarts/issues/14675#issuecomment-820067637


   Hi, @Bilge. That's a feature we have been discussed for a while internally. But the option design is still not settled. 
   
   1. The simplest will be like what theme did:
   ```ts
   {
     line: { itemStyle: {} }
     bar: { itemStyle: {} }
   }
   ```
   But it's too rough and easy to have namespace conflicts.
   
   2. Use a CSS like className:
   ```ts
   {
     styles: { lineStyle1: {}, lineStyle2: {}, barStyle: {} },
     series: [{  
          type: 'line',
          lineStyle: 'lineStyle1'
      }]
   }
   ```
   It's much more flexible. But it's not as easy as the first solution in simple cases. Also, it's not type-friendly. It's hard to detect the types of style property. We can't know what properties `lineStyle1`, `lineStyle2` may have since we don't known which series they will be used. 
   
   3.   Use mixins
   ```ts
   {
     seriesMixins: { lineMixin: {
       type: 'line'  // Add series type so we can have right type again.
     }, barMixin: {} },
     series: [{ type: 'line', mixin: 'lineMixin' }]
   }
   ```
   
   It's even more flexible than the second solution because there is no limit on the mixin. But I'm not sure if things will get messed up because of its flexibility. Perhaps type-friendly may help it a lot.
   
   Perhaps we need to combine one or two of these three solutions so we can balance the flexibility and usability. We will pick up the discussion in the later versions when the current developing features are all stable.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] echarts-bot[bot] commented on issue #14675: No way to set global style for chart series

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on issue #14675:
URL: https://github.com/apache/echarts/issues/14675#issuecomment-819467394


   Hi! We've received your issue and please be patient to get responded. 🎉
   The average response time is expected to be within one day for weekdays.
   
   In the meanwhile, please make sure that **you have posted enough image to demo your request**. You may also check out the [API](http://echarts.apache.org/api.html) and [chart option](http://echarts.apache.org/option.html) 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 dev@echarts.apache.org. 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](https://echarts.apache.org/en/maillist.html).
   
   Have a nice day! 🍵


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang edited a comment on issue #14675: No way to set global style for chart series

Posted by GitBox <gi...@apache.org>.
pissang edited a comment on issue #14675:
URL: https://github.com/apache/echarts/issues/14675#issuecomment-820067637


   Hi, @Bilge. That's a feature we have been discussed for a while internally. But the option design is still not settled.  There are three potential solutions:
   
   1. The simplest will be like what theme did:
   ```ts
   {
     line: { itemStyle: {} }
     bar: { itemStyle: {} }
   }
   ```
   But it's too rough and easy to have namespace conflicts.
   
   2. Use a CSS like className:
   ```ts
   {
     styles: { lineStyle1: {}, lineStyle2: {}, barStyle: {} },
     series: [{  
          type: 'line',
          lineStyle: 'lineStyle1'
      }]
   }
   ```
   It's much more flexible. But it's not as easy as the first solution in simple cases. Also, it's not type-friendly. It's hard to detect the types of style property. We can't know what properties `lineStyle1`, `lineStyle2` may have since we don't known which series they will be used. 
   
   3.   Use mixins
   ```ts
   {
     seriesMixins: { lineMixin: {
       type: 'line'  // Add series type so we can have right type again.
     }, barMixin: {} },
     series: [{ type: 'line', mixin: 'lineMixin' }]
   }
   ```
   
   It's even more flexible than the second solution because there is no limit on the mixin. But I'm not sure if things will get messed up because of its flexibility. Perhaps type-friendly may help it a lot.
   
   Perhaps we need to combine one or two of these three solutions so we can balance the flexibility and usability. We will pick up the discussion in the later versions when the current developing features are all stable.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org