Public
Edited
Jan 17, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
polarToCartesian = (x, y, r, degrees) => {
const radians = degrees * Math.PI / 180.0;
return [x + (r * Math.cos(radians)),
y + (r * Math.sin(radians))]
}
Insert cell
segmentPath = (x, y, r0, r1, d0, d1) => {
// https://svgwg.org/specs/paths/#PathDataEllipticalArcCommands
const arc = Math.abs(d0 - d1) > 180 ? 1 : 0;
const point = (radius, degree) =>
polarToCartesian(x, y, radius, degree)
.map((n) => n.toPrecision(5))
.join(",");
return [
`M${point(r0, d0)}`,
`L${point(r0, d1)}`,
`L${point(r1, d1)}`,
`L${point(r1, d0)}`,
"Z"
].join("");
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
range = (n) => [...Array(n).keys()]
Insert cell
chroma = require('chroma-js')
Insert cell
import {form} from "@mbostock/form-input"
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