Published
Edited
Apr 25, 2020
2 stars
Insert cell
Insert cell
Insert cell
import { trans, ttrans } from '@rabelais/d3-lib-2'
Insert cell
// initialize only once: boot-up process is very expensive
// simplex = new SimplexNoise(seed)
// simplex.noise2D(x, y)
SimplexNoise = require('https://cdnjs.cloudflare.com/ajax/libs/simplex-noise/2.4.0/simplex-noise.min.js')
Insert cell
getNoise = () => {
const simplex = new SimplexNoise();
const noises = Array.from({ length: column }).map(() => []);
for (let c = 0; c < column; c++) {
for (let r = 0; r < row; r++) {
noises[c][r] = simplex.noise2D(c, r);
}
}
return noises;
}
Insert cell
getNoise()
Insert cell
width / 40
Insert cell
column = Math.round(config.clippedWidth / 23)
Insert cell
row = Math.round(config.clippedWidth / 23)
Insert cell
scaleX = d3
.scaleLinear()
.domain([0, row])
.range([config.margin, config.clippedWidth])
Insert cell
scaleY = d3
.scaleLinear()
.domain([0, column])
.range([config.margin, config.clippedHeight])
Insert cell
scaleColor = d3
.scaleQuantile()
.domain([-1, 0, 1])
.range(['orange', 'transparent', 'pink'])
Insert cell
scaleSize = d3
.scaleQuantile()
.domain([-1, 0, 1])
.range([2, 4, 6])
Insert cell
radius = 3
Insert cell
{
while (true) {
await Promises.tick(1000);
const data = getNoise();
art.render(data);
yield;
}
}
Insert cell
config = ({
margin: 20,
width: width,
height: width,
clippedWidth: width - 40,
clippedHeight: width - 40
})
Insert cell
d3 = require('d3@5.15.0')
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