diff options
| author | Alon Levy <alon@pobox.com> | 2014-09-29 13:31:28 +0300 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-09-29 13:31:35 +0300 |
| commit | 8461b01095284697deda2e755f91212356a09373 (patch) | |
| tree | 9a4ea66b63c1af1484adf628a377dbcd769ea38e | |
| parent | 8bda55cf4b52d0279ed48bacb2021772dc34e51f (diff) | |
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
<link>
<link>
<node>
<node>
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
<link>
<node>
<link>
<node>
With this commit all links are created in a single group, getting back
the correct order:
<g>
<link>
<link>
</g>
<node>
<node>
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
| -rw-r--r-- | scripts/rhizicore.js | 6 |
1 files changed, 5 insertions, 1 deletions
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") |
