Skip to content

Commit

Permalink
Some more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Oct 23, 2019
1 parent 8066422 commit 1dc078e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
9 changes: 5 additions & 4 deletions src/controllers/controller.bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,22 @@ function parseFloatBar(arr, item, vScale, i) {
function parseArrayOrPrimitive(meta, data, start, count) {
var iScale = this._getIndexScale();
var vScale = this._getValueScale();
var labels = iScale._getLabels() || [];
var labels = iScale._getLabels();
var singleScale = iScale === vScale;
var parsed = [];
var i, ilen, item, entry;

for (i = start, ilen = start + count; i < ilen; ++i) {
entry = data[i];
item = {_index: i};
item[iScale.id] = singleScale || iScale._parse(labels[i], i);

if (helpers.isArray(entry)) {
parseFloatBar(entry, item, vScale, i);
} else {
item[vScale.id] = vScale._parse(entry, i);
}
if (!singleScale) {
item[iScale.id] = iScale._parse(labels[i], i);
}

parsed.push(item);
}
return parsed;
Expand Down
21 changes: 14 additions & 7 deletions src/controllers/controller.line.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,6 @@ module.exports = DatasetController.extend({
return values;
},

calculatePointY: function(value, index, datasetIndex) {
var me = this;
var chart = me.chart;
var controller = datasetIndex === me.index ? me : chart.getDatasetMeta(datasetIndex).controller;
return controller._getStackedValue(me._yScale, index);
},

updateBezierControlPoints: function() {
var me = this;
var chart = me.chart;
Expand Down Expand Up @@ -288,4 +281,18 @@ module.exports = DatasetController.extend({
model.borderWidth = valueOrDefault(options.hoverBorderWidth, options.borderWidth);
model.radius = valueOrDefault(options.hoverRadius, options.radius);
},

// DEPRECATIONS

/**
* Provided for backward compatibility
* @deprecated since version 2.9.0
* @todo remove at version 3
*/
calculatePointY: function(value, index, datasetIndex) {
var me = this;
var chart = me.chart;
var controller = datasetIndex === me.index ? me : chart.getDatasetMeta(datasetIndex).controller;
return controller._getStackedValue(me._yScale, index);
},
});
14 changes: 5 additions & 9 deletions src/core/core.datasetController.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,18 +473,15 @@ helpers.extend(DatasetController.prototype, {
_parsePrimitiveData: function(meta, data, start, count) {
var iScale = this._getIndexScale();
var vScale = this._getValueScale();
var labels = iScale._getLabels() || [];
var oneScale = iScale === vScale;
var labels = iScale._getLabels();
var singleScale = iScale === vScale;
var parsed = [];
var i, ilen, item;

for (i = start, ilen = start + count; i < ilen; ++i) {
item = {_index: i};
item[iScale.id] = singleScale || iScale._parse(labels[i], i);
item[vScale.id] = vScale._parse(data[i], i);
if (!oneScale) {
item[iScale.id] = i >= 0 && i < labels.length
? iScale._parse(labels[i], i) : NaN;
}
parsed.push(item);
}
return parsed;
Expand Down Expand Up @@ -591,14 +588,13 @@ helpers.extend(DatasetController.prototype, {
var metaData = meta.data;
var ilen = metaData.length;
var crossRef = chart._xref || (chart._xref = {});
var min = Number.POSITIVE_INFINITY;
var max = Number.NEGATIVE_INFINITY;
var minPositive = Number.POSITIVE_INFINITY;
var stacked = scale.options.stacked;
var indices = getSortedDatasetIndices(chart, true);
var i, item, value, parsed, stack;
var i, item, value, parsed, stack, min, minPositive;

stacked = canStack && (stacked || (stacked === undefined && meta.stack !== undefined));
min = minPositive = Number.POSITIVE_INFINITY;

for (i = 0; i < ilen; ++i) {
item = metaData[i];
Expand Down
9 changes: 8 additions & 1 deletion src/core/core.scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,13 @@ var Scale = Element.extend({
}];
},

/**
* @private
*/
_getAxisID: function() {
return this.isHorizontal() ? 'xAxisID' : 'yAxisID';
},

/**
* Returns visible dataset metas that are attached to this scale
* @param {string} [type] - if specified, also filter by dataset type
Expand All @@ -1463,7 +1470,7 @@ var Scale = Element.extend({
_getMatchingVisibleMetas: function(type) {
var me = this;
var metas = me.chart._getSortedVisibleDatasetMetas();
var axisID = me.isHorizontal() ? 'xAxisID' : 'yAxisID';
var axisID = me._getAxisID();
var result = [];
var i, ilen, meta;

Expand Down
3 changes: 3 additions & 0 deletions src/scales/scale.time.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,9 @@ var defaultConfig = {

module.exports = Scale.extend({
_parse: function(raw, index) { // eslint-disable-line no-unused-vars
if (raw === undefined) {
return NaN;
}
return toTimestamp(this, raw);
},

Expand Down

0 comments on commit 1dc078e

Please sign in to comment.