diff options
| author | Alon Levy <alon@pobox.com> | 2015-03-09 16:46:02 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-03-09 16:46:02 +0200 |
| commit | 05e7b8021d17772f3fb0db4667b7901b1c34a474 (patch) | |
| tree | 224b0b53d26ca2780f30a5376ae6567e7cab3927 | |
| parent | 8c8951a1cf05bd1a2b1c86efb5bba6237c328f8d (diff) | |
client/graph_view: set maximal size of 100px for an image, keeping aspect ratio
| -rw-r--r-- | src/client/view/graph_view.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/client/view/graph_view.js b/src/client/view/graph_view.js index e2b7520e..d4cfb145 100644 --- a/src/client/view/graph_view.js +++ b/src/client/view/graph_view.js @@ -482,8 +482,11 @@ function GraphView(spec) { var element = this, image = new Image(); image.onload = function () { - element.setAttribute("width", this.width); - element.setAttribute("height", this.height); + var aspect = this.height / this.width, + width = Math.min(100, this.width); + + element.setAttribute("width", width); + element.setAttribute("height", Math.min(width * aspect, this.height)); element.setAttributeNS("http://www.w3.org/1999/xlink", "href", this.src); } image.src = urlImage(d) ? d.url : "/static/img/url-icon.png"; |
