I'm trying to set up a date filter for the movements in my network graph. The filter includes a start and end date and currently works on one pass-through, but doesn't work when extending the range again (e.g. the previously filtered out nodes/edges don't restore once removed). I've also looked in to restore() but am unsure of how to apply that here. Below is what I've tried thus far, I appreciate any feedback.
const min = datespan[0].toLocaleDateString()
const max = datespan[1].toLocaleDateString()
//filter movements (edges) that occured between that range
const matched_movements = cy.edges()
.filter(d => d.data('new_date').toLocaleDateString() >= min && d.data('new_date').toLocaleDateString() <= max)
//get the connected nodes for those movements
//structure via 'data' prop so cyto can render graph (same for edges below)
const filteredNodes = matched_movements.connectedNodes()
.map(d => ({data: d.data()}))
const filteredEdges = matched_movements.map(d => ({data: d.data()}))
//rebuild into single array
const filteredData = [...filteredEdges, ...filteredNodes]
cy.json({elements: filteredData})