function getPlot(data) {
const gray25 = "#444444";
const gray50 = "#888888";
const gray75 = "#cccccc";
const ecb = "#800030";
const fonts = "DecimaMono,Consolas,Monaco,monospace";
const xmin = d3.min(data, d => d.Election);
const xmax = d3.max(data, d => d.Election);
const titX = (xmin+xmax)/2;
const titY = 1.05;
const svg = Plot.plot({
marginTop: 50,
width: 800,
x: {grid: false},
y: {grid: false},
facet: {
data: data,
x: "column",
y: "row",
label: null
},
marks: [
Plot.area(data, {x1: "Election", y1: "Turnout_lo", y2: "Turnout_hi", fill: "#d2b2c1"}),
Plot.ruleX([xmin, xmax], {y1: d=>0, y2: d=>1, stroke: gray75}),
Plot.ruleY([.5], {x1:xmin, x2:xmax, stroke: gray75, strokeDasharray: 1}),
Plot.ruleY([0, 1]),
Plot.ruleY(data, {y: [0,.5,1], x1: d=>xmax, x2: d=>xmax+.25, stroke: gray75}),
Plot.text(data, {text: "Province", x: d => titX, y: d => titY, fill: gray25, fontFamily: fonts}),
Plot.text(data, {text: ["0%", "50%", "100%"], x: d=>xmax+.75, y: [0,.5,1], fill: "gray", fontFamily: fonts}),
Plot.text(data, {text: ["2004", "2021"], x: [xmin,xmax], y: [-0.05,-0.05], fill: "gray", fontFamily: fonts}),
Plot.line(data, {x: "Election", y: "Turnout", stroke: ecb}),
],
style : {background: "white", color: "white"}
})
svg.id = "PlotFacet";
d3.select("#PlotFacet")
.append("text")
.attr("x", 200)
.attr("y", 200)
.attr("text-anchor", "middle")
.style("font-size", "24px")
.style("text-decoration", "bold")
.style("color", "black")
.text("On-reserve turnout (2004-2021)");
return svg;
}