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 2020/01/03 05:50:07 UTC

[GitHub] [incubator-echarts] pissang commented on a change in pull request #11847: Fix visualMap has error when stops is empty array (#5801)

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