Published
Edited
Mar 7, 2021
1 fork
12 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
projection = projections.geoNaturalEarth()
.scale(width / 2 / Math.PI)
.translate([width / 2, height / 2])
.center([0, 0])
Insert cell
Insert cell
geoPath = d3.geoPath()
.projection(projection);
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dataSim = createGeoPoints(array);
Insert cell
Insert cell
function createGeoPoints(thisData) {
const newArray = [];
for (var i = 0; i < thisData.length; i++) {
newArray.push({
cluster: thisData[i].cluster,
center: thisData[i].center,
country: thisData[i].country,
lon_lat: thisData[i].lon_lat,
});
}
simulation_geo
.nodes(newArray);
for (let i = 0; i < 300; ++i) simulation_geo.tick();
return newArray;

}
Insert cell
Insert cell
simulation_geo = d3.forceSimulation()
.force('collide', forceCluster_Collision)
.force("x", forceX)
.force("y", forceY)
.stop();
Insert cell
Insert cell
Insert cell
Insert cell
forceCluster_Collision = forceClusterCollision()
.radius(d => radius + padding / 3)
.strength(0.8)
.clusterPadding(padding)
Insert cell
Insert cell
forceX = d3.forceX(d => projection(d.lon_lat)[0]).strength(0.7)
Insert cell
forceY = d3.forceY(d => projection(d.lon_lat)[1]).strength(0.7)
Insert cell
Insert cell
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