{
const width = 500;
const height = 100;
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
const xScale = d3.scaleLinear().domain([0, 30]).range([0, width]);
const childAgeRange = [vars.childAgeAtBirth, vars.childAgeAtBirth + 30];
const grandparentAgeRange = [
vars.grandparentAgeAtBirth,
vars.grandparentAgeAtBirth + 30
];
svg
.append("rect")
.attr("x", xScale(childAgeRange[0]))
.attr("y", height / 4)
.attr("width", xScale(childAgeRange[1]) - xScale(childAgeRange[0]))
.attr("height", height / 2)
.style("fill", "lightblue");
svg
.append("rect")
.attr("x", xScale(grandparentAgeRange[0]))
.attr("y", height / 4)
.attr(
"width",
xScale(grandparentAgeRange[1]) - xScale(grandparentAgeRange[0])
)
.attr("height", height / 2)
.style("fill", "pink");
svg
.append("text")
.attr("x", xScale(childAgeRange[0]))
.attr("y", height / 2 + 20)
.text("Child Age");
svg
.append("text")
.attr("x", xScale(grandparentAgeRange[0]))
.attr("y", height / 2 - 10)
.text("Grandparent Age");
return svg.node();
}