Published
Edited
Oct 27, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dataPoints = 5000;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
columns = 45;
Insert cell
rows = 25;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
K = dataPoints * 0.1;
Insert cell
powerParameter = 16;
Insert cell
function getShephardsInterpolatedValue(P) {
// add your own code here ...
// feel free to create more more cells for functions, variables, etc.
return 0;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
height = 500;
Insert cell
margin = 10;
Insert cell
dotRadius = 3;
Insert cell
resolution = 4;
Insert cell
perlinOctaves = 8;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function renderGrid(canvas) {
const grid = canvas.select("g.grid")
.attr("transform", `translate(${margin}, ${margin})`);
grid.selectAll("*").remove();
// generates a rows x columns matrix, using values from a Perlin noise field.
const linearizedMatrix = linearizeMatrix(matrix);
const cells = grid.selectAll("g.cell").data(linearizedMatrix).enter()
.append("g")
.attr("class", "cell")
.attr("transform", d => `translate(${d.col * spacing}, ${d.row * spacing})`);
const boundary = cells.append("rect")
.attr("class", "boundary")
.attr("width", spacing)
.attr("height", spacing)
.attr("stroke", "transparent")
.attr("fill", d => color(getShephardsInterpolatedValue(d.value)))
.on("click", (event, d) => {
});
return canvas;
}
Insert cell
/**
* Draws the dots that represent the Perlin noise from the matrix.
*/
function renderDots(canvas) {
const points = canvas.select("g.points");
points.selectAll("*").remove();
const point = points.selectAll("circle.point").data(randomData).enter()
.append("circle")
.attr("class", "point")
.attr("r", dotRadius)
.attr("cx", d => d.x)
.attr("cy", d => d.y)
.attr("fill", d => color(d.z))
.attr("stroke", "#ccc");
point.append("title").text(d => d.value);
return canvas;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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