Browse Source

#3246 - fix issue when showMajorLabels == false is used with a weekly scale. (#3305)

* fixes showMajorLabel issue in #3246

https://github.com/almende/vis/issues/3246

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

* pass options in TimeStep construction
revert-3409-performance
Chris Sand 7 years ago
committed by Yotam Berkowitz
parent
commit
fbbb2cc730
2 changed files with 6 additions and 2 deletions
  1. +5
    -1
      lib/timeline/TimeStep.js
  2. +1
    -1
      lib/timeline/component/TimeAxis.js

+ 5
- 1
lib/timeline/TimeStep.js View File

@ -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
@ -58,6 +58,8 @@ function TimeStep(start, end, minimumStep, hiddenDates) {
}
this.format = TimeStep.FORMAT; // default formatting
this.options = options ? options : {};
}
// Time formatting
@ -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');

+ 1
- 1
lib/timeline/component/TimeAxis.js View File

@ -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);

Loading…
Cancel
Save