From d438a91cdf2a7914efe7f4f284c430156a1e53a4 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Mon, 24 Feb 2025 20:55:09 -0500 Subject: [PATCH] Fetch SVG size from HTML, instead of re-defining it in JS --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 8f1f448..1ba6732 100644 --- a/index.js +++ b/index.js @@ -43,7 +43,9 @@ const colorMap = { const colors9 = ["#75d795", "#EFDFD8", "#D5F6FB", "#E5ECF8", "#F0EBD8", "#F7DFC2", "#B4D9EF", "#F8C57C", "#A4D8D8"] function drawMap(world) { - const projection = d3.geoMercator().fitSize([1000,600], world) + const mapWidth = document.getElementById("indiaMap").getAttribute("width") + const mapHeight = document.getElementById("indiaMap").getAttribute("height") + const projection = d3.geoMercator().fitSize([mapWidth, mapHeight], world) const path = d3.geoPath().projection(projection); // Draw the map