arrays - How to access nested data Values in D3 -


i have nested data this

var nested_data = d3.nest()   .key(function(d) { return d.country; })   .entries(csv); 

and have found can access values of array if use function when bind data

name.selectall('.name')     .data(function(d) {       return d.values;   <--- accesses nested data     })      .text(function(d) {       return d.name;     <--- nested value     }) 

however having trouble using elsewhere in project. nested value need string called ['starting point']. how can can access value use in d3.filter() example?

var filter = nested_data.filter(function(d) {     return ("island" == d['starting point']) }); 

i'd try: d.values['starting point']

or creating new variable

var nested_values = nested_data(function(d) { return d.values});

but none of valid. should here?

you can filter data on nested data this:

nested_data.map(function(m) {   //for each group filter on each value   m.values = m.values.filter(function(d) {     //return true having starting point island.     return d['starting point'] == 'island';   }) }) 

working code here


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -