0

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);
Robin van Hoorn
  • 334
  • 1
  • 10

1 Answers1

3

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

Ahmed Bajra
  • 391
  • 1
  • 2
  • 14
  • I know, that doesn't fix my problem :( – Robin van Hoorn Jun 01 '18 at 10:04
  • 2
    If the same error is thrown when using `document.getElementById("container")`, I'd check if it even returns anything. If not, the element either doesn't exist at all or the document isn't ready at the time of the code being executed. By the error you're describing, my guess is that it isn't an issue with d3.js but with the last three lines. – Ahmed Bajra Jun 01 '18 at 11:31