Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perf improvement for ticks.source:'labels' #6354

Merged
merged 3 commits into from
Jul 18, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/scales/scale.time.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,16 +534,16 @@ 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 i, j, ilen, jlen, data, timestamp;
var timestamps, i, j, ilen, jlen, data, timestamp;
var dataLabels = me._getLabels();

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

// Convert data to timestamps
for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) {
Expand All @@ -560,9 +560,6 @@ module.exports = Scale.extend({
datasets[i][j] = timestamp;
}
} else {
for (j = 0, jlen = labels.length; j < jlen; ++j) {
timestamps.push(labels[j]);
}
datasets[i] = labels.slice(0);
}
} else {
Expand All @@ -571,8 +568,6 @@ module.exports = Scale.extend({
}

if (labels.length) {
// Sort labels **after** data have been converted
labels = arrayUnique(labels).sort(sorter);
min = Math.min(min, labels[0]);
max = Math.max(max, labels[labels.length - 1]);
}
Expand Down