Public
Edited
Feb 17, 2022
1 fork
8 stars
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
data = Array.from(10000, d3.randomUniform())
Insert cell
numPoints = 10000
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@4159'
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more