Custom properties?

Hi !

I want to store a property with my nodes and links that does not get translated into anything visual, but that only is manipulated by the javascript code. Can’t figure out how to make that work, in particular not how to get them stored into JSON with the rest of the model. Is there a simple way to do this?

You should be adding properties to the node data and link data objects that are in your model, not to the Node and Link GraphObjects. All of the samples are written in this manner.

Or am I misunderstanding what you are doing?

Well, I can’t really understand how to access those once they are created (when nodes are created by dragging from the palette and links are created by drawing lines between the nodes). In other words I’m not first creating a datastructure that I’m then creating the model from… I have tried to manually add this property to JSON and load it, and it does indeed get loaded, but I can’t really figure out how to by code manipulate in such a way that when writing to JSON again the new value will be written…

To clarify, let’s say i get the current selection with myDiagram.selection.first(). How can I from here find the node data associated with the selected object and modify a property ?

Sorry for the delay – I was busy getting beta 7 ready.

Getting from a Part (such as a Node or a Link) to the model data is easy – just get the The property is actually defined on Panel, so that the Panels created for each object in a Panel.itemArray can be data bound too:

For example, look at the updateProperties and updateData functions in the Org Chart Editor sample ( and how those two functions are called.

If you want to modify the property of a node data object, you can do so directly in JavaScript. However if that property is data-bound, it is easier to call Model.setDataProperty.

Thanks ! Sounds obvious now …