pissang commented on a change in pull request #11847: Fix visualMap has error 
when  stops is empty array (#5801)
URL: 
https://github.com/apache/incubator-echarts/pull/11847#discussion_r362710952
 
 

 ##########
 File path: src/component/visualMap/PiecewiseModel.js
 ##########
 @@ -369,6 +369,30 @@ var PiecewiseModel = VisualMapModel.extend({
             }
         }, this);
 
+        // stop needs to have something
+        if (!stops.length) {
+            // get value axis
+            var cartesian = 
visualMapModel.ecModel.getComponent('series').coordinateSystem;
+            var baseAxis = cartesian.getBaseAxis();
+            var valueAxis = cartesian.getOtherAxis(baseAxis);
+            var extent = valueAxis.scale.getExtent();
+            zrUtil.each(pieceList, function (piece) {
+                for (var i = 0; i < piece.interval.length; i++) {
+                    // Because CanvasRenderingContext2D doesn't support 
Infinity
+                    // So set stop value to axis end.
+                    var value = piece.interval[i] === -Infinity
+                        ? extent[0]
+                        : piece.interval[i] === Infinity
+                        ? extent[1]
+                        : piece.interval[i];
+                    stops.push({
+                        value: value,
+                        color: piece.visual.color
+                    });
+                }
+            });
+        }
+
 
 Review comment:
   This specific defensive code should be put in the LineView. 
https://github.com/apache/incubator-echarts/blob/master/src/chart/line/LineView.js#L157
   
   VisualMap should be not aware of the implementation detail of series.

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