Skip to content

Commit

Permalink
fix(timeline.setgroups): nested groups fold correcly when input is array
Browse files Browse the repository at this point in the history
Squash of following:

commit 840ca81
Author: Matthew Strasiotto <[email protected]>
Date:   Tue Oct 13 20:46:21 2020 +1100

    chore(examples.nestedgroups): revert prev

    This reverts commit 1a8fd7e.

    Please squash this.

commit 1a8fd7e
Author: Matthew Strasiotto <[email protected]>
Date:   Tue Oct 13 20:45:11 2020 +1100

    chore(examples.nestedgroups): add example to demonstrate fix of visjs#203

commit 5a64274
Author: Matthew Strasiotto <[email protected]>
Date:   Tue Oct 13 20:41:51 2020 +1100

    fix(timeline.setgroups): nested groups fold correcly when input is array

    Fixes visjs#113
  • Loading branch information
strazto committed Oct 13, 2020
1 parent eb1d6b9 commit 0fe0ea8
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/timeline/Timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,18 +341,17 @@ export default class Timeline extends Core {
setGroups(groups) {
// convert to type DataSet when needed
let newDataSet;
const filter = group => group.visible !== false;

if (!groups) {
newDataSet = null;
}
else {
const filter = group => group.visible !== false;
if (groups instanceof DataSet || groups instanceof DataView) {
newDataSet = new DataView(groups,{filter});
}
else {
// turn an array into a dataset
newDataSet = new DataSet(groups.filter(filter));
}
// If groups is array, turn to DataSet & build dataview from that
if (groups instanceof Array) groups = new DataSet(groups);

newDataSet = new DataView(groups,{filter});

}

// This looks weird but it's necessary to prevent memory leaks.
Expand Down

0 comments on commit 0fe0ea8

Please sign in to comment.