Published
Edited
Dec 12, 2019
Insert cell
md`# Patterns for extending traffic accident dataset`
Insert cell
Insert cell
vegalite = require("@observablehq/vega-lite@0.2")
Insert cell
data = FileAttachment("drivers.csv").text()
Insert cell
md`## filter = ${filter}`
Insert cell
viewof filter = html`<input type=range min=20 max=50 step=5>`
Insert cell
vegalite({
data: {
values: data,
format: { type: 'csv' }
},
width: 750,
// height: 750,
layer: [
{
mark: "bar",
transform: [
{
filter: {
field:
"Percentage Of Drivers Involved In Fatal Collisions Who Were Alcohol-Impaired",
gte: filter
}
}
],
encoding: {
x: {
field: "State",
type: "ordinal"
},
y: {
field:
"Number of drivers involved in fatal collisions per billion miles",
type: "quantitative"
},
tooltip: {
field:
"Percentage Of Drivers Involved In Fatal Collisions Who Were Alcohol-Impaired",
type: "quantitative"
}
}
}
// {
// mark: "bar",
// encoding: {
// x: {
// field: "State",
// type: "nominal"
// },
// y: {
// field:
// "Percentage Of Drivers Involved In Fatal Collisions Who Were Alcohol-Impaired",
// type: "quantitative"
// },
// color: {
// field: "State",
// type: "nominal"
// },
// opacity: { value: .75 }
// }
// }
]
})
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