Newer
Older
indexation / public / js / resize.js
(function() {
  var canvas = document.querySelector("canvas"),
    container = document.querySelector("#container"),
    d3Canvas = d3.select("canvas");

  var height = container.clientHeight || window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
    width = container.clientWidth || window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
  d3Canvas
    .style("height", Math.round(height) + 'px')
    .style("width", Math.round(width) + 'px')
    .attr("height", Math.round(height))
    .attr("width", Math.round(width));

  d3.select(window)
    .on("resize", function() {
      var height = container.clientHeight || window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
        width = container.clientWidth || window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
      d3Canvas
        .style("height", Math.round(height) + 'px')
        .style("width", Math.round(width) + 'px')
        .attr("height", Math.round(height))
        .attr("width", Math.round(width));
    });
})();