{
const splom = {
repeat: {
row: ['temp_max', 'precipitation', 'wind'],
column: ['wind', 'precipitation', 'temp_max']
},
spec: {
mark: { type: 'circle', size: 15, opacity: 0.5 },
encoding: {
x: { field: { repeat: 'column' }, type: 'Q' },
y: { field: { repeat: 'row' }, type: 'Q' }
},
width: 125,
height: 125
}
};
const dateHist = {
repeat: {
row: ['temp_max', 'precipitation', 'wind']
},
spec: {
layer: [
{
mark: { type: 'bar' },
encoding: {
x: { timeUnit: 'month', field: 'date', type: 'O', title: 'Month' },
y: { aggregate: 'average', field: { repeat: 'row' } }
}
},
{
mark: { type: 'rule', stroke: 'firebrick' },
encoding: {
y: { aggregate: 'average', field: { repeat: 'row' } }
}
}
],
width: 175,
height: 125
}
};
const tempHist = {
facet: {
column: { field: 'weather' }
},
spec: {
mark: { type: 'bar' },
encoding: {
x: {
field: 'temp_max', type: 'Q', bin: true,
title: 'Temperature (°C)'
},
y: { aggregate: 'count' },
color: {
field: 'weather', type: 'N',
scale: {
domain: ['drizzle', 'fog', 'rain', 'snow', 'sun'],
range: ['#aec7e8', '#c7c7c7', '#1f77b4', '#9467bd', '#e7ba52']
}
}
},
width: 115,
height: 100
}
};
return render({
data: { values: weather },
transform: [
{ filter: 'datum.location == "Seattle"' }
],
title: 'Seattle Weather Dashboard',
vconcat: [
{ hconcat: [splom, dateHist] },
tempHist
],
resolve: { legend: { color: 'independent' } },
config: { axis: { labelAngle: 0 } }
});
}