Public
Edited
May 26, 2024
2 stars
Insert cell
Insert cell
points = 200
Insert cell
md`# Stressed Trout`
Insert cell
data = d3.range(points)
.map(function (i) {
var a = 2 * Math.PI * Math.random(), //A random point along a circle
d = Math.sqrt(Math.random()); //Distribution Factor
return {
id: i,
// r: 4 * (1 + 5 * Math.random() * Math.random()),
r: 3 + (4 * Math.random()),
// r: (Math.random() * 3) + 5,
// r: (Math.random() * 3) + 15,
x: 200 * Math.cos(a) * d,
// y: 200 * Math.sin(a) * d,
y: 100 * d,
color: 'blue',
};
})
//Add n feelers
.map(function (d) {
// var n = Math.floor(4 + d.r / 3), //For each polygon, the # feelers is proportional to the radius
// start = 2 * Math.PI * Math.random(); //Start at a random point along circle
// d.children = d3.range(n)
// .map(function (i) {
// //Plot points around the radius of a circle
// var angle = i * (Math.PI * 2 / n) + start,
// t = {
// length: 1,
// angle: angle,
// sin: Math.sin(angle),
// cos: Math.cos(angle),
// parent: d,
// };
var n = Math.floor(4 + d.r) //Start at a random point along circle
d.children = d3.range(n)
.map(function (i) {
//Plot points around the radius of a circle
var angle = Math.PI - (i * (Math.PI * 2 / n)),
// var angle = i * (Math.PI * 2 / n),
t = {
length: 1,
angle: angle,
sin: Math.sin(angle),
cos: Math.cos(angle),
parent: d,
};
return t;
});
return d;
});
Insert cell
buffer = 2.5;
Insert cell
color = function(i) { return d3.cubehelix((i%100)*3.60, 1.2, 0.6); }
Insert cell
function nodes(quadtree){
var nodes = [];
quadtree.visit(function(node,x0,y0,x1,y1){
node.x0 = x0, node.y0 = y0;
node.x1 = x1, node.y1 = y1;
nodes.push(node);
});
return nodes;
}
Insert cell
width = 900;
Insert cell
height = 500;
Insert cell
line = d3.radialLine()
.curve(d3.curveCatmullRomClosed);
Insert cell
d3 = require("d3@5")
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