0

I have to make this d3 chart responsive. I am using

 var svg = d3.select("div#container")
.append("svg")
.attr("preserveAspectRatio", "xMinYMin meet")
.attr("viewBox", "0 0 300 300")
.classed("svg-content", true);

and the class has

 .svg-content {
display: inline-block;
position: absolute;
top: 0;
left: 0;
}

But it doesnot seem to work. Here's the working fiddle https://jsfiddle.net/84hp8m6p/1/

separ1
  • 205
  • 2
  • 20
  • Your fiddle doesn't set a `viewBox`! Try adding that and set `width` and `height` to some relative values and you are done. – altocumulus Oct 25 '16 at 09:14
  • 1
    Works for me: https://jsfiddle.net/84hp8m6p/4/ – altocumulus Oct 25 '16 at 09:22
  • Possible duplicate of [Whats the best way to make a d3.js visualisation layout responsive?](http://stackoverflow.com/questions/9400615/whats-the-best-way-to-make-a-d3-js-visualisation-layout-responsive) – Ajay S Oct 26 '16 at 20:00

0 Answers0