chart = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg
.append("g")
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(xAxis);
svg
.append("g")
.call(yAxis)
.attr("transform", `translate(${margin.left},0)`);
const yLabel = svg.append("g").call(yTitle);
const xLabel = svg.append("g").call(xTitle);
const xgridlines = svg.append("g").call(xGrid);
const ygridlines = svg.append("g").call(yGrid);
const symbols = svg
.append("g")
.attr("stroke-width", 1)
.attr("font-family", "sans-serif")
.attr("font-size", 10)
.selectAll("path")
.data(penguins)
.join("path")
.attr(
"transform",
d => `translate(${xScale(xAccessor(d))}, ${yScale(yAccessor(d))})`
)
.attr("fill", d => color(d.species))
.attr("d", d => shape(d.species));
const legends = svg
.append("g")
.call(legendLabel)
.attr(
"transform",
`translate(${width - margin.right - margin.left - 50}, ${height - 200})`
)
.style("font-size", "13px")
.style("font-family", "sans-serif");
return svg.node();
}