vl.markBar()
.data(census)
.transform(
vl.groupby(['Age', 'Year'])
.aggregate(vl.sum('People').as('TotalPeople'))
)
.encode(
vl.x().fieldN('Age').sort('mean').title(['Age Group', '(in five-year intervals)']),
vl.y().fieldQ('TotalPeople').title('U.S. Population'),
vl.color().fieldN('Year'),
vl.xOffset().fieldN('Year'),
vl.tooltip().fieldQ('TotalPeople').format(',')
)
.width(600)
.height(400)
.title(['How has the age distribution','of the U.S. population changed from 1900 to 2000?'])
.render()