dagrejs / dagre-d3

A D3-based renderer for Dagre
MIT License
2.84k stars 587 forks source link

Support markers at start and midpoint of edges #316

Closed AlanHohn closed 5 years ago

AlanHohn commented 6 years ago

Adds "arrowtail" and "arrowmid" attributes to edges.

Default to "undirected" so default behavior is the same.

Fixes #194

lutzroeder commented 6 years ago

Can you resolve conflicts and maybe also a short sample how this is being used?

AlanHohn commented 6 years ago

Thanks for taking a look. I fixed the merge conflict.

I did make some changes to demos/arrows.html to show how you'd use it; please let me know if you prefer me to add samples somewhere else as well.

Basically it adds the attributes arrowmid and arrowtail to edges so you can place markers there as well. The value of those attributes is identical to arrowhead (i.e. the name of the arrow style).

I did have to do a little update to the standard "normal" and "vee" arrows to detect when they're being used as arrowtail so they can draw themselves upside down (orient: auto on the marker aligns them with the edge but it doesn't flip the point of the arrow). Anyone who wants to use arrowtail with custom arrows would need to do the same but the change doesn't break any existing use of arrowhead.

So long story short you'd make a double-headed arrow edge like this:

g.setEdge("leftNode", "rightNode", {
  arrowhead: "normal",
  arrowtail: "normal"
});
Little-Fan commented 6 years ago

I need this feature,thx!

mhyleomak commented 5 years ago

Hi all, Will this feature branch merge to master? It would be a great feature for me. Thanks!

clement911 commented 5 years ago

I'd love to use this too!

ralphtq commented 5 years ago

Also keen to have this merge

ralphtq commented 5 years ago

Did the merge happen?

lutzroeder commented 5 years ago

Updated to #361.