Hi
Tezcan,
If you need to update the label before the object adds into the diagram, then you can use nodeCollectionChange event to achieve your requirement. Also if you need to update the label once the drawing(drawing rectangle object) completed, then you can use updateLabel method to achieve your requirement. please refer to the code example and JSPlayground link below.
Code example:
$("#diagram").ejDiagram({
//define nodeCollectionChange event
nodeCollectionChange:nodeCollectionChange,
});
function nodeCollectionChange(args) {
if (args && args.element) {
for (i = 0; i < args.element.labels.length; i++) {
args.element.labels[i].text = "1 cm";
}
}
}
function updateLabel() {
var diagram = $("#diagram").ejDiagram("instance");
var node = diagram.model.selectedItems.children[0];
if (node) {
//update the label at runtime
diagram.updateLabel(node.name, node.labels[0], { text: "2cm" });
}
}
JSPlayground link:http://jsplayground.syncfusion.com/oujc30b3
Regards,
Shyam G