]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix #507 - calculate container width and heigh without padding 722/head 851/head
authorJerome Touffe-Blin <jtblin@gmail.com>
Sat, 25 Oct 2014 02:14:30 +0000 (13:14 +1100)
committerJerome Touffe-Blin <jtblin@gmail.com>
Sat, 25 Oct 2014 02:21:52 +0000 (13:21 +1100)
src/Chart.Core.js

index 03b99b45a582e69ae57ea79f3ed3e5bbae3bb0d1..fb171451dd8f61948c11440ae28defb62c70a06d 100755 (executable)
                                if (filterCallback(currentItem)){
                                        return currentItem;
                                }
-                       };
+                       }
                },
                findPreviousWhere = helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex){
                        // Default to end of the array
                                if (filterCallback(currentItem)){
                                        return currentItem;
                                }
-                       };
+                       }
                },
                inherits = helpers.inherits = function(extensions){
                        //Basic javascript inheritance based on the model created in Backbone.js
                        });
                },
                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){