xAxis = g => {
const tickValues = scenario === "rcp45" ? [-300, -150, 0, 150] : [-400, -200, 0, 200, 400];
const axis = g.append("g")
.attr("transform", `translate(0, ${chartheight})`)
.call(
d3.axisBottom(x)
.tickValues(tickValues)
.tickSizeOuter(0)
.tickSizeInner(10)
);
axis.select(".domain").remove()
axis.selectAll("text")
.attr("font-size", 12)
.attr("font-family", franklinLight);
axis.selectAll("line")
.attr("stroke-width", 0.5)
.attr("shape-rendering", "crispEdges")
.attr("stroke", d => d ? "#c2c2c2" : "#000");
const grid = g.append("g")
.call(
d3.axisBottom(x)
.tickValues(tickValues)
.tickSize(chartheight)
)
grid.select(".domain").remove();
grid.selectAll("text").remove();
grid.selectAll("line")
.attr("stroke-width", 0.5)
.attr("shape-rendering", "crispEdges")
.attr("stroke", d => d ? "#c2c2c2" : "#000");
g.append("text")
.attr("transform", `translate(${x(0)}, ${chartheight})`)
.attr("text-anchor", "middle")
.attr("dy", margin.bottom - 24)
.html("<tspan y=-4>⟵ </tspan><tspan dy=4>Change in mortality linked to temperature</tspan><tspan dy=-4> ⟶</tspan>");
g.append("text")
.attr("transform", `translate(${x(0)}, ${chartheight})`)
.attr("text-anchor", "middle")
.attr("dy", margin.bottom - 4)
.attr("font-size", 14)
.text("Annual deaths per 100,000 people")
return g;
}