Public
Edited
Feb 11
Insert cell
Insert cell
Insert cell
import {vl} from "@vega/vega-lite-api-v5"
Insert cell
import {printTable} from "@uwdata/data-utilities"
Insert cell
census = FileAttachment("census2000-1@4.csv").csv()
Insert cell
printTable(census.slice(0,5))
Insert cell
vl.markBar()
.title("Age Distribution of the U.S. Population in 1900 vs 2000 ")
.data(census)
.transform(
vl.groupby('Year')
.joinaggregate(vl.sum("People").as("Total_population")),
vl.calculate('datum.People / datum.Total_population * 100').as('Percentage')
)
.encode(
vl.x().fieldO('Age').title('Age Group (Binned Into 5-Year Segments)').sort(null),
vl.y().sum('Percentage').title("Percentage (%) of Yearly Total Population"),
vl.tooltip().sum('Percentage').format('0.2f'),
vl.color().fieldN('Year').title('Character Type').scale({scheme: 'set1'}),
vl.xOffset().fieldN('Year'),
)
.render()
Insert cell
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