Public
Edited
Aug 3, 2023
Insert cell
Insert cell
Plot.plot({
y: { grid: true },
x: {
nice: true,
ticks: 20,
tickFormat: (d) =>
d === Math.floor(d) ? d3.format("~s")(Math.pow(10, d)) : "•",
label: "bail amount (log scale) →"
},
marks: [
Plot.rectY(
bonded_inmates,
Plot.binX(
{ y: "count" },
{ x: (d) => Math.log10(d.bail || NaN), tip: true }
)
),
Plot.ruleY([0])
]
})
Insert cell
bonded_inmates
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
CCSO_BIU_FOIA_Newman_07202023_DRAFT_v1.0.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
bonded_inmates = {
let highest_bond_charges = [];
const inmate_charges = d3.group(
snapshot.filter(
(d) =>
!no_bond.has(d.Inmateid) && d.Bondtype !== "" && d["Current Bond"] > 0
),
(d) => d.Inmateid
);
for (const charges of inmate_charges.values()) {
const bails = charges.map((d) =>
d.Bondtype === "Cash Bond" ? d["Current Bond"] : d["Current Bond"] * 0.1
);
const max_bail = Math.max(...bails);
const highest_bond_charge = charges[bails.indexOf(max_bail)];
highest_bond_charge.bail = max_bail;
highest_bond_charges = [...highest_bond_charges, highest_bond_charge];
}
return highest_bond_charges.map((d) => ({
inmate: d.Inmateid,
booking_date: d.Bookingdate,
bond_type: d.Bondtype,
bond: d["Current Bond"],
bail: d.bail
}));
}
Insert cell
no_bond = new Set(
snapshot.filter((d) => d.Bondtype === "No Bond").map((d) => d.Inmateid)
)
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