You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "Ovilia (via GitHub)" <gi...@apache.org> on 2024/11/08 02:43:42 UTC

Re: [PR] feat: allow closing a curve on polar line series [echarts]

Ovilia commented on code in PR #17720:
URL: https://github.com/apache/echarts/pull/17720#discussion_r1833624117


##########
src/chart/line/poly.ts:
##########
@@ -211,12 +211,29 @@ function drawSegment(
     return k;
 }
 
+function getSmoothableLoopedPoints(shape: ECPolygonShape) {
+    let points = (shape.points as number[]);
+
+    if (shape.connectNulls) {
+        const nonNull: number[] = [];
+        for (let i = 0; i < points.length; i += 2) {
+            if (!isPointNull(points[i], points[i + 1])) {
+                nonNull.push(points[i], points[i + 1]);
+            }
+        }
+        points = nonNull;
+    }
+
+    return [points[points.length - 2], points[points.length - 1], ...points, points[0], points[1]];

Review Comment:
   What if `points.length` is less than 5?



##########
src/chart/line/poly.ts:
##########
@@ -245,8 +262,15 @@ export class ECPolyline extends Path<ECPolylineProps> {
     }
 
     buildPath(ctx: PathProxy, shape: ECPolylineShape) {
-        const points = shape.points;
+        if (shape.loop) {
+            return ECPolygon.prototype.buildPath.call(this, ctx, {

Review Comment:
   I didn't mean implement loop inside Polyline by calling Polygon, because this will cause dependency on the later. Instead, we should decide to call Polygon or Polyline in LineView.



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