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/08/04 13:39:50 UTC

[GitHub] [incubator-echarts] pissang commented on a change in pull request #12669: fix(markArea): hide labels when markArea is not inside grid #12591

pissang commented on a change in pull request #12669:
URL: https://github.com/apache/incubator-echarts/pull/12669#discussion_r465055401



##########
File path: src/component/marker/MarkAreaView.js
##########
@@ -208,9 +208,35 @@ MarkerView.extend({
         // Update visual and layout of line
         areaData.each(function (idx) {
             // Layout
-            areaData.setItemLayout(idx, zrUtil.map(dimPermutations, function (dim) {
+            var points = zrUtil.map(dimPermutations, function (dim) {
                 return getSingleMarkerEndPoint(areaData, idx, dim, seriesModel, api);
-            }));
+            });
+            // If none of the area is inside coordSys, allClipped is set to be true
+            // in layout so that label will not be displayed. See #12591
+            var allClipped = true;
+            zrUtil.each(dimPermutations, function (dim) {
+                if (!allClipped) {
+                    return;
+                }
+                var xValue = areaData.get(dim[0], idx);
+                var yValue = areaData.get(dim[1], idx);
+                var xScale = coordSys.getAxis('x').scale;
+                var yScale = coordSys.getAxis('y').scale;
+                var xExtent = xScale.getExtent();
+                var yExtent = yScale.getExtent();
+                var x = xScale.parse(xValue);
+                var y = yScale.parse(yValue);
+                // If is infinity, the axis should be considered not clipped
+                if ((isInifinity(x) || x >= xExtent[0] && x <= xExtent[1])

Review comment:
       There is a builtin method to check if value is in the extent
   ```js
   coordSys.getAxis('x').containData(xValue)
   coordSys.getAxis('y').containData(yValue)
   ```




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



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