Published
Edited
Jul 29, 2020
1 fork
Importers
Insert cell
Insert cell
Insert cell
Insert cell
colours = {
return {
primary: '#C1272D',
primary50: '#FF8186',
primary00: '#FFD1D3',
secondary: '#000000',
secondary50: '#575757',
secondary00: '#BEBEBE',
chart: [
'#000000',
'#434343',
'#C1272D',
'#C4C4C4'
]
};
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
officerFTETotalByYear = (year, force = false) => {
if(force) {
let ydata = officerFTEByYear.find(d => d.label == year)
let fdata = ydata.data.find(f => f.force == force)
return fdata.fte
} else {
let ydata = officerFTEByYear.find(d => d.label == year).data
return ydata.reduce((acc,val)=>acc+ val.fte,0)
}
}
Insert cell
Insert cell
officerFTETotalByYear(2019, "Greater Manchester")
Insert cell
Insert cell
getCedPer100ByForceYear()
Insert cell
Insert cell
Insert cell
Insert cell
yoyIncPc = (force)=>{
return taserUse(force,"2019").Total/taserUse(force,"2018").Total * 100 - 100
}
Insert cell
yoyIncPc("Greater Manchester")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
pre2011 = d3.csv("https://data.resistancelab.network/cleaned_data/taser-use/pre-2011/table2-2009-2010.csv",d3.autoType)
Insert cell
total0910 = pre2011.reduce((acc,force)=>{
let keys=["April-June 2009 Totals","July-September 2009 Totals","October-December 2009 Totals","January-March 2010 Totals"]
keys.map(k=>{acc += force[k]})
return acc
},0)
Insert cell
// borrowed from https://github.com/d3/d3-time-format/issues/10
function ordinalSuffix(number) {
const ordinalSuffixes = ['th', 'st', 'nd', 'rd'];

const value = number % 100;

return `${number}${ordinalSuffixes[(value - 20) % 10] || ordinalSuffixes[value] || ordinalSuffixes[0]}`;
}
Insert cell
Insert cell
d3 = require("d3@5")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more