Published
Edited
Mar 19, 2021
Importers
2 stars
Insert cell
Insert cell
Insert cell
addDays = (date, days) => {
const copy = new Date(Number(date))
copy.setDate(date.getDate() + days)
return copy
}
Insert cell
getWeekNumber = (thisDate) => {
// this returns a 0-based week number in the year (0-52)
var firstOfJan = new Date(thisDate.getUTCFullYear(), 0, 1); // first day of year
var firstOfJanDoW = firstOfJan.getDay();
var dayOfYear = Math.floor((thisDate.valueOf() - firstOfJan.valueOf()) / (24*60*60*1000))
return Math.ceil((dayOfYear - firstOfJanDoW) / 7)
}
Insert cell
Insert cell
Insert cell
Insert cell
dashboard_example
Insert cell
Insert cell
Insert cell
function embedView (cells=[], text="Embedded notebook view") {
const embedUrl = document.baseURI.replace(/observablehq.com/, "observablehq.com/embed");
const paramChar = document.baseURI.includes("?") ? "&" : "?";
const cellsText = cells.length>0 ? paramChar + "cells="+cells.reduce((a,c)=>a+"%2C"+c) : "";
return md`[${text}](${embedUrl+cellsText})`
}
Insert cell
embedView(["test"], "test embedded view")
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