Skip to content

Commit

Permalink
fix: Graph > text, line, circle 쌓임 문제
Browse files Browse the repository at this point in the history
  • Loading branch information
YuHyun-P committed Dec 7, 2023
1 parent 519ed79 commit c4e7b6d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/frontend/src/components/graph/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function renderD3(svgRef: RefObject<SVGGElement>, data: InitialDataProps[]) {

// Add text next to each node
svg
.select("#text")
.selectAll("text")
.data(treeData.descendants())
.join(
Expand Down Expand Up @@ -65,6 +66,7 @@ function renderD3(svgRef: RefObject<SVGGElement>, data: InitialDataProps[]) {

// Draw edges (links) between nodes
svg
.select("#link")
.selectAll("line")
.data([...treeData.links(), ...addedLine])
.join(
Expand All @@ -83,6 +85,7 @@ function renderD3(svgRef: RefObject<SVGGElement>, data: InitialDataProps[]) {
.style("opacity", 1);

svg
.select("#node")
.selectAll("circle")
.data(treeData.descendants())
.join(
Expand Down Expand Up @@ -127,7 +130,11 @@ export function Graph({ className }: GraphProps) {
return (
<div className={className}>
<svg width="100%">
<g ref={gRef} transform="translate(100,70)" />
<g ref={gRef} transform="translate(100,70)">
<g id="link" />
<g id="node" />
<g id="text" />
</g>
</svg>
<button type="button" onClick={handleNewData}>
click
Expand Down

0 comments on commit c4e7b6d

Please sign in to comment.