From a95f466f3f92a2aab1f63e27200c25ce297d3db1 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sun, 12 Jul 2015 00:11:18 +0200 Subject: [PATCH] map/graph: implement render --- lib/forcegraph.js | 8 +++++++- lib/gui.js | 4 ++-- lib/map.js | 8 +++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/forcegraph.js b/lib/forcegraph.js index c760b15..fa01ebc 100644 --- a/lib/forcegraph.js +++ b/lib/forcegraph.js @@ -501,7 +501,6 @@ define(["d3"], function (d3) { el = document.createElement("div") el.classList.add("graph") - self.div = el zoomBehavior = d3.behavior.zoom() .scaleExtent([1 / 3, 3]) @@ -699,6 +698,13 @@ define(["d3"], function (d3) { force.stop() canvas.remove() force = null + + if (el.parentNode) + el.parentNode.removeChild(el) + } + + self.render = function (d) { + d.appendChild(el) } return self diff --git a/lib/gui.js b/lib/gui.js index 830fe8f..26e3db7 100644 --- a/lib/gui.js +++ b/lib/gui.js @@ -28,7 +28,7 @@ function (chroma, Map, Sidebar, Tabs, Container, Meshstats, Linklist, router.removeTarget(content) dataTargetRemove(content) content.destroy() - contentDiv.removeChild(content.div) + content = null } @@ -36,7 +36,7 @@ function (chroma, Map, Sidebar, Tabs, Container, Meshstats, Linklist, removeContent() content = new K(config, linkScale, sidebar.getWidth, router, buttons) - contentDiv.appendChild(content.div) + content.render(contentDiv) if (latestData) content.setData(latestData) diff --git a/lib/map.js b/lib/map.js index c54877a..32c9f99 100644 --- a/lib/map.js +++ b/lib/map.js @@ -207,7 +207,6 @@ define(["map/clientlayer", "map/labelslayer", var el = document.createElement("div") el.classList.add("map") - self.div = el map = L.map(el, options) @@ -435,6 +434,13 @@ define(["map/clientlayer", "map/labelslayer", self.destroy = function () { clearButtons() map.remove() + + if (el.parentNode) + el.parentNode.removeChild(el) + } + + self.render = function (d) { + d.appendChild(el) } return self