I'm trying to do something relatively simple. I'm trying to get the following working in D3:
I'm stuck on how to draw the image as an SVG element. So far I have:
content.append("image")
.attr("xlink:href",this.store.image_url);
But how can I get the natural width / height of this element?
You can do this with a bit of javascript
var img = new Image();
img.onload = function(){
img.naturalWidth and img.naturalHeight can be read off within here
};
img.src = this.store.image_url;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.