Skip to content

Commit

Permalink
#1 filter nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Scobiform committed Apr 17, 2024
1 parent 27af429 commit 59e6f80
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions templates/graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,13 @@
el => Graph.width(el.offsetWidth)
);

function filterNodes(filterType) {
Graph.graphData().nodes.forEach(node => {
node.hidden = (filterType !== 'all' && node.type !== filterType);
});
Graph.refresh(); // This function call updates the graph rendering
}



</script>
6 changes: 5 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
{% else %}
<a href="/login">Login with Mastodon</a>
{% endif %}

<!-- Buttons to show and hide nodes based on type-->
<button onclick="filterNodes('follower');">Show Followers</button>
<button onclick="filterNodes('followings');">Show Followings</button>
<button onclick="filterNodes('all');">Show All</button>
</header>

{{ graph | safe }}


</body>
</html>

Expand Down

0 comments on commit 59e6f80

Please sign in to comment.