Hi i was facing problem with filtering out the most recent data from my data file. I have the following data
var data=
[
{"id":1,"speed":50,time:10:51.30},
{"id":1,"speed":40,time:10:51.40},
{"id":1,"speed":60,time:10:51.50},
{"id":1,"speed":55,time:10:51.55},
{"id":2,"speed":55,time:10:51.50},
{"id":2,"speed":65,time:10:51.58}
]
I want to filter out the data to visualize or show the data with most recent time. So my filtered data should contain the following
var filtereddata=
[
{"id":1,"speed":55,time:10:51.55},
{"id":2,"speed":65,time:10:51.58}
]
How can i get the filtered data from data using crossfilter? I was trying with
var ndx=crossfilter(data);
var dim=ndx.dimension(function(d){return d.time;});
var filter=dim.filter(function(d){d3.max(data,function(d){return d.time;})});
But its not working? How can i do it?
Problem is that you are looking at the filter object. You need to convert filtered dim to array using either top or bottom.
Please see the code below or better check out Here for the working version.
______UPDATE_____
OK I see what you meant. See below for updated code snippet. I also updated solution at jsfiddle