treemapChart = (unorderedProperty) => {
const margin = 100;
const hierarchy = d3.hierarchy(animationProperty).sum((d) => d.value);
const viewWidth = size + margin * 2;
const svg = d3
.create("svg")
.attr("viewBox", [0, 0, viewWidth, viewWidth])
.attr("font-family", "sans-serif");
svg
.append("rect")
.attr("width", viewWidth)
.attr("height", viewWidth)
.attr("fill", "white");
const rectWidth = 40;
const legend = svg
.append("g")
.attr("transform", `translate(5, 50)`)
.attr("id", "legend")
.selectAll("g")
.data(Object.entries(propertyTypes))
.join("g")
.attr("transform", (d, i) => `translate(0, ${i * (rectWidth + 10)})`)
.attr("data-name", (d) => d[0]);
legend
.append("rect")
.attr("fill", (d) => d[1])
.attr("rx", "2")
.attr("stroke-width", "1px")
.attr("stroke", "black")
.attr("width", rectWidth)
.attr("height", rectWidth);
legend
.append("text")
.attr("x", rectWidth + 8)
.attr("y", rectWidth / 1.6)
.attr("width", rectWidth)
.text((d) => d[0]);
const propertyName = svg
.append("text")
.attr("x", viewWidth / 2)
.attr("y", 60)
.attr("font-size", 42)
.attr("text-anchor", "middle")
.text(hierarchy.data.name);
const voronoi = svg
.append("g")
.attr("transform", `translate(${margin}, ${margin})`);
voronoiTreeMap(hierarchy);
let allNodes = hierarchy.descendants();
voronoi
.selectAll("path")
.data(allNodes)
.join("path")
.attr("d", (d) => "M" + d.polygon.join("L") + "Z")
.attr("stroke", "black")
.style("fill", (d) => propertyTypes[d.data.type])
.attr("class", "path")
.attr("stroke-width", (d) => 15 - d.depth * 7)
.append("title")
.text((d) => d.data.name);
voronoi
.selectAll("text")
.data(allNodes.filter((d) => d.depth === 1))
.join("text")
.attr("text-anchor", "middle")
.attr("font-size", 24)
.attr(
"transform",
(d) => "translate(" + [d.polygon.site.x, d.polygon.site.y + 6] + ")"
)
.text((d) => d.data.name.split("animation")[1])
.attr("cursor", "default")
.attr("pointer-events", "none")
.attr("fill", "black");
return svg.node();
}