Published
Edited
May 2, 2022
Insert cell
landguzzlers.selectAll(".guzzlerstitle")
.data(data.filter(d => d.title == "LARGE DOG" || d.title == "MEDIUM-SIZED DOG" || d.title == "TOYOTA LAND CRUISER" || d.title == "VOLKSWAGEN GOLF" || d.title == "CAT"))
.join("text")
.attr("x", d => (Math.sqrt(Number(d["footprint"])) * 900 - 10))
.attr("y", d => (1020 - (Math.sqrt(Number(d["footprint"])) * 850 - 8)))
.text(d => d["title"])
.attr("class", "title")
.classed("title", true)
Insert cell
landguzzlers.selectAll(".guzzlerssubtitle")
.data(data)
// if (d["title"] != "HAMSTER")
.join("text")
.attr("x", d => (Math.sqrt(Number(d["footprint"])) * 900 - 30))
.attr("y", d => (1020 - (Math.sqrt(Number(d["footprint"])) * 850 - 30)))
.text(d => d["subtitle"])
.attr("class", "subtitle")
.classed("subtitle", true)
Insert cell
landguzzlers.selectAll(".guzzlerssubtitle2")
.data(data)
// if (d["title"] != "HAMSTER")
.join("text")
.attr("x", d => (Math.sqrt(Number(d["footprint"])) * 900 - 30))
.attr("y", d => (1020 - (Math.sqrt(Number(d["footprint"])) * 850 - 40)))
.text(d => d["subtitle2"])
.attr("class", "subtitle")
.classed("subtitle", true)
Insert cell
landguzzlers.selectAll(".guzzlerssubtitle3")
.data(data)
// if (d["title"] != "HAMSTER")
.join("text")
.attr("x", d => (Math.sqrt(Number(d["footprint"])) * 900 - 30))
.attr("y", d => (1020 - (Math.sqrt(Number(d["footprint"])) * 850 - 50)))
.text(d => d["subtitle3"])
.attr("class", "subtitle")
.classed("subtitle", true)
Insert cell
landguzzlers.selectAll(".guzzlerHORIZONTAL")
.data(data.filter(d => d.title == "TOYOTA LAND CRUISER" || d.title == "MEDIUM-SIZED DOG"))
.join("line")
.attr("x1", d => (Math.sqrt(Number(d["footprint"])) * 900 - 250))
.attr("x2", d => (Math.sqrt(Number(d["footprint"])) * 900 - 25))
.attr("y1", d => (1020 - (Math.sqrt(Number(d["footprint"])) * 850 - 14)))
.attr("y2", d => (1020 - (Math.sqrt(Number(d["footprint"])) * 850 - 14)))

Insert cell
landguzzlers.selectAll(".guzzlerVERTICAL")
.data(data.filter(d => d.title == "TOYOTA LAND CRUISER" || d.title == "MEDIUM-SIZED DOG"))
.join("line")
.attr("x1", d => (Math.sqrt(Number(d["footprint"])) * 900 - 25))
.attr("x2", d => (Math.sqrt(Number(d["footprint"])) * 900 - 25))
.attr("y1", d => (1020 - (Math.sqrt(Number(d["footprint"])) * 850 - 14)))
.attr("y2", d => (1020 - (Math.sqrt(Number(d["footprint"])) * 850 - 50)))

Insert cell
landguzzlers.selectAll(".guzzlersECOFOOTPRINTrotate")
.data(data.filter(d => d.title == "LARGE DOG" || d.title == "TOYOTA LAND CRUISER" || d.title == "MEDIUM-SIZED DOG" || d.title == "CAT"))
.join("text")
.attr("x", d => (Math.sqrt(Number(d["footprint"])) * 900 - 20))
.attr("y", d => (1020 - (Math.sqrt(Number(d["footprint"])) * 850 - 75)))
.attr("transform", (d,i,nodes) => "rotate(90, "+ nodes[i].getAttribute("x") + "," + nodes[i].getAttribute("y") + ")")
.text("Eco-footprint:")
.attr("class", "subtitle")
.classed("subtitle", true)
Insert cell
landguzzlers.selectAll(".guzzlersFOOTPRINTrotate")
.data(data.filter(d => d.title == "LARGE DOG" || d.title == "TOYOTA LAND CRUISER" || d.title == "MEDIUM-SIZED DOG" || d.title == "CAT"))
.join("text")
.attr("x", d => (Math.sqrt(Number(d["footprint"])) * 900 - 20))
.attr("y", d => (1020 - (Math.sqrt(Number(d["footprint"])) * 850 - 95)))
.attr("transform", (d,i,nodes) => "rotate(90, "+ nodes[i].getAttribute("x") + "," + nodes[i].getAttribute("y") + ")")
.text(d => d["footprint"])
.attr("class", "subtitle")
.classed("subtitle", true)
Insert cell
landguzzlers.selectAll(".guzzlersHECTARESrotate")
.data(data.filter(d => d.title == "LARGE DOG" || d.title == "TOYOTA LAND CRUISER" || d.title == "MEDIUM-SIZED DOG" || d.title == "CAT"))
.join("text")
.attr("x", d => (Math.sqrt(Number(d["footprint"])) * 900 - 20))
.attr("y", d => (1020 - (Math.sqrt(Number(d["footprint"])) * 850 - 140)))
.attr("transform", (d,i,nodes) => "rotate(90, "+ nodes[i].getAttribute("x") + "," + nodes[i].getAttribute("y") + ")")
.text("hectares")
.attr("class", "subtitle")
.classed("subtitle", true)
Insert cell
landguzzlers.selectAll(".guzzlersHAMSTER")
.data(data.filter(d => d.title == "HAMSTER"))
.join("text")
.attr("x", d => (Math.sqrt(Number(d["footprint"])) * 900 + 4))
.attr("y", d => (1020 - (Math.sqrt(Number(d["footprint"])) * 850 - 8)))
.text(d => d["title"])
.attr("class", "titleHAMSTER")
.classed("titleHAMSTER", true)
Insert cell
landguzzlers.selectAll(".guzzlersHAMSTERecofootprint")
.data(data.filter(d => d.title == "HAMSTER"))
.join("text")
.attr("x", d => (Math.sqrt(Number(d["footprint"])) * 900 + 60))
.attr("y", d => (1020 - (Math.sqrt(Number(d["footprint"])) * 850 - 25)))
.text("Ecofootprint:")
.attr("class", "subtitle")
.classed("subtitle", true)
Insert cell
landguzzlers.selectAll(".guzzlersHAMSTERfootprint")
.data(data.filter(d => d.title == "HAMSTER"))
.join("text")
.attr("x", d => (Math.sqrt(Number(d["footprint"])) * 900 + 70))
.attr("y", d => (1020 - (Math.sqrt(Number(d["footprint"])) * 850 - 40)))
.text("0.014 hectares")
.attr("class", "subtitle")
.classed("subtitle", true)
Insert cell
landguzzlers.selectAll(".guzzlersrects")
.data(data)
.join("rect")
.attr("x", d => 0)
.attr("y", d => (1000 - (Math.sqrt(Number(d["footprint"])) * 850)))
.attr("width", d => (Math.sqrt(Number(d["footprint"])) * 900))
.attr("height", d => (Math.sqrt(Number(d["footprint"])) * 900))
.style("fill", (d,i) => colors[i])
Insert cell
<svg width="1000" height="1000">
<text x="3" y="30" style="font-family: Chathura; font-size:40; fill:black;">Land guzzlers</text>
<text x="3" y="60" style="font-family: Chathura; font-size:20; fill:black;">The ecological footprints of our pets can make SUVs look positively eco-friendly</text>
</svg>
Insert cell
numbers = [1,2,3,4,5,6]
Insert cell
colors = ["#a5620b", "#c29657", "#cc1f5e", "#a81849", "#f7991d", "black"]
Insert cell
landguzzlers = d3.select(svgContainer)
Insert cell
data = FileAttachment("land_guzzlers (1).csv").csv()
Insert cell
<style>
@import url('https://fonts.googleapis.com/css2?family=Chathura&display=swap');
.title {
font-family: Chathura;
font-size:40px;
fill: white;
text-anchor: end}

.titleHAMSTER {
font-family: Chathura;
font-size:40px;
fill: white;
text-anchor: beginning}

.subtitle {
font-family: Chathura;
font-size:20px;
fill: white;
text-anchor: end}

}
</style>
Insert cell


<style>
rect {stroke: white; stroke-width:2;}
line {stroke:white; stroke-width: 2;}
</style>

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