I am creating a bootstrap page. I work fine, but one of the elements is a scalable map of the USA (using d3). The zoom function that I use requires the width and height of the div in pixels to calculate how to translate and scale the map. I tried to use interest, but I can not do anything. Is there a way to dynamically get the height and width of a div. I searched everything, but the search terms are too universal (or I'm not smart enough to formulate them correctly).
Alternatively, how else can I get the necessary values.
Here is my implementation using hard coded width and height (which will not work if the page changes).
var width = 1000;
var height = 1000;
var svg = d3.select("#Map")
.append("svg")
.attr("id", "chosvg")
.attr("height", height)
.attr("width", width)
.style("preserveAspectRatio", "true");
cbsa = svg.append("g");
d3.json("data/us-cbsa.json", function(json) {
cbsa.selectAll("path")
.attr("id", "cbsa")
.data(json.features)
.enter()
.append("path")
.attr("class", data ? quantize : null)
.attr("d", path)
.on("click", clicked);
});
clicked(), , ,
cbsa.transition()
.duration(750)
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")scale(" + k + ")translate(" + -x + "," + -y + ")")
.style("stroke-width", 1.5 / k + "px");
- : var width = column.width()// -,
html, .