From f1b704a419f3c9d7b59691e576e6ee66f75c2442 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Thu, 24 Sep 2015 18:53:48 -0400 Subject: [PATCH] Fix scale fitting to give padding around the scale title & to account for label rotation --- src/core/core.scale.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/core/core.scale.js b/src/core/core.scale.js index b11ed5f98..4a7347a04 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -204,6 +204,15 @@ this.minSize.height = this.maxHeight; // fill all the height } + // Are we showing a title for the scale? + if (this.options.scaleLabel.show) { + if (this.isHorizontal()) { + this.minSize.height += (this.options.scaleLabel.fontSize * 1.5); + } else { + this.minSize.width += (this.options.scaleLabel.fontSize * 1.5); + } + } + this.paddingLeft = 0; this.paddingRight = 0; this.paddingTop = 0; @@ -217,7 +226,9 @@ if (this.isHorizontal()) { // A horizontal axis is more constrained by the height. var maxLabelHeight = this.maxHeight - this.minSize.height; - var labelHeight = 1.5 * this.options.ticks.fontSize; + var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.ticks); + var labelHeight = (Math.sin(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.ticks.fontSize; + this.minSize.height = Math.min(this.maxHeight, this.minSize.height + labelHeight); labelFont = helpers.fontString(this.options.ticks.fontSize, this.options.ticks.fontStyle, this.options.ticks.fontFamily); -- 2.47.3