D3 cannot read property offsetHeight of null

2.2k views Asked by At

I get this cannot read property 'offsetHeight' of null while i just initialized its height.

Here is my code:

d3.select("#container")
    .style("height", "100%")
    .style("width", "100%") 
    .style("position", "relative")
    .style("bottom", 0);


var width = document.getElementById("#container").offsetWidth,
    height = document.getElementById("#container").offsetHeight,
    radius = (Math.min(width, height) / 1.5);
1

There are 1 answers

2
Ahmed Bajra On

When using document.getElementById() you don't have to explicitly type a # before the id.