xstate-viz icon indicating copy to clipboard operation
xstate-viz copied to clipboard

Feature Request: Improve Diagram Layout

Open amitnovick opened this issue 5 years ago • 6 comments

Description

Currently, the Visualizer layout algorithm isn't producing very readable diagrams. The following is a comparison between a diagram produced by PlantUML to one made by XState-Viz:

Details

Suggestion

Two possible approaches:

  • Experiment and tweak the layout algorithm and/or the resizing of the diagram.
  • Research layout solutions implemented in similar tools and try to adapt them for use in our Visualizer system.

amitnovick avatar Sep 16 '19 20:09 amitnovick

Might be useful to implement some pathfinding algorithm to find the most optimal path around state nodes to a target state node which avoids "areas of interest" (such as state names, event labels, actions, etc.)

davidkpiano avatar Sep 16 '19 22:09 davidkpiano

Integrating cola.js into the cytoscape-based graph viz may be enough to make nice force-directed graph layouts. This example could be useful: https://js.cytoscape.org/demos/colajs-graph/

Unfortunately I don't have a ton of time out of work to implement something like this, but I'll subscribe to this issue so that I can come back to it during Hacktober or something

jdpigeon avatar Jan 03 '20 22:01 jdpigeon

I was playing with https://github.com/OpenKieler/elkjs and it works pretty well. SCION a project in which XState is a backer, has a visualizer https://gitlab.com/scion-scxml/schviz which uses KlayJS that is an older version of ELKjs and it works. One option I evaluated is to modify https://gitlab.com/scion-scxml/schviz to support the XState format and this way we could reuse the layout logic.

carloslfu avatar Jan 07 '20 13:01 carloslfu

If we want to go one step further and want to have an bidirectionnal editing experience (from diagram to code), do we want to reinvent the wheel ?

Could we investigate a more robust diagram base, so we can plugin graph layouts and interactivity ?

@davidkpiano thoughts appreciated.

anyway I'd like to experiment on that.

tclain avatar May 13 '20 14:05 tclain

@tclain, I think https://github.com/OpenKieler/elkjs works pretty well. I am not sure but I think @davidkpiano is working on an improved visualizer, I saw something about it on Twitter.

carloslfu avatar May 13 '20 19:05 carloslfu

thanks @carloslfu ! will take a look.

I'm investigating:

  • sprotty (full typescript support and have layout features vial elk)
  • mxgraph (the base tech behind draw.io/diagrams.net (very capable but no great typescript support)
  • jointjs (very nice as well, the dual licencing might be an issue though)

I think that having stable xstate viz/editor will be definitely a huge step. @davidkpiano I'm working and researching on that personnally, if there is an ongoing effort and I can help in any way let me know.

tclain avatar May 13 '20 19:05 tclain