We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to update Node, Connector, and Label at runtime?

Platform: JavaScript |
Control: ejDiagram |
Published Date: May 27, 2015 |
Last Revised Date: May 30, 2019

To update Node:

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>

 

ADD COMMENT
You must log in to leave a comment
Comments
Marek
Nov 29, 2015
The updateNode function seem not to work inside the events, we needed to do the setTimeout workaround. Is there any better way? nodeCollectionChange: function (args) { var diagram = $("#diagram").ejDiagram("instance"); setTimeout(function () { var NodeConstraints = ej.datavisualization.Diagram.NodeConstraints & ~ConnectorConstraints.DragSourceEnd; diagram.updateNode(node.name, { width: 60, height: 60, constraints: NodeConstraints.Default & ~NodeConstraints.Rotate & ~NodeConstraints.Resize }); }, 1); } Reply

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon