You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "helgasoft (via GitHub)" <gi...@apache.org> on 2023/02/15 20:31:17 UTC

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

helgasoft commented on code in PR #11847:
URL: https://github.com/apache/echarts/pull/11847#discussion_r1107688847


##########
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:
   has been a long time (~5 years) since first reported and many duplicates ...
   Original PR code would be now at https://github.com/apache/echarts/blob/master/src/component/visualMap/PiecewiseModel.ts#L412.
   _"VisualMap is not aware of the implementation detail of series"_ - valid statement, but is [LineView.ts](https://github.com/apache/echarts/blob/master/src/chart/line/LineView.ts) aware of _visualMap_ ?  I see _getVisualGradient_ but it doesn't look like the right place.
   Anyway, this code fix is in limbo, not able to find a home...



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

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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