D3.js强制布局

编程入门 行业动态 更新时间:2024-10-25 18:27:33
本文介绍了D3.js强制布局 - 仅显示图形的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

早上好,

刚开始的真棒d3js库...

just starting with the awesome d3js library ...

只有具有力定向布局的图的一部分。这个想法是将一个节点声明为中心,并显示距离该中心节点两个(例如)距离内的所有节点,中心节点的邻居和邻居的邻居。如果用户点击显示的节点之一,则它变成新的中心节点并且显示不同的子图。我不知道是否有一个关于实现这种子图布局的示例,如果某种类型的节点距离算法已经在d3js中实现。

I want to show only a portion of a graph with the force directed layout. The idea is to have one node declared as the "center" and show all nodes within a distance of two (for example) from this center node, the neighbors of the center node and the neighbors of the neighbors. If the user clicks on one of the displayed nodes it becomes the "new" center node and a different "subgraph" is displayed. I wonder if there is an example around implementing this kind of subgraph layout and if some kind of a "node-distance" algorithm is already implemented in d3js.

非常感谢

martin

:只是找到了示例修改强制布局,其中阐明了如何添加和删除节点和边缘从力导向的布局。

UPDATE: Just found the example Modifying a Force Layout which illuminates how to add and remove nodes and edges from a force directed layout.

推荐答案

我刚刚上传了一个互动力量导向子图的概念证明级别。

I just uploaded a "proof of concept level" of an interactive force directed subgraph.

http://justdharma/d3/sub-graph/

在本例中,我使用了backbonejs。作为我第一次使用backbonejs实现一些东西,我肯定以非常粗暴的方式使用它。虽然这个例子可以说明如何实现一个交互式子图表,但它是肯定不是一个模板如何做到 - 只是一个概念的证明hack ...

In this example I use backbonejs under the hood. Being the first time I implement something with backbonejs, I for sure use it in a very crude manner. While this example might illuminate one way how an interactive sub-graph can be achieved it is for sure not a template how to do it - as said just a proof of concept hack ...

更多推荐

D3.js强制布局

本文发布于:2023-07-18 12:56:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1145008.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:布局   js

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!