joinedData = cleanedData
.sort((a, b) => b.creationDate - a.creationDate)
.filter((d, i, arr) => {
if (d.region !== 1) return false
if (d.share === 0) return false
return true
})
.filter((d, i, arr) => {
if (
arr.slice(0, i).find(f => d3.timeDay.count(f.date, d.date) === 0 && f.variant === d.variant)
) return false
return true
})
.map(vd => {
const w = wastewaterData.find(wd => d3.timeDay.count(wd.date, vd.date) === 0 && wd.system === wastewaterSystem)
return {
...vd,
...w,
}
})
.sort((a, b) => a.date - b.date)
.filter(d => d3.utcDay.count(startDate, d.date) > 0)
.filter(d => !!d.concentration)