ex4 = {
const line = vl.markRule({stroke:"firebrick", strokeWidth: 2})
.data([{'week':12}])
.encode(
vl.x().fieldO('week'),
vl.tooltip().value("When Covid Lockdown Started")
)
const lineplot = vl.markLine({strokeWidth: 3, opacity: 0.5, interpolate: 'monotone', point:{size:50}})
.data(df)
.encode(
vl.x().fieldO("week").title("Week").axis({labelAngle: 0}).axis(null),
vl.y().fieldQ("bikes_14counters").title("# of Bike Riders"),
vl.color().fieldO("year").title("Year").scale(colorMapping).legend({orient: 'top-right'}),
vl.shape().fieldO("year").scale(shapeMapping).legend({orient: 'top-right'}),
vl.tooltip(["bikes_14counters", "year", "week", "starting_from"])
)
.title({
text: 'Bike Riders',
anchor: 'middle',
fontSize: 12
})
.width(700)
.height(200)
const lineplot2 = vl.markLine({strokeWidth: 3, opacity: 0.5, interpolate: 'monotone', point:{size:50}})
.data(df)
.encode(
vl.x().fieldO("week").title("Week").axis({labelAngle: 0}),
vl.y().fieldQ("pedestrians_14counters").title("# of Pedestrians"),
vl.color().fieldO("year").title("Year").scale(colorMapping).legend({orient: 'top-right'}),
vl.shape().fieldO("year").scale(shapeMapping).legend({orient: 'top-right'}),
vl.tooltip(["pedestrians_14counters", "year", "week", "starting_from"])
)
.title({
text: 'Pedestrians',
anchor: 'middle',
fontSize: 12
})
.width(700)
.height(200)
const layer_bike = vl.layer([lineplot, line])
const layer_peds = vl.layer([lineplot2, line])
return vl.vconcat([layer_bike, layer_peds])
.title({
text: 'Comparison of Number of Bike Riders/Pedestrians on Trails in 2019/2020',
anchor: 'middle',
fontSize: 16
})
.render()
}