简体   繁体   English

D3.JS:为我的标签数据结构实现力导向图

[英]D3.JS: implementing Force-Directed Graph for my tag data structure

I'm trying to use the Force-Directed Graph in my application. 我正在尝试在应用程序中使用力导向图 But I'm really stuck in implementing it with my tags data. 但是我真的很难用我的标签数据来实现它。

My tag data structure is like: 我的标签数据结构如下:

for each Tag{
"name":<The name of the tags>
"friends":<a list of names of other tags that this tag need to be connected with>
}

I noticed in the example links has indexes for source and target nodes. 我在示例链接中注意到,链接具有源节点和目标节点的索引。 But I don't have this with my dynamic data. 但是我的动态数据没有这个功能。

Any idea? 任何想法?

BTW, I'm using AngularJS with D3 and data is in Angular. 顺便说一句,我在D3中使用AngularJS,数据在Angular中。

Thanks!! 谢谢!!

My final approach is using angular directive. 我最后的方法是使用角度指令。 In the functions for the directive, I first generates links object then do other d3 stuff. 在指令的函数中,我首先生成links对象,然后执行其他d3任务。 This article is very helpful! 本文非常有帮助! My unperfected code is here . 不完善的代码是在这里

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

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