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