d3.js - Using d3 to read in information from a CSV file, how can i store values of a particular type into a variable? -


i have code reads information in csv file. information regarding road traffic accidents.

enter image description here

so code, can target values using 'd['weather conditions']' gives me -

enter image description here

which great! i'm looking store values of particular types in variables. e.g values equal 'fine without high winds' stored in array object 'var windy' or similar, there anyway go simply?

*update

some sample data enter image description here

any appreciated. thanks

right now, in code, printing console each weather condition encounter go on dataset row row.

if want group data based on weather conditions, can using d3.nest().

the example below uses simple json data show how can it. here, using d3.nest(), setting key weather condition , values object.

after structuring, data grouped, can check running script below: accidents rainy under key rainy , same other weather conditions.

var data = [{    "weather condition": "rainy",    "property1": "val1",    "property2": "val2"  }, {    "weather condition": "sunny",    "property1": "val1",    "property2": "val2"  }, {    "weather condition": "sunny",    "property1": "val1",    "property2": "val2"  }];    // put snippet below in d3.csv function  var expensesbyname = d3.nest()    .key(function(d) {      return d["weather condition"];    })    .entries(data);    console.log(expensesbyname);
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -