aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Spiers <git@adamspiers.org>2015-01-07 16:01:55 +0000
committerAdam Spiers <git@adamspiers.org>2015-01-08 01:27:45 +0000
commit98797b96520061eaeac4ed2398f8ebab960798f2 (patch)
treecc8e41cec451cc4745e6d7bd2c3e0c27a4348414
parentad545356d65d9c522b36a640376b6bd11052d7b7 (diff)
downloadgit-deps-98797b96520061eaeac4ed2398f8ebab960798f2.tar.gz
move functions out of draw_graph
-rw-r--r--html/js/git-deps-graph.js68
1 files changed, 34 insertions, 34 deletions
diff --git a/html/js/git-deps-graph.js b/html/js/git-deps-graph.js
index 44b9b79..ae7477f 100644
--- a/html/js/git-deps-graph.js
+++ b/html/js/git-deps-graph.js
@@ -16,6 +16,12 @@ jQuery(function () {
draw_graph();
});
+function redraw_on_zoom () {
+ fg.attr("transform",
+ "translate(" + d3.event.translate + ")" +
+ " scale(" + d3.event.scale + ")");
+}
+
function draw_graph () {
svg = d3.select("body").append("svg")
.attr("width", WIDTH)
@@ -29,12 +35,6 @@ function draw_graph () {
fg = svg.append('g');
- function redraw_on_zoom () {
- fg.attr("transform",
- "translate(" + d3.event.translate + ")" +
- " scale(" + d3.event.scale + ")");
- }
-
d3.json("test.json", function (error, graph) {
d3cola
.nodes(graph.nodes)
@@ -92,34 +92,6 @@ function draw_graph () {
label.attr("x", function (d) { return d.rect_width / 2; })
.attr("y", function (d) { return d.rect_height / 2; });
- var lineFunction = d3.svg.line()
- .x(function (d) { return d.x; })
- .y(function (d) { return d.y; })
- .interpolate("linear");
-
- var routeEdges = function () {
- d3cola.prepareEdgeRouting(EDGE_ROUTING_MARGIN);
- path.attr("d", function (d) {
- return lineFunction(d3cola.routeEdge(d)
- // // show visibility graph
- //, function (g) {
- // if (d.source.id === 10 && d.target.id === 11) {
- // g.E.forEach(function (e) {
- // vis.append("line").attr("x1", e.source.p.x).attr("y1", e.source.p.y)
- // .attr("x2", e.target.p.x).attr("y2", e.target.p.y)
- // .attr("stroke", "green");
- // });
- // }
- // }));
- );
- });
- if (isIE()) {
- path.each(function (d) {
- this.parentNode.insertBefore(this, this);
- });
- }
- };
-
d3cola.start(10,20,20);
d3cola.on("tick", function () {
@@ -174,6 +146,34 @@ function draw_graph () {
});
}
+var lineFunction = d3.svg.line()
+ .x(function (d) { return d.x; })
+ .y(function (d) { return d.y; })
+ .interpolate("linear");
+
+var routeEdges = function () {
+ d3cola.prepareEdgeRouting(EDGE_ROUTING_MARGIN);
+ path.attr("d", function (d) {
+ return lineFunction(d3cola.routeEdge(d)
+ // // show visibility graph
+ //, function (g) {
+ // if (d.source.id === 10 && d.target.id === 11) {
+ // g.E.forEach(function (e) {
+ // vis.append("line").attr("x1", e.source.p.x).attr("y1", e.source.p.y)
+ // .attr("x2", e.target.p.x).attr("y2", e.target.p.y)
+ // .attr("stroke", "green");
+ // });
+ // }
+ // }));
+ );
+ });
+ if (isIE()) {
+ path.each(function (d) {
+ this.parentNode.insertBefore(this, this);
+ });
+ }
+};
+
function isIE () {
return (navigator.appName == 'Microsoft Internet Explorer') ||
((navigator.appName == 'Netscape') &&