]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Core Scale now plays nice with layoutService and full width
authorTanner Linsley <tannerlinsley@gmail.com>
Tue, 27 Oct 2015 08:33:19 +0000 (02:33 -0600)
committerTanner Linsley <tannerlinsley@gmail.com>
Tue, 27 Oct 2015 08:33:19 +0000 (02:33 -0600)
src/core/core.scale.js

index edf807de07e882eda14592438b25df8d43fd4938..2f8432146e608256cdbd26b43deb236d3ecce1bb 100644 (file)
                        // Absorb the master measurements
                        this.maxWidth = maxWidth;
                        this.maxHeight = maxHeight;
-                       this.margins = margins;
+                       this.margins = helpers.extend({
+                               left: 0,
+                               right: 0,
+                               top: 0,
+                               bottom: 0
+                       }, margins);
 
                        // Dimensions
                        this.beforeSetDimensions();
 
                        // Width
                        if (this.isHorizontal()) {
-                               this.minSize.width = this.maxWidth; // fill all the width
+                               // subtract the margins to line up with the chartArea
+                               this.minSize.width = this.maxWidth - this.margins.left - this.margins.right;
                        } else {
                                this.minSize.width = this.options.gridLines.show && this.options.display ? 10 : 0;
                        }
                                if (includeOffset) {
                                        pixel += tickWidth / 2;
                                }
-                               return this.left + Math.round(pixel);
+                               return this.left + this.margins.left + Math.round(pixel);
                        } else {
                                var innerHeight = this.height - (this.paddingTop + this.paddingBottom);
                                return this.top + (index * (innerHeight / (this.ticks.length - 1)));
                                var innerWidth = this.width - (this.paddingLeft + this.paddingRight);
                                var valueOffset = (innerWidth * decimal) + this.paddingLeft;
 
-                               return this.left + Math.round(valueOffset);
+                               return this.left + this.margins.left + Math.round(valueOffset);
                        } else {
                                return this.top + (decimal * this.height);
                        }