Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

d3: force directed graph: node filtering

I was going through the following post:

highlight selected node

enter image description here

Really a nice solution... I am a newbie to d3 and fascinated with its flexibility. I am facing problem at one point. Instead of filtering the nodes on mouseover, I want to filter it on the basis of text entered (node name or id) in a html textbox. Any idea how to achieve this??

Regards

like image 806
Vicky Avatar asked Jan 30 '13 09:01

Vicky


1 Answers

I actually had to do something like this for a project at work. The solution I came up with was to give each node a boolean property which I called isInFilter.

Once the user enters in the text, process it and then loop through all the nodes and assign isInFilter for each node either TRUE or FALSE. Then, your condition for the node displaying (or doing whatever transition you want to do) simply becomes a check on the isInFilter property.

like image 143
Matthew Herbst Avatar answered Oct 22 '22 15:10

Matthew Herbst