Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 6924

How to Add Link Label Text

$
0
0

@ivrtech wrote:

Greetings,

I am trying to create a link label when the "ExternalObjectsDropped" listener is executed. I was able to create a link from a new node to another but unable to auto-generate the text label on the link.

The code below shows how I am creating the link on ExternalObjectsDropped.

Thanks

      //diagram listener when a Tag is drop on pane;
      myDiagram.addDiagramListener("ExternalObjectsDropped", function(e) {
        var newnode = JSON.parse(myDiagram.model.toJson());
        for(i=0;i<newnode["nodeDataArray"].length;i++){
          key = newnode["nodeDataArray"][i]["key"]
        }

        //check if a datasource tag.
        //alert(newnode['nodeDataArray']);
        var size = newnode['nodeDataArray'].length;
        if(newnode['nodeDataArray'][size-1]['text'] == 'Datasource'){
          myDiagram.startTransaction("add node and link");
          newlink = { from: newnode['nodeDataArray'][size-1]['key'], to: 0, text:"hangup" };
            
          myDiagram.model.addLabelKeyForLinkData(newlink, newnode['nodeDataArray'][size-1]['key'])
          myDiagram.model.addLinkData(newlink);
            openModalWindow('Datasource', newnode['nodeDataArray'][size-1]);
            //alert(newnode);
        }
        if(newnode['nodeDataArray'][size-1]['text'] == 'Play'){
          openModalWindow('Play', newnode['nodeDataArray'][size-1]);
          //alert(newnode);
        }
        // do something with newnode
      });

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6924

Trending Articles