chart1 = {
const svg = d3
.create("svg")
.attr("width", width + 50)
.attr("height", height + 100);
svg.append("g").call(xAxis1);
svg.append("g").call(yAxis1);
svg.append("g").attr("transform", "translate(600,390)");
svg
.append("text")
.attr("class", "x label")
.attr("text-anchor", "middle")
.attr("x", width / 2)
.attr("y", height + 30)
.text("Attack Power");
svg
.append("text")
.attr("class", "y label")
.attr("text-anchor", "end")
.attr("x", -height / 2.75)
.attr("y", 6)
.attr("transform", "rotate(-90)")
.text("Speed");
svg
.append("text")
.text("Attack Vs Speed")
.style("text-anchor", "middle")
.attr("transform", `translate(${width / 2}, 40)`)
.style("font-size", "1.5em");
svg
.selectAll("circle")
.data(pokemon1)
.join(enter => enter.append("circle"))
.transition()
.duration(2000)
.attr("cx", d => xScale1(d.x))
.attr("cy", d => yScale1(d.y))
.attr("fill", d => colorScale1(d.color))
.style("opacity", 0.7)
.attr("r", 8);
svg
.append("g")
.attr("transform", "translate(100,30)")
.append(() =>
legend({
color: color,
width: width - 2 * (margin.left + margin.right),
title: "Type of Pokemon"
})
);
return svg.node();
}