legend3 = {
const svg = d3.create("svg")
.attr("width", series.length * 100)
.attr("height", 40)
.style("font", "10px sans-serif")
.style("margin-left", `${margin.left}px`)
.style("display", "block")
.attr("text-anchor", "middle");
const g = svg.append("g")
.selectAll("g")
.data(series)
.join("g")
.attr("transform", (d, i) => `translate(${i * 100},0)`);
g.append("rect")
.attr("width", 110)
.attr("height", 25)
.attr("fill", d => color2(d.key));
g.append("text")
.attr("x", 50)
.attr("y", 32)
.attr("dy", "0.35em")
.text(d => d.key);
return svg.node();
}