100pah commented on a change in pull request #10487: Label color support 
function
URL: 
https://github.com/apache/incubator-echarts/pull/10487#discussion_r288089667
 
 

 ##########
 File path: src/util/graphic.js
 ##########
 @@ -653,6 +653,10 @@ export function setLabelStyle(
         setTextStyle(emphasisStyle, emphasisModel, emphasisSpecified, opt, 
true);
     }
 
+    if (typeof normalModel.get('color') === 'function') {
+        normalStyle.textFill = normalModel.get('color')(labelDataIndex);
+    }
+
 
 Review comment:
   (1) normalStyle.textFill should not be modified after `setTextStyle` called, 
because it will make the the style different from the cache created in 
`setTextStyle` for a feature that "auto add text stroke when text is inside a 
symbol".
   (2) If we support `label.color` callback, we should better not call the 
callback at this view stage, but in visual stage, like `symbol` and 
`symbolSize` did. Otherwise, it bring trouble to further optimization or 
prevent other components from using this color in future without break change 
of calling time. 
   (3) `labelDataIndex` should not pass to user directly, because it is a 
"inner index" that is not the raw data index when some data filter existing.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to