Skip to content

Commit

Permalink
Merge branch 'develop' into fix/node-fill-color
Browse files Browse the repository at this point in the history
  • Loading branch information
pverscha committed Apr 29, 2021
2 parents bad3753 + 4f18409 commit def8e81
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions dist/unipept-visualizations.js

Large diffs are not rendered by default.

23 changes: 13 additions & 10 deletions src/visualizations/treeview/Treeview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,19 @@ export default class Treeview {
private initialExpand(root: HPN<TreeviewNode>): void {
if (!this.settings.enableAutoExpand) {
root.data.expand(this.settings.levelsToExpand);
} else {
root.data.expand(1);
let allowedCount = root.data.count * (this.settings.enableAutoExpand ? this.settings.autoExpandValue : 0.8);
const pq = new MaxCountHeap<HPN<TreeviewNode>>(root.children, (a: HPN<TreeviewNode>, b: HPN<TreeviewNode>) => b.data.count - a.data.count);
while (allowedCount > 0 && pq.size() > 0) {
const toExpand = pq.remove();
allowedCount -= toExpand.data.count;
toExpand.data.expand(1);
toExpand.children?.forEach((d: HPN<TreeviewNode>, i: number) => pq.add(d));
}
return;
}

root.data.expand(1);
let allowedCount = root.data.count * (this.settings.enableAutoExpand ? this.settings.autoExpandValue : 0.8);
const pq = new MaxCountHeap<HPN<TreeviewNode>>([...(root.children || [])], (a: HPN<TreeviewNode>, b: HPN<TreeviewNode>) => b.data.count - a.data.count);
while (allowedCount > 0 && pq.size() > 0) {
const toExpand = pq.remove();
allowedCount -= toExpand.data.count;
toExpand.data.expand(1);
toExpand.children?.forEach((d: HPN<TreeviewNode>, i: number) => {
pq.add(d);
});
}
}

Expand Down

0 comments on commit def8e81

Please sign in to comment.