From 1049aa65b8f59eb4ef6eb40bbbbc047c29c616d3 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Sun, 10 Nov 2019 04:49:16 -0800 Subject: [PATCH] Remove unused method. Prefix private ones with underscore (#6721) --- docs/getting-started/v3-migration.md | 4 ++++ src/scales/scale.time.js | 26 +++++++++----------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/docs/getting-started/v3-migration.md b/docs/getting-started/v3-migration.md index 51035bc90..eab3a3c48 100644 --- a/docs/getting-started/v3-migration.md +++ b/docs/getting-started/v3-migration.md @@ -72,6 +72,7 @@ Chart.js is no longer providing the `Chart.bundle.js` and `Chart.bundle.min.js`. * `_model.datasetLabel` * `_model.label` +* `TimeScale.getLabelWidth` ### Renamed @@ -84,6 +85,9 @@ Chart.js is no longer providing the `Chart.bundle.js` and `Chart.bundle.min.js`. * `helpers.log10` was renamed to `helpers.math.log10` * `Chart.Animation.animationObject` was renamed to `Chart.Animation` * `Chart.Animation.chartInstance` was renamed to `Chart.Animation.chart` +* `TimeScale.getLabelCapacity` was renamed to `TimeScale._getLabelCapacity` +* `TimeScale.tickFormatFunction` was renamed to `TimeScale._tickFormatFunction` +* `TimeScale.getPixelForOffset` was renamed to `TimeScale._getPixelForOffset` ### Changed diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index 36024c1d1..c3d56680a 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -408,7 +408,7 @@ function getTimestampsForTicks(scale) { var min = scale.min; var max = scale.max; var options = scale.options; - var capacity = scale.getLabelCapacity(min); + var capacity = scale._getLabelCapacity(min); var source = options.ticks.source; var timestamps; @@ -593,7 +593,7 @@ module.exports = Scale.extend({ // determineUnitForFormatting relies on the number of ticks so we don't use it when // autoSkip is enabled because we don't yet know what the final number of ticks will be me._unit = timeOpts.unit || (tickOpts.autoSkip - ? determineUnitForAutoTicks(timeOpts.minUnit, me.min, me.max, me.getLabelCapacity(min)) + ? determineUnitForAutoTicks(timeOpts.minUnit, me.min, me.max, me._getLabelCapacity(min)) : determineUnitForFormatting(me, ticks.length, timeOpts.minUnit, me.min, me.max)); me._majorUnit = !tickOpts.major.enabled || me._unit === 'year' ? undefined : determineMajorUnit(me._unit); @@ -622,7 +622,7 @@ module.exports = Scale.extend({ * Function to format an individual tick mark * @private */ - tickFormatFunction: function(time, index, ticks, format) { + _tickFormatFunction: function(time, index, ticks, format) { var me = this; var adapter = me._adapter; var options = me.options; @@ -648,14 +648,14 @@ module.exports = Scale.extend({ for (i = 0, ilen = ticks.length; i < ilen; ++i) { tick = ticks[i]; - tick.label = this.tickFormatFunction(tick.value, i, ticks); + tick.label = this._tickFormatFunction(tick.value, i, ticks); } }, /** * @private */ - getPixelForOffset: function(time) { + _getPixelForOffset: function(time) { var me = this; var offsets = me._offsets; var pos = interpolate(me._table, 'time', time, 'pos'); @@ -670,14 +670,14 @@ module.exports = Scale.extend({ } if (value !== null) { - return me.getPixelForOffset(value); + return me._getPixelForOffset(value); } }, getPixelForTick: function(index) { var ticks = this.getTicks(); return index >= 0 && index < ticks.length ? - this.getPixelForOffset(ticks[index].value) : + this._getPixelForOffset(ticks[index].value) : null; }, @@ -707,24 +707,16 @@ module.exports = Scale.extend({ }, /** - * Crude approximation of what the label width might be * @private */ - getLabelWidth: function(label) { - return this._getLabelSize(label).w; - }, - - /** - * @private - */ - getLabelCapacity: function(exampleTime) { + _getLabelCapacity: function(exampleTime) { var me = this; var timeOpts = me.options.time; var displayFormats = timeOpts.displayFormats; // pick the longest format (milliseconds) for guestimation var format = displayFormats[timeOpts.unit] || displayFormats.millisecond; - var exampleLabel = me.tickFormatFunction(exampleTime, 0, ticksFromTimestamps(me, [exampleTime], me._majorUnit), format); + var exampleLabel = me._tickFormatFunction(exampleTime, 0, ticksFromTimestamps(me, [exampleTime], me._majorUnit), format); var size = me._getLabelSize(exampleLabel); var capacity = Math.floor(me.isHorizontal() ? me.width / size.w : me.height / size.h); -- 2.47.2