Skip to content

Commit

Permalink
Added +/- icon for expand/collapse button
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehab Wahba committed Nov 3, 2023
1 parent f68fb96 commit 166f71b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions dag.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,32 @@ function drawTree(drawData,state)
.on("mouseout", function () { d3.select(this).attr("r", 12); })
.on("click", onNodeToggleChildrenClicked);

nodesHaveChildren.append("text")
.attr("class", "iText")
.attr("x",function (d) {
switch (shownNodeChildrenMap[d.data.id]) {
case 1:
return nodeWidth/2 - 4.25;
default:
return nodeWidth/2 - 7;
}
})
.attr("y",function (d) {
switch (shownNodeChildrenMap[d.data.id]) {
case 1:
return nodeHeight + 6;
default:
return nodeHeight + 8.5;
}
})
.html(function (d) {
switch (shownNodeChildrenMap[d.data.id]) {
case 1:
return "-";
default:
return "+";
}
})
}
/**
* Search for nodes children and add them to the currentTree
Expand Down Expand Up @@ -402,6 +428,7 @@ function NodeExpand(currentNodeId,data)
nodeChildren.push(data[i]["id"]);
}
}
///Link new nodes (clicked node children) to their existing children
for(let i = 0;i<nodeChildren.length;i++)
{
let nodeGrandChildren = getNodeChildren(nodeChildren[i],data);
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ body {
/*}*/

.node .iText {
font-size: 18px;
font-size: 25px;
fill: var(--main-bg);
pointer-events: none;
font-family: Georgia, 'Times New Roman', Times, serif;
Expand Down

0 comments on commit 166f71b

Please sign in to comment.