d3: force directed graph: node filtering

左心房为你撑大大i 提交于 2019-12-21 09:06:19

问题


I was going through the following post:

highlight selected node

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


回答1:


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.



来源:https://stackoverflow.com/questions/14600967/d3-force-directed-graph-node-filtering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!