{
const row_order = ['wind_avg', 'precipitation', 'temp_max'];
const splom = vl.markCircle({ size: 30 })
.encode(
vl.x().fieldQ(vl.repeat('column')),
vl.y().fieldQ(vl.repeat('row'))
)
.width(140)
.height(125)
.repeat({
row: row_order,
column: row_order.toReversed()
});
const monthBars = vl.layer(
vl.markBar()
.encode(
vl.x().month('date'),
vl.y().average(vl.repeat('row'))
),
vl.markRule({ color: 'firebrick', strokeWidth: 2 })
.encode(
vl.y().average(vl.repeat('row'))
)
)
.width(125)
.height(125)
.repeat({
row: row_order
});
const colors = {
domain: ['drizzle', 'fog', 'rain', 'hazy', 'sun'],
range: ['#aec7e8', '#c7c7c7', '#1f77b4', '#9467bd', '#e7ba52']
};
const weatherFacets = vl.markBar()
.encode(
vl.x().fieldQ('temp_max').bin(true),
vl.y().count().title('Number of days'),
vl.color().fieldN('weather').scale(colors)
)
.width(125)
.height(125)
.facet({column: vl.field('weather')});
return vl.data(weather)
.transform(vl.filter('datum.city === "San Luis Obispo"'))
.title('San Luis Obispo Weather Dashboard')
.vconcat(
vl.hconcat(splom, monthBars),
weatherFacets
)
.resolve({ legend: { color: 'independent' } })
.render()
}