I'm trying to create a suite of histograms for a website. I want to created a mapped variable that only pulls out the speed data if the character has a specific rank. My data set looks like the following (I've bolded the relevant variables that I want to deal with):
myData = [{name:'Maru', rank:'L', speed:117.6},{name:'Kharg', rank:'G', speed:114.4}...and so on...]
I'm trying to use an if statement (pseudocode: if myData.rank = 'L'...) in conjunction with the following:
var speedData = myData.map(function(i){ return i.speed; })
However, I'm not having any luck. Here's a sample of what I'm trying (among other things, but I suspect that this is the closest to working):
var lightData = myData.map(function(i){
if (i.rank == 'L'){
return i.speed;}
})
Is this possible using just js and D3? I suspect that something like Django might make this easier, but it's an assignment that limits to just js and D3.
I realize that if my data set was smaller, I could manually separate all the ranks and then do a merge when I need to run all the data at once. However, that's just not practical with the data I have.