Browse Source

Merge remote-tracking branch 'origin/develop' into develop

fixDataView
Alex de Mulder 9 years ago
parent
commit
7087b2dff9
3 changed files with 26 additions and 9 deletions
  1. +3
    -0
      HISTORY.md
  2. +1
    -1
      docs/timeline/index.html
  3. +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 ## 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 ## 2015-11-27, version 4.10.0

+ 1
- 1
docs/timeline/index.html View File

@ -1529,7 +1529,7 @@ var items = new vis.DataSet([
}; };
</pre> </pre>
A full example is available here: <a href="../../examples/timeline/08_manipulation_callbacks.html">08_manipulation_callbacks.html</a>.
A full example is available here: <a href="../../examples/timeline/editing/editingItemsCallbacks.html">editingItemsCallbacks.html</a>.
<h2 id="Templates">Templates</h2> <h2 id="Templates">Templates</h2>

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

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

Loading…
Cancel
Save