All examples By author By category About

eesur

d3 | width of div container

simple example showing how to get the width of a div and use it's value/number

var containerWidth = +d3.select('.some-div').style('width').slice(0, -2)

it's an easy way to size/re-size drawings based on the containing div:

selection.append('svg')
    .attr('width', containerWidth)
    ...