{
let landguzzlersViz = d3.select(svgContainer)
landguzzlersViz.selectAll("rect")
.data(land_guzzlers)
.join("rect")
.attr("width", d => 1000*Math.sqrt(d["footprint"]))
.attr("height", d => 1000*Math.sqrt(d["footprint"]))
.attr("x", 0)
.attr("y", d => 1100 - 1000*Math.sqrt(d["footprint"]))
.style("fill", (d,i) => colors[i]);
landguzzlersViz.selectAll(".line1")
.data(land_guzzlers.filter(d => d["subtitle1","subtitle2","subtitle3"] !=""))
.join("line")
.attr("x1", d => 1000*Math.sqrt(d["footprint"]) - 26.5)
.attr("x2", d => 1000*Math.sqrt(d["footprint"]) - 276.5)
.attr("y1", d => 1000*Math.sqrt(d["footprint"]) - 696.5)
.attr("y2", d => 1000*Math.sqrt(d["footprint"]) - 696.5)
.attr("class","line")
landguzzlersViz.selectAll(".line2")
.data(land_guzzlers.filter(d => d["subtitle1","subtitle2","subtitle3"] !=""))
.join("line")
.attr("x1", d => 1000*Math.sqrt(d["footprint"]) - 26.5)
.attr("x2", d => 1000*Math.sqrt(d["footprint"]) - 26.5)
.attr("y1", d => 1000*Math.sqrt(d["footprint"]) - 696.5)
.attr("y2", d => 1000*Math.sqrt(d["footprint"]) - 635.7)
.attr("class","line")
landguzzlersViz.selectAll(".title")
.data(land_guzzlers)
.join("text")
.attr("x", d => 1000*Math.sqrt(d["footprint"]) - 5)
.attr("y", d => 1100 - 1000*Math.sqrt(d["footprint"]) + 30)
.text(d => d["title"])
.attr("class", "title"); // tag it with the style class 'title'
landguzzlersViz.selectAll(".footprint")
.data(land_guzzlers)
.join("text")
.attr("x", d => 1000*Math.sqrt(d["footprint"]) - 20)
.attr("y", d => (1100 - 1000*Math.sqrt(d["footprint"])) + 35)
.text(d => "Eco-footprint: " + d["footprint"] + " hectares")
.attr("transform", (d,i,nodes) => "rotate(90 " + nodes[i].getAttribute("x") + " " + nodes[i].getAttribute("y") + ")")
// ^^ OK, so you would not have gotten this one on your own easily. See if you can figure it out.
// also compare this back against your manual SVG code for the rotate. Similar?
.attr("class", "footprint"); // tag it with the style class 'title'
landguzzlersViz.selectAll(".subtext1") // notice that I'm selectingAll objects of a class called .title, to only get those text.
.data(land_guzzlers) // same dataset
.join("text") // new object type created
.attr("x", d => 1000*Math.sqrt(d["footprint"]) - 31)
.attr("y", d => 1100 - 1000*Math.sqrt(d["footprint"]) + 57)
.text(d => d["subtitle"]) // this is how we actually write the text content
.attr("class", "subtext1"); // tag it with the style class 'title'
landguzzlersViz.selectAll(".subtext2") // notice that I'm selectingAll objects of a class called .title, to only get those text.
.data(land_guzzlers) // same dataset
.join("text") // new object type created
.attr("x", d => 1000*Math.sqrt(d["footprint"]) - 31)
.attr("y", d => 1100 - 1000*Math.sqrt(d["footprint"]) + 75)
.text(d => d["subtitle2"]) // this is how we actually write the text content
.attr("class", "subtext2"); // tag it with the style class 'title'
landguzzlersViz.selectAll(".subtext3") // notice that I'm selectingAll objects of a class called .title, to only get those text.
.data(land_guzzlers) // same dataset
.join("text") // new object type created
.attr("x", d => 1000*Math.sqrt(d["footprint"]) - 31)
.attr("y", d => 1100 - 1000*Math.sqrt(d["footprint"]) + 93)
.text(d => d["subtitle3"]) // this is how we actually write the text content
.attr("class", "subtext3"); // tag it with the style class 'title'
}