Published
Edited
Jan 25, 2021
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
visualizeRandom = (rand, xDomain, length) => {
// Gather an array of point samples from `rand`
let data = Array.from({ length }, rand);

// Create a density estimator with a constant y value
let density = pointDensity(width * devicePixelRatio, 1)
.xDomain(xDomain)
.x(d => d)
.y(d => 1);

// Create a plotter
let plot = densityPlot(density, [width, 60])
.drawAxes(false)
.color(buf => d3.scaleSequential(d3.extent(buf), d3.interpolateGreens));

// Plot the data
return plot(data);
}
Insert cell
comma = d3.format(',')
Insert cell
d3 = require('d3@6')
Insert cell
html = (await require("htl@0.2")).html
Insert cell
import { densityPlot, pointDensity } from '@twitter/density-plot@4155'
Insert cell
import { slider } from "@jashkenas/inputs";
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