Skip to content

Commit

Permalink
Use tick.major rather than recomputing (chartjs#6265)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored and nagix committed May 14, 2019
1 parent 6522b13 commit 71bc870
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/scales/scale.time.js
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,10 @@ module.exports = Scale.extend({
var minorFormat = formats[me._unit];
var majorUnit = me._majorUnit;
var majorFormat = formats[majorUnit];
var majorTime = +adapter.startOf(time, majorUnit);
var tick = ticks[index];
var tickOpts = options.ticks;
var majorTickOpts = tickOpts.major;
var major = majorTickOpts.enabled && majorUnit && majorFormat && time === majorTime;
var major = majorTickOpts.enabled && majorUnit && majorFormat && tick && tick.major;
var label = adapter.format(time, format ? format : major ? majorFormat : minorFormat);
var nestedTickOpts = major ? majorTickOpts : tickOpts.minor;
var formatter = helpers.options.resolve([
Expand Down Expand Up @@ -785,7 +785,7 @@ module.exports = Scale.extend({

// pick the longest format (milliseconds) for guestimation
var format = displayFormats[timeOpts.unit] || displayFormats.millisecond;
var exampleLabel = me.tickFormatFunction(exampleTime, 0, [], format);
var exampleLabel = me.tickFormatFunction(exampleTime, 0, ticksFromTimestamps(me, [exampleTime], me._majorUnit), format);
var size = me._getLabelSize(exampleLabel);

// Using margins instead of padding because padding is not calculated
Expand Down

0 comments on commit 71bc870

Please sign in to comment.