data = {
let raw;
try {
raw = await d3.json(
"https://www.washingtonpost.com/graphics/investigations/police-shootings-database/data/policeshootings_all.json"
);
} catch (err) {
raw = await FileAttachment("policeshootings_all_6-1-2020.json").json();
}
const data = raw.map((d) => {
const date = d3.utcParse("%Y-%m-%d")(d.date);
return {
type: "Feature",
geometry: { type: "Point", coordinates: [d.lon, d.lat] },
properties: {
date: date,
s: +date,
city: d.city,
state: d.state
}
};
});
return data.sort((a, b) => a.properties.date - b.properties.date);
}