From 8c8951a1cf05bd1a2b1c86efb5bba6237c328f8d Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Mon, 9 Mar 2015 16:43:30 +0200 Subject: client/graph_view: show images with correct size, but force layout doesn't take it into account --- src/client/view/graph_view.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/client') diff --git a/src/client/view/graph_view.js b/src/client/view/graph_view.js index 591c54b5..e2b7520e 100644 --- a/src/client/view/graph_view.js +++ b/src/client/view/graph_view.js @@ -479,12 +479,14 @@ function GraphView(spec) { .attr("dx", nodeTextX); node.select('g.node a image') .each(function (d, i) { - if (urlImage(d)) { - console.log('an image!'); + var element = this, + image = new Image(); + image.onload = function () { + element.setAttribute("width", this.width); + element.setAttribute("height", this.height); + element.setAttributeNS("http://www.w3.org/1999/xlink", "href", this.src); } - this.setAttribute("width", "14"); - this.setAttribute("height", "14"); - this.setAttributeNS("http://www.w3.org/1999/xlink", "href", "/static/img/url-icon.png"); + image.src = urlImage(d) ? d.url : "/static/img/url-icon.png"; }); circle = nodeEnter.insert("circle"); node.select('g.node circle') -- cgit v1.3.1