chart = {
const height= 400;
const width = 1000;
const margin = ({top: 20, right: 430, bottom: 30, left: 60});
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height)
.style('background-color', "FEFDF8");
const yScale = d3.scaleLinear()
.domain([0, d3.max(DataUnrolled, d => d[variable])]).nice()
.range([height-margin.bottom , margin.top]);
const xScale = d3.scaleLinear()
.domain([2016,2020])
.range([margin.left, width-margin.right ]);
const xAxis = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(xScale).ticks(width / 200).tickSizeOuter(0));
const yAxis = g => g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(yScale))
.call(g => g.select(".domain"))
.call(g => g.select(".tick:last-of-type text").clone()
.attr("x", 6)
.attr("text-anchor", "start")
.attr("font-weight", "bold")
.text(variable));
let lineMultiCases = d3.line()
.x(d => xScale(d.Any))
.y(d => yScale(d[variable]));
svg.append("g").call(yAxis);
svg.append("g").call(xAxis);
svg.selectAll('.line')
.data(DataGrouped)
.join('path')
.attr("class", "line")
.attr("d", d =>(lineMultiCases(d[1])))
.attr('stroke', sex=>(sex==="0"? "#5fa2c1": "grey" ) )
.style("fill", "none")
.style("opacity", 0.5)
var dummy = svg.selectAll("rect")
.data(squares)
.join("rect")
.attr("x", d=>d.xplace)
.attr("y", d=>d.yplace)
.attr("height", d=> d.height)
.attr("width",d=> d.width )
.attr('stroke', 'grey')
.attr('fill', 'lightgrey')
svg.append("path")
.datum(regions)
.attr("stroke", "grey")
.attr("fill", "none")
.attr("stroke-width", 1.5)
.attr(d=>regions.points)
d3.select('path').attr('d', regions);
return svg.node();
}