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 2019/10/22 15:23:18 UTC

[GitHub] [incubator-echarts] 100pah commented on a change in pull request #10766: pie/funnel legend can use visualMap color.

100pah commented on a change in pull request #10766: pie/funnel legend can use visualMap color.
URL: https://github.com/apache/incubator-echarts/pull/10766#discussion_r337561333
 
 

 ##########
 File path: src/component/legend/LegendView.js
 ##########
 @@ -191,10 +191,15 @@ export default echarts.extendComponentView({
                     }
 
                     if (seriesModel.legendDataProvider) {
-                        var data = seriesModel.legendDataProvider();
+                        // pie/funnel legend can use visualMap color.
+						var data = seriesModel.getData();
                         var idx = data.indexOfName(name);
                         if (idx < 0) {
-                            return;
+							var rawData = seriesModel.legendDataProvider();
+                            idx = rawData.indexOfName(name);
+                            if (idx < 0) {
+                                return;
+                            }
                         }
 
 Review comment:
   `seriesModel.legendDataProvider()` and `seriesModel.getData()` probably get total different data and has nothing to do with each other. (For example, in `graph series`).
   
   
   
   
   
   I think we might let `legendDataProvider` only return info that legend needed but not return data.
   
   For example:
   
   In `legendModel`:
   ```js
   var provider = seriesModel.legendDataProvider;
   if (provider) {
       var names = provider.getNames();
       // ...
   }
   ```
   
   In `legendView`:
   ```js
   var provider = seriesModel.legendDataProvider;
   if (provider) {
       var visual = provider.getVisualByName(name);
       var color = visual.color;
       var borderColor = viusal.borderColor;
       // ...
   }
   ```
   
   In `PieSeries`:
   ```js
   var series = this;
   this.legendDataProvider = {
       getNames: function () {
           var rawData = series.getRawData();
           return rawData.mapArray(rawData.getName);
       },
       getVisualByName: function (name) {
           var data = series.getData();
           var idx = data.indexOfName(name);
           return {
               color: data.getItemVisual(idx, 'color'),
               borderColor: data.getItemVisual(idx, 'borderColor')
           };
       }
   };
   ```
   
   
   

----------------------------------------------------------------
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: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org