Rendering in gojs

initilally there are 10 elements in nodeDataArray

case 1:
now I’m calling an addNodeData method with an new element , is gojs only updates the newNode or entire model…?

case 2:
now I’m re-render the node data with 11 elements, is gojs only updates the newNode or entire model…?

which will be the efficient way, and how will gojs behave while adding, deleting nodes or links…?

Are you using React? Are all of your props data immutable?

GoJS was designed for mutable data and model. When dealing with large diagrams and limited resources, for example when moving nodes, frequently copying memory is inherently inefficient.

For case 1, Model.addNodeData modifies the Model.nodeDataArray by pushing onto the Array. Of course there is a lot of other work to be done within the transaction: copying the template Node, adding it to a Layer, evaluating its Bindings, measuring and arranging all of the objects in its visual tree that need it, performing any invalid layouts, updating the document bounds and scrollbars if needed, and updating the drawn viewport.

For case 2, it depends on what you mean by:

If you are setting Model.nodeDataArray to a new Array, the diagram will discard all of the existing Nodes and create new Nodes as I just outlined for case 1.

If you are calling Model.mergeNodeDataArray, the model/diagram will make the minimum changes needed for update the diagram. That is what gojs-react calls.

Please read the rest of the page starting at GoJS Using Models -- Northwoods Software