if (tickOpts.display && display) {
// Don't bother fitting the ticks if we are not showing them
- if (!this.longestTextCache) {
- this.longestTextCache = {};
+ if (!me.longestTextCache) {
+ me.longestTextCache = {};
}
- var largestTextWidth = helpers.longestText(this.ctx, tickLabelFont, this.ticks, this.longestTextCache);
- var tallestLabelHeightInLines = helpers.numberOfLabelLines(this.ticks);
+ var largestTextWidth = helpers.longestText(me.ctx, tickLabelFont, me.ticks, me.longestTextCache);
++ var tallestLabelHeightInLines = helpers.numberOfLabelLines(me.ticks);
+ var lineSpace = tickFontSize * 0.5;
if (isHorizontal) {
// A horizontal axis is more constrained by the height.
- this.longestLabelWidth = largestTextWidth;
+ me.longestLabelWidth = largestTextWidth;
// TODO - improve this calculation
- var labelHeight = (Math.sin(helpers.toRadians(me.labelRotation)) * me.longestLabelWidth) + 1.5 * tickFontSize;
- var labelHeight = (Math.sin(helpers.toRadians(this.labelRotation)) * this.longestLabelWidth) + (tickFontSize * tallestLabelHeightInLines) + (lineSpace * tallestLabelHeightInLines);
++ var labelHeight = (Math.sin(helpers.toRadians(me.labelRotation)) * me.longestLabelWidth) + (tickFontSize * tallestLabelHeightInLines) + (lineSpace * tallestLabelHeightInLines);
- minSize.height = Math.min(this.maxHeight, minSize.height + labelHeight);
- this.ctx.font = tickLabelFont;
+ minSize.height = Math.min(me.maxHeight, minSize.height + labelHeight);
+ me.ctx.font = tickLabelFont;
- var firstLabelWidth = this.ctx.measureText(this.ticks[0]).width;
- var lastLabelWidth = this.ctx.measureText(this.ticks[this.ticks.length - 1]).width;
+ var firstLabelWidth = me.ctx.measureText(me.ticks[0]).width;
+ var lastLabelWidth = me.ctx.measureText(me.ticks[me.ticks.length - 1]).width;
// Ensure that our ticks are always inside the canvas. When rotated, ticks are right aligned which means that the right padding is dominated
// by the font height
context.font = tickLabelFont;
context.textAlign = (isRotated) ? "right" : "center";
context.textBaseline = (isRotated) ? "middle" : options.position === "top" ? "bottom" : "top";
- context.fillText(label, 0, 0);
+
+ if (helpers.isArray(label)) {
+ for (var i = 0, y = 0; i < label.length; ++i) {
+ // We just make sure the multiline element is a string here..
+ context.fillText('' + label[i], 0, y);
+ // apply same lineSpacing as calculated @ L#320
+ y += (tickFontSize * 1.5);
+ }
+ } else {
+ context.fillText(label, 0, 0);
+ }
+
context.restore();
}
- }, this);
+ }, me);
if (scaleLabel.display) {
// Draw the scale label