Browse Source

minor cleanups.

codeClimate
Ludo Stellingwerff 8 years ago
parent
commit
aa2a2d61a9
1 changed files with 4 additions and 12 deletions
  1. +4
    -12
      lib/timeline/DataStep.js

+ 4
- 12
lib/timeline/DataStep.js View File

@ -26,9 +26,7 @@
*/ */
function DataStep(start, end, minimumStep, containerHeight, customRange, formattingFunction, alignZeros) { function DataStep(start, end, minimumStep, containerHeight, customRange, formattingFunction, alignZeros) {
// variables // variables
this.current = 0;
this.autoScale = true;
this.current = -1;
this.stepIndex = 0; this.stepIndex = 0;
this.step = 1; this.step = 1;
this.scale = 1; this.scale = 1;
@ -36,7 +34,6 @@ function DataStep(start, end, minimumStep, containerHeight, customRange, formatt
this.marginStart; this.marginStart;
this.marginEnd; this.marginEnd;
this.deadSpace = 0;
this.majorSteps = [1, 2, 5, 10]; this.majorSteps = [1, 2, 5, 10];
this.minorSteps = [0.25, 0.5, 1, 2]; this.minorSteps = [0.25, 0.5, 1, 2];
@ -67,13 +64,9 @@ DataStep.prototype.setRange = function(start, end, minimumStep, containerHeight,
this._end = customRange.max === undefined ? end : customRange.max; this._end = customRange.max === undefined ? end : customRange.max;
if (this._start === this._end) { if (this._start === this._end) {
this._start = customRange.min === undefined ? this._start - 0.75 : this._start; this._start = customRange.min === undefined ? this._start - 0.75 : this._start;
this._end = customRange.max === undefined ? this._end + 1 : this._end;;
}
if (this.autoScale === true) {
this.setMinimumStep(minimumStep, containerHeight);
this._end = customRange.max === undefined ? this._end + 1 : this._end;
} }
this.setMinimumStep(minimumStep, containerHeight);
this.setFirst(customRange); this.setFirst(customRange);
}; };
@ -138,9 +131,7 @@ DataStep.prototype.setFirst = function(customRange) {
this.marginEnd += this.marginEnd % this.step; this.marginEnd += this.marginEnd % this.step;
} }
this.deadSpace = this.roundToMinor(niceEnd) - niceEnd + this.roundToMinor(niceStart) - niceStart;
this.marginRange = this.marginEnd - this.marginStart; this.marginRange = this.marginEnd - this.marginStart;
this.current = this.marginEnd; this.current = this.marginEnd;
}; };
@ -194,6 +185,7 @@ DataStep.prototype.previous = function() {
DataStep.prototype.getCurrent = function() { DataStep.prototype.getCurrent = function() {
// prevent round-off errors when close to zero // prevent round-off errors when close to zero
var current = (Math.abs(this.current) < this.step / 2) ? 0 : this.current; var current = (Math.abs(this.current) < this.step / 2) ? 0 : this.current;
var returnValue = current; var returnValue = current;
if (typeof this.formattingFunction === 'function') { if (typeof this.formattingFunction === 'function') {
return this.formattingFunction(current); return this.formattingFunction(current);

Loading…
Cancel
Save