Skip to content

Commit

Permalink
fontFunction added to tick options
Browse files Browse the repository at this point in the history
  • Loading branch information
cormacrelf committed Nov 15, 2017
1 parent 9183160 commit 0250f51
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/core/core.scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,13 @@ module.exports = function(Chart) {
var size = valueOrDefault(options.fontSize, globalDefaults.defaultFontSize);
var style = valueOrDefault(options.fontStyle, globalDefaults.defaultFontStyle);
var family = valueOrDefault(options.fontFamily, globalDefaults.defaultFontFamily);
var func = valueOrDefault(options.fontFunction, null);

return {
size: size,
style: style,
family: family,
font: helpers.fontString(size, style, family)
font: func || helpers.fontString(size, style, family)
};
}

Expand Down Expand Up @@ -849,7 +850,12 @@ module.exports = function(Chart) {
context.save();
context.translate(itemToDraw.labelX, itemToDraw.labelY);
context.rotate(itemToDraw.rotation);
context.font = itemToDraw.major ? majorTickFont.font : tickFont.font;

if (typeof tickFont.font === 'function') {
context.font = tickFont.font(index);
} else {
context.font = itemToDraw.major ? majorTickFont.font : tickFont.font;
}

if (Object.prototype.toString.call( tickFontColor ) === '[object Array]') {
context.fillStyle = itemToDraw.major ? majorTickFontColor[index] : tickFontColor[index];
Expand Down

0 comments on commit 0250f51

Please sign in to comment.