dagrejs / dagre

Directed graph layout for JavaScript
MIT License
4.69k stars 602 forks source link

Support for rendering labels next to edges, while ensuring edges never cross labels #132

Open Confusion opened 10 years ago

Confusion commented 10 years ago

Would it be possible to modify dagre to achieve the title goal: rendering labels next to edges, instead of on top of them? My use case is that I have reasonably large labels (say 6 lines of 30 characters) and they tend to obscure the edges.

cpettitt commented 10 years ago

There is no direct support for it at the moment, though I could see it being a useful feature. A hack to get you going would be to specify a width of 2 * (size of node + padding) and then shift the x coordinate (assuming top-to-bottom layout) during rendering by size of node / 2 + padding. The downside is that this will spread the graph out more than necessary.

The real fix to make this work would go into the positioning part of the layout algorithm.