{
const data = origenesTreemapData;
const width = 600, height = 600;
const radius = 250;
const angle = d3.scaleBand()
.domain(data.map(d => d.genre))
.range([0, 2 * Math.PI]);
const r = d3.scaleLinear()
.domain([0, d3.max(data, d => d.count)])
.range([40, radius]);
const color = d3.scaleOrdinal(d3.schemeSet3);
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height);
const group = svg.append("g")
.attr("transform", `translate(${width / 2}, ${height / 2})`);
const lines = group.selectAll("line")
.data(data)
.join("line")
.attr("stroke", d => color(d.genre))
.attr("stroke-width", 3)
.attr("x1", 0)
.attr("y1", 0)
.attr("x2", d => r(d.count) * Math.cos(angle(d.genre) - Math.PI / 2))
.attr("y2", d => r(d.count) * Math.sin(angle(d.genre) - Math.PI / 2));
const labels = group.selectAll("text")
.data(data)
.join("text")
.attr("x", d => (r(d.count) + 15) * Math.cos(angle(d.genre) - Math.PI / 2))
.attr("y", d => (r(d.count) + 15) * Math.sin(angle(d.genre) - Math.PI / 2))
.attr("text-anchor", "middle")
.attr("alignment-baseline", "middle")
.text(d => d.genre)
.style("font-size", "10px");
let angleDeg = 0;
d3.timer(() => {
angleDeg = (angleDeg + 0.2) % 360;
group.attr("transform", `translate(${width / 2}, ${height / 2}) rotate(${angleDeg})`);
});
return svg.node();
}