Code Monkey home page Code Monkey logo

Comments (5)

bcakmakoglu avatar bcakmakoglu commented on June 3, 2024

Alas, this is not a bug but expected to happen since both labels use the same position.
You’ll have to either use different edges with non overlapping paths or offer labels if they overlap.
There’s not a built in solution for this sorry

from vue-flow.

mwessendorf avatar mwessendorf commented on June 3, 2024

Alas, this is not a bug but expected to happen since both labels use the same position. You’ll have to either use different edges with non overlapping paths or offer labels if they overlap. There’s not a built in solution for this sorry

Understood. Thanks.

from vue-flow.

bcakmakoglu avatar bcakmakoglu commented on June 3, 2024

@mwessendorf Sorry I have to disappoint you about a built-in helper or sth and sorry that my response was a little short; I responded from my phone πŸ˜….

To expand a bit on this - the default edge labels (meaning edge.label) will always be rendered at the center position.
So if two edges follow the same path or a path that would make their centers cross, the labels will, by default, inadvertently overlap. There's really no way around it unless you modify your handles in a way that edges don't overlap/cross.

If you're using a custom edge, you can use the EdgeLabelRenderer to place a label as a div on an edge.
This EdgeLabelRenderer needs you to apply some styles for the label to be centered, like transform.
The transformation is given an X and Y position so that the label gets centered, these positions are (usually) taken from the utils like getBezierPath -> const [path, centerX, centerY] = getBezierPath(params).
But in this case you have the option of just offsetting these center positions by whatever you deem adequate so that the labels do not overlap anymore.

Again, there's no built-in mechanism that would catch this overlap and reposition edges but you can build this sort of logic yourself.

from vue-flow.

bcakmakoglu avatar bcakmakoglu commented on June 3, 2024

You can find an example of how to use the EdgeLabelRenderer here.
Just open up the file CustomEdge.vue and check the template :)

from vue-flow.

mwessendorf avatar mwessendorf commented on June 3, 2024

@bcakmakoglu Many thanks for explanation. That helps a lot. Will dive in there again and play with the positioning =)

from vue-flow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.