简体   繁体   English

使用D3库进行动态过滤

[英]Dynamic filtering with D3 Library

I am familiar with python, much less with javascript. 我熟悉python,更不用说javascript。 I was given the task to have a visual representation of our network infrastructure. 我的任务是直观地了解我们的网络基础架构。 I decided I want to try to accomplish my task with D3 library within a web page. 我决定要尝试通过网页中的D3库完成任务。

My Python code works and deliver proper json data files, but sometimes there are just too much nodes and links to display, it's not very user friendly. 我的Python代码可以正常工作并提供适当的json数据文件,但是有时要显示的节点和链接太多,这不是非常用户友好。 I would like to add a table in the html page, where you can tick cases which will filter the data displayed. 我想在html页面中添加一个表格,您可以在其中勾选要过滤显示数据的案例。

Full working code I was inspired from is available here: https://networkgeekstuff.com/networking/network-topology-visualization-example-of-using-lldp-neighborships-netconf-and-little-python-javascript/ 可以从这里获得我启发的完整工作代码, 网址为: https : //networkgeekstuff.com/networking/network-topology-visualization-example-of-using-lldp-neighborships-netconf-and-little-python-javascript/

and the output: https://networkgeekstuff.com/article_upload/visualize/full/ 和输出: https : //networkgeekstuff.com/article_upload/visualize/full/

From this code, I am able to add a "category" field to my nodes - in the json file-, and I would like that if the user tick the case, we only display the selected matching category(ies) dynamically. 通过此代码,我能够在json文件中的节点上添加一个“类别”字段,并且我希望如果用户勾选了这种情况,我们将仅动态显示所选的匹配类别。

Would that be simple ? 这样简单吗? I could not find any example I could be inspired from to work on it that would match the need. 我找不到任何可以激发需要的示例,可以从中进行启发。

Thanks 谢谢

You could put an event listener for the change event on the checkbox, and then use the native filter array method in javascript to do this. 您可以在复选框上放置更改事件的事件侦听 ,然后使用javascript中的本机筛选器数组方法执行此操作。 There's an example here: 这里有一个例子:

https://bl.ocks.org/johnnygizmo/3d593d3bf631e102a2dbee64f62d9de4 https://bl.ocks.org/johnnygizmo/3d593d3bf631e102a2dbee64f62d9de4

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM