fix: hierarchy tree to update node context, not to add new

This commit is contained in:
Azgaar 2022-06-19 13:45:08 +03:00
parent 6ab87d5627
commit 2aa2fab54d

View file

@ -1,6 +1,5 @@
appendStyleSheet();
insertHtml();
addListeners();
const MARGINS = {top: 10, right: 10, bottom: -5, left: 10};
@ -178,8 +177,6 @@ function insertHtml() {
byId("dialogs").insertAdjacentHTML("beforeend", html);
}
function addListeners() {}
function getRoot() {
const root = d3
.stratify()
@ -260,12 +257,18 @@ function renderTree(root, treeLayout) {
.call(d3.drag().on("start", dragToReorigin));
node
.append("path")
.attr("d", ({data}) => shapesMap[getShape(data)])
.selectAll("path")
.data(d => [d])
.join("path")
.attr("d", d => shapesMap[getShape(d.data)])
.attr("fill", d => d.data.color || "#ffffff")
.attr("stroke-dasharray", d => (d.data.cells ? "none" : "1"));
node.append("text").text(d => d.data.code || "");
node
.selectAll("text")
.data(d => [d])
.join("text")
.text(d => d.data.code || "");
}
function mapCoords(newRoot, prevRoot) {