diff --git a/Changelog.md b/Changelog.md index 4128328ab..02542b0fd 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,7 @@ # 2.0 Series +## 2.0.0 beta 24 +* Only auto-calculate width/height once - sizes were getting calculated wrong ([#1070](https://github.com/dc-js/dc.js/issues/1070)) and charts were changing size on redraw if they didn't have a fixed size in the chart spec or in the div style ([#980](https://github.com/dc-js/dc.js/issues/980)) + ## 2.0.0 beta 23 * Domain was getting set for composite charts even when `elasticY` disabled. ([#1056](https://github.com/dc-js/dc.js/issues/1056) diff --git a/src/base-mixin.js b/src/base-mixin.js index 229130830..b74038f41 100644 --- a/src/base-mixin.js +++ b/src/base-mixin.js @@ -130,7 +130,11 @@ dc.baseMixin = function (_chart) { */ _chart.height = function (height) { if (!arguments.length) { - return _height(_root.node()); + if (!dc.utils.isNumber(_height)) { + // only calculate once + _height = _height(_root.node()); + } + return _height; } _height = d3.functor(height || _defaultHeight); return _chart; @@ -155,7 +159,11 @@ dc.baseMixin = function (_chart) { */ _chart.width = function (width) { if (!arguments.length) { - return _width(_root.node()); + if (!dc.utils.isNumber(_width)) { + // only calculate once + _width = _width(_root.node()); + } + return _width; } _width = d3.functor(width || _defaultWidth); return _chart;