Public
Edited
Mar 24, 2023
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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"]
}
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = FileAttachment("data.csv").csv({typed: true })
Insert cell
Insert cell
movingAvg = Plot.line(data, Plot.windowY({ x: "date", y: "kwh", k: 7, shift: "trailing" }))
.initialize()
.channels.y.value
Insert cell
Insert cell
Insert cell
dateFormat = d3.timeFormat("%Y-%m-%d")
Insert cell
timeFormat = d3.timeFormat("%m/%d")
Insert cell
tip = d => `${dateFormat(d.date)} (${Plot.formatWeekday()(d.date.getDay())}): ${d.kwh}`
Insert cell
Insert cell
Insert cell
import { addTooltips } from "@mkfreeman/plot-tooltip"
Insert cell
import {authorship, navigation, workshop} from "@observablehq/timeseries-assets"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more