Skip to content

Commit

Permalink
almende#3246 - fix issue when showMajorLabels == false is used with a…
Browse files Browse the repository at this point in the history
… weekly scale. (almende#3305)

* fixes showMajorLabel issue in almende#3246

almende#3246

* fix at TimeStep level, for weekly mode, when showMajorLabels == false

* pass options in TimeStep construction
  • Loading branch information
ponml authored and Primoz Susa committed Jan 3, 2019
1 parent efd2ba5 commit 13d5041
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/timeline/TimeStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var util = require('../util');
* @param {Date} [end] The end date
* @param {Number} [minimumStep] Optional. Minimum step size in milliseconds
*/
function TimeStep(start, end, minimumStep, hiddenDates) {
function TimeStep(start, end, minimumStep, hiddenDates, options) {
this.moment = moment;

// variables
Expand Down Expand Up @@ -58,6 +58,8 @@ function TimeStep(start, end, minimumStep, hiddenDates) {
}

this.format = TimeStep.FORMAT; // default formatting
this.options = options ? options : {};

}

// Time formatting
Expand Down Expand Up @@ -222,6 +224,8 @@ TimeStep.prototype.next = function() {
if (this.current.weekday() !== 0){ // we had a month break not correlating with a week's start before
this.current.weekday(0); // switch back to week cycles
this.current.add(this.step, 'week');
} else if(this.options.showMajorLabels === false) {
this.current.add(this.step, 'week'); // the default case
} else { // first day of the week
var nextWeek = this.current.clone();
nextWeek.add(1, 'week');
Expand Down
2 changes: 1 addition & 1 deletion lib/timeline/component/TimeAxis.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ TimeAxis.prototype._repaintLabels = function () {
var minimumStep = timeLabelsize - DateUtil.getHiddenDurationBefore(this.options.moment, this.body.hiddenDates, this.body.range, timeLabelsize);
minimumStep -= this.body.util.toTime(0).valueOf();

var step = new TimeStep(new Date(start), new Date(end), minimumStep, this.body.hiddenDates);
var step = new TimeStep(new Date(start), new Date(end), minimumStep, this.body.hiddenDates, this.options);
step.setMoment(this.options.moment);
if (this.options.format) {
step.setFormat(this.options.format);
Expand Down

0 comments on commit 13d5041

Please sign in to comment.