<ej-diagram id="diagram" e-height="600px" e-width="100%" e-nodes="nodes" e-nodeCollectionChange="collectionChange" e-connectorCollectionChange="connectorCollectionChange" e-selectionChange="selectionChange" e-textChange="textChange"></ej-diagram>
function textChange(args) {
if(args.elementType === "connector") {
// Returns the changed label value
console.log(args.value);
// Returns the connector’s label
console.log(args.label);
}
} |
document.getElementById('addLabel').onclick = function() {
var diagram = $("#diagram").ejDiagram("instance");
var connector = diagram.selectionList[0];
diagram.insertLabel(connector.name, {fontColor:"red", text:"Label-1", alignment: "before", segmentOffset: 0}, 0);
diagram.insertLabel(connector.name, {fontColor:"green", text:"Label-2", alignment: "after", segmentOffset: 1}, 1);
} |
var diagram = $("#diagram").ejDiagram("instance");
var connector = diagram.selectionList[0];
diagram.insertLabel(connector.name, {name: connector.name + "Label1" , fontColor:"red", text:"Label-1", alignment: "before", segmentOffset: 0}, 0);
diagram.insertLabel(connector.name, {name: connector.name + "Label2", fontColor:"green", text:"Label-2", alignment: "after", segmentOffset: 1}, 1);
function textChanged(args) {
if(args.elementType = "connector") {
// Get the label name
console.log(args.label.name);
// element args returns the connector
console.log(args.element);
}
} |