chart3b = {
const select = vl.selectMulti().fields("key").bind("legend");
const panzoom = vl
.selectInterval()
.encodings("x")
.bind("scales")
.zoom("wheel!");
const plot1 = vl
.markPoint({ filled: true })
.encode(
vl.x().fieldT("date").axis({ time: "Date" }),
vl
.y()
.fieldQ("median_duration")
.axis({ title: "Median Watch Time (Minutes)" })
.scale({ type: "log" }),
vl
.shape()
.fieldN("label")
.scale({
shape: [
"circle",
"circle",
"square",
"triangle",
"triangle",
"triangle"
]
})
.legend(null),
vl
.color()
.fieldN("label")
.scale({
domain: ["fL", "L", "AW", "C", "R", "fR"],
range: ["#2166AC", "#92C5DE", "#7FC97F", "gray", "#F4A582", "#B2182B"]
})
.legend({ title: "Political Categories" })
)
.select(panzoom, select)
.width(width);
const plot1ra = vl
.markLine()
.encode(
vl.x().fieldT("date").axis({ title: "Date" }).scale({ type: "log" }),
vl.y().fieldQ("rolling"),
vl
.color()
.fieldN("label")
.scale({
domain: ["fL", "L", "AW", "C", "R", "fR"],
range: ["#2166AC", "#92C5DE", "#7FC97F", "gray", "#F4A582", "#B2182B"]
})
);
return vl
.layer(plot1, plot1ra)
.transform(vl.filter(select))
.data(fig3A_data)
.autosize({ type: "fit-x", contains: "padding" })
.render();
}