diff options
| author | Alon Levy <alon@pobox.com> | 2015-03-09 16:43:30 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-03-09 16:43:30 +0200 |
| commit | 8c8951a1cf05bd1a2b1c86efb5bba6237c328f8d (patch) | |
| tree | 85729415b45ed42a6928c2c00e4cd9f3e2e92785 /src | |
| parent | 5b2631b3aa95613b0cebc713f569229ddd950890 (diff) | |
client/graph_view: show images with correct size, but force layout doesn't take it into account
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/view/graph_view.js | 12 |
1 files changed, 7 insertions, 5 deletions
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') |
