Published
Edited
Apr 15, 2018
1 fork
Insert cell
Insert cell
chartMap = {
var projection = d3.geoMercator()
.scale(18000)
.center([-7.9, 43.3]);
const path = d3.geoPath()
.projection(projection);
const g = svgMap.append('g');
g.selectAll('.concello')
.data(galicia.features)
.enter()
.append("path")
.attr("fill", "#ccc")
.attr("stroke", "#fff")
.attr("d", path);
g.selectAll("circle")
.data(galicia.features)
.enter().append("circle")
.attr("fill", "red")
.attr("fill-opacity", 0.5)
.attr("stroke", "#fff")
.attr("stroke-width", 0.5)
.attr("transform", d => `translate(${path.centroid(d)})`)
.attr("r", d => radiusFn(d.properties.population));

return svgMap.node();
}
Insert cell
legendMap = {
const legend = svgMap.append("g")
.attr("fill", "#777")
.attr("transform", `translate(${900 - 70},${900 - 70})`)
.attr("text-anchor", "middle")
.style("font", "10px sans-serif")
.selectAll("g")
.data([3e5, 3e4, 1e3])
.enter().append("g");

legend.append("circle")
.attr("fill", "none")
.attr("stroke", "#ccc")
.attr("cy", d => -radiusFn(d))
.attr("r", radiusFn);

legend.append("text")
.attr("y", d => -2 * radiusFn(d))
.attr("dy", "1.3em")
.text(d3.format(".1s"));
return legend;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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