From: Jerome Touffe-Blin Date: Sat, 25 Oct 2014 02:14:30 +0000 (+1100) Subject: Fix #507 - calculate container width and heigh without padding X-Git-Tag: v2.0-alpha~40^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F722%2Fhead;p=thirdparty%2FChart.js.git Fix #507 - calculate container width and heigh without padding --- diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 03b99b45a..fb171451d 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -238,7 +238,7 @@ if (filterCallback(currentItem)){ return currentItem; } - }; + } }, findPreviousWhere = helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex){ // Default to end of the array @@ -250,7 +250,7 @@ if (filterCallback(currentItem)){ return currentItem; } - }; + } }, inherits = helpers.inherits = function(extensions){ //Basic javascript inheritance based on the model created in Backbone.js @@ -738,14 +738,21 @@ }); }, getMaximumWidth = helpers.getMaximumWidth = function(domNode){ - var container = domNode.parentNode; + var container = domNode.parentNode, + padding = parseInt(getStyle(container, 'padding-left')) + parseInt(getStyle(container, 'padding-right')); // TODO = check cross browser stuff with this. - return container.clientWidth; + return container.clientWidth - padding; }, getMaximumHeight = helpers.getMaximumHeight = function(domNode){ - var container = domNode.parentNode; + var container = domNode.parentNode, + padding = parseInt(getStyle(container, 'padding-bottom')) + parseInt(getStyle(container, 'padding-top')); // TODO = check cross browser stuff with this. - return container.clientHeight; + return container.clientHeight - padding; + }, + getStyle = helpers.getStyle = function (el, property) { + return el.currentStyle ? + el.currentStyle[property] : + document.defaultView.getComputedStyle(el, null).getPropertyValue(property); }, getMaximumSize = helpers.getMaximumSize = helpers.getMaximumWidth, // legacy support retinaScale = helpers.retinaScale = function(chart){