score:3

Accepted answer

Ok, I fixed by adding:

...
var svg = d3.select("#chart").append("svg")
.attr("width", width)
.attr("height", height)
.attr("viewBox", "0, 0, " + width + ", " + height)
.attr("preserveAspectRatio", "xMinYMin")
...

Then I updated the width and height on resize event


Related Query

More Query from same tag