Browse Source

Fixed #141: a bug in replacing the DataSet of groups via `Timeline.setGroups(groups)`

css_transitions
jos 10 years ago
parent
commit
3d7618baf0
4 changed files with 27 additions and 14 deletions
  1. +1
    -0
      HISTORY.md
  2. +18
    -6
      dist/vis.js
  3. +5
    -5
      dist/vis.min.js
  4. +3
    -3
      src/timeline/component/ItemSet.js

+ 1
- 0
HISTORY.md View File

@ -7,6 +7,7 @@ http://visjs.org
### Timeline
- Some tweaks in snapping dragged items to nice dates.
- Fixed a bug in replacing the DataSet of groups via `Timeline.setGroups(groups)`.
### Graph

+ 18
- 6
dist/vis.js View File

@ -5,7 +5,7 @@
* A dynamic, browser-based visualization library.
*
* @version 1.0.2-SNAPSHOT
* @date 2014-05-20
* @date 2014-05-23
*
* @license
* Copyright (C) 2011-2014 Almende B.V, http://almende.com
@ -2885,8 +2885,7 @@ TimeStep.prototype.snap = function(date) {
clone.setSeconds(0);
clone.setMilliseconds(0);
}
else if (this.scale == TimeStep.SCALE.DAY ||
this.scale == TimeStep.SCALE.WEEKDAY) {
else if (this.scale == TimeStep.SCALE.DAY) {
//noinspection FallthroughInSwitchStatementJS
switch (this.step) {
case 5:
@ -2899,6 +2898,19 @@ TimeStep.prototype.snap = function(date) {
clone.setSeconds(0);
clone.setMilliseconds(0);
}
else if (this.scale == TimeStep.SCALE.WEEKDAY) {
//noinspection FallthroughInSwitchStatementJS
switch (this.step) {
case 5:
case 2:
clone.setHours(Math.round(clone.getHours() / 12) * 12); break;
default:
clone.setHours(Math.round(clone.getHours() / 6) * 6); break;
}
clone.setMinutes(0);
clone.setSeconds(0);
clone.setMilliseconds(0);
}
else if (this.scale == TimeStep.SCALE.HOUR) {
switch (this.step) {
case 4:
@ -5190,7 +5202,8 @@ ItemSet.prototype.setGroups = function setGroups(groups) {
// remove all drawn groups
ids = this.groupsData.getIds();
this._onRemoveGroups(ids);
this.groupsData = null;
this._onRemoveGroups(ids); // note: this will cause a repaint
}
// replace the dataset
@ -5441,8 +5454,7 @@ ItemSet.prototype._orderGroups = function () {
// hide all groups, removes them from the DOM
var groups = this.groups;
groupIds.forEach(function (groupId) {
var group = groups[groupId];
group.hide();
groups[groupId].hide();
});
// show the groups again, attach them to the DOM in correct order

+ 5
- 5
dist/vis.min.js
File diff suppressed because it is too large
View File


+ 3
- 3
src/timeline/component/ItemSet.js View File

@ -519,7 +519,8 @@ ItemSet.prototype.setGroups = function setGroups(groups) {
// remove all drawn groups
ids = this.groupsData.getIds();
this._onRemoveGroups(ids);
this.groupsData = null;
this._onRemoveGroups(ids); // note: this will cause a repaint
}
// replace the dataset
@ -770,8 +771,7 @@ ItemSet.prototype._orderGroups = function () {
// hide all groups, removes them from the DOM
var groups = this.groups;
groupIds.forEach(function (groupId) {
var group = groups[groupId];
group.hide();
groups[groupId].hide();
});
// show the groups again, attach them to the DOM in correct order

Loading…
Cancel
Save