Plot.plot({
height: 600,
width: 400,
marginLeft: 25,
x: { ticks: [], label: null },
y: { ticks: [], inset: 0, label: null },
fy: { padding: 0 },
facet: {
label: null
},
marks: [
Plot.axisFy({ anchor: "left", dy: 28, dx: -15, textAnchor: "start" }),
Plot.image(images, {
x: 2014.5,
fy: "Victim Category",
src: "url",
width: 40
}),
Plot.line(accidentsByYear, {
x: "Year",
y: "YearTotal",
fy: "Victim Category",
frameAnchor: "left",
stroke: (d) =>
d["Victim Category"] === "Passenger" ? "#DC4743" : "#B9BDBD",
strokeWidth: 3,
sort: { fy: "y", reduce: "max", order: "descending" }
}),
Plot.ruleX([2017], {
stroke: "#B9BDBD",
strokeDasharray: "4, 4",
opacity: 0.5
}),
Plot.dot(accidentsByYear, {
x: (d) => {
return d.Year === 2017 ? d.Year : null;
},
y: "YearTotal",
stroke: (d) => {
return d.Year === 2017 && d["Victim Category"] === "Passenger"
? "#DC4743"
: "#B9BDBD";
},
fill: (d) => {
return d.Year === 2017 && d["Victim Category"] === "Passenger"
? "#DC4743"
: "#B9BDBD";
},
fy: "Victim Category"
}),
Plot.ruleY([0], { stroke: "#B9BDBD", strokeDasharray: "1, 2" }),
Plot.text(accidentsByYear, {
x: (d) => {
return d.Year === 2015 || d.Year === 2017 ? d.Year : null;
},
y: "YearTotal",
fy: "Victim Category",
text: "YearTotal",
frameAnchor: "top",
dy: 10
})
]
})