Public
Edited
Oct 18, 2022
1 fork
11 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
min = -2000;
Insert cell
max = 2000;
Insert cell
triples = {
const out = [];
for (let a = min; a <= max; a++){
for (let b = min; b <= max; b++){
const c = Math.sqrt(a ** 2 + b ** 2);
if (a && b && Number.isInteger(c)) out.push({ a, b, c });
}
}
return out;
}
Insert cell
frequency = d3
.groups(triples, d => d.a)
.map(([a, entries]) => ({ a, count: entries.length }))
Insert cell
fy = d3.scaleLinear()
.domain([0, d3.max(frequency, d => d.count)])
.range([chartHeight, 0]);
Insert cell
Insert cell
style = `
circle.triple {
fill: tomato;
}
.axis .domain {
display: none;
}
.grid .domain {
display: none;
}
.grid text {
display: none;
}
.grid line {
stroke: #ddd;
shape-rendering: crispEdges;
}
`
Insert cell
Insert cell
x = d3.scaleLinear()
.domain([min, max])
.range([0, chartWidth]);
Insert cell
y = d3.scaleLinear()
.domain([min, max])
.range([chartHeight, 0]);
Insert cell
Insert cell
margin = ({ left: 40, right: 10, top: 10, bottom: 40 });
Insert cell
size = Math.min(width, 500);
Insert cell
chartWidth = size - margin.left - margin.right;
Insert cell
chartHeight = size - margin.top - margin.bottom;
Insert cell
Insert cell
import { toc } from "@harrystevens/toc";
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