Browse Source

Fixed #1441: Height of subgroups not immediately updated after updating data in a DataSet or DataView

fixDataView
jos 8 years ago
parent
commit
6fc2a655d5
2 changed files with 25 additions and 8 deletions
  1. +3
    -0
      HISTORY.md
  2. +22
    -8
      lib/timeline/component/Group.js

+ 3
- 0
HISTORY.md View File

@ -4,7 +4,10 @@ http://visjs.org
## not yet released, version 4.10.1-SNAPSHOT
### Timeline
- Fixed #1441: Height of subgroups not immediately updated after updating
data in a DataSet or DataView.
## 2015-11-27, version 4.10.0

+ 22
- 8
lib/timeline/component/Group.js View File

@ -177,6 +177,9 @@ Group.prototype.redraw = function(range, margin, restack) {
restack = true;
}
// recalculate the height of the subgroups
this._calculateSubGroupHeights();
// reposition visible items vertically
if (typeof this.itemSet.options.order === 'function') {
// a custom order function
@ -244,6 +247,25 @@ Group.prototype.redraw = function(range, margin, restack) {
return resized;
};
/**
* recalculate the height of the subgroups
* @private
*/
Group.prototype._calculateSubGroupHeights = function () {
if (Object.keys(this.subgroups).length > 0) {
var me = this;
this.resetSubgroups();
util.forEach(this.visibleItems, function (item) {
if (item.data.subgroup !== undefined) {
me.subgroups[item.data.subgroup].height = Math.max(me.subgroups[item.data.subgroup].height, item.height);
me.subgroups[item.data.subgroup].visible = true;
}
});
}
};
/**
* recalculate the height of the group
* @param {{item: {horizontal: number, vertical: number}, axis: number}} margin
@ -254,20 +276,12 @@ Group.prototype._calculateHeight = function (margin) {
// recalculate the height of the group
var height;
var visibleItems = this.visibleItems;
//var visibleSubgroups = [];
//this.visibleSubgroups = 0;
this.resetSubgroups();
var me = this;
if (visibleItems.length > 0) {
var min = visibleItems[0].top;
var max = visibleItems[0].top + visibleItems[0].height;
util.forEach(visibleItems, function (item) {
min = Math.min(min, item.top);
max = Math.max(max, (item.top + item.height));
if (item.data.subgroup !== undefined) {
me.subgroups[item.data.subgroup].height = Math.max(me.subgroups[item.data.subgroup].height,item.height);
me.subgroups[item.data.subgroup].visible = true;
}
});
if (min > margin.axis) {
// there is an empty gap between the lowest item and the axis

Loading…
Cancel
Save