From 9f29885c8804cd41f3b8e3d93e10740187e55842 Mon Sep 17 00:00:00 2001 From: Michael Rutter Date: Fri, 20 Nov 2015 11:50:26 +0000 Subject: [PATCH] Fix overall svg canvas height/width attribute Typically the appended svg on line 18-20 needs to have a width/height that includes the margins. An example can be found here: http://bl.ocks.org/mbostock/3883245. --- snippets/javascript/javascript.d3.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/javascript/javascript.d3.snippets b/snippets/javascript/javascript.d3.snippets index a3f7fa7..f5be918 100644 --- a/snippets/javascript/javascript.d3.snippets +++ b/snippets/javascript/javascript.d3.snippets @@ -16,8 +16,8 @@ snippet marginconvention var ${8:height} = ${9:500} - $1.top - $1.bottom; var ${10:svg} = d3.select("${11}").append("svg") - .attr("width", $6) - .attr("height", $8) + .attr("width", $6 + $1.left + $1.right) + .attr("height", $8 + $1.top + $1.bottom) .append("g") .attr("transform", "translate(" + $1.left + "," + $1.top + ")") snippet nest