From 71bc8703e80de3fa6ca24c457e27b5389179e1fd Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Mon, 13 May 2019 23:29:41 -0700 Subject: [PATCH] Use tick.major rather than recomputing (#6265) --- src/scales/scale.time.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index 849dd8dcc6e..b00daa2403e 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -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([ @@ -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