Skip to content

Commit

Permalink
Rename INTERVALS.major to INTERVALS.common (#4777)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored and etimberg committed Sep 29, 2017
1 parent 52145de commit 8a4ac1e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/scales/scale.time.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,47 @@ var MAX_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;

var INTERVALS = {
millisecond: {
major: true,
common: true,
size: 1,
steps: [1, 2, 5, 10, 20, 50, 100, 250, 500]
},
second: {
major: true,
common: true,
size: 1000,
steps: [1, 2, 5, 10, 30]
},
minute: {
major: true,
common: true,
size: 60000,
steps: [1, 2, 5, 10, 30]
},
hour: {
major: true,
common: true,
size: 3600000,
steps: [1, 2, 3, 6, 12]
},
day: {
major: true,
common: true,
size: 86400000,
steps: [1, 2, 5]
},
week: {
major: false,
common: false,
size: 604800000,
steps: [1, 2, 3, 4]
},
month: {
major: true,
common: true,
size: 2.628e9,
steps: [1, 2, 3]
},
quarter: {
major: false,
common: false,
size: 7.884e9,
steps: [1, 2, 3, 4]
},
year: {
major: true,
common: true,
size: 3.154e10
}
};
Expand Down Expand Up @@ -261,7 +261,7 @@ function determineUnit(minUnit, min, max, capacity) {
interval = INTERVALS[UNITS[i]];
factor = interval.steps ? interval.steps[interval.steps.length - 1] : MAX_INTEGER;

if (Math.ceil((max - min) / (factor * interval.size)) <= capacity) {
if (interval.common && Math.ceil((max - min) / (factor * interval.size)) <= capacity) {
return UNITS[i];
}
}
Expand All @@ -271,7 +271,7 @@ function determineUnit(minUnit, min, max, capacity) {

function determineMajorUnit(unit) {
for (var i = UNITS.indexOf(unit) + 1, ilen = UNITS.length; i < ilen; ++i) {
if (INTERVALS[UNITS[i]].major) {
if (INTERVALS[UNITS[i]].common) {
return UNITS[i];
}
}
Expand Down

0 comments on commit 8a4ac1e

Please sign in to comment.