Reputation: 2577
This question uses the Highcharts API. I am developing a chart using Highcharts that populates based upon a user's option select. This feature works exactly as I intend, except for a Uncaught TypeError: Cannot read property 'data' of undefined
error at the specific line below:
update[t].addPoint(listrepeat.classmakeup[t].studentsize);
My JSFiddle below
https://jsfiddle.net/4ufoj5cx/1/
The code works perfectly. However, I would like to know what I am doing wrong that is causing this error message to show on my console.
Upvotes: 0
Views: 74
Reputation: 10075
The error comes because of repeated setInterval
on change of select
. You have to use clearInterval()
to clear previous setInterval
. Rest everything is fine.
function opmiddle(listreader){
classcat.addEventListener('change', function(){
opend(listreader);
clearInterval(previousInterval); //you have to clear previous setInterval
});
classcat.innerHTML += "<option>--</option>";
for (i = 0; i < listreader.school.length; i++){
classcat.innerHTML += "<option>"+listreader.school[i].directory+"</option>";
}
}
Fiddle demonstration
Upvotes: 2