Django 和交互式图形/网络可视化
我正在创建一个 Django 应用程序,并且想要实现社交网络的可视化。我正在寻找一个既可以绘制图形/网络数据结构,又可以使其具有交互性的库。我希望能够单击一个节点并在页面上的其他位置显示该节点的信息(名称、网络等)
到目前为止,我发现 python-graph 和 graphviz 是非常强大的可视化工具,但它们会创建静态图像,因此您无法单击它们。我还发现了这个线程
Graph Visualization Library in JavaScript
其中有很多建议,但其中一些适用于图表中的图表,而不是社交网络图表中的图表。其中一些非常古老,而另一些则是交互式的,因为节点可以在画布上拖动并移动到其他位置。我不太关心用户是否能够更改图表,我只想让节点对象携带可以在某处显示的数据。
有什么建议吗?
I am creating a Django app and want to have visualizations of a social network. I'm looking for a library that can draw a graph/network data structure, but also make it interactive. I'd like to be able to click on a node and have information from that node be displayed (Name, Network, etc) somewhere else on the page
So far I've found python-graph and graphviz to be very powerful visualization tools, but they create static images, so you can't click on them. I've also found this thread
Graph visualization library in JavaScript
which had a lot of suggestions, but some of them are for graphs as in charts, not graph as in social network graph. Some of them are very old, and some of them are interactive only in that the node can be dragged and moved elsewhere on a canvas. I don't care so much about the user being able to change the graph, I'd just like to have the node object carry data with it that can be displayed somewhere.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我使用 PyGraphviz 做了类似的事情。您可以将图形另存为 SVG 并在您的网站中显示该 SVG。然后,您可以使用 jQuery SVG 之类的内容将处理程序附加到节点。
我实现了一个更灵活的解决方案,并将所有节点和边序列化为 JSON 格式并将其发送到网站。然后我使用 Raphaël 绘制图表。该解决方案跨浏览器兼容并且非常灵活。
I did something similar using PyGraphviz. You can save the graph as SVG and show the SVG in your website. Then you can use something like jQuery SVG to attach handlers to the nodes.
I implemented a more flexible solution and serialized all nodes and edges to a JSON format and sent it to the website. Then I draw the graph using Raphaël. This solution is cross-browser compatible and very flexible.
还可以查看 django-netjsongraph。
Checkout also django-netjsongraph.
我喜欢 d3。下面是一个强制导向图的示例(通常用于显示社交网络) 。
将您正在寻求的点击处理类型添加到 d3 Force 示例中将相当容易。
I like d3. Here's an example of a force-directed graph (often used to display social networks).
It would be fairly easy to add the kind of click handling you're seeking to the d3 force example.
库
d3graph
将从Python内部构建一个强制导向的d3图。您可以根据边权重“破坏”网络,并将鼠标悬停在节点上以获取更多信息。双击节点将聚焦于该节点及其连接的边。示例:
The library
d3graph
will build a force-directed d3-graph from within python. You can "break" the network based on the edge weight, and hover over the nodes for more information. Double click on a node will focus on the node and its connected edges.Example: