From ff6b46e9ff7827c409693b7ab61d72d8f17aef31 Mon Sep 17 00:00:00 2001 From: Ryan Cummins Date: Fri, 12 Jun 2015 12:19:18 +0100 Subject: [PATCH] Updated svg block to be responsive Added preserveAspectRatio and viewBox to the SVG element to allow for responsive changes. --- d3pie-source/_helpers.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/d3pie-source/_helpers.js b/d3pie-source/_helpers.js index c0335ac..90de8bf 100644 --- a/d3pie-source/_helpers.js +++ b/d3pie-source/_helpers.js @@ -10,7 +10,9 @@ var helpers = { var svg = d3.select(element).append("svg:svg") .attr("width", canvasWidth) - .attr("height", canvasHeight); + .attr("height", canvasHeight) + .attr("preserveAspectRatio", "xMinYMin meet") + .attr("viewBox", "0 0 " + canvasWidth + " " + canvasHeight); if (backgroundColor !== "transparent") { svg.style("background-color", function() { return backgroundColor; }); @@ -326,4 +328,4 @@ var extend = function() { } } return target; -}; \ No newline at end of file +};