From 072af64a257e99bd597a93bb483987297a83096f Mon Sep 17 00:00:00 2001 From: Maria Date: Thu, 14 Mar 2013 12:19:00 -0400 Subject: [PATCH] keep the size of pie chart when change the svg size --- nv.d3.js | 5 +++-- src/models/pieChart.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nv.d3.js b/nv.d3.js index ec02db9..702e43b 100644 --- a/nv.d3.js +++ b/nv.d3.js @@ -490,6 +490,7 @@ nv.models.axis = function() { var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin') //.data(scale.domain()) .data([scale.domain()[0], scale.domain()[scale.domain().length - 1]]); + axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text'); axisMaxMin.exit().remove(); axisMaxMin .attr('transform', function(d,i) { @@ -8177,9 +8178,9 @@ nv.models.pieChart = function() { var container = d3.select(this), that = this; - var availableWidth = (width || parseInt(container.style('width')) || 960) + var availableWidth = (width || parseInt(container.style('width')) || 960) + 40 //to keep the size of the chart but reduce svg area, might not work with legend. - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) + availableHeight = (height || parseInt(container.style('height')) || 400) + 40 - margin.top - margin.bottom; chart.update = function() { chart(selection); }; diff --git a/src/models/pieChart.js b/src/models/pieChart.js index bf61f0b..12df8a6 100644 --- a/src/models/pieChart.js +++ b/src/models/pieChart.js @@ -48,9 +48,9 @@ nv.models.pieChart = function() { var container = d3.select(this), that = this; - var availableWidth = (width || parseInt(container.style('width')) || 960) + var availableWidth = (width || parseInt(container.style('width')) || 960) + 40 //to keep the size of the chart but reduce svg area, might not work with legend. - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) + availableHeight = (height || parseInt(container.style('height')) || 400) + 40 - margin.top - margin.bottom; chart.update = function() { chart(selection); };