Skip to content

Commit

Permalink
Implement code review suggestions
Browse files Browse the repository at this point in the history
- avoid useless push while building the lookup table
- rename `this._timestamps` to `this._data`
  • Loading branch information
simonbrunel committed Jul 29, 2017
1 parent bd2d713 commit d86cc9c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/scales/scale.time.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,9 @@ function buildLookupTable(timestamps, min, max, distribution) {
}

var table = [];
var items = [];
var items = [min];
var i, ilen, prev, curr, next;

items.push(min);

for (i = 0, ilen = timestamps.length; i < ilen; ++i) {
curr = timestamps[i];
if (curr > min && curr < max) {
Expand Down Expand Up @@ -507,9 +505,9 @@ module.exports = function(Chart) {
me.max = Math.max(min + 1, max);

// PRIVATE
me._data = timestamps;
me._datasets = datasets;
me._horizontal = me.isHorizontal();
me._timestamps = timestamps;
me._labels = labels;
me._table = [];
},
Expand All @@ -531,7 +529,7 @@ module.exports = function(Chart) {

switch (ticksOpts.source) {
case 'data':
timestamps = me._timestamps;
timestamps = me._data;
break;
case 'labels':
timestamps = me._labels;
Expand Down Expand Up @@ -566,7 +564,7 @@ module.exports = function(Chart) {
me._majorUnit = majorUnit;
me._minorFormat = formats[unit];
me._majorFormat = formats[majorUnit];
me._table = buildLookupTable(me._timestamps, min, max, options.distribution);
me._table = buildLookupTable(me._data, min, max, options.distribution);

return ticksFromTimestamps(ticks, majorUnit);
},
Expand Down

0 comments on commit d86cc9c

Please sign in to comment.