Plot.barX(data,
Plot.binY({x: "count"},
{ y: "kwh",
thresholds: [0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130],
fill: (d, i) => (d.kwh > movingAvg[i] + 5 ? 1 : 0)
}))
.plot({
facet: {
data,
x: d => d.date.getMonth(),
},
marks: [
Plot.ruleX([0], {stroke: "black"}),
],
y: { grid: false, reverse: true},
fx: {
tickFormat: d => Plot.formatMonth()(d)
},
marginLeft: 30,
marginBottom: 100,
width: width,
style: {
fontSize: "9px"
},
color: {
range: ["steelblue", "orange"]
}
})