d3:力有向图:节点过滤 [英] d3: force directed graph: node filtering

查看:545
本文介绍了d3:力有向图:节点过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在浏览以下讯息:

突出显示所选节点

真的是一个不错的解决方案...我是一个新手d3和迷恋它的灵活性。我在一点上面临问题。我不想过滤鼠标悬停上的节点,而是基于在html文本框中输入的文本(节点名或id)对其进行过滤。任何想法如何实现这一点

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??

尊重

推荐答案

实际上不得不做这样的一个项目在工作。我想出的解决方案是给每个节点一个布尔属性,我调用isInFilter。

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.

一旦用户输入文本,处理它,然后循环遍历所有节点并为每个节点分配isInFilter TRUE或FALSE。然后,你的节点显示的条件(或做任何你想做的任何转换)只是成为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.

这篇关于d3:力有向图:节点过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆