Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/sprint2 #77

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/Tree/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
interface TreeNode {
id: number;
name: string;
cut?: boolean; // Cut children
children?: TreeNode[];
_children?: TreeNode[]; // Hidden children when collapsed
collapsedCount?: number; // Count of collapsed children
Expand Down
32 changes: 31 additions & 1 deletion components/Tree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,38 @@ export default function Tree({ data, nextComponent }: TreeProps) {
.attr("y1", (d) => (d.source as d3.HierarchyPointNode<TreeNode>).y)
.attr("x2", (d) => (d.target as d3.HierarchyPointNode<TreeNode>).x)
.attr("y2", (d) => (d.target as d3.HierarchyPointNode<TreeNode>).y)
.attr("stroke", "#e9bc39")
// .attr("stroke", "#e9bc39")
.attr("stroke", (d) =>
d.source.data.cut || d.target.data.cut ? "#d4d4d4" : "#e9bc39",
) // Set stroke to black if cut is true
.attr("stroke-width", 3);

// 暂时先用X
g.selectAll("text.cut-marker")
.data(links)
.enter()
.filter((d: any) => d.source.data.cut || d.target.data.cut) // Only add 'X' for cut links
.append("text")
.attr("class", "cut-marker")
.attr(
"x",
(d) =>
((d.source as d3.HierarchyPointNode<TreeNode>).x +
(d.target as d3.HierarchyPointNode<TreeNode>).x) /
2,
)
.attr(
"y",
(d) =>
((d.source as d3.HierarchyPointNode<TreeNode>).y +
(d.target as d3.HierarchyPointNode<TreeNode>).y) /
2,
)
.attr("text-anchor", "middle")
.attr("font-size", "14px")
.attr("fill", "red")
.text("X");

// Create groups for each node
const groups = g
.selectAll("g")
Expand Down
Loading