Published
Edited
Mar 15, 2021
Insert cell
md`# Pecentage of Educational Attainment in St.Louis County, Minnesota
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([d3.min([...data.values()]), (d3.min([...data.values()])+d3.max([...data.values()]))/2, 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.2em")
.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
width = 610
Insert cell
height = 775
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@1.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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more