Published
Edited
Mar 15, 2021
1 fork
Insert cell
md`# Point Symbol Map
Assignment #4`
Insert cell
proportionalSymbols = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
svg.append("path")
.datum(topojson.feature(county, county.objects.St))
.attr("fill", "#ccc")
.attr("stroke", "white")
.attr("stroke-linejoin", "round")
.attr("d", path_basemap);
// svg.append("path")
// .datum(topojson.mesh(county, county.objects.St, (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", "#777")
.attr("transform", "translate(150,450)")
.attr("text-anchor", "middle")
.style("font", "10px sans-serif")
.selectAll("g")
.data([1e7, d3.max([...data.values()])])
.join("g");
legend.append("circle")
.attr("fill", "none")
.attr("stroke", "#ccc")
.attr("cy", d => -radius(d))
.attr("r", radius);
legend.append("text")
.attr("y", d => -2 * radius(d))
.attr("dy", "1.3em")
.text(format);
svg.append("g")
.attr("fill", "red")
.attr("fill-opacity", 0.5)
.attr("stroke", "#f768a1")
.attr("stroke-width", 0.5)
.selectAll("circle")
.data(points.features
.map(d => (d.value = data.get(d.properties.AFFGEOID), d))
.sort((a, b) => b.value - a.value))
.join("circle")
.attr("transform", d => `translate(${path_point.centroid(d)})`)
.attr("r", d => radius(data.get(d.properties.AFFGEOID)))
.append("title")
.text(d => `${d.properties.AFFGEOID} : ${format(d.value)}`);
return svg.node();
}
Insert cell
Insert cell
height = 610
Insert cell
width = 975
Insert cell
path_point = d3.geoPath().projection(projection)
Insert cell
path_basemap = d3.geoPath().projection(projection)
Insert cell
projection = d3.geoConicConformal()
.parallels([45 + 37 / 60, 47 + 3 / 60])
.rotate([94 + 15 / 60, 0]).fitExtent([[20, 20], [width, height]], topojson.feature(county, county.objects.St));
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
csv_data = d3.csvParse(await FileAttachment("minnesotacsvdata.csv").text(),({geoid, pcteducationattainment}) => [geoid,+pcteducationattainment])
Insert cell
//Pointpolygon import
points=FileAttachment("Cpountypoints.geojson").json()
Insert cell
//basemap import
county=FileAttachment("St.Louiscensustract_wgs84.json").json()
Insert cell
topojson=require("topojson-client@3")
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more