diff options
author | Adam Spiers <git@adamspiers.org> | 2015-01-08 18:51:52 +0000 |
---|---|---|
committer | Adam Spiers <git@adamspiers.org> | 2015-01-08 18:52:14 +0000 |
commit | e226b6679ea3073a9a5b83affa83bf34b4dc5c6d (patch) | |
tree | 645768c5f372f8b4b6a4b71985108e25eba55460 /html | |
parent | d69fad2ce8f684e966a2f5433f73b6fa1a846525 (diff) | |
download | git-deps-e226b6679ea3073a9a5b83affa83bf34b4dc5c6d.tar.gz |
no need to initialize cola more than once
Diffstat (limited to 'html')
-rw-r--r-- | html/js/git-deps-graph.js | 29 |
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; |