Skip to content

Commit 62370b0

Browse files
committed
Address review comments
1 parent d6f37ae commit 62370b0

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/scales/scale.time.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -534,18 +534,18 @@ module.exports = Scale.extend({
534534
var unit = options.time.unit || 'day';
535535
var min = MAX_INTEGER;
536536
var max = MIN_INTEGER;
537+
var timestamps = [];
537538
var datasets = [];
538539
var labels = [];
539-
var timestamps, i, j, ilen, jlen, data, timestamp;
540+
var i, j, ilen, jlen, data, timestamp, labelsAdded;
540541
var dataLabels = me._getLabels();
541542

542-
// Convert labels to timestamps
543+
// Set labels
543544
for (i = 0, ilen = dataLabels.length; i < ilen; ++i) {
544545
labels.push(parse(me, dataLabels[i]));
545546
}
546-
timestamps = labels.slice(0);
547547

548-
// Convert data to timestamps
548+
// Set timestamps
549549
for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) {
550550
if (chart.isDatasetVisible(i)) {
551551
data = chart.data.datasets[i].data;
@@ -561,6 +561,10 @@ module.exports = Scale.extend({
561561
}
562562
} else {
563563
datasets[i] = labels.slice(0);
564+
if (!labelsAdded) {
565+
timestamps = timestamps.concat(labels);
566+
labelsAdded = true;
567+
}
564568
}
565569
} else {
566570
datasets[i] = [];
@@ -573,7 +577,9 @@ module.exports = Scale.extend({
573577
}
574578

575579
if (timestamps.length) {
576-
timestamps = arrayUnique(timestamps).sort(sorter);
580+
if (ilen > 1) {
581+
timestamps = arrayUnique(timestamps).sort(sorter);
582+
}
577583
min = Math.min(min, timestamps[0]);
578584
max = Math.max(max, timestamps[timestamps.length - 1]);
579585
}

0 commit comments

Comments
 (0)