{
const select = vl.selectMulti().encodings("x");
const mapChart = vl.markGeoshape({stroke: '#aaa', strokeWidth: 0.25})
.data(vl.topojson(usa).feature('counties'))
.transform(
vl.lookup('id').from(vl.data(obesityDataParsed).key('id').fields('State','County','Median_Household_Income')),
vl.filter(select)
)
.encode(
vl.x().fieldQ('Median_Income').scale({domain: [40000, 90000]}),
vl.y().fieldQ('Num_Restaurants'),
vl.color().fieldQ('Median_Household_Income').scale({domain: [0, 100000], clamp: true, scheme: "blues" }).legend({format:'$K'}),
vl.tooltip([{field:"State"},{field:"County"},{field:"Median_Household_Income",format:"$K", title:"Median Household Income"}])
)
.width(600)
.height(600)
.project(vl.projection('albersUsa'))
.title('US Median Household Income by County VS Number of Fast Food Restaurants')
.config({view: {stroke: null}})
const selectChart = vl.markBar()
.data(data_parsed)
.encode(
vl.x().fieldN("State"),
vl.y().sum("Num_Restaurants"),
vl.tooltip([{field:"State"},{field: "Num_Restaurants", title: "Number of Fast Food Restaurants"}])
)
.params(select)
.height(250)
.width(700)
.title("Click on the bars to see details")
return vl.vconcat(mapChart,selectChart)
.render()
}