proportionalSymbols = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height])
.attr("style", "background: #252525");
svg.append("path")
.datum(topojson.feature(basepolygons, basepolygons.objects.states_simple))
.attr("fill", "#d9d9d9")
.attr("d", path_basemap);
svg.append("path")
.datum(topojson.mesh(basepolygons, basepolygons.objects.states_simple, (a, b) => a !== b))
.attr("fill", "none")
.attr("stroke", "gray")
.attr("stroke-linejoin", "round")
.attr("d", path_basemap);
const legend = svg.append("g")
.attr("fill", "white")
.attr("transform", "translate(150,450)")
.attr("text-anchor", "middle")
.style("font", "7px sans-serif")
.selectAll("g")
.data([2000, 7000])
.join("g");
legend.append("circle")
.attr("fill", "none")
.attr("stroke", "#d9d9d9")
.attr("cy", d => -radius(d))
.attr("r", radius);
legend.append("text")
.attr("y", d => -2 * radius(d))
.attr("dy", "1.3em")
.text(d => `${Math.round(d / 1000)}GW`);
//This portion of the code positions the text within the legend circles. The final line makes the legend text only display one digit with the unit of gigawatts.
svg.append("g")
.attr("fill", "#7a0177")
.attr("fill-opacity", 0.5)
.attr("stroke", "#f768a1")
.attr("stroke-width", 0.5)
.selectAll("circle")
// This portion sets the style of the proportional symbols on the map. The line with "fill" sets the color of the symbols to purple. The next line makes the symbols 50% tranparent, allowing for the visibilty of overlapping points. The next line sets the borders of the symbols to pink, making the points more distinguishable. The next line sets the width of those borders to a value of 0.5.
.data(points.features
.map(d => (d.value = data.get(d.properties.Facility), d))
.sort((a, b) => b.value - a.value))
// This portion of the code finds and connects the values associated with each "Facility" and updates the corresponding point on the map to have such a value.
.join("circle")
//Sets the symbol type to circle.
.attr("transform", d => `translate(${path_points.centroid(d)})`)
.attr("r", d => radius(data.get(d.properties.Facility)))
// This portion sets the location of the points on the map as well as the radius of each circle on the map according the the data associated with each "Facility".
.append("title")
.text(d => `${d.properties.Facility} : ${formattedValue(d.value)}`);
// This part allows for "hover over" values, as well as the associated facility name, to be displayed on the map. It uses the "formattedValue" line from earlier to assign the appropriate unit to each value.
return svg.node();
}