A super simple, no-nonsense diagramming library written in React that just works.
A no-nonsense diagramming library written entirely in React with the help of Lodash. It aims to be:
- Simple, and void of any fuss/complications when implementing it into your own application
- Customizable without having to hack the core (adapters/factories etc..)
- Simple to operate and understand without sugar and magic
- Fast and optimized to handle large diagrams with hundreds of nodes/links
- Super easy to use, and should work as you expect it to
npm install storm-react-diagrams
or
yarn add storm-react-diagrams
- Its only dependency is Lodash and obviously React so it will install that too.
Simply run webpack
in the root directory (or webpack -p
if you want a production build) and it will spit out the transpiled code and typescript definitions into the dist directory as a single file. It will also compile the code for the demos .We use webpack for this because TSC cannot compile a single UMD file (TSC can currently only output multiple UMD files).
- checkout the project
- run
webpack
in the root - open up one of the demos folders and load the corresponding index.html file.
To see how to create your own nodes like the one below, take a look at demo3:
The library uses a Model Graph to represent the virtual diagram and then renders the diagram using 2 layers:
- Node Layer -> which is responsible for rendering nodes as HTML components
- Link Layer -> which renders the links as SVG paths
Each node and link is fed into a factory that then generates the corresponding node or link react widget. Therefore, to create custom nodes and links, register your own factories that return your own widgets.
As long as a node contains at least one port and the corresponding NodeWidget contains at least one PortWidget, a link can be connected to it.
- onLinkStateChanged (link, isConnected)
- diagramEngine
Because its vastly better to render nodes as standard HTML so that we can embed input controls and not have to deal with the complexities of trying to get SVG to work like we want it to. I also created this primarily to embed into enterprise applications where the nodes themselves are highly interactive with buttons and other controls that cave when I try to use SVG.
Because it can transpile into any level of ECMA Script, and the library got really complicated, so I ported it to Typescript to accommodate the heavy architectural changes I was starting to make. <3 Type Script
Because most of the library is 95% all logic anyway, and I construct very complex DOM elements with many dynamic properties. JSX Would just get in the way, and I personally hate JSX for a multitude of reasons anyway.
Take a look at the defaults directory, with specific attention to the DefaultNodeWidget
Take a look at the demo folders, they have simple and complex examples of the complete usage.
This is a demo of the interaction taken directly from the test folder.
del key will remove anything selected including links
shift and drag will trigger a multi selection box
shift and select nodes/links/points will select multiple nodes
drag canvas will drag the complete diagram
mouse wheel will zoom in or out the entire diagram
click link and drag will create a new link anchor/point that you can then drag around
click node-port and drag will create a new link that is anchored to the port, allowing you to drag the link to another connecting port