Hello. I've been trying to remove a node dynamically but the way I've been doing it it's really not working because I may remove the selected node but its child remains and, of course, I get an error when building the tree because the properties can't find it's parent.
I actually just been filtering the object. Is there a better way to do this?
document.getElementById('removeButton').addEventListener('click', function(){
var value = document.getElementById('removeText').value;
data = data.filter(function( obj ) {
return obj.name !== value;
});
var treePlugin = new d3.mitchTree.boxedTree()
.setIsFlatData(true)
.setData(data)
.setElement(document.getElementById("visualisation"))
.setIdAccessor(function(data) {
return data.id;
})
.setParentIdAccessor(function(data) {
return data.parentId;
})
.setBodyDisplayTextAccessor(function(data) {
return data.description;
})
.setTitleDisplayTextAccessor(function(data) {
return data.name;
})
.initialize();
});
Hello. I've been trying to remove a node dynamically but the way I've been doing it it's really not working because I may remove the selected node but its child remains and, of course, I get an error when building the tree because the properties can't find it's parent.
I actually just been filtering the object. Is there a better way to do this?
This is how I've been doing.