From 8461b01095284697deda2e755f91212356a09373 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Mon, 29 Sep 2014 13:31:28 +0300 Subject: rhizicore: bug fix: draw links below nodes bug introduced in cd7157955d15802f34dee6ac4578ae249f3e397d before that we recreated the links and nodes every update, and since all links were created before nodes the document order was which per SVG rendering order [1] leads to nodes being drawn on top of links. But after that commit the new links and nodes where created as they were being edited, so we got With this commit all links are created in a single group, getting back the correct order: nodes are ungrouped but there is no need for that (except that it looks strangely assymetrical). [1] http://dev.w3.org/SVG/modules/renderorder/SVGRenderOrder.html --- scripts/rhizicore.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/rhizicore.js b/scripts/rhizicore.js index 10a42fb7..593121b7 100644 --- a/scripts/rhizicore.js +++ b/scripts/rhizicore.js @@ -388,6 +388,10 @@ function myGraph(el) { .attr("y", -$(el).innerHeight() * 5); $('.overlay').click(mousedown); + // SVG rendering order is last rendered on top, so to make sure + // all links are below the nodes we group them under a single g + vis.append("g").attr("id", "link-group"); + function zoom() { if (graphstate === "GRAPH") { vis.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")"); @@ -500,7 +504,7 @@ function myGraph(el) { }; var update = function() { - link = vis.selectAll(".link") + link = vis.select("#link-group").selectAll(".link") .data(links); link.enter().append("svg:defs").selectAll("marker") -- cgit v1.3.1