From d7ab51f29b933659ca2058110e35219d3d002068 Mon Sep 17 00:00:00 2001 From: Ben Woodford Date: Thu, 24 Sep 2015 15:54:10 +0100 Subject: [PATCH 1/2] Only rotate label while rotation is < maxRotation 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index 939d32404..5ba78e2d6 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -147,7 +147,7 @@ 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)); From b0679a80aeb951efc887b639323bb71dab470978 Mon Sep 17 00:00:00 2001 From: Ben Woodford Date: Thu, 24 Sep 2015 16:02:58 +0100 Subject: [PATCH 2/2] Fixed label padding not affecting x-axis label --- src/scales/scale.category.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index 5ba78e2d6..188bf83aa 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -303,7 +303,7 @@ if (this.options.labels.show) { this.ctx.save(); - this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); + this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 + this.options.labels.padding : this.top + this.options.labels.padding); this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); this.ctx.font = this.font; this.ctx.textAlign = (isRotated) ? "right" : "center";