Published
Edited
May 27, 2021
1 fork
1 star
Insert cell
Insert cell
Insert cell
// viewof year = Inputs.select(d3.range(2010, 2021), { label: "year", format: d => ""+d})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.barX(data, Plot.stackX(Plot.groupY({ x: "count" }, {
y: "Command",
fill: d => d.date.getFullYear() || "NA",
// stroke: "lightgrey"
}))).plot({
y: {
domain: TopN(data, { groupby: "Command", order: "count", n: 50 }),
// tickFormat: d => officerUniqueIds.get(d)
},
color: { scheme: "greens" },
marginLeft: 120,
grid: true
})
Insert cell
Plot.barX(data, Plot.stackX(Plot.groupY({ x: "count" }, {
y: "FADO Type",
fill: d => d.date.getFullYear() || "NA",
// stroke: "lightgrey"
}))).plot({
y: {
domain: TopN(data, { groupby: "FADO Type", order: "count", n: 50 }),
// tickFormat: d => officerUniqueIds.get(d)
},
color: { scheme: "purples" },
marginLeft: 120,
grid: true
})
Insert cell
Insert cell
substantial = Array.from(d3.group(data, d => d["Board Disposition"].includes("Substantiated")).entries())
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.barY(data, Plot.binX({ y: "count" }, {
x: "date",
thresholds: d3.timeMonth.every(1),
fill: d => d["Board Disposition"].includes("Substantiated")
// fill: d => d.date.getFullYear() || "NA",
// stroke: "lightgrey"
})).plot({
x: { tickRotate: 90 },
color: { scheme: "reds" },
marginLeft: 50,
marginRight: 10,
marginBottom: 120,
width,
grid: true
})
Insert cell
Plot.barY(data, Plot.binX({ y: "count" }, {
x: "date",
thresholds: d3.timeMonth.every(3),
fill: d => d["Board Disposition"].includes("Substantiated")
// fill: d => d.date.getFullYear() || "NA",
// stroke: "lightgrey"
})).plot({
facet: {
data: data,
y: "Unique Id",
marginRight: 100
},
fy: {
domain: TopN(data, { groupby: "Unique Id", order: "count", n: 10 }),
tickFormat: d => officerUniqueIds.get(d),
},
x: { tickRotate: 90 },
color: { scheme: "reds" },
marginLeft: 50,
marginRight: 100,
marginBottom: 120,
width,
grid: true
})
Insert cell
Plot.barX(data, Plot.stackX(Plot.groupY({ x: "count" }, {
y: "Unique Id",
fill: "FADO Type",
// fill: d => d.date.getFullYear() || "NA",
// stroke: "lightgrey"
}))).plot({
marks: [ Plot.frame({ stroke: "lightgray" }) ],
facet: {
data: data,
x: d => d.date.getFullYear() || "NA"
},
y: {
domain: TopN(data, { groupby: "Unique Id", order: "count", n: 100 }),
tickFormat: d => officerUniqueIds.get(d)
},
x: { axis: false },
// color: { scheme: "blues" },
marginLeft: 120,
width,
grid: true
})
Insert cell
Insert cell
Plot.barX(data, Plot.stackX(Plot.groupY({ x: "count" }, {
y: "Unique Id",
fill: "FADO Type",
// fill: d => d.date.getFullYear() || "NA",
// stroke: "lightgrey"
}))).plot({
marks: [ Plot.frame({ stroke: "lightgray" }) ],
// facet: {
// data: data,
// // y: d => d.date.getFullYear() || "NA",
// x: "FADO Type"
// },
y: {
domain: TopN(data, { groupby: "Unique Id", order: "count", n: 100 }),
tickFormat: d => officerUniqueIds.get(d)
},
x: { axis: false },
// color: { scheme: "blues" },
marginLeft: 120,
width,
grid: true
})
Insert cell
top10 = TopN(data, { groupby: "Unique Id", order: "count", n: 50 })
Insert cell
Inputs.table(complaints)
Insert cell
import { TopN } from "@enjalot/topn"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more