proportionalSymbols = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
svg.append("path")
.datum(topojson.feature(basepolygons_states, basepolygons_states.objects.States))
.attr("fill", "#ccc")
.attr("d", path_basemap);
svg.append("path")
.datum(topojson.mesh(basepolygons_states, basepolygons_states.objects.States, (a, b) => a !== b))
.attr("fill", "none")
.attr("stroke", "white")
.attr("stroke-linejoin", "round")
.attr("d", path_basemap);
const legend = svg.append("g")
.attr("fill", "black")
.attr("transform", "translate(825,400)")
.attr("text-anchor", "middle")
.style("font", "10px sans-serif")
.selectAll("g")
.data([1.4, d3.max([...data.values()])])
.join("g");
legend.append("circle")
.attr("fill", "none")
.attr("stroke", "#8856a7")
.attr("cy", d => -radius(d))
.attr("r", radius);
legend.append("text") //This chunk adds text to the legend
.attr("y", d => -2 * radius(d))
.attr("dy", "1.3em") // This changes the position of the text in the circle
.text(format);
svg.append("g") // This is how the point symbols are added to the map.
.attr("fill", "#8856a7") // This is the color I want to fill my points with (that will be shown as the proportional symbol).
.attr("fill-opacity", 0.5) // Fill transparency for my points. It is currently at 50%
.attr("stroke", "#252525") // This is the color of the outline for the point symbol.
.attr("stroke-width", 0.5) // This is the thickness of the point symbol outline.
.selectAll("circle") // The point symbols will be represented as a circle.
.data(points.features // This gathers the features from my data calls points. It goes through each shape and takes the ID (That is PLACEFIPS) and returns the value and assigns it to the point.
.map(d => (d.value = data.get(d.properties.PLACEFIPS), d))
.sort((a, b) => b.value - a.value)) // The sort function orders the circles by size and then the larger circles are displayed in the back so that the small circles, if they overlap with the larger circles can be seen.
.join("circle")
.attr("transform", d => `translate(${path_points.centroid(d)})`) //This finds the centroid of the circle and shows the circle right in the center of point.
.attr("r", d => radius(data.get(d.properties.PLACEFIPS))) // Once the value of the average family size has been returned, it will assign the point as radius size depending upon the value and the size of canvas. It assigns it an attribute "r" which is the radius of the circle
.append("title")
.text(d => `${d.properties.NAME} : ${format(d.value)}`); // When the reader hovers over the point (city,state), the ID of the point and the value of the average family size of that point is displayed.
return svg.node();
}