Published
Edited
Aug 11, 2021
2 forks
12 stars
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
formatTitle = (d) =>
`${d3.timeFormat("%Y/%m/%d")(d.date)}\n${d.hour}\n${d.usage.toFixed(2)} kW`
Insert cell
filtered = data.filter(d => d.hour === hour)
Insert cell
st = {
const values = filtered.map(d => d.usage)
return {
max: d3.quantile(values, range.high),
upper: d3.quantile(values, 0.75),
lower: d3.quantile(values, 0.25),
min: d3.quantile(values, range.low),
mean: d3.mean(values),
median: d3.median(values)
}
}
Insert cell
formatDate = function (date) {
return date.toLocaleString(undefined, {
weekday: "short",
month: "short",
day: "numeric"
});
}
Insert cell
dateRange = d3.extent(data.map(d => d.date))
Insert cell
dataRange = d3.extent(data, d => d.usage)
Insert cell
hours = [...new Set(data.map(d => d.hour))]
Insert cell
data = {
const src = await FileAttachment("pge-electric-data.csv").csv();
return src.map(d => ({
date: d3.timeParse("%Y-%m-%d")(d.DATE),
hour: +d["START TIME"].substring(0, 2),
usage: +d.USAGE
}));
}
Insert cell
Insert cell
Insert cell
Insert cell
import { addTooltips } from "@mkfreeman/plot-tooltip"
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more