Open fchaverot opened 7 years ago
I have suggested a way to do this: allow states to be defined before transitions (rather than as an adjunct to transitions.) That way, you could provide dot attributes to the state nodes.
It would also have a side benefit - transition definitions could check the provided 'to-from' states and insure they exist.
I'm working on a branch to do just this. Will issue a pull request when I'm done.
Don't know if anyone is still following this, but I have a branch at https://github.com/rickbsgu/javascript-state-machine that does this.
Clone it and check out the 'statedefs' branch.
To use it, add a 'statedefs' array in the fsm definition, like so:
...
statedefs: [
{ name: 'enter', dot: { fillcolor: 'green', shape:'rect' } },
...
],
'dot' defs are optional, but once you specify statedefs, all states must be defined in the array.
This triggers additional checks:
(Helps me...)
It also defines an overall dot style prefix for the entire chart. Makes it look a bit less ugly. You can override it with the 'dotPrefix' key. Look at the 'statedefs.js' test to see how to do that.
rickb
@rickbsgu You may check the dot command line args as well.
For example, you get a graph some graph to be displayed with a box shape
dot -Nshape=box -Tpng some.dot > some.png
I would like to add this kind of dot output:
digraph "door" { rankdir=LR; "closed" [ style=filled, color = black, fillcolor=red ]; "open" [ style=filled, color = black, fillcolor=blue ]; "closed" -> "open" [ color="blue" ]; "open" -> "closed" [ color="red" ]; }
So in real time I will be able to change the color of the node according to the node state
I can do it also by postprocessing the dot output of the visualise() function, isn't it simpler ?