]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Category scale now takes a smaller size if no labels are being displayed. 1403/head
authorEvert Timberg <evert.timberg@gmail.com>
Sat, 22 Aug 2015 18:30:30 +0000 (14:30 -0400)
committerEvert Timberg <evert.timberg@gmail.com>
Sat, 22 Aug 2015 18:30:30 +0000 (14:30 -0400)
Updated linear scale code to use proper bottom padding. This is important when not displaying x axis labels

src/scales/scale.category.js
src/scales/scale.linear.js

index 98b28d072fa3a187e9173b43dac31e95b75e45f6..ec355c77cd1aedd26bc56d1dc4f1ec06cacf3cb3 100644 (file)
             if (this.isHorizontal()) {
                 minSize.width = maxWidth;
             } else if (this.options.display) {
-                minSize.width = Math.min(longestLabelWidth + 6, maxWidth);
+                var labelWidth = this.options.labels.show ? longestLabelWidth + 6 : 0;
+                minSize.width = Math.min(labelWidth, maxWidth);
             }
 
             // Height
             if (this.isHorizontal() && this.options.display) {
                 var labelHeight = (Math.sin(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize;
-                minSize.height = Math.min(labelHeight, maxHeight);
+                minSize.height = Math.min(this.options.labels.show ? labelHeight : 0, maxHeight);
             } else if (this.options.display) {
                 minSize.height = maxHeight;
             }
index 7adf6391a52b8a56d945085684597f748c9ba991..b39c89bdc0c618027e45aecdb5232e53659a15de 100644 (file)
                        } else {
                                // Bottom - top since pixels increase downard on a screen
                                var innerHeight = this.height - (this.paddingTop + this.paddingBottom);
-                               pixel = this.bottom - (innerHeight / range * (value - this.start));
+                               pixel = (this.bottom - this.paddingBottom) - (innerHeight / range * (value - this.start));
                                pixel += this.paddingTop;
                        }