]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Only rotate label while rotation is < maxRotation
authorBen Woodford <ben@woodfordnet.co.uk>
Thu, 24 Sep 2015 14:54:10 +0000 (15:54 +0100)
committerBen Woodford <ben@woodfordnet.co.uk>
Thu, 24 Sep 2015 14:54:10 +0000 (15:54 +0100)
Checking for <= maxRotation results in a labelRotation of 1 if maxRotation is 0, which doesn't make any sense (and also causes the text to be right aligned not centred)

src/scales/scale.category.js

index 939d32404d0d2abe383a8dd4d36ee4087ef1c7d7..5ba78e2d6644547970bb07e4650ef894da673601 100644 (file)
                 var datasetWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6;
 
                 //Max label rotation can be set or default to 90 - also act as a loop counter
-                while (this.labelWidth > datasetWidth && this.labelRotation <= this.options.labels.maxRotation) {
+                while (this.labelWidth > datasetWidth && this.labelRotation < this.options.labels.maxRotation) {
                     cosRotation = Math.cos(helpers.toRadians(this.labelRotation));
                     sinRotation = Math.sin(helpers.toRadians(this.labelRotation));