Started working on resizing SVG
This commit is contained in:
14
index.js
14
index.js
@@ -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")
|
||||
|
Reference in New Issue
Block a user