Published
Edited
May 16, 2019
Importers
Insert cell
Insert cell
dataFromFunction = (func, options = {}) => {
const defaultOptions = {
start: 0,
step: 1,
length: 10,
};
const { start, step, length } = { ...defaultOptions, ...options };
return Array(length).fill().map((_, i) => start + (step * i)).map(x => ({ x, y: func(x) }));
};
Insert cell
data = dataFromFunction(Math.log2, { start: 1 });
Insert cell
Insert cell
d3 = require('https://d3js.org/d3.v5.min.js');
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