Blazor-Diagrams / Blazor.Diagrams

A fully customizable and extensible all-purpose diagrams library for Blazor
https://blazor-diagrams.zhaytam.com
MIT License
919 stars 176 forks source link

[3.0 pre-release] Links dont connect to Ports #298

Closed AlmightyLks closed 1 year ago

AlmightyLks commented 1 year ago

image

Migrating from v2 to v3, the links don't connect to the ports anymore
The ports however are rendered within the model properly, so that part should be fine

zHaytam commented 1 year ago

Hey,

Can you tell me what you changed from v2 to v3?

AlmightyLks commented 1 year ago

image

image

image

zHaytam commented 1 year ago

Using v2, the port was also in the same position? Because it looks a bit to the left side?

AlmightyLks commented 1 year ago

(Following image is v2) image

Seems so to me

zHaytam commented 1 year ago

Im guessing when you move the nodes the links are still out of place?

AlmightyLks commented 1 year ago

Yep

zHaytam commented 1 year ago

Can you upload me the project as is? I don't want to do these changes to my other clone since I'm cehcking the performance problem in that one

AlmightyLks commented 1 year ago

Latest v3 state is up on the repo Snatch the zip clone 😄

zHaytam commented 1 year ago

Hey, found the issue!

Since your ports don't really have a shape (0 height), the SinglePortAnchor returns a wrong position because UseShapeAndAlignment is true by default.

Change your ports initiation to:

if (current.Parent.GetPort(PortAlignment.Bottom) is { } sourcePort)
    link.SetSource(new SinglePortAnchor(sourcePort) { UseShapeAndAlignment = false });

if (current.GetPort(PortAlignment.Top) is { } targetPort)
    link.SetTarget(new SinglePortAnchor(targetPort) { UseShapeAndAlignment = false });

image

AlmightyLks commented 1 year ago

Oh wow! 😄 Yeah, I would've never found that

Thanks!