chart = addTooltips(Plot.plot({
height: 600,
width: width,
y: {
axis: null,
domain: [0, d3.max(data, d => d.y) / (overlap + 1)]
},
x: {
label: "mean no. of infected neighboring nodes →"
},
fy: {
axis: "left",
label: "CDC week",
tickFormat: d => formatDate(cdc[d]),
},
facet: {
data: data,
y: "week",
x: "network",
marginLeft:100
},
style: {
pointerEvents: "all"
},
marks: [
Plot.areaY(data, {x: "x", y:"y", fillOpacity: 0.5, fill: d => color(getDiff(d)), title: d => `week ${d.week}\np-value: ${d.pval}`}),
Plot.lineY(data, {x: "x", y: "y", strokeWidth: 1}),
Plot.ruleX(data, Plot.selectLast({x: "obs", strokeOpacity: 0.5, stroke: "red", strokeWidth: 5, title: d => `observed mean: ${d.obs}`}))
]
}), { fill: "gray", opacity: 0.5, "stroke-width": "3px", stroke: "pink" })