{
let landguzzlersViz = d3.select(svgContainer)
land_guzzlers.sort((a, b) => b.footprint - a.footprint);
const scaleFactor = 980;
const svgHeight = 1100;
landguzzlersViz.selectAll("rect")
.data(land_guzzlers)
.join("rect")
.attr("width", d => Math.sqrt(d.footprint) * 1000)
.attr("height", d => Math.sqrt(d.footprint) * 1000)
.attr("x", (d, i) => 50 + i * 110)
.attr("x", 0)
.attr("y", d => {
let side = Math.sqrt(d.footprint) * scaleFactor;
return svgHeight - side;
})
.style("fill", (d, i) => colors[i])
.style("stroke", "#fff")
.style("stroke-width", 2);
landguzzlersViz.selectAll(".title")
.data(land_guzzlers)
.data(land_guzzlers.filter(d => d.title !== "HAMSTER"))
.join("text")
.attr("x", d => Math.sqrt(d.footprint) * 1000 - 10)
.attr("y", d => svgHeight - Math.sqrt(d.footprint) * scaleFactor + 27)
.text(d => d.title)
.attr("class", "title");
landguzzlersViz.selectAll(".footprint")
.data(land_guzzlers)
.join("text")
.data(land_guzzlers.filter(d => d.footprint !== "0.014"))
.data(land_guzzlers.filter(d => d.title !== "HAMSTER"))
.attr("x", d => Math.sqrt(d.footprint) * 1000 -23)
.attr("y", d => svgHeight - Math.sqrt(d.footprint) * scaleFactor + 32)
.text(d => "Eco-footprint" + d.footprint + "hectacres")
.attr("transform", function(d, i, nodes) {
let x = nodes[i].getAttribute("x");
let y = nodes[i].getAttribute("y");
return "rotate(90 " + x + " " + y + ")";
})
.style("font-size", "24px")
.attr("class", "footprint");
}