score:1

Accepted answer

This snippet is problematic:

data.forEach(function (d) {
  d.date = parseTime(d.date);
  d.units = parseInt(d.units);
});
tdata.forEach(function (d) {
  d.date = parseTime(d.date);
  d.units = parseInt(d.units);
});

tdata and data are arrays holding references to the same objects. So the second forEach is then acting on the same objects and the parseTime fails. Just do:

tdata.forEach(function(d) {
  d.date = parseTime(d.date);
  d.units = parseInt(d.units);
});

var data = tdata.filter(e => e.prod === prod_name);

Here's your code all cleaned up.


Related Query

More Query from same tag