From bc3f69bfa3457b278c6a4230858a15d8c183a4ce Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Mon, 24 Feb 2025 20:24:32 -0500 Subject: [PATCH] Added colors to the map (used four-color theorem, but did it manually) --- index.html | 147 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 94 insertions(+), 53 deletions(-) diff --git a/index.html b/index.html index 1931a17..dc1a7d3 100644 --- a/index.html +++ b/index.html @@ -1,64 +1,105 @@ - - - - GeoJSON Map with D3.js - - - - + + + + GeoJSON Map with D3.js + + + + - - + // Draw the map + svg.selectAll("path") + .data(world.features) + .enter() + .append("path") + .attr("d", path) + .attr("class", "state") + .attr("fill", d => colorMap[d.properties.name]) + .append("title") // Tooltip + .text(d => d.properties.name) + .each(function(d) { + map1.set(d.properties.name, d3.geoCentroid(d)); + }) - + } + + // Load GeoJSON file + d3.json("india.json").then(drawMap) + + console.log(map1) + + +