概念图网络 - 节点问题

Mus*_*yed 14 javascript jquery d3.js

我正在尝试使用d3.js.实现Concept Map网络图.图表的样本可以在js-fiddle中找到.

JS-小提琴

小提琴代码 节点方向仅指向左方向.右侧的所有节点都具有矩形背面的线条.我想显示左侧和右侧的所有节点.

预期图表: 概念图预期图

Mus*_*yed 3

我通过使用此代码检查曲线位置找到了解决方案。

 if(af.x>180)
 {
   af.xOffset = -S;
 }else
 {
   af.xOffset = S;
 }
Run Code Online (Sandbox Code Playgroud)

并通过检查推送功能的条件

if (ab.x > 180) {
                    H.push({
                        source: ae,
                        target: ab,
                        key: aa,
                        canonicalKey: aa,
                        x1: ae.x + (ab.type === "theme" ? 0 : U),
                        y1: ae.y + K / 2,
                        x2: Math.cos(Y) * X + ab.xOffset,
                        y2: Math.sin(Y) * X
                    })
                }
                else if (ae.x < 180) {
                    H.push({
                        source: ae,
                        target: ab,
                        key: aa,
                        canonicalKey: aa,
                        x1: ae.x + (ab.type === "theme" ? U : 0),
                        y1: ae.y + K / 2,
                        x2: Math.cos(Y) * X + ab.xOffset,
                        y2: Math.sin(Y) * X
                    })
                }
Run Code Online (Sandbox Code Playgroud)

预期输出为

在此输入图像描述