I've added a "Move Node" html button above my NetChart. I want the user to be able to re-parent a node.
The scenario is this:
1. User clicks a node - call it NODE1 (I track which node it was in a JS variable)
2. User clicks my Move Node button (I toggle a JS variable movingNode to be true so that I know the next node click event will be to re-parent NODE1)
3. User clicks a different node (NODE2) to identify what the new parent of NODE1 should be
I figured all I had to do at that point is
for (i = 0; i < NODE1.links.length; i++)
{
if ( NODE1.links[i].to.id == NODE1.id)
{
chart1.removeData({links: [{ from: NODE1.links[0].from.id, to: NODE1.links[0].to.id }] }, "chartData");
}
}
chart1.addData( {links: [{ from: NODE2.id, to: NODE1.id }] }, "chartData");
Assuming for a moment that this pseudo code is right, shouldn't removeData remove the link? addData works flawlessly.
Question 2: Is there a better technique to use?