aboutsummaryrefslogtreecommitdiffstats
path: root/html/js/git-deps-graph.js
diff options
context:
space:
mode:
Diffstat (limited to 'html/js/git-deps-graph.js')
-rw-r--r--html/js/git-deps-graph.js29
1 files changed, 20 insertions, 9 deletions
diff --git a/html/js/git-deps-graph.js b/html/js/git-deps-graph.js
index d9af62b..f21e110 100644
--- a/html/js/git-deps-graph.js
+++ b/html/js/git-deps-graph.js
@@ -10,6 +10,8 @@ var d3cola = cola.d3adaptor()
.avoidOverlaps(true)
.size([WIDTH, HEIGHT]);
+var cola_initialized = false;
+
// The list of nodes, links, and constraints to feed into WebCola.
// These will be dynamically built as we retrieve them via XHR.
var nodes = [], links = [], constraints = [];
@@ -175,24 +177,33 @@ function init_svg() {
fg = svg.append('g');
}
+function init_cola() {
+ if (cola_initialized)
+ return;
+
+ d3cola
+ .nodes(nodes)
+ .links(links)
+ .flowLayout("y", 150)
+ .symmetricDiffLinkLengths(30);
+ //.jaccardLinkLengths(100);
+
+ define_arrow_markers(fg);
+
+ cola_initialized = true;
+}
+
function draw_graph(commitish) {
d3.json("deps.json/" + commitish, function (error, data) {
var new_data = add_data(data);
+ init_cola();
+
if (! new_data) {
noty_warn('No new commits or dependencies found!');
return;
}
- d3cola
- .nodes(nodes)
- .links(links)
- .flowLayout("y", 150)
- .symmetricDiffLinkLengths(30);
- //.jaccardLinkLengths(100);
-
- define_arrow_markers(fg);
-
path = fg.selectAll(".link")
.data(links, function (d) {
return d.source + " " + d.target;