/ 设置 10 秒超时 // 每日统计清 0 runtime_set('todaycomments', 0); runtime_set('todayarticles', 0); runtime_set('todayusers', 0); if ($forumlist) { $fidarr = array(); foreach ($forumlist as $fid => $forum) { $fidarr[] = $forum['fid']; } forum_update($fidarr, array('todayposts' => 0, 'todaythreads' => 0)); } // 清理临时附件 attach_gc(); // 当天24点 $today = strtotime(date('Ymd')) + 86400; runtime_set('cron_2_last_date', $today, TRUE); // 往前推8个小时,尽量保证在前一天 升级过来和采集的数据会很卡 // table_day_cron($time - 8 * 3600); cache_delete('cron_lock_2'); } } } ?>javascript - How can I get the natural width and height of an svg image element? - Stack Overflow|Concepts Of Algorithm

javascript - How can I get the natural width and height of an svg image element? - Stack Overflow

admin2025-04-19  4

I'm trying to do something relatively simple. I'm trying to get the following working in D3:

  • Draw an image as an SVG element in its natural width and height.
  • Be able to click on this image to draw circles with 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?

I'm trying to do something relatively simple. I'm trying to get the following working in D3:

  • Draw an image as an SVG element in its natural width and height.
  • Be able to click on this image to draw circles with 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?

Share Improve this question asked Jul 29, 2014 at 2:52 JamieJamie 2,3011 gold badge22 silver badges38 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

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;
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745001898a279278.html

最新回复(0)