0

The options for my Vis timeline are as follows...

var options = {

    height: '150px',
    min: start.add(-3, 'M'),
    max: finish.add(3, 'M'),
    start: start,
    end: finish,
    zoomMin: 21600000
};

I'm finding that with this config, start and finish are ignored and the initial visible period is bounded by min and max.

If I remove min and max, then the initial visible period is start and end, except that the min and max are thousands of years in the past and future.

How do I use both of these sets of properties at the same time?

YakovL
  • 7,557
  • 12
  • 62
  • 102
Ian Warburton
  • 15,170
  • 23
  • 107
  • 189

1 Answers1

2

Vis is not the problem here but moment.js. The documentation for the add method says:

Mutates the original moment by adding time.

So the adding is made in place and basically when you call it to set min and max, this also does it for the start and end.

To solve this, you can either initialize two objects when you create your start and finish object or you can go with some other workaround like is suggested here.

João Menighin
  • 3,083
  • 6
  • 38
  • 80
  • I've tried using `clone()` like this... `start.clone().add(-3, 'M')` but it's having no effect. – Ian Warburton Apr 23 '18 at 17:03
  • Try making it outside your options object and assign it to variables. Then print to see what dates it is getting. If you make a fiddle I can help you with that. – João Menighin Apr 23 '18 at 17:08
  • Instead of adding a negative value, consider using substract: https://momentjs.com/docs/#/manipulating/subtract/ – Jogai Apr 24 '18 at 09:48