From a002f611332b47a46f01dde1fc94e885d8521939 Mon Sep 17 00:00:00 2001 From: jos Date: Thu, 1 May 2014 14:05:14 +0200 Subject: [PATCH] Fixed zero height of itemSet in case of no DataSet for items --- HISTORY.md | 12 ++++++------ src/timeline/component/Group.js | 10 +--------- src/timeline/component/ItemSet.js | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 1df68f3d..cd5b9f0a 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -17,19 +17,19 @@ http://visjs.org - Fixed initial visible window in case items exceed `zoomMax`. Thanks @Remper. - Option `order` is now deprecated. This was needed for performance improvements. - Fixed an offset in newly created items when using groups. -- Minor bug fixes. - More examples added. - -### DataSet - -- A DataSet can now be constructed with initial data, like - `new DataSet(data, options)`. +- Minor bug fixes. ### Graph - added recalculate hierarchical layout to update node event. - added arrowScaleFactor to scale the arrows on the edges. +### DataSet + +- A DataSet can now be constructed with initial data, like + `new DataSet(data, options)`. + ## 2014-04-18, version 0.7.4 diff --git a/src/timeline/component/Group.js b/src/timeline/component/Group.js index 6f3c6820..b8d6df9b 100644 --- a/src/timeline/component/Group.js +++ b/src/timeline/component/Group.js @@ -113,21 +113,13 @@ Group.prototype.getLabelWidth = function getLabelWidth() { /** * Repaint this group * @param {{start: number, end: number}} range - * @param {number | {item: number, axis: number}} margin + * @param {{item: number, axis: number}} margin * @param {boolean} [restack=false] Force restacking of all items * @return {boolean} Returns true if the group is resized */ Group.prototype.repaint = function repaint(range, margin, restack) { var resized = false; - if (typeof margin === 'number') { - margin = { - item: margin, - axis: margin - }; - } - - // update visible items this.visibleItems = this._updateVisibleItems(this.orderedItems, this.visibleItems, range); // reposition visible items vertically diff --git a/src/timeline/component/ItemSet.js b/src/timeline/component/ItemSet.js index 302e6414..e4651239 100644 --- a/src/timeline/component/ItemSet.js +++ b/src/timeline/component/ItemSet.js @@ -287,6 +287,14 @@ ItemSet.prototype.repaint = function repaint() { resized = false, frame = this.frame; + // TODO: document this feature to specify one margin for both item and axis distance + if (typeof margin === 'number') { + margin = { + item: margin, + axis: margin + }; + } + // update className frame.className = 'itemset' + (options.className ? (' ' + asString(options.className)) : ''); @@ -297,12 +305,14 @@ ItemSet.prototype.repaint = function repaint() { this.lastWidth = this.width; // repaint all groups - var restack = zoomed || this.stackDirty; - var height = 0; + var restack = zoomed || this.stackDirty, + height = 0, + minHeight = margin.axis + margin.item; util.forEach(this.groups, function (group) { resized = group.repaint(range, margin, restack) || resized; height += group.height; }); + height = Math.max(height, minHeight); this.stackDirty = false; // reorder the groups (if needed)