{ const graph1 = vl
.markLine({opacity: 0.3, strokeWidth:3, interpolate: "monotone", point:{size:70}})
.data(df)
.encode(
vl.x().fieldQ('week').title('Week').axis(null),
vl.y().fieldQ('bikes_14counters').title('# of Bike Riders').axis({labelAngle: 0, fontSize:12}),
vl.color().fieldN('year').scale(colorMapping).legend({orient: 'top-right'}),
vl.shape().fieldN('year').scale(shapeMapping).legend({orient: 'top-right'}),
vl.opacity().value(0.6),
vl.tooltip(["bikes_14counters", "year", "week", "starting_from"])
)
.width(900)
.height(300)
.title({text: 'Biker Riders', anchor: 'middle', offset: 6, fontSize: 14})
.resolve({legend: {orient: 'independent'}})
const graph2 = vl
.markLine({opacity: 0.3, strokeWidth:3, interpolate: "monotone", point:{size:70}})
.data(df)
.encode(
vl.x().fieldQ('week').title('Week').axis({labelAngle: 0, grid:false}),
vl.y().fieldQ('pedestrians_14counters').title('# of Pedestrians').axis({labelAngle: 0, fontSize:12}),
vl.color().fieldN('year').scale(colorMapping).legend({orient: 'top-right'}),
vl.shape().fieldN('year').scale(shapeMapping).legend({orient: 'top-right'}),
vl.opacity().value(0.6),
vl.tooltip(["pedestrians_14counters", "year", "week", "starting_from"])
)
.width(900)
.height(300)
.title({text: 'Pedestrians', anchor: 'middle', offset: 6, fontSize: 14})
.resolve({legend: {orient: 'independent'}})
const graph3 = vl
.markRule({stroke: 'firebrick', strokeWidth:4})
.data([{'week': 12}])
.encode(
vl.x().fieldQ('week')
)
const graph4 = vl.layer(graph1,graph3);
const graph5 = vl.layer(graph2,graph3);
return vl
.vconcat(graph4, graph5)
.title({
text: 'Comparison of Number of Bike Riders/Pedestrians on Trails in 2009/2020)',
dx: 150, dy: -10,fontSize: 20, font: "Tahoma"})
.render()
}