66
rated 0 times
[
70]
[
4]
/ answers: 1 / hits: 50709
/ 11 Years ago, thu, october 31, 2013, 12:00:00
I am using d3js to find the width of an svg element the code given below:
<script>
var body = d3.select(body);
console.log(body);
var svg = body.select(svg);
console.log(svg);
console.log(svg.style(width));
</script>
<svg class=svg height=3300 width=2550>
<image x=0 y=0 height=3300 width=2550 xlink:href=1.jpg></image>
<rect class=word id=15 x=118 y=259 width=182 height=28
text=Substitute></rect>
</svg>
But it returned this error:
Uncaught TypeError: Cannot call method 'getPropertyValue' of null
I think, the svg variable is a null array.
How can I get the width of an svg element using d3js?
More From » svg