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 2022/02/15 07:58:51 UTC

[GitHub] [echarts] Gyyi commented on a change in pull request #16435: fix(line): 过滤空节点, 避免阶梯线条变为斜线

Gyyi commented on a change in pull request #16435:
URL: https://github.com/apache/echarts/pull/16435#discussion_r806547011



##########
File path: src/chart/line/LineView.ts
##########
@@ -161,32 +161,35 @@ function turnPointsIntoStep(
     const pt: number[] = [];
     const nextPt: number[] = [];
     for (; i < points.length - 2; i += 2) {
-        nextPt[0] = points[i + 2];
-        nextPt[1] = points[i + 3];
-        pt[0] = points[i];
-        pt[1] = points[i + 1];
-        stepPoints.push(pt[0], pt[1]);
-
-        switch (stepTurnAt) {
-            case 'end':
-                stepPt[baseIndex] = nextPt[baseIndex];
-                stepPt[1 - baseIndex] = pt[1 - baseIndex];
-                stepPoints.push(stepPt[0], stepPt[1]);
-                break;
-            case 'middle':
-                const middle = (pt[baseIndex] + nextPt[baseIndex]) / 2;
-                const stepPt2 = [];
-                stepPt[baseIndex] = stepPt2[baseIndex] = middle;
-                stepPt[1 - baseIndex] = pt[1 - baseIndex];
-                stepPt2[1 - baseIndex] = nextPt[1 - baseIndex];
-                stepPoints.push(stepPt[0], stepPt[1]);
-                stepPoints.push(stepPt2[0], stepPt2[1]);
-                break;
-            default:
-                // default is start
-                stepPt[baseIndex] = pt[baseIndex];
-                stepPt[1 - baseIndex] = nextPt[1 - baseIndex];
-                stepPoints.push(stepPt[0], stepPt[1]);
+        if (!isNaN(points[i]) && !isNaN(points[i + 1])) {      
+            pt[0] = points[i];
+            pt[1] = points[i + 1];
+            stepPoints.push(pt[0], pt[1]);
+        }
+        if (!isNaN(points[i + 2]) && !isNaN(points[i + 3])) { 

Review comment:
       Haha, OK, I have fixed this problem. And I also dealt with filtering nulls only when using connectNull: true. 
   Please review the code again,Thanks~




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