Public
Edited
Apr 16, 2023
Fork of Simple D3
Insert cell
Insert cell
Insert cell
chart = {
const svg = d3.create("svg").attr("width", width).attr("height", height);
const center = [width / 2, height / 2];
const center_dark = [width * 0.25, height / 2];
const center_gold = [width * 0.75, height / 2];
const segment_width = width * 0.25;
const Tau = Math.PI * 2;

const fx = (i, N, radius, center_x) =>
Math.cos((Tau * i) / N) * radius + center_x;
const fy = (i, N, radius, center_y) =>
Math.sin((Tau * i) / N) * radius + center_y;

const colors = {
stroke: {
faded: "#73613f",
bright: "#b6a17a"
},
bg: {
dark: "",
gold: "#927a4e"
}
};

// TODO: Add circular/linear gradient for both bg rects
// Dark square
const dark_square = svg.append("g");
dark_square
.append("rect")
.attr("x", 0)
.attr("y", 0)
.attr("width", width / 2)
.attr("height", height)
.attr("fill", "#4f3e2c");

// Gold square
const gold_square = svg.append("g");
gold_square
.append("rect")
.attr("x", width / 2)
.attr("y", 0)
.attr("width", width / 2)
.attr("height", height)
.attr("fill", colors.bg.gold);

// OUTER CIRCLES
const outer_radius = segment_width * 1.1;
dark_square
.selectAll("line")
.data(d3.range(150))
.join("line")
.attr("x1", center_dark[0])
.attr("y1", center_dark[1])
.attr("x2", (_, i, N) => fx(i, N.length, outer_radius, center_dark[0]))
.attr("y2", (_, i, N) => fy(i, N.length, outer_radius, center_dark[1]))
.attr("stroke", colors.stroke.faded);
gold_square
.selectAll("line")
.data(d3.range(150))
.join("line")
.attr("x1", center_gold[0])
.attr("y1", center_gold[1])
.attr("x2", (_, i, N) => fx(i, N.length, outer_radius, center_gold[0]))
.attr("y2", (_, i, N) => fy(i, N.length, outer_radius, center_gold[1]))
.attr("stroke", colors.stroke.faded);

// OUTER ARC
// INFINITY SYMBOL
// INNER ARC
// SOLID CIRCLE

return svg.node();
}
Insert cell
height = 500
Insert cell
width = 1000
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