dchen71
dchen71

Reputation: 170

Filtering array in d3

I'm trying to filter out an array using D3. I have nested it and taken an map of the keys from a csv file. I want to filter it to show the values that match any of those keys in the array but am getting blank whenever I check the console after filtering.

var id = d3.nest()
           .key(function(d) {return d.id})
           .map(rows);        
id = d3.keys(id);
id.filter(function(d){d==input})

Upvotes: 0

Views: 70

Answers (1)

dchen71
dchen71

Reputation: 170

Just a work around but I created a function to filter the array which works for me.

function contain_item(item){
  return(item == input);
}

id = id.filter(contain_item);

Upvotes: 1

Related Questions