4

私は何を達成しようとしていますか?

各ルートがメインルートであるか、別のツリーの葉の子孫であるツリーのような構造で、ノードのグループを持ちたいと思います。

以下に示すものを生成するのは簡単ですが、私が本当に見たいのは、各ルートの周りの完全な円です。ただし、ノードは互いに反発しているため、各クラスター間に以下のギャップが存在します。解決策は、異なる根から来る葉の間の電荷によって引き起こされる反発を無視することであると思います

ここに画像の説明を入力

私のアイデア

  • 各根の周りにある種の半径を設定し、その半径を超えるすべての方向で他のノードを反発させ、葉がその中で円形になるようにします
  • linkDistances と linkStrengths を使用して、クラスターが大きく相互作用しないように何らかの方法で配置します。

これは可能ですか?

私の漠然としたアイデア以外に、これを行う方法が本当にわかりません!

D3 のドキュメントを読むと、動的な linkDistance および linkStrength メソッドとは異なり、ノード チャージの操作は普遍的であることがわかりました。

"All nodes are assumed to be infinitesimal points with equal charge and mass."

この声明が真実である場合、誰かが私を正しい方向に導くことができますか?

4

2 に答える 2

0

I'm think the beginning of an answer might be in this stackoverflow question, Space out nodes evenly around root node in D3 force layout

Do know that is possible to make each node's charge dependent on some attribute of same. Try it with something like

   .charge(function(d) { console.log(d); //you'll see this brings up the nodes
   if (d.something == onething) { 
      return    -1300;} 
   else { 
      return -100; } 
    }) 

As the linked-to answer mentions, you'll almost certainly have to experiment with "friction" and "linkDistance." Don't be afraid of trial and error--I at least have been intermittently dealing with this kind of issue for a few months now, and haven't yet found a "general" solution.

于 2015-09-29T06:36:03.337 に答える