The context of VizJs
PlantUML uses Graphviz/DOT to compute node positionning for every UML diagrams (except Sequence Diagrams and Activity Beta Diagrams). The fact that DOT computes automatically the position of node is a key feature, and algorithms implemented in DOT usually give very good result.
However, there are some drawbacks of using DOT : the computation is done by an external program (dot.exe on Windows, dot on linux), and that means that :
-
PlantUML has to create a new process for each diagram, (and communication with this new process could be source of bugs).
-
Users have to install DOT on their system, in addition of Java.
-
PlantUML is not fully portable.
There is a work-in-progress to have link::smetana02[a full Java implementation of PlantUML.] However, even if this is somehow working, this is not finished yet.
Recently, some user points out another possible solution (We thank him by the way!).
Using both VizJs (a port to Javascript of GraphViz) and J2V8 (a highly efficient JavaScript runtime for Java), it is theorically possible to have a (almost) full Java implementation.
With the great help of Andreas Studer that makes a lot of work to test various JavaScript engine, we are now able to propose a working version.
Using visjs
This means that it is possible to use PlantUML without installing GraphViz (which can be useful when you do not have administration right for example). To do so, in addition to plantuml.jar, you must have:
-
vizjs: A Java library written by Andreas Studer that embed viz.js and call J2V8
-
The corresponding J2V8 implementation for your OS:
-
For Windows x86/64 bit: j2v8\_win32\_x86\_64-3.1.6.jar
-
For Linux x86: j2v8\_linux\_x86\_64-3.1.6.jar
-
For Mac OS: j2v8\_macosx\_x86\_64-3.1.6.jar
So, having the three files plantuml.jar, vizjs.jar and j2v8\_XXXXX-3.1.6.jar in the very same folder (this is important) you can run PlantUML without having GraphViz installed.
Finally, you have to set up the GRAPHVIZ_DOT
link::graphviz-dot[environment variable] value to vizjs
(or through the command line with -D flag or -graphvizdot flag).
Then, you can double-check your configuration by running the usual:
@startuml testdot @enduml
Limitations
Note that this is only working with Java 8 (because of J2V8). For complex diagrams (especially with labels on arrow), the solution is not working very well.
An issue has been opened on viz.js side (see Error when generating graph).
However, in that case, PlantUML falls back to some degrated solution.