Published
Edited
Nov 1, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d18moving = movingAverage(data18, N)
Insert cell
Insert cell
data19 = dataraw.filter(function(d){ return d.date <= year19 && d.date > year18 }).map(({date, value, value2}) => ({date: new Date(2020, date.getMonth(), date.getDate()), value, value2}))
Insert cell
d19moving = movingAverage(data19, N)
Insert cell
data20 = dataraw.filter(function(d){ return d.date <= year20 && d.date > year19 }).map(({date, value, value2}) => ({date: new Date(2020, date.getMonth(), date.getDate()), value, value2}))
Insert cell
d20moving = movingAverage(data20, N)
Insert cell
Insert cell
Insert cell
Insert cell
year19 = new Date(2019, 11, 31)
Insert cell
year20 = new Date(2020, 11, 31)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
xAxis = (g, x, height) => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x).ticks(width / 80).tickSizeOuter(0))
Insert cell
yAxis = (g, y, title) => g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y))
.call(g => g.select(".domain").remove())
.call(g => g.selectAll(".title").data([title]).join("text")
.attr("class", "title")
.attr("x", -margin.left)
.attr("y", 10)
.attr("fill", "currentColor")
.attr("text-anchor", "start")
.text(title))
Insert cell
margin = ({top: 20, right: 20, bottom: 30, left: 40})
Insert cell
height = width/1.6
Insert cell
focusHeight = 100
Insert cell
d3 = require("d3@6")
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