This library was built to allow for the easy generation of diagrams.net MX based files supporting the C4 diagram style. It is constrained to only support:
- C4 Stencil object styles
- Nesting of objects, such that containers can be placed inside a Software System, for example
- Auto layout of entities so that they are reasonably easy to start editing in diagrams.net
Install with npm:
npm install --save-prod mxbuilder
Install with yarn:
yarn add mxbuilder
To generate an MX file you create an instance of mxbuilder and then make calls to add specific C4 entities. When you are done, call toDiagram()
to fetch the resulting diagrams.net file.
Example:
var mx = new MxBuilder();
var id = mx.placeSoftwareSystem('System Name', 'System Description', 'ss001');
var str = await mx.toDiagram();
This project relies on elkjs to implement the diagram layout function.
This package is released under the MIT license.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Tests are written assuming the Jest test framework.