0

Possible Duplicate:
Whats the best way to make a d3.js visualisation layout responsive?

All the D3 examples I've seen do something like this:

        var width = 1500,
            height = 1500;

        var svg = d3.select('body')
          .append('svg')
            .attr('width', width)
            .attr('height', height);

How would I have the graph dynamically resize to fill the size of the current window? (ie: you set the window the size you want, and the graph fills it. Also, when you resize the window, the graph resizes to take up the space available)

Community
  • 1
  • 1
Chris Withers
  • 10,837
  • 4
  • 33
  • 51
  • 1
    See http://stackoverflow.com/questions/9400615/whats-the-best-way-to-make-a-d3-js-visualisation-layout-responsive. – Bill Oct 09 '12 at 05:54
  • http://stackoverflow.com/a/9539361/216229 gives an answer, but not sure it works correctly. If you go to the [example](http://jsfiddle.net/shawnbot/BJLe6/), the circles re-size but the distance from the left of the graph to the first circle doesn't resize at the same rate as the circles. @matt-alcock points this out, and also asks something else : what browsers are [viewBox](http://www.w3.org/TR/SVGTiny12/coords.html#ViewBoxAttribute) and [preserveAspectRatio](http://www.w3.org/TR/SVGTiny12/coords.html#PreserveAspectRatioAttribute) compatible with? – Chris Withers Oct 09 '12 at 06:01

0 Answers0