Closed MoMaghraby closed 9 years ago
@StefanKage link to this page where I can see it and help debug?
Okay i solved the error, now i have a problem. I want to enter an IP address and turn it into a country name then change its color on the map. But i can't enter the country name as a variable.
var interval_1=window.setInterval(function() {
var name = "USA";
map.updateChoropleth({
name : colors(Math.random() * 10),
}); }, 2000);
To follow up on the original issue - that error is caused when element
returns null
, for instance if you said:
new Datamap({
element: document.getElementById('not-on-page')
});
If an element with an id of not-on-page
is not on the page at the time that code runs, you'll see this error.
Great ! thanks alot.
people trying to use datamaps in react
If you're trying to use data maps on a component in react, make sure you create the map (e.g. var map = new Datamap({element: document.getElementById('container')});
inside of the componentDidMount()
method. I was running the code to bind the map to an element I thought was on the DOM before it was mounted effectively causing the same issue mark mentioned above.
Whenever i run the code i get this error.
Uncaught TypeError: Cannot read property 'offsetWidth' of null