Bikeway miles against road miles
Plot.plot({
width: 700,
height: 440,
grid: true,
x: {label: "Total road miles (log) →", type: "log", domain: [10, 5000]},
y: {label: "Selected bikeway miles (log) →", type: "log", domain: [0.1, 500]},
color: {domain: ["Above average", "Below average"], range: ["#007EA7", "#D96E34"], legend: true},
style: {backgroundColor: "transparent"},
marks: [
Plot.line(d3.range(10, 5000, 100), {x: d => d, y: d => d * avgRatio / 100, stroke: "#888", strokeDasharray: "4,4"}),
Plot.dot(rowsTagged.filter(d => d.bike > 0), {x: "All Roads", y: "bike", stroke: "group", fill: "group", fillOpacity: 0.3, r: 4, tip: true,
title: d => `${d.Name}\nBikeway: ${d.bike.toFixed(1)} mi\nRoads: ${d["All Roads"]} mi\nShare: ${d.ratio.toFixed(1)}%`}),
Plot.dot(highlighted, {x: "All Roads", y: "bike", stroke: "currentColor", strokeWidth: 2, r: 8}),
Plot.text(highlighted, {x: "All Roads", y: "bike", text: "Name", dy: -16, fontWeight: "bold", stroke: "white", strokeWidth: 4, paintOrder: "stroke", fill: "#333"})
]
})
Top 15 by bikeway miles
Inputs.table(
[...rows].sort((a, b) => b.bike - a.bike).slice(0, 15),
{
columns: ["Name", "bike", "All Roads", "ratio"],
header: {Name: "City", bike: "Bike mi", "All Roads": "Road mi", ratio: "Share %"},
format: {bike: x => x.toFixed(1), "All Roads": x => x.toFixed(0), ratio: x => x.toFixed(1)},
rows: 15, maxHeight: 520
}
)