From bf8825294b02276f3550b5dcc31cb47a9c1b5cbf Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Thu, 10 Apr 2025 11:37:55 -0400 Subject: [PATCH] Mostly working --- index.html | 2 +- index.js | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index f8297ff..6a579d4 100644 --- a/index.html +++ b/index.html @@ -19,7 +19,7 @@ display: flex; align-items: flex-start; justify-content: space-evenly; - gap: 10% 10%; + gap: 2em 2em; } svg { diff --git a/index.js b/index.js index 3b37e63..368a171 100644 --- a/index.js +++ b/index.js @@ -213,19 +213,21 @@ function stateOrDistrictOrLanguage(d) { // const mapWidth = document.getElementById("indiaMap").getAttribute("width") // const mapHeight = document.getElementById("indiaMap").getAttribute("height") -const mapWidth = window.innerWidth - document.querySelector("#svgContainer").offsetWidth; +const mapWidth = /*window.innerWidth - */document.querySelector("#svgContainer").offsetWidth * 0.85; +// const mapHeight = document.querySelector("#svgContainer").offsetHeight; +const mapHeight = window.innerHeight - document.querySelector("#svgContainer").getBoundingClientRect().top * 0.7; const svg = d3.select("#svgContainer") .append('svg') - .attr('width', '1300') - .attr('height', '1300') + .attr('width', mapWidth.toString()) + .attr('height', (mapHeight).toString()) // .attr('viewbox', '0 0 860 500') // .attr('preserveAspectRatio', "xMidYMid meet") .attr('id', 'indiaMap') - .call(responsivefy); + // .call(responsivefy); function drawMap(world) { - const projection = d3.geoMercator().fitWidth(mapWidth,world) + const projection = d3.geoMercator().fitSize([mapWidth, mapHeight], world) const path = d3.geoPath().projection(projection); const states = svg.selectAll("g")