{
const brush = vl.selectInterval().encodings('x');
const years = vl.markBar({width: 10})
.title({text: "Select region to filter the scatterplot by time", fontStyle: "italic",
fontWeight: "normal", anchor: "start", dx: 30})
.data(filtered)
.params(brush)
.encode(
vl.x().fieldT('date').title(null),
vl.y().mean('unemp').title('avg unemp')
)
.width(600).height(50);
const unemp = vl.markCircle()
.title({text: "Each point represents a population group in a certain year (2004-2020)",
subtitle: "Virginia, source: US Bureau of Labor Statistics"})
.data(filtered)
.encode(
vl.x().fieldQ('percent_in_laborforce').title("Percent in Labor Force"),
vl.y().fieldQ('unemp').title("Unemployment Rate"),
vl.tooltip(['year', {'field': 'populationgroup', 'title': 'group'}]),
vl.color().if(brush, vl.value("gold")),
vl.stroke().if(brush, vl.value("black")),
vl.opacity().if(brush, vl.value("0.9")).value("0.4")
)
.width(600).height(400);
return vl.vconcat(years, unemp).spacing(5).render();
}