Public
Edited
Apr 30, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = FileAttachment("us-population-state-age.csv")
.csv({ typed: true })
Insert cell
Insert cell
Insert cell
Inputs.table(data)
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.barY(data, {x: "name", y: "20-29"})
]
})
Insert cell
Insert cell
Insert cell
Plot.plot({
width: 1000,
marks: [
Plot.barY(data, {x: "name", y: "20-29"})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
width: 1000,
marginLeft: 40,
y: {
transform: d => d /1000
},
marks: [
Plot.barY(data, {x: "name", y: "20-29"})
]
})
Insert cell
Insert cell
Insert cell
Plot.plot({
width: 1000,
marginLeft: 40,
y: {
label: "↑ Million People",
transform: d => d /1_000_000
},
x: {
label: "State"
},
marks: [
Plot.barY(data, {x: "name", y: "20-29"})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
width: 1000,
marginLeft: 40,
y: {
label: "↑ Million People",
transform: d => d /1_000_000
},
x: {
label: "State"
},
marks: [
Plot.barY(data, {x: "name", y: "20-29", sort:{x: "y", reverse:true}})
]
})
Insert cell
Insert cell
Insert cell
Plot.plot({
width: 1000,
marginLeft: 40,
y: {
label: "↑ Million People",
transform: d => d /1_000_000
},
x: {
label: "State"
},
marks: [
Plot.barY(data, {
x: "name",
y: "20-29",
fill: "goldenrod",
sort:{x: "y", reverse:true}})
]
})
Insert cell
Insert cell
Plot.plot({
width: 1000,
marginLeft: 40,
y: {
label: "↑ Million People",
transform: d => d /1_000_000
},
x: {
label: "State"
},
marks: [
Plot.barY(data, {
x: "name",
y: "20-29",
sort:{x: "y", reverse:true},
fill: d => d["20-29"] > 1_000_000 ? "salmon" : "dodgerblue"
})
]
})
Insert cell
Insert cell
Plot.plot({
width: 1000,
marginLeft: 40,
y: {
label: "↑ Million People",
transform: d => d /1_000_000
},
x: {
label: "State"
},
marks: [
Plot.barY(data, {
x: "name",
y: "20-29",
sort:{x: "y", reverse:true},
fill: d => d["name"] === "VA" ? "red" : "dodgerblue"
})
]
})
Insert cell
Insert cell
Insert cell
Inputs.table(data)
Insert cell
Insert cell
Insert cell
ageRangeToFocus = "≥80"
Insert cell
Insert cell
Plot.plot({
width: 1000,
marginLeft: 40,
y: {
label: "↑ Million People",
transform: d => d /1_000_000
},
x: {
label: "State"
},
marks: [
Plot.barY(data, {
x: "name",
y: ageRangeToFocus,
sort:{x: "y", reverse:true},
fill: d => d["name"] === "VA" ? "red" : "dodgerblue"
})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
currrent value is ${ageRange_dropdown}
Insert cell
Insert cell
Plot.plot({
width: 1000,
marginLeft: 40,
y: {
label: "↑ Million People",
transform: d => d /1_000_000
},
x: {
label: "State"
},
marks: [
Plot.barY(data, {
x: "name",
y: ageRange_dropdown,
sort:{x: "y", reverse:true},
fill: d => d["name"] === "VA" ? "red" : "dodgerblue"
})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {toc} from "@nebrius/indented-toc"
Insert cell
import {imageToDo} from "@clokman/student-blocks"
Insert cell
imageToDo
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