Public
Edited
Nov 26, 2023
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
groupedMonthly = _.groupBy(data, (d) => {
const m = d.date.getMonth();
const y = d.date.getFullYear();
return `${y}-${_.padEnd("0", 2, m)}`;
})
Insert cell
monthly = Object.entries(groupedMonthly).map(([key, items]) => {
return {
year: +key.slice(0, 4),
month: +key.slice(5, 7),
total: _.sum(items.map((d) => d.consumption))
};
})
Insert cell
Plot.plot({
facet: {
data: monthly,
x: (d) => d.month,
y: (d) => d.year
},
marks: [
Plot.frame(),
Plot.dot(data, { x: "month", y: "total" })
]
})
Insert cell
Insert cell
Plot.plot({
facet: {
data: data,
x: (d) => d.date.getMonth(),
y: (d) => d.date.getFullYear()
},
marks: [
Plot.frame(),
Plot.dot(data, { x: (d) => d.date.getDay(), y: "consumption" })
]
})
Insert cell
data = bchydroExport.map(row => ({ date: new Date(row['Interval Start Date/Time'].slice(0, 10).replaceAll('/', '-')), consumption: row['Net Consumption (kWh)']})).filter(row => !isNaN(row.consumption))
Insert cell
data
Insert cell
bchydro-export.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
bchydroExport[2]
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