I need to make my d3 js chart to be responsive, i.e. scales the chart when user resizes the window. I tried with svg's attributes "viewbox" and "preserveaspectratio" but with no luck. Here is my fiddle
var svg = d3.select("#chart1").append("svg")
.call(zoom)
.attr("class", "chart")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom);
.attr('viewBox','0 0 '+Math.min(pWidth,height)+' '+Math.min(pWidth,height))
.attr('preserveAspectRatio','xMinYMin');