Plot.line(
data,
Plot.windowY({
x: d => (!limits || d.date >= limits[0] && d.date <= limits[1]) ? d.date : NaN,
y: "value",
k: smooth
})
).plot({
marks: [Plot.ruleY([0])],
marginLeft: 50,
x: { label: "date (utc)→", domain: limits || undefined },
y: {
label: "↑ Electricity Demand (MWh)",
domain: [0, d3.max(data, (d) => d.value)]
},
width,
height: 400,
caption: md`<em>Note, this displays the x-axis in UTC time, not the local time for California.</em>`
})