Public
Edited
Apr 29, 2022
5 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof size = Inputs.range([500, 2000], {label: "zoom"})
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
FileAttachment("image@8.png").image()
Insert cell
Insert cell
r = 20
Insert cell
Insert cell
Insert cell
function polygon ({numSides = 3, fill = "black", stroke="none", center, size = r, theta = 0}) {
const points = [...Array(numSides).keys()]
.map(i => ((2 * Math.PI * i/ numSides) + theta) % (2 * Math.PI))
.map(d => [
Math.cos(d) * size + center[0],
Math.sin(d) * size + center[1]
]
);
const pointsStr = points
.map(p => p.join(","))
.reduce((m, e) => `${m.trim()} ${e}`, "");
return htl.svg.fragment`<polygon points="${pointsStr}" fill="${fill}"/>`
}
Insert cell
function starryGon ({numSides = 3, fill = "black", stroke="none", center, size = r, theta = 0}) {
const points = [...Array(numSides).keys()]
.map(i => ((4 * Math.PI * i/ numSides) + theta))
.map(d => [
Math.cos(d) * size + center[0],
Math.sin(d) * size + center[1]
]
);
const pointsStr = points
.map(p => p.join(","))
.reduce((m, e) => `${m.trim()} ${e}`, "");
return htl.svg.fragment`<polygon points="${pointsStr}" fill="${fill}"/>`
}
Insert cell
function i_to_center(i) {
const x = 2 * r * i + r;
const y = 2 * r * Math.floor(x / width) + r ;
return [x % width, y];
}
Insert cell
Insert cell
height = 200
Insert cell
width = 900
Insert cell
{
const baseShapes = [
{ numSides: 3, }
];
}
Insert cell
# References
https://observablehq.com/@d3/color-schemes
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