Question

I need to provide "renaming" functionality to rename nodes using the Icicle example (http://bl.ocks.org/mbostock/4347473).

I am not able to find any solutions similar to what I would like to do, and as browsers usually do not allow for right click, I was wondering if anyone has any suggestions on how to allow for this option and then also how to go about allowing someone to be able to rename a specific node's name.

Thanks.

Was it helpful?

Solution

For the record and per kind request by user2651192, the most workable path for this that we could find is here and, more specifically, the code to change the text is:

...
node.append("text")
    .text(function(d){ return d.name; })
    .on('click', function(d){
        var result = prompt('Change the name of the node',d.name);
        if(result) {
            d.name = result; 
            var node1 = canvas.selectAll('.node').data(nodes);
            node1.select('text')
                .text(function(d){ return d.name; });
        }
    )};
...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top