Plot.plot({
height: dynamicHeight,
width: 1000,
marginRight: 100,
marginLeft: 100,
marks: [
Plot.dot(
final,
Plot.stackX2({
filter: (d) => d.year >= yearSelect,
x: (d) => (d.shadow === true ? -1 : 1),
y: "year",
fill: "#ccc",
opacity: 0.3,
r: 5
})
),
Plot.dot(
final,
Plot.stackX2({
filter: (d) =>
d.year >= yearSelect &&
regionFilter.includes(d.region) &&
nameFilter.includes(d.name),
x: (d) => (d.shadow === true ? -1 : 1),
y: "year",
fill: "shadow",
r: 5,
channels: { name: "name", region: "region" }
})
),
Plot.dot(
final,
Plot.pointer(
Plot.stackX2({
filter: (d) =>
d.year >= yearSelect &&
regionFilter.includes(d.region) &&
nameFilter.includes(d.name),
x: (d) => (d.shadow === true ? -1 : 1),
y: "year",
r: 8,
fill: "red",
opacity: 0.5,
tip: true,
title: (d) =>
`${d.name} \nfrom ${d.city} predicted ${
d.shadow === true ? "long winter" : "early spring"
} in ${d.year}`
})
)
)
],
x: { axis: null },
color: { range: ["#e0c600", "#3e6589"] },
y: {
domain: [yearSelect, d3.max(final, (d) => d.year)],
ticks: d3.range(yearSelect, d3.max(final, (d) => d.year) + 1, 1),
tickSize: 0,
tickFormat: d3.format(".0f"),
tickPadding: 20,
label: null
},
title: htl.html`<h3 style = "text-align: center">Did the groundhogs predict <b style="color:#3e6589">long winter</b> or <b style="color:#e0c600">early spring</b></h3><br>`
})