How to update node at runtime in JavaScript Diagram?
To update Node:
JavaScript Diagram’s clientside updateNode API allows the user to update the node at runtime by setting the node’s specific property.
JS
<div id="diagramcontent"></div> <script> var diagram = $("#diagramcontent").ejDiagram("instance"); var node = diagram.model.selectedItems.children[0]; diagram.updateNode( node.name, { width:200, height:200, fillColor:"blue", type:"basic", shape:"ellipse" } ); </script>
To update Connector:
Diagram’s clientside updateConnector API allows the user to update the connector at runtime by setting the connector specific property.
JS
<div id="diagramcontent"></div> <script> var diagram = $("#diagramcontent").ejDiagram("instance"); var connector = diagram.model.selectedItems.children[0]; diagram.updateConnector( connector.name, { linewidth:4, lineColor:"blue", segments: [{ type: "orthogonal" }] } ); </script>
To update Label:
Diagram’s clientside updateLabel API allows the user to update the label at runtime by setting the label style.
JS
<div id="diagramcontent"></div> <script> var diagram = $("#diagramcontent").ejDiagram("instance"); var node = diagram.model.selectedItems.children[0]; diagram.updateLabel( node.name, node.labels[0], { bold: true, italic: true, fontSize: 18 } ); </script>
Conclusion
I hope you enjoyed learning about how to update node, connector, label at runtime in JavaScript Diagram.
You can refer to our JavaScript Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our JavaScript Diagram example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!