Plot.plot({
marks: [
Plot.areaY(timeline, {
x: "year",
y1: -50,
y2: "diffPreDiversion",
curve: "natural",
fill: "#d1e5ff",
filter: (d) => d.year >= 1930
}),
Plot.lineY(timeline, {
x: "year",
y: "diffPreDiversion",
stroke: "dimgray",
strokeWidth: 1,
filter: (d) => d.year >= 1930,
curve: "natural"
}),
Plot.ruleY([6392 - 6417], {
x1: 1994,
x2: 2017,
stroke: "coral",
strokeWidth: 2,
strokeDasharray: "4,3"
}),
Plot.ruleY([0], {
x1: 1941,
x2: 2017,
stroke: "#275bc4",
strokeWidth: 2,
strokeDasharray: "4,3"
}),
Plot.tip(
[
`Mono Lake level mandated by Decision D-1631 in 1994 (6,392 feet above sea level)`
],
{ x: 1994, y: 6392 - 6417, anchor: "bottom", stroke: "gainsboro" }
),
Plot.tip([`1940 (pre-diversion) level: 6,417 ft`], {
x: 1970,
y: 0,
anchor: "bottom",
stroke: "gainsboro"
}),
Plot.dot(timeline, {
x: "year",
y: "diffPreDiversion",
r: 4,
stroke: "#275bc4",
strokeWidth: 2,
fill: "dodgerblue",
filter: (d) => d.detail != null
}),
Plot.frame({ stroke: "gray" }),
Plot.tip(
timeline,
Plot.pointerX({
x: "year",
y: "diffPreDiversion",
title: (d) =>
d.detail == null
? `Year: ${d.year}\nChange from pre-diversion level: ${d3.format(
","
)(d.diffPreDiversion)} ft`
: `Year: ${d.year}\nChange from pre-diversion level: ${d3.format(
","
)(d.diffPreDiversion)} ft\n\n${d.detail}`,
stroke: "gainsboro",
opacity: 0.95
})
)
],
y: {
domain: [-50, 10],
ticks: 5,
label:
"Difference in lake level (feet) from pre-diversion level\n recorded in 1940 (6,417 feet above sea level)"
},
x: {
tickFormat: "Y",
domain: [1930, d3.max(monoYearly, (d) => d.year)],
label: null,
ticks: 10
},
height: 500,
width: 800,
margin: 30
})