From c7054d71aae5a4b2cc3b3e99f3bccf06d3e2313a Mon Sep 17 00:00:00 2001 From: Pascal Gula Date: Fri, 24 Nov 2017 10:27:13 +0100 Subject: [PATCH] implementation of visibleGroups with a proper example (#3674) --- examples/timeline/groups/visibleGroups.html | 113 ++++++++++++++++++++ lib/timeline/Core.js | 8 ++ lib/timeline/component/ItemSet.js | 19 ++++ 3 files changed, 140 insertions(+) create mode 100644 examples/timeline/groups/visibleGroups.html diff --git a/examples/timeline/groups/visibleGroups.html b/examples/timeline/groups/visibleGroups.html new file mode 100644 index 00000000..5025a23b --- /dev/null +++ b/examples/timeline/groups/visibleGroups.html @@ -0,0 +1,113 @@ + + + + Timeline | A lot of grouped data + + + + + + + + + + +

Timeline visible Groups

+ + +
+

visible groups:

+

+

(Scroll with the mouse and see the items being focus automatically on the timeline)

+
+ +
+
+ + + + + + \ No newline at end of file diff --git a/lib/timeline/Core.js b/lib/timeline/Core.js index 376eacb7..d3652641 100644 --- a/lib/timeline/Core.js +++ b/lib/timeline/Core.js @@ -664,6 +664,14 @@ Core.prototype.getVisibleItems = function() { return this.itemSet && this.itemSet.getVisibleItems() || []; }; +/** + * Get the id's of the currently visible groups. + * @returns {Array} The ids of the visible groups + */ +Core.prototype.getVisibleGroups = function() { + return this.itemSet && this.itemSet.getVisibleGroups() || []; +}; + /** * Set Core window such that it fits all items * @param {Object} [options] Available options: diff --git a/lib/timeline/component/ItemSet.js b/lib/timeline/component/ItemSet.js index ca3d4005..00586826 100644 --- a/lib/timeline/component/ItemSet.js +++ b/lib/timeline/component/ItemSet.js @@ -612,6 +612,25 @@ ItemSet.prototype.getVisibleItems = function() { return ids; }; +/** + * Get the id's of the currently visible groups. + * @returns {Array} The ids of the visible groups + */ +ItemSet.prototype.getVisibleGroups = function() { + var ids = []; + + for (var groupId in this.groups) { + if (this.groups.hasOwnProperty(groupId)) { + var group = this.groups[groupId]; + if (group.isVisible) { + ids.push(groupId) + } + } + } + + return ids; +}; + /** * Deselect a selected item * @param {string | number} id