]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Remove unused method. Prefix private ones with underscore (#6721)
authorBen McCann <322311+benmccann@users.noreply.github.com>
Sun, 10 Nov 2019 12:49:16 +0000 (04:49 -0800)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sun, 10 Nov 2019 12:49:16 +0000 (07:49 -0500)
docs/getting-started/v3-migration.md
src/scales/scale.time.js

index 51035bc90c70b0a4c9bc6df69d20262aa1b5a620..eab3a3c48335ebe45752cd00511679ff5a9f5a83 100644 (file)
@@ -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
 
index 36024c1d1647a353b3f6239b94d99f77c0955f43..c3d56680a172167e70de1f332260391b8ab1e22c 100644 (file)
@@ -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);