Skip to content

Commit

Permalink
Fix codeclimate warning
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Oct 14, 2019
1 parent 30157ba commit 98532b1
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/core/core.scale.js
Expand Up @@ -214,6 +214,18 @@ function parseTickFontOptions(options) {
return {minor: minor, major: major};
}

function nonSkipped(ticksToFilter) {
var filtered = [];
var item, index, len;
for (index = 0, len = ticksToFilter.length; index < len; ++index) {
item = ticksToFilter[index];
if (typeof item._index !== 'undefined') {
filtered.push(item);
}
}
return filtered;
}

function getEvenSpacing(arr) {
var len = arr.length;
var i, diff;
Expand All @@ -237,13 +249,15 @@ function calculateSpacing(majorIndices, ticks, axisLength, ticksLimit) {

// If the major ticks are evenly spaced apart, place the minor ticks
// so that they divide the major ticks into even chunks
if (evenMajorSpacing) {
factors = helpers.math._factorize(evenMajorSpacing);
for (i = 0, ilen = factors.length - 1; i < ilen; i++) {
factor = factors[i];
if (factor > spacing) {
return factor;
}
if (!evenMajorSpacing) {
return Math.max(spacing, 1);
}

factors = helpers.math._factorize(evenMajorSpacing);
for (i = 0, ilen = factors.length - 1; i < ilen; i++) {
factor = factors[i];
if (factor > spacing) {
return factor;
}
}
return Math.max(spacing, 1);
Expand Down Expand Up @@ -945,18 +959,6 @@ var Scale = Element.extend({
var last = majorIndices[numMajorIndices - 1];
var i, ilen, spacing, avgMajorSpacing;

function nonSkipped(ticksToFilter) {
var filtered = [];
var item, index, len;
for (index = 0, len = ticksToFilter.length; index < len; ++index) {
item = ticksToFilter[index];
if (typeof item._index !== 'undefined') {
filtered.push(item);
}
}
return filtered;
}

// If there are too many major ticks to display them all
if (numMajorIndices > ticksLimit) {
skipMajors(ticks, majorIndices, numMajorIndices / ticksLimit);
Expand Down

0 comments on commit 98532b1

Please sign in to comment.