diff --git a/HISTORY.md b/HISTORY.md
index 0f2f49fd..12a4ed0a 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -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
diff --git a/docs/timeline/index.html b/docs/timeline/index.html
index 94da630f..286357ad 100644
--- a/docs/timeline/index.html
+++ b/docs/timeline/index.html
@@ -1529,7 +1529,7 @@ var items = new vis.DataSet([
};
- A full example is available here: 08_manipulation_callbacks.html.
+ A full example is available here: editingItemsCallbacks.html.
Templates
diff --git a/lib/timeline/component/Group.js b/lib/timeline/component/Group.js
index 51761959..8a09e4ae 100644
--- a/lib/timeline/component/Group.js
+++ b/lib/timeline/component/Group.js
@@ -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