skanaar / nomnoml

The sassy UML diagram renderer
https://www.nomnoml.com
MIT License
2.66k stars 208 forks source link

[New feature] Optional minlen = 0 attribute on arrow #141

Closed ronkok closed 3 years ago

ronkok commented 3 years ago

nomnoml runs, I think, with dagre edges that have attribute minlen = 1. So any two nodes connected by an association are always at least one rank apart.

I use nomnoml to create flowcharts, and it's awesome. If I could wish for one addition, it would be the optional ability to set minlen = 0 on an arrow. I would use this mostly on arrows that run away from a <choice> node. The normal flow of activity would get the standard treatment, but I could run a sideways minlen = 0 arrow to an end node when the choice is to stop the project. It would help to clean up the diagram.

I don't have a use case for any association except an forward leading arrow. Maybe the syntax could be -0>?

skanaar commented 3 years ago

Great suggestion!

Over the years the nodes have gotten much more configurable, but the edges are still pretty much hardcoded.

This syntax would be nice I think, with instead of - to denote minlen = 1 edges `[quit] > [the end]`

If there are several aspects of edges that can be customized this would be a more flexible syntax (and would mirror the custom styles syntax).

#_escape: minlen=0 end=arrow dashed stroke=#888
[<choice>quit] <escape> [<end>the end]

I am only a little bit afraid of opening a pandora's box of problems with these kinds of new features/syntax additions. 🙂

skanaar commented 3 years ago

@ronkok you can try out a release candidate here: http://stage.nomnoml.com/ If it looks good then I'll release it

ronkok commented 3 years ago

I like your syntax proposal for _>. Of course, creating a new arrow type via a directive would be more powerful, but nomnoml's simplicity is one of its strengths.

I tried the release candidate but I have not yet been successful at creating a sideways arrow. My attempted code is:

#_escape: minlen=0 end=arrow dashed stroke=#888
[<start> start] -> [phase 1]
[phase 1] -> [<choice> Review]
[Review] <escape> No [<end> stop]
[Review] -> Go [phase 2]

It still places the end node 1 rank away from the source. I tried both _> and <escape> for the arrow. No luck.

skanaar commented 3 years ago

I didn't implement any custom edge directives. So <escape> won't have any effect. And yeah, I noticed that Dagre still keeps the vetical layout of edges. I think it still is nice to expose a bit more of Dagres feature set, but it didn't turn our as good as I hoped.

I did implement a #gravity: 0 directive that sets minlen = 0 on every edge.

skanaar commented 3 years ago

This is now released as v1.2.0. I'll gladly hear any other feedback @ronkok :)