Hi, currently evaluating GoJS as a solution for a diagram-type webapp.
Is there a way to apply rules to nodes? For example:
Node 1 cannot connect to node types of “Server”, but it can connect to nodes with type “user”
Node 2 can connect to both a server node and a user node, but cannot connect to a database node
Node 3 can connect to all types of node
How would one go about assigning a type to a node and how would one implement rules upon types?
You can assign a “type” to your Node by assigning some property on the node’s data object in the model. If you named that property “type”, then the value would be available as the someNode.data.type. The example at GoJS Validation -- Northwoods Software uses the “color” property to only allow linking between nodes of the same color.
Hey again. I’m trying it out today, but with the below code (edited from the color example you linked) every time I drag an arrow from a node (doesn’t matter which node) it magnets to a random point on the diagram and won’t drag to another node. Am I applying the type correctly by assigning it in the array or do I have to assign the type property in the node template?
The data in the model looks good, but the Bindings on Shape.stroke and Shape.fill aren’t going to work because “server” and “database” are not valid CSS color strings.