Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Commit

Permalink
Fix for majorLabels showing wrong dates (almende#3573)
Browse files Browse the repository at this point in the history
  • Loading branch information
knokit authored and mojoaxel committed Jun 9, 2019
1 parent 08dcc71 commit 58f8c93
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/timeline/TimeStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ TimeStep.prototype.next = function() {
* @return {Moment} current The current date
*/
TimeStep.prototype.getCurrent = function() {
return this.current;
return this.current.clone();
};

/**
Expand Down
12 changes: 4 additions & 8 deletions lib/timeline/component/TimeAxis.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,14 @@ TimeAxis.prototype._repaintLabels = function () {
dom.majorTexts = [];
dom.minorTexts = [];

var current; // eslint-disable-line no-unused-vars
var current;
var next;
var x;
var xNext;
var isMajor;
var nextIsMajor; // eslint-disable-line no-unused-vars
var showMinorGrid;
var width = 0, prevWidth;
var line;
var labelMinor;
var xFirstMajorLabel = undefined;
var count = 0;
const MAX = 1000;
Expand All @@ -245,14 +243,12 @@ TimeAxis.prototype._repaintLabels = function () {

isMajor = step.isMajor();
className = step.getClassName();
labelMinor = step.getLabelMinor();

current = next;
x = xNext;

step.next();
next = step.getCurrent();
nextIsMajor = step.isMajor();
xNext = this.body.util.toScreen(next);

prevWidth = width;
Expand All @@ -263,7 +259,7 @@ TimeAxis.prototype._repaintLabels = function () {
}

if (this.options.showMinorLabels && showMinorGrid) {
var label = this._repaintMinorText(x, labelMinor, orientation, className);
var label = this._repaintMinorText(x, step.getLabelMinor(current), orientation, className);
label.style.width = width + 'px'; // set width to prevent overflow
}

Expand All @@ -272,7 +268,7 @@ TimeAxis.prototype._repaintLabels = function () {
if (xFirstMajorLabel == undefined) {
xFirstMajorLabel = x;
}
label = this._repaintMajorText(x, step.getLabelMajor(), orientation, className);
label = this._repaintMajorText(x, step.getLabelMajor(current), orientation, className);
}
line = this._repaintMajorLine(x, width, orientation, className);
}
Expand Down Expand Up @@ -427,7 +423,7 @@ TimeAxis.prototype._repaintMinorLine = function (x, width, orientation, classNam
}
line.style.width = width + 'px';



return line;
};
Expand Down

0 comments on commit 58f8c93

Please sign in to comment.