Support drawing graphs in the `test/examples` directory
I know that elkjs does not officially support the drawing of graphs (just layout), but I wondered if you would like to add a simple script that allows us to see the graphs in the test/examples directory.
I have found this very useful when working on ELK. My workflow is:
- Make changes in ELK.
- Rebuild elkjs in a sibling directory.
- Reload a page from elkjs/test/examples in the browser.
- Repeat.
I've written SimpleGraphDrawer.js which draws ELK graphs given in JSON format as SVG.
Furthermore, it handles all of the new JSON coordinate modes ~~proposed~~ added in https://github.com/eclipse/elk/pull/1071 .
This PR includes ~~four files~~ five files:
SimpleGraphDrawer.js: The drawing class (and a supportingSvgDrawingclass).test-browser-draw.html: Same as the existingtest-browser.html, except that now we draw the graph.test-browser-draw2.html: Liketest-browser-draw.htmlbut with a more interesting graph (namely, the one from here ).test-browser-draw-all-modes.html: Draws a single graph 6 times, with all possible combinations of the new JSON coordinate modes.
EDIT: I've added a fifth file:
test-coord-modes.html: Maybe a better demonstrator of the coordinate modes for new users.
I've added a new file, test-coord-modes.html which is designed to be a helpful demonstrator of the different coordinate modes, for new users. The JS within the file is (hopefully) well-commented, to help users see how to use the modes.
One purpose of including this could be to help head off issues like #332.
Screenshots
There are some introductory notes:
And here's the full table:
I don' t know if there's any interest in merging this, but, if so, it might be worth discussing which of the five files it adds are really needed. Maybe they are a little redundant at this point.
I think this would be helpful :+1:
I made a few changes:
-
Now showing the input graph on the
test-coord-modes.htmlpage. I think this is very helpful for users to understand what is being drawn. -
I renamed the class
SimpleGraphDrawer-->SimpleElkGraphDrawer. This is a better (more specific) name, describing what the class actually does. -
I removed the file
test-browser-draw-all-modes.htmlsince I think it adds little value beyond whattest-coord-modes.htmlalready does.