viewof dashboard = {
const magBarChart = vl
.markBar()
.encode(
vl.x().fieldQ("magnitude").bin({ maxbins: 30 }).title("Magnitude"),
vl.y().count().title(null)
);
const magBarChartLayer = vl
.layer(
magBarChart.params(brush)
.encode(vl.color().value('lightgrey')),
magBarChart.transform(vl.filter(brush))
)
.title("Number of Events by Magnitude")
.data(earthquakes)
.width(width * 0.40)
.height(200);
const depthBarChart = vl
.markBar()
.encode(
vl.x().fieldQ("depth").bin({ maxbins: 30 }).title("Depth"),
vl.y().count().title(null)
);
const depthBarChartLayer = vl
.layer(
depthBarChart.params(brush)
.encode(vl.color().value('lightgrey')),
depthBarChart.transform(vl.filter(brush))
)
.title("Events by Depth (km)")
.data(earthquakes)
.width(width * 0.40)
.height(200);
const eventsPerHour = vl
.markLine()
.encode(
vl.x().fieldT("origintime").timeUnit("hoursdatemonth").title("Date"),
vl.y().count().title(null)
);
const eventsPerHourLayer = vl
.layer(
eventsPerHour.encode(vl.color().value('lightgrey')),
eventsPerHour.transform(vl.filter(brush))
)
.title("Events per Hour")
.data(earthquakes)
.width(width - 40)
.height(150);
return vl
.vconcat(vl.hconcat(
vl.vconcat(magBarChartLayer, depthBarChartLayer), map_view), eventsPerHourLayer)
.resolve({scale: {size: 'independent'}})
.render();
}