我目前正在探索一个大型专有代码库,其中包含许多单独的项目和相互依赖关系。为了获得更好的概述,我想创建依赖关系的图形表示,这些依赖关系由有向无环图表示。希望最终能够更好地理解依赖项集群并(了解单个项目的内容)以帮助重建项目和依赖项。
目前,我正在使用 D3 进行可视化。下面是我当前尝试的完整代码(项目名称被替换为虚拟名称)。正如你所看到的,它看起来仍然很混乱。将鼠标悬停在项目节点上时可以看到一些顺序。
我已经看过(但尚未尝试)d3-dag,它可能很有前途,但只包含数据集相当小的示例。
我还考虑过使用分层边缘捆绑的图形之类的东西,但这里并没有真正的层次结构。
有人建议比当前使用的力模拟布局更好的方法吗?
<!DOCTYPE html>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.2/d3.min.js"></script>
<style>
#controls {
position: fixed;
left: 0px;
width: 20%;
top: 0px;
height: 10%;
}
#chart {
position: fixed;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
}
path.link {
fill: none;
stroke: #c5c5c5;
stroke-width: 1.0px;
}
circle {
fill: #ccc;
stroke: #fff;
stroke-width: 1.5px;
}
text {
fill: #000000;
font: 11px sans-serif;
pointer-events: none;
}
.ingoing {
stroke: #237690!important;
stroke-width: 1.5px!important;
}
.outgoing …
Run Code Online (Sandbox Code Playgroud)