Started working on resizing SVG

This commit is contained in:
2025-04-08 23:53:13 -04:00
parent ad254d2760
commit 66d88c133b
2 changed files with 13 additions and 6 deletions

View File

@@ -1,4 +1,12 @@
const svg = d3.select("svg")
// const mapWidth = document.getElementById("indiaMap").getAttribute("width")
// const mapHeight = document.getElementById("indiaMap").getAttribute("height")
const mapWidth = window.innerWidth - document.querySelector(".svgContainer").offsetWidth;
const svg = d3.select(".svgContainer")
.append('svg')
.attr('width', '100%')
.attr('preserveAspectRatio', "xMinYMin meet")
.attr('id', 'indiaMap');
const defaultColor = "#555555"
@@ -186,9 +194,7 @@ function stateOrDistrictOrLanguage(d) {
}
function drawMap(world) {
const mapWidth = document.getElementById("indiaMap").getAttribute("width")
const mapHeight = document.getElementById("indiaMap").getAttribute("height")
const projection = d3.geoMercator().fitSize([mapWidth, mapHeight], world)
const projection = d3.geoMercator().fitWidth(mapWidth,world)
const path = d3.geoPath().projection(projection);
const states = svg.selectAll("g")