You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2019/05/28 15:48:34 UTC

[GitHub] [incubator-echarts] 100pah edited a comment on issue #10487: Label color support function

100pah edited a comment on issue #10487: Label color support function
URL: https://github.com/apache/incubator-echarts/pull/10487#issuecomment-496574763
 
 
   (See the comment above.)
   
   I think we should not support a callback like `series.label.color`.
   If we support `series.label.color`, what about other style properties?
   If I intent to make glyph of a data item "big, red, has border, has special label", 
   I think it is not a good idea to write code like that:
   ```js
   series: {
       symbolSize: function (value) {
         if (someCondition(value)) {return 50;}
       },
       label: {
           color: function (value) {
               if (someCondition(value)) {return 'red';}   
           },
           borderWidth: function (value) {
               if (someCondition(value)) {return 5;}   
           },
           borderColor: function (value) {
               if (someCondition(value)) {return '#777';}   
           },
           ...
       }
   }
   ```
   where the `someCondition` is called multiple times and not convenient to make more detailed settings.
   
   A callback is convenient, especially using `dataset`. 
   Probably we might provide a callback like this? 
   ```js
   var option = {
       series: {
           dataItemOption: function (api) {
               var dimension = 3;
               var val = api.value(dim);
               if (val < 6 || val > 100) {
                   return {
                       itemStyle: {
                           color: 'blue'
                       },
                       label: {
                           color: 'red'
                       },
                       symbol: 'diamond',
                       symbolSize: 50,
                       emphasis: {
                           label: {
                               borderColor: 'green'
                           }
                       }
                   };
               }
               // 返回空取默认颜色
           }
       }
   };
   ```
   
   I think we should think this through before we add a callback mechanism.
   But sorry, because of the reasons and the defects mentioned above, could I revert this commit?
   @Ovilia @susiwen8 
   

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


With regards,
Apache Git Services

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