Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix the implementation of polyline in the indented tree case #6213

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/g6/__tests__/demos/case-indented-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ export const caseIndentedTree: TestCase = async (context) => {
}

class IndentedEdge extends Polyline {
protected getControlPoints(attributes: Required<PolylineStyleProps>, sourcePoint: Point, targetPoint: Point) {
protected getControlPoints(attributes: Required<PolylineStyleProps>) {
const [sourcePoint, targetPoint] = this.getEndpoints(attributes, false);
const [sx] = sourcePoint;
const [, ty] = targetPoint;
return [[sx, ty]] as Point[];
Expand Down
8 changes: 7 additions & 1 deletion packages/g6/src/elements/edges/polyline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class Polyline extends BaseEdge {
super(mergeOptions({ style: Polyline.defaultStyleProps }, options));
}

protected getPoints(attributes: ParsedPolylineStyleProps): Point[] {
protected getControlPoints(attributes: ParsedPolylineStyleProps): Point[] {
const { router } = attributes;
const { sourceNode, targetNode } = this;
const [sourcePoint, targetPoint] = this.getEndpoints(attributes, false);
Expand All @@ -79,6 +79,12 @@ export class Polyline extends BaseEdge {
}
}

return controlPoints;
}

protected getPoints(attributes: ParsedPolylineStyleProps): Point[] {
const controlPoints = this.getControlPoints(attributes);

const [newSourcePoint, newTargetPoint] = this.getEndpoints(attributes, true, controlPoints);
return [newSourcePoint, ...controlPoints, newTargetPoint];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ class IndentedNode extends BaseNode {
}

class IndentedEdge extends Polyline {
getControlPoints(attributes, sourcePoint, targetPoint) {
getControlPoints(attributes) {
const [sourcePoint, targetPoint] = this.getEndpoints(attributes, false);
const [sx] = sourcePoint;
const [, ty] = targetPoint;
return [[sx, ty]];
Expand Down
Loading