Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Jun 24, 2019
1 parent d6f37ae commit 907ae42
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/scales/scale.time.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,18 +534,18 @@ module.exports = Scale.extend({
var unit = options.time.unit || 'day';
var min = MAX_INTEGER;
var max = MIN_INTEGER;
var timestamps = [];
var datasets = [];
var labels = [];
var timestamps, i, j, ilen, jlen, data, timestamp;
var i, j, ilen, jlen, data, timestamp, labelsAdded;
var dataLabels = me._getLabels();

// Convert labels to timestamps
// Set labels
for (i = 0, ilen = dataLabels.length; i < ilen; ++i) {
labels.push(parse(me, dataLabels[i]));
}
timestamps = labels.slice(0);

// Convert data to timestamps
// Set timestamps
for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) {
if (chart.isDatasetVisible(i)) {
data = chart.data.datasets[i].data;
Expand All @@ -561,19 +561,20 @@ module.exports = Scale.extend({
}
} else {
datasets[i] = labels.slice(0);
if (!labelsAdded) {
timestamps = timestamps.concat(labels);
labelsAdded = true;
}
}
} else {
datasets[i] = [];
}
}

if (labels.length) {
min = Math.min(min, labels[0]);
max = Math.max(max, labels[labels.length - 1]);
}

if (timestamps.length) {
timestamps = arrayUnique(timestamps).sort(sorter);
if (ilen > 1) {
timestamps = arrayUnique(timestamps).sort(sorter);
}
min = Math.min(min, timestamps[0]);
max = Math.max(max, timestamps[timestamps.length - 1]);
}
Expand Down

0 comments on commit 907ae42

Please sign in to comment.