Published
Edited
Nov 10, 2018
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
height = Math.max(300, width * 0.4)
Insert cell
y = d3.scaleLinear()
.domain([d3.min(data_y), d3.max(data_y)])
.range([0, height/10])
Insert cell
x = d3.scaleLinear()
.domain([d3.min(data) - 3, d3.max(data) + 3])
.range([0, width])
Insert cell
Insert cell
data = {
const rand = d3.randomNormal()

while(true) {
let n = (Math.random() * 300 + 750)|0
const x = d3.range(n).map(n => rand()).sort(d3.ascending)
if (Math.random() < 0.99) {
const scale = Math.random() + 1;
const q = Math.random() / 2;
x.forEach((val,i) => {if (i>n*(1-q) && Math.random()<0.7) x[i] = val*scale});
x.forEach((val,i) => {if (i<n*q && Math.random()<0.7) x[i] = (x[i]+x[i+1])/2});
}
yield x
await Promises.tick(2000)
}
}
Insert cell
Insert cell
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