skanaar / nomnoml

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

Transition description between states is not in the middle #131

Closed bletvaska closed 3 years ago

bletvaska commented 3 years ago

hello

I am trying to create a state diagram. there is no problem with the state diagram itself. the problem is with the placing of transition's description: I expect, it will be placed in the middle of the arrow, but instead, it is placed over the state, where the transition starts.

my code is:

#direction: right
#arrowSize: 0.4
#fontSize: 12
#padding: 20
#spacing: 100
#bendSize: .8
#gutter: 50

[<start>st]->[<state>day]
[day] intensity < 43 ->[<state>night]
[night] movement ->[<state>light]
[light] no movement ->[night]
[night] intensity > 45% ->[day]

the (exported) result looks like this:

nomnoml

I tried to use labels instead, but this approach is not very UML-ish ;)

what am I doing wrong? ;)

mirek

skanaar commented 3 years ago

Nomnoml's rules are based on UML class diagrams. In UML a state machine diagram is a separate kind of diagram with slightly different rules.

The syntax is designed to support this UML pattern: [parent] * -> 0..2 [child] Where the start and end of an arrow has separate labels. In this case it signifies that a parent can have arbitrarily many children, but the child can have at most two parents.

Unfortunately nomnoml doesn't currently support labels centered on the transition midpoint.

bletvaska commented 3 years ago

Hmm... can you point me, where are state diagrams in UML described this way? Because what you are describing here (the parent and child) looks more like a class diagram or entity-relationship diagram (ERD) and not like a state diagram. There are no parents and children in state diagrams. There are just states (without hierarchy) and transitions between them. You can check Wikipedia for example.

skanaar commented 3 years ago

As I said: "Nomnoml's rules are based on UML class diagrams."

I have added the <start>, <end>, <state> node types to support flowcharts, and basic UML state diagrams. But the full UML State Diagram specification is not implemented.

bletvaska commented 3 years ago

sorry. I overlooked this.

hmm... that's a pity anyway :-( I thought I finally found the good looking state diagrams build/create/design online tool. I'll check later.

anyway - you are doing a great tool. all the best.

skanaar commented 3 years ago

Closing this issue as it is a duplicate of #135