我正在寻找建议或一些想法。 我需要构建一些D3图表(看起来像组织结构图),但要具有一些高级功能。某些节点必须通过路径连接与其他节点连接。看起来像在screenshot 1上。这些线应分开(每个连接-不同的线)。
我想做的事情:为每个节点留一些余量,并在这些点的基础上建立路径(visual in here),并为每条单独的线添加一些填充。
我无法选择其他类型的图表。
我当前的图形如下:https://blog.zubasoft.at/Examples/D3.js/OrgChart/
关于如何进行此类连接的任何想法?
答案 0 :(得分:0)
我相信您将必须为每个连接创建一个path。例如,在视觉效果中,您可以将连接向右移动5个像素,然后向底部移动10个像素,然后向右移动直到您到达目标节点的中心,然后向上移动。
如果您具有固定的节点垂直和水平边距,则制定这些规则也不会太糟糕。
答案 1 :(得分:0)
您将需要找到两条线之间的交点,但是公式很复杂,请参见https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
您可以使用演示波纹管作为起点
var chart = new OrgChart(document.getElementById("tree"), {
template: "ula",
layout: BALKANGraph.mixed,
mouseScroolBehaviour: BALKANGraph.none,
scaleInitial: BALKANGraph.match.boundary,
nodeBinding: {
field_0: "name",
field_1: "title",
img_0: "img"
},
nodes: [
{ id: 1, name: "Jack Hill", title: "Chairman and CEO", email: "amber@domain.com", img: "https://balkangraph.com/js/img/1.jpg" },
{ id: 2, pid: 1, name: "Lexie Cole", title: "QA Lead", email: "ava@domain.com", img: "https://balkangraph.com/js/img/2.jpg" },
{ id: 3, pid: 1, name: "Janae Barrett", title: "Technical Director", img: "https://balkangraph.com/js/img/3.jpg" },
{ id: 4, pid: 1, name: "Aaliyah Webb", title: "Manager", email: "jay@domain.com", img: "https://balkangraph.com/js/img/4.jpg" },
{ id: 5, pid: 2, name: "Elliot Ross", title: "QA", img: "https://balkangraph.com/js/img/5.jpg" },
{ id: 6, pid: 2, name: "Anahi Gordon", title: "QA", img: "https://balkangraph.com/js/img/6.jpg" },
{ id: 7, pid: 2, name: "Knox Macias", title: "QA", img: "https://balkangraph.com/js/img/7.jpg" },
{ id: 8, pid: 3, name: "Nash Ingram", title: ".NET Team Lead", email: "kohen@domain.com", img: "https://balkangraph.com/js/img/8.jpg" },
{ id: 9, pid: 3, name: "Sage Barnett", title: "JS Team Lead", img: "https://balkangraph.com/js/img/9.jpg" },
{ id: 10, pid: 8, spids: [2], name: "Alice Gray", title: "Programmer & QA", img: "https://balkangraph.com/js/img/10.jpg" },
{ id: 11, pid: 8, name: "Anne Ewing", title: "Programmer", img: "https://balkangraph.com/js/img/11.jpg" },
{ id: 12, pid: 9, name: "Reuben Mcleod", title: "Programmer", img: "https://balkangraph.com/js/img/12.jpg" },
{ id: 13, pid: 9, name: "Ariel Wiley", title: "Programmer", img: "https://balkangraph.com/js/img/13.jpg" },
{ id: 14, pid: 4, name: "Lucas West", spids: [1], title: "Marketer", img: "https://balkangraph.com/js/img/14.jpg" },
{ id: 15, pid: 4, name: "Adan Travis", title: "Designer", img: "https://balkangraph.com/js/img/15.jpg" },
{ id: 16, pid: 4, name: "Alex Snider", title: "Sales Manager", img: "https://balkangraph.com/js/img/16.jpg" }
]
});
html, body {
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
font-family: Helvetica;
overflow: hidden;
}
#tree {
width: 100%;
height: 100%;
}
<script src="https://balkangraph.com/js/latest/OrgChart.js"></script>
<div id="tree"></div>