{
const svg = d3.create("svg");
const fo = svg
.selectAll(".legend-fo")
.data(["legend-fo"])
.join("foreignObject")
.attr("transform", "translate(20,20)")
.classed("legend-fo", true)
.attr("width", 100)
.attr("height", 100);
const div = fo
.selectAll(".legend-div")
.data(["legend-div"])
.join("xhtml:div")
.classed("legend-div", true)
.html(
data
.map((v) => {
return `<div style="font-size:11px;margin-top:5px;">
<div style="border-radius:10px;
width:10px;
height:10px;
background-color:${v.color};
display:inline-block">
</div>
${v.name}
</div>`;
})
.join("")
);
yield svg.node();
}