From 42248c77f87056d2a88c10e12532ae7e42eaa88e Mon Sep 17 00:00:00 2001 From: EvilDrW Date: Wed, 23 Sep 2015 20:38:11 -0500 Subject: [PATCH 1/2] Use style attribute instead of width/height in svg --- src/angular-nvd3.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/angular-nvd3.js b/src/angular-nvd3.js index e0e8a0e..8ad03bc 100644 --- a/src/angular-nvd3.js +++ b/src/angular-nvd3.js @@ -165,11 +165,13 @@ scope.options.chart.transitionDuration = +scope.options.chart.transitionDuration || 250; // remove whole svg element with old data d3.select(element[0]).select('svg').remove(); + + if (scope.options.chart.width && !isNaN(scope.options.chart.height)) scope.options.chart.height += 'px'; + if (scope.options.chart.width && !isNaN(scope.options.chart.width)) scope.options.chart.width += 'px'; // Select the current element to add element and to render the chart in d3.select(element[0]).append('svg') - .attr('height', scope.options.chart.height) - .attr('width', scope.options.chart.width || '100%') + .style({height: scope.options.chart.height, width: scope.options.chart.width}) .datum(data) .transition().duration(scope.options.chart.transitionDuration) .call(scope.chart); From 0cd525a21ff0d58c877f7d2f85693c31c1766add Mon Sep 17 00:00:00 2001 From: EvilDrW Date: Wed, 23 Sep 2015 20:42:39 -0500 Subject: [PATCH 2/2] correctly check for existence of height --- src/angular-nvd3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/angular-nvd3.js b/src/angular-nvd3.js index 8ad03bc..ab65a8f 100644 --- a/src/angular-nvd3.js +++ b/src/angular-nvd3.js @@ -166,7 +166,7 @@ // remove whole svg element with old data d3.select(element[0]).select('svg').remove(); - if (scope.options.chart.width && !isNaN(scope.options.chart.height)) scope.options.chart.height += 'px'; + if (scope.options.chart.height && !isNaN(scope.options.chart.height)) scope.options.chart.height += 'px'; if (scope.options.chart.width && !isNaN(scope.options.chart.width)) scope.options.chart.width += 'px'; // Select the current element to add element and to render the chart in