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

Misaligned arrowheads #174

Open
codemacabre opened this issue Nov 26, 2024 · 2 comments · May be fixed by #175
Open

Misaligned arrowheads #174

codemacabre opened this issue Nov 26, 2024 · 2 comments · May be fixed by #175
Assignees
Labels
bug Something isn't working

Comments

@codemacabre
Copy link
Collaborator

codemacabre commented Nov 26, 2024

In working on #141, I've encountered a weird bug with the arrowheads:
Image

I believe it's because of the Bezier curves from bezier.js, so disabling the library entirely and using CSS transform to offset the lines, it improves, but the arrowheads are still misaligned:
Image

Two points:

  1. We're currently using the SVGtoBeziers() function which is not recommended to be used and has since been removed.
  2. I don't think the CSS approach (second image) is very robust, and may break with larger graphs.
@codemacabre codemacabre added the bug Something isn't working label Nov 26, 2024
@codemacabre codemacabre linked a pull request Nov 28, 2024 that will close this issue
@codemacabre
Copy link
Collaborator Author

On investigation, it looks like the issue is actually the type of curve we're using for the edges in the graph. We're using curveMonotoneX. The best alternatives which don't break arrowheads I've found are using either:

Neither of these are perfect, so we might have to produce a custom curve ourselves.

@codemacabre
Copy link
Collaborator Author

codemacabre commented Dec 10, 2024

I've possibly fixed this by modifying the D3 monotoneX curve code to smooth the ends of the lines. The only change was to adjust line 33, from:

that._context.bezierCurveTo(x0 + dx, y0 + dx * t0, x1 - dx, y1 - dx * t1, x1, y1);

to:

that._context.bezierCurveTo(x0 + dx * 0.9, y0 + dx * t0 * 0.9, x1 - dx * 0.9, y1 - dx * t1 * 0.9, x1, y1);

I'll add this change to the latest PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

1 participant