Published
Edited
Dec 2, 2020
2 forks
11 stars
Insert cell
Insert cell
Insert cell
viewof cut = html`<input type=checkbox />`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
daysFilter = d => [1, 3, 5].includes(d.getDay()) // Monday, Wednesday, Friday
Insert cell
year = startDate.getUTCFullYear()
Insert cell
inch = n => pRound(n * 72)
Insert cell
Insert cell
Insert cell
MOON_R = 10
Insert cell
CUT_R = MOON_R + 1
Insert cell
Insert cell
TAU = Math.PI*2
Insert cell
radians = n => n/360 * TAU
Insert cell
pointOnArc = (r, a) =>
pRound(Math.sin(radians(a)) * r) + " " + pRound(Math.cos(radians(a)) * r)
Insert cell
pRound = n => Math.round(n * 100000) / 100000
Insert cell
isoDate = d => d.toISOString().split('T')[0]
Insert cell
projection = d3
.geoOrthographic()
.translate([0, 0])
.scale(MOON_R)
Insert cell
path = d3.geoPath(projection)
Insert cell
hemisphere = d3.geoCircle()()
Insert cell
dayScale = {
const scale = d3
.scalePoint()
.domain(d3.range(15))
.range([margin.left, width - margin.right])
.padding(1);
return (d, i) => {
const base = i % 12;
const offset = Math.floor(base / 3);
return scale(base + offset);
};
}
Insert cell
rowScale = {
const scale = d3
.scalePoint()
.domain(d3.range(13))
.range([margin.top, height - margin.bottom])
.padding(1);
return (d, i) => scale(Math.floor(i / 12));
}
Insert cell
days = {
return d3.timeDay.range(startDate, endDate).filter(daysFilter);
}
Insert cell
months = {
const now = new Date(year, 0, 1);
const start = d3.timeYear(now);
return d3.timeMonths(start, d3.timeYear.offset(start, 1));
}
Insert cell
width = inch(WIDTH)
Insert cell
height = inch(HEIGHT)
Insert cell
margin = ({
top: inch(3 / 4),
right: inch(3 / 4),
bottom: inch(1 / 2),
left: inch(3 / 4)
})
Insert cell
Insert cell
suncalc = require("suncalc@1")
Insert cell
d3 = require("d3@5")
Insert cell
import { renderTextArray, renderTextPaths } from '@meetamit/hershey-fonts'
Insert cell
//import { compileSVG } from '@forresto/svg-to-cnc'
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