Public
Edited
Nov 7, 2022
Insert cell
Insert cell
viewof table = Inputs.table(cars)
Insert cell
Inputs.table(cars, {rows:3})
Insert cell
Inputs.table(cars, {
columns:['name', 'cylinders', 'power (hp)', 'year']
})
Insert cell
Plot.plot({
marks: [
Plot.barY(cars, {x:'year', y:'cylinders'})
]
})
Insert cell
states = d3.csv("https://raw.githubusercontent.com/smach/SampleData/master/east_coast_states.csv")
Insert cell
Inputs.table(states)
Insert cell
// Region filter
viewof selected_region =
Inputs.select(states.map(d => d.Region), {sort: true, unique: true, label: "Select region:"})
Insert cell
// Percent change filter
viewof selected_change = Inputs.range([-12, 19], {label: "Minimum Pct Change", step: 0.5, placeholder: "5"})
Insert cell
// filtered data set based on values from above filters.
// Use === in JavaScript to test for strict equality
filtered_states = states.filter(function(d) {return d.Region === selected_region && d.PctChange_2020 >= selected_change})
Insert cell
Plot.plot({
marginLeft: 120,
marks: [
Plot.barX(states, {x:'PctChange_2020', y:'State', fill: 'Division',
sort: {y: 'x', reverse: true}})
],
color: { legend: true
}
})
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