Comments (6)
My $0.02, since I've been called in:
Basically, what's core to understanding the lib (and feel free to correct me @dylanvorster, I'm still kinda learning it :D) is this:
- If you're familiar with MVC, it's kind of like that, with all the Widget classes being the View layer and Models are, sliiightly contrary to their name, something in-between actual Models and Controllers, depending on how you want to play it. @dylanvorster seems particularly keen on giving you the freedom to make the call which of the two do you want them to be.
- DiagramEngine is the main thing running the show, with its DiagramModel (which is baked in, you can access it via
getDiagramModel()
or just substitute your own. This is where you'll add factories that are what binds models and widgets together. - Factories, by default work like this: your node models (nodels, if you will?) each have a nodeType (which is a string). DiagramModel uses that type to pick which factory to use. Then, when you add a new node to the model, it's gonna use the factory's
generateReactWidget
method to actually deliver the widget. Do note, so as not to make my mistake, that multiple nodels can have the same type, with the logic dedicated to deciding which widget to pick might be delegated elsewhere: to the factory, or where have you. - Don't sweat factories too much. Just get a good base going (e.g. by taking my advice above and not making too many specialized ones), and the majority of work you'll be doing with the lib will be in nodels and widgets anyway.
Apologies if the above is too ranting and chaotic, I've scarcely had any sleep last night :D
Anyway, if you have any questions, don't hesitate to ask them, @gen4sp (or anyone i suppose) :)
from react-diagrams.
the best way to learn how to create your own nodes is to take a look at the default folder. I do plan to make guides and docs, I just don't have too much time at the moment. But more to the point: the best way would be to create your own NodeModel (like MyNewNodeModel extends NodeModel) and then to register a WidgetFactory that knows how to render that type. I will provide a 'demo3' folder now that shows how to create custom nodes and models. In the mean time, please check out https://github.com/mwozniczak/adventure-weave by @mwozniczak who has been pushing me for quite a few of these things (thanks @mwozniczak for all the support thus far :) ). I am also willing to help on bitter if you need some assistance :)
from react-diagrams.
I just added a demo3 folder which shows a more complex example on how to really extend this library as intended, it created a diamond node, that has 4 inputs at each corner.
from react-diagrams.
Awesome, thanks!
from react-diagrams.
I kind of one to pin this until I can get some guides going o_o
from react-diagrams.
Well, by all means :D
from react-diagrams.
Related Issues (20)
- custom code
- [Bug] Right angled links are diagonal if the points are added after the link is created
- 50 Errors in build HOT 2
- BezierCurve
- Tutorial not working HOT 1
- Deserialization not working HOT 2
- Demos should be refactored to be consistent with modern react standards and styles HOT 2
- I can't see the any nodes. HOT 1
- Is there a way with smart routing to ensure that the link line is never going through the node?
- Deregister Listener when links are created
- DragNewLinkState bug when pressing down with another mouse button while dragging.
- Does storm-react-diagrams support nonce attribute for CSP?
- Node EventListeners don't work when setting a state from component
- can't find createEngine export HOT 1
- Adding NodeModel to NodeLayer set itself as its parent, but NodeModel's parent must be a Diagram
- Module '"@projectstorm/react-diagrams"' has no exported member 'AbstractReactFactory'.
- Intermittent bug in dragNewLink with allowLooseLinks = false HOT 2
- Bug: running `diagrams-demo-project` error `TS2345: Argument of type 'Element' is not assignable to parameter of type 'ReactNode'. Property 'children' is missing in type 'Element' but required in type 'ReactPortal'.`
- Deserialization isn't working properly HOT 1
- got an error in gallary demo: diagrams-demo-gallery HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-diagrams.