Skip to content

Commit

Permalink
Add helpers._deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed May 11, 2019
1 parent c5431f8 commit 9ccb407
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
19 changes: 6 additions & 13 deletions src/controllers/controller.bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var defaults = require('../core/core.defaults');
var elements = require('../elements/index');
var helpers = require('../helpers/index');

var deprecated = helpers._deprecated;
var valueOrDefault = helpers.valueOrDefault;

defaults._set('bar', {
Expand Down Expand Up @@ -123,14 +124,6 @@ function computeFlexCategoryTraits(index, ruler, options) {
};
}

function deprecated(value, previous, current) {
if (value !== undefined) {
console.warn(
'bar chart: "' + previous + '" is deprecated. ' +
'Please use "' + current + '" instead');
}
}

module.exports = DatasetController.extend({

dataElementType: elements.Rectangle,
Expand All @@ -156,11 +149,11 @@ module.exports = DatasetController.extend({
meta.bar = true;

scaleOpts = me._getIndexScale().options;
deprecated(scaleOpts.barPercentage, 'scales.[x/y]Axes.barPercentage', 'dataset.barPercentage');
deprecated(scaleOpts.barThickness, 'scales.[x/y]Axes.barThickness', 'dataset.barThickness');
deprecated(scaleOpts.categoryPercentage, 'scales.[x/y]Axes.categoryPercentage', 'dataset.categoryPercentage');
deprecated(me._getValueScale().options.minBarLength, 'scales.[x/y]Axes.minBarLength', 'dataset.minBarLength');
deprecated(scaleOpts.maxBarThickness, 'scales.[x/y]Axes.maxBarThickness', 'dataset.maxBarThickness');
deprecated('bar chart', scaleOpts.barPercentage, 'scales.[x/y]Axes.barPercentage', 'dataset.barPercentage');
deprecated('bar chart', scaleOpts.barThickness, 'scales.[x/y]Axes.barThickness', 'dataset.barThickness');
deprecated('bar chart', scaleOpts.categoryPercentage, 'scales.[x/y]Axes.categoryPercentage', 'dataset.categoryPercentage');
deprecated('bar chart', me._getValueScale().options.minBarLength, 'scales.[x/y]Axes.minBarLength', 'dataset.minBarLength');
deprecated('bar chart', scaleOpts.maxBarThickness, 'scales.[x/y]Axes.maxBarThickness', 'dataset.maxBarThickness');
},

update: function(reset) {
Expand Down
7 changes: 7 additions & 0 deletions src/helpers/helpers.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,13 @@ var helpers = {

ChartElement.__super__ = me.prototype;
return ChartElement;
},

_deprecated: function(scope, value, previous, current) {
if (value !== undefined) {
console.warn(scope + ': "' + previous +
'" is deprecated. Please use "' + current + '" instead');
}
}
};

Expand Down
15 changes: 4 additions & 11 deletions src/scales/scale.time.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var defaults = require('../core/core.defaults');
var helpers = require('../helpers/index');
var Scale = require('../core/core.scale');

var deprecated = helpers._deprecated;
var valueOrDefault = helpers.valueOrDefault;

// Integer constants are from the ES6 spec.
Expand Down Expand Up @@ -60,14 +61,6 @@ var INTERVALS = {

var UNITS = Object.keys(INTERVALS);

function deprecated(value, previous, current) {
if (value !== undefined) {
console.warn(
'time scale: "' + previous + '" is deprecated. ' +
'Please use "' + current + '" instead');
}
}

function sorter(a, b) {
return a - b;
}
Expand Down Expand Up @@ -488,9 +481,9 @@ module.exports = Scale.extend({
var adapter = me._adapter = new adapters._date(options.adapters.date);

// DEPRECATIONS: output a message only one time per update
deprecated(time.format, 'time.format', 'time.parser');
deprecated(time.min, 'time.min', 'ticks.min');
deprecated(time.max, 'time.max', 'ticks.max');
deprecated('time scale', time.format, 'time.format', 'time.parser');
deprecated('time scale', time.min, 'time.min', 'ticks.min');
deprecated('time scale', time.max, 'time.max', 'ticks.max');

// Backward compatibility: before introducing adapter, `displayFormats` was
// supposed to contain *all* unit/string pairs but this can't be resolved
Expand Down

0 comments on commit 9ccb407

Please sign in to comment.