chart = {
const selection = vl.selectSingle('Select')
.fields('district')
.bind({district: vl.menu(districts)});
const big_hist_size = width - 80;
const left_hist_width = width * 0.45;
const right_hist_width = width * 0.31;
const brush = vl.selectInterval().encodings('x').resolve('intersect');
const brush_hist = vl.markBar()
.data(covid)
.encode(
vl.x().fieldT("date"),
vl.y().fieldQ("cases")
);
const brush_hist_layer = vl.layer(
brush_hist.select(brush).encode(vl.color().value('steelblue'))
)
.height(80).width(left_hist_width);
const horizontal_hist = vl.markBar()
.data(hr_totals)
.encode(
vl.x().sum('cases'),
vl.y().fieldN('district').sort(vl.sum('cases').order('descending'),
vl.tooltip(['cases']))
)
.title("Total Cases")
.height(80)
.width(right_hist_width);
const x = vl.x().fieldT('date').title(null);
const big_histogram = vl.markBar()
.data(covid)
.encode(
x.scale({domain: brush}),
vl.y().fieldQ("cases"),
vl.tooltip(['cases', 'date']))
.height(300)
.width(big_hist_size);
const big_histogram_layer = vl.layer(
big_histogram.select(selection).encode(vl.color().value('lightgrey')),
big_histogram.transform(vl.filter(selection)));
const top = vl.hconcat(brush_hist_layer, horizontal_hist);
return vl.vconcat(top, big_histogram_layer)
.render();
}