1

I'm trying to do it like this

function btnChangeDirClick(){
            var fromNode = document.getElementById("linkMenuLinkFrom").value;
            var toNode = document.getElementById("linkMenuLinkTo").value;
            chart.addData({
                        links:[{id:document.getElementById("linkMenuLinkid").value,
                             from:toNode,
                             to:fromNode
                             }]
                    });
        }

but my console returns

Changing link from,to not supported 

Of course it's possible to delete and recreate, but are there any alternatives?

Graphileon
  • 5,275
  • 3
  • 17
  • 31

2 Answers2

0

One alternative is to store a direction flag in data and assign from and to decorations depending on it.

I suggest using delete/recreate for now. Link reconnection support will come.

Viesturs
  • 1,691
  • 4
  • 21
  • 25
  • using decoration would work for me, because it complicates processing json having to check whether I can rely on the .from and .to or should switch them. – Graphileon Apr 25 '14 at 06:57
  • I implemented it using delete/recreate. solution included in original question – Graphileon Apr 25 '14 at 06:58
0

Finally I ended up implementing is as follows, which works fine:

        function btnChangeDirClick(){

            var fromNode = document.getElementById("linkMenuLinkFrom").value;
            var toNode = document.getElementById("linkMenuLinkTo").value;

            chart.removeData({links:[{id:document.getElementById("linkMenuLinkid").value}]});
            chart.addData({
                links:[{
                    "id":document.getElementById("linkMenuLinkid").value,
                     from:toNode,
                     to:fromNode,
                     "style":{label:document.getElementById("linkMenuLinklabel").value}
                     }]
                });
            nextId += 1;
            document.getElementById("linkMenuLinkFrom").value = toNode;
            document.getElementById("linkMenuLinkTo").value = fromNode;

        }
Graphileon
  • 5,275
  • 3
  • 17
  • 31