{
const bikeline = vl.markLine({strokeWidth: 3, opacity: 0.5, interpolate: 'monotone'})
.data(df)
.encode(
vl.x().fieldO("week").axis(null),
vl.y().fieldQ("bikes_14counters").title('# of Bike Riders'),
vl.color().fieldO("year").title('Year')
.legend({orient:'top-right'})
)
const bikepoint = vl.markPoint({size:70, filled:true})
.data(df)
.encode(
vl.x().fieldO("week"),
vl.y().fieldQ("bikes_14counters"),
vl.color().fieldO("year")
.scale({domain:[2019,2020], range:['#FF8C00','#9400D3']}),
vl.shape().fieldO("year")
.scale({domain:[2019,2020], range:['circle','triangle']})
)
const bikeredline = vl.markRule({stroke: 'firebrick'})
.data(df.filter(d=> d.week === 12))
.encode(
vl.x().fieldO('week')
)
const bike = vl.layer(bikeline, bikepoint, bikeredline)
.width(700)
.height(200)
.title({text:'Bike Riders', fontSize:14})
const pedline = vl.markLine({strokeWidth: 3, opacity: 0.5, interpolate: 'monotone'})
.data(df)
.encode(
vl.x().fieldO("week").axis({labelAngle:[0]}).title('Week'),
vl.y().fieldQ("pedestrians_14counters").title('# of Pedestrians'),
vl.color().fieldO("year")
.legend(null)
)
const pedpoint = vl.markPoint({size:70, filled:true})
.data(df)
.encode(
vl.x().fieldO("week"),
vl.y().fieldQ("pedestrians_14counters"),
vl.color().fieldO("year")
.scale({domain:[2019,2020], range:['#FF8C00','#9400D3']}),
vl.shape().fieldO("year")
.scale({domain:[2019,2020], range:['circle','triangle']})
)
const pedredline = vl.markRule({stroke: 'firebrick'})
.data(df.filter(d=> d.week === 12))
.encode(
vl.x().fieldO('week')
)
const pedestrian = vl.layer(pedline, pedpoint, pedredline)
.width(700)
.height(200)
.title({text:'Pedestrians', fontSize:14})
return vl.vconcat(bike, pedestrian)
.title({text:'Comparison of Number of Bike Riders/Pedestrians on Trails in 2019/2020', anchor: 'middle', fontSize:20})
.render()
}