Browse Source

fixed snapping of minimum steps with hidden dates

v3_develop
Alex de Mulder 10 years ago
parent
commit
0803da355c
4 changed files with 43 additions and 23 deletions
  1. +22
    -12
      dist/vis.js
  2. +12
    -7
      lib/timeline/DateUtil.js
  3. +2
    -0
      lib/timeline/TimeStep.js
  4. +7
    -4
      lib/timeline/component/TimeAxis.js

+ 22
- 12
dist/vis.js View File

@ -5,7 +5,7 @@
* A dynamic, browser-based visualization library.
*
* @version 3.5.0
* @date 2014-10-13
* @date 2014-10-14
*
* @license
* Copyright (C) 2011-2014 Almende B.V, http://almende.com
@ -12860,7 +12860,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
var duration = exports.getHiddenDuration(Core.body.hiddenDates, Core.range);
time = exports.getHiddenTimeBefore(Core.body.hiddenDates, Core.range, time);
time = exports.correctTimeForHidden(Core.body.hiddenDates, Core.range, time);
var conversion = Core.range.conversion(width, duration);
return (time.valueOf() - conversion.offset) * conversion.scale;
@ -12914,7 +12914,13 @@ return /******/ (function(modules) { // webpackBootstrap
* @param time
* @returns {{duration: number, time: *, offset: number}}
*/
exports.getHiddenTimeBefore = function(hiddenDates, range, time) {
exports.correctTimeForHidden = function(hiddenDates, range, time) {
time = moment(time).toDate().valueOf();
time -= exports.getHiddenDurationBefore(hiddenDates,range,time);
return time;
};
exports.getHiddenDurationBefore = function(hiddenDates, range, time) {
var timeOffset = 0;
time = moment(time).toDate().valueOf();
@ -12928,12 +12934,12 @@ return /******/ (function(modules) { // webpackBootstrap
}
}
}
time -= timeOffset;
return time;
};
return timeOffset;
}
/**
* Support function
* sum the duration from start to finish, including the hidden duration,
* until the required amount has been reached, return the accumulated hidden duration
* @param hiddenDates
* @param range
* @param time
@ -12950,7 +12956,6 @@ return /******/ (function(modules) { // webpackBootstrap
// if time after the cutout, and the
if (startDate >= range.start && endDate < range.end) {
duration += startDate - previousPoint;
previousPoint = endDate;
if (duration >= requiredDuration) {
break;
@ -14055,10 +14060,13 @@ return /******/ (function(modules) { // webpackBootstrap
var orientation = this.options.orientation;
// calculate range and step (step such that we have space for 7 characters per label)
var start = util.convert(this.body.range.start, 'Number'),
end = util.convert(this.body.range.end, 'Number'),
minimumStep = this.body.util.toTime((this.props.minorCharWidth || 10) * 7).valueOf()
-this.body.util.toTime(0).valueOf();
var start = util.convert(this.body.range.start, 'Number');
var end = util.convert(this.body.range.end, 'Number');
var timeLabelsize = this.body.util.toTime((this.props.minorCharWidth || 10) * 7).valueOf();
var minimumStep = DateUtil.getHiddenDurationBefore(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);
this.step = step;
@ -14549,6 +14557,8 @@ return /******/ (function(modules) { // webpackBootstrap
return;
}
//var b = asc + ds;
var stepYear = (1000 * 60 * 60 * 24 * 30 * 12);
var stepMonth = (1000 * 60 * 60 * 24 * 30);
var stepDay = (1000 * 60 * 60 * 24);

+ 12
- 7
lib/timeline/DateUtil.js View File

@ -281,7 +281,7 @@ exports.toScreen = function(Core, time, width) {
}
var duration = exports.getHiddenDuration(Core.body.hiddenDates, Core.range);
time = exports.getHiddenTimeBefore(Core.body.hiddenDates, Core.range, time);
time = exports.correctTimeForHidden(Core.body.hiddenDates, Core.range, time);
var conversion = Core.range.conversion(width, duration);
return (time.valueOf() - conversion.offset) * conversion.scale;
@ -335,7 +335,13 @@ exports.getHiddenDuration = function(hiddenTimes, range) {
* @param time
* @returns {{duration: number, time: *, offset: number}}
*/
exports.getHiddenTimeBefore = function(hiddenDates, range, time) {
exports.correctTimeForHidden = function(hiddenDates, range, time) {
time = moment(time).toDate().valueOf();
time -= exports.getHiddenDurationBefore(hiddenDates,range,time);
return time;
};
exports.getHiddenDurationBefore = function(hiddenDates, range, time) {
var timeOffset = 0;
time = moment(time).toDate().valueOf();
@ -349,12 +355,12 @@ exports.getHiddenTimeBefore = function(hiddenDates, range, time) {
}
}
}
time -= timeOffset;
return time;
};
return timeOffset;
}
/**
* Support function
* sum the duration from start to finish, including the hidden duration,
* until the required amount has been reached, return the accumulated hidden duration
* @param hiddenDates
* @param range
* @param time
@ -371,7 +377,6 @@ exports.getAccumulatedHiddenDuration = function(hiddenDates, range, requiredDura
// if time after the cutout, and the
if (startDate >= range.start && endDate < range.end) {
duration += startDate - previousPoint;
previousPoint = endDate;
if (duration >= requiredDuration) {
break;

+ 2
- 0
lib/timeline/TimeStep.js View File

@ -254,6 +254,8 @@ TimeStep.prototype.setMinimumStep = function(minimumStep) {
return;
}
//var b = asc + ds;
var stepYear = (1000 * 60 * 60 * 24 * 30 * 12);
var stepMonth = (1000 * 60 * 60 * 24 * 30);
var stepDay = (1000 * 60 * 60 * 24);

+ 7
- 4
lib/timeline/component/TimeAxis.js View File

@ -175,10 +175,13 @@ TimeAxis.prototype._repaintLabels = function () {
var orientation = this.options.orientation;
// calculate range and step (step such that we have space for 7 characters per label)
var start = util.convert(this.body.range.start, 'Number'),
end = util.convert(this.body.range.end, 'Number'),
minimumStep = this.body.util.toTime((this.props.minorCharWidth || 10) * 7).valueOf()
-this.body.util.toTime(0).valueOf();
var start = util.convert(this.body.range.start, 'Number');
var end = util.convert(this.body.range.end, 'Number');
var timeLabelsize = this.body.util.toTime((this.props.minorCharWidth || 10) * 7).valueOf();
var minimumStep = DateUtil.getHiddenDurationBefore(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);
this.step = step;

Loading…
Cancel
Save