Skip to content

Commit

Permalink
fix error when no links are connected
Browse files Browse the repository at this point in the history
Was complaining about accessing undefined before
  • Loading branch information
hfxbse committed May 14, 2024
1 parent 85f0556 commit 7a2e8e4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/visualization/graph/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ export default class UserGraphVisualization extends HTMLElement {

onClick(link, d) {
const clickedNodeId = d.id;
const linksToUpdate = link.filter(linkData => linkData.source.id === clickedNodeId || linkData.target.id === clickedNodeId);
const linksToUpdate = link?.filter(linkData => linkData.source.id === clickedNodeId || linkData.target.id === clickedNodeId);

if ((linksToUpdate?._groups[0]?.length ?? 0) < 1) return

if (!this.colorGroupList[d.id]) {
this.colorGroupList[d.id] = Math.random();
Expand All @@ -207,7 +209,7 @@ export default class UserGraphVisualization extends HTMLElement {
this.colorGroupList[user.id] = Math.random();
}

linksToUpdate.attr("stroke", this.color(this.colorGroupList[user.id]));
linksToUpdate?.attr("stroke", this.color(this.colorGroupList[user.id]));
}

removeHighlights() {
Expand Down

0 comments on commit 7a2e8e4

Please sign in to comment.