Published
Edited
Aug 30, 2020
1 fork
Insert cell
Insert cell
import {ramp} from "@mbostock/color-ramp"
Insert cell
ramp(t => `hsl(${t * 360}, 100%, 50%)`)
Insert cell
Insert cell
import {map} from "@d3/interrupted-sinu-mollweide"
Insert cell
map
Insert cell
Insert cell
Insert cell
import {chart as treemap}
with {treemap_data as data}
from "@d3/treemap"
Insert cell
treemap
Insert cell
treemap_data = FileAttachment("d3.json").json()
Insert cell
Insert cell
import {chart as histogram}
with {histogram_data as data}
from "@d3/histogram"
Insert cell
Insert cell
histogram
Insert cell
histogram_data = new Array(10000).fill().map(() => randb(...alphabeta))
Insert cell
Insert cell
import {interval} from "@mbostock/countdown"
Insert cell
interval
Insert cell
Insert cell
// i
Insert cell
import {i} from "@mbostock/generator-cells-functions-and-objects"
Insert cell
Insert cell
import {map as map2} from "@d3/interrupted-sinu-mollweide"
Insert cell
map === map2
Insert cell
Insert cell
Insert cell
Insert cell
import {hello} from "1b9f514e4db7af3a"
Insert cell
hello
Insert cell
Insert cell
Insert cell
url = "https://api.observablehq.com/@observablehq/introduction-to-imports.js?v=3"
Insert cell
orient = "LR"
Insert cell
import {graphic as graph} with {url, orient} from "@observablehq/notebook-import-visualizer"
Insert cell
function randb(alpha, beta) {
const u = randg(alpha);
return u / (u + randg(beta));
}
Insert cell
// Returns a gamma deviate by the method of Marsaglia and Tsang.
function randg(shape) {
let oalph = shape, a1, a2, u, v, x, mat;
if (!shape) shape = 1;
if (shape < 1) shape += 1;
a1 = shape - 1 / 3;
a2 = 1 / Math.sqrt(9 * a1);
do {
do {
x = randn();
v = 1 + a2 * x;
} while (v <= 0);
v = v * v * v;
u = Math.random();
} while (
u > 1 - 0.331 * Math.pow(x, 4) &&
Math.log(u) > 0.5 * x * x + a1 * (1 - v + Math.log(v))
);
if (shape === oalph) return a1 * v; // alpha > 1
do u = Math.random(); while (u === 0); // alpha < 1
return Math.pow(u, 1 / oalph) * a1 * v;
}
Insert cell
// Returns a normal deviate (mu=0, sigma=1).
function randn() {
let u, v, x, y, q;
do {
u = Math.random();
v = 1.7156 * (Math.random() - 0.5);
x = u - 0.449871;
y = Math.abs(v) + 0.386595;
q = x * x + y * (0.19600 * y - 0.25472 * x);
} while (q > 0.27597 && (q > 0.27846 || v * v > -4 * Math.log(u) * u * u));
return v / u;
}
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