chart1 = {
const svg = d3
.create("svg")
.attr("viewBox", [-50, -50, width + 100, height + 100]);
svg.append("g").call(xAxis1);
svg.append("g").call(yAxis1);
svg.append("g").attr("transform", "translate(700,390)");
svg
.append("text")
.attr("class", "x label")
.attr("text-anchor", "middle")
.attr("x", width / 2)
.attr("y", height + 30)
.text("Average SAT Score (Out of 1600)");
svg
.append("text")
.attr("class", "y label")
.attr("text-anchor", "end")
.attr("x", -height / 2.75)
.attr("y", 6)
.attr("transform", "rotate(-90)")
.text("Acceptance Rate (%)");
svg
.append("text")
.text(
"Average Accepted SAT Score Vs Acceptance Rate of Universities in USA"
)
.style("text-anchor", "middle")
.attr("transform", `translate(${width / 2}, 0)`)
.style("font-size", "1.3em");
svg
.selectAll("circle")
.data(search_university)
.join(enter => enter.append("circle"))
.transition()
.duration(2000)
.attr("cx", d => xScale(d.x))
.attr("cy", d => yScale(d.y))
.attr("fill", d => colorScale(d.color))
.style("opacity", 0.7)
.attr("r", 2);
return svg.node();
}