Skip to content

Commit

Permalink
fix(timeline.setgroups): nested groups fold correcly when input is ar…
Browse files Browse the repository at this point in the history
…ray (#718)

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

Fixes #113

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

* chore(examples.nestedgroups): revert prev

This reverts commit 1a8fd7e.

Please squash this.

Co-authored-by: Yotam Berkowitz <[email protected]>
  • Loading branch information
strazto and yotamberk authored Oct 24, 2020
1 parent 2822ab4 commit 97d3f16
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/timeline/Timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,18 +340,16 @@ 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 (isDataViewLike("id", groups)) {
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 97d3f16

Please sign in to comment.