Skip to content

Commit

Permalink
Merge branch 'develop' into fix/overwrite-id
Browse files Browse the repository at this point in the history
  • Loading branch information
pverscha committed Apr 30, 2021
2 parents 2de4d0b + 229f31e commit 241f94d
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 21 deletions.
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
examples
docs
.github
jest-setup.js
jest.config.js
snapshotResolver.js
unipept-visualizations.iml
10 changes: 10 additions & 0 deletions dist/test/TestConsts.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export declare type ImageSnapshotSettings = {
comparisonMethod: string;
customSnapshotsDir: string;
customDiffDir: string;
failureThreshold: number;
failureThresholdType: string;
};
export default class TestConsts {
static resolveImageSnapshotFolder(path: string): ImageSnapshotSettings;
}
3 changes: 3 additions & 0 deletions dist/test/TestDataGenerator.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default class TestDataGenerator {
generateSmall2DDataset(): number[][];
}
15 changes: 15 additions & 0 deletions dist/test/TestUtils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export declare function sleep(ms: number): Promise<unknown>;
/**
* This function waits a specified amount of time for promises to be fullfilled before returning.
*
* @param ms How many ms should we wait before continueing test execution?
*/
export declare function waitForPromises(ms: number): Promise<void>;
/**
* This function returns only when the given condition evaluates to true, or when the given timeout has been exceeded.
*
* @param condition
* @param timeout
* @param interval
*/
export declare function waitForCondition(condition: () => boolean, timeout?: number, interval?: number): Promise<void>;
4 changes: 2 additions & 2 deletions dist/unipept-visualizations.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unipept-visualizations",
"version": "2.0.6",
"version": "2.0.7",
"description": "The Unipept visualisation library",
"homepage": "https://github.com/unipept/unipept-visualizations",
"bugs": "https://github.com/unipept/unipept-visualizations/issues",
Expand Down
8 changes: 4 additions & 4 deletions src/visualizations/heatmap/HeatmapSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,22 @@ export default class HeatmapSettings extends Settings {
) => string = (value: HeatmapValue, row: HeatmapFeature, column: HeatmapFeature) => {
return `
<style>
.tooltip {
.unipept-tooltip {
padding: 10px;
border-radius: 5px;
background: rgba(0, 0, 0, 0.8);
color: #fff;
}
.tooltip div,a {
.unipept-tooltip div, .unipept-tooltip a {
font-family: Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.tooltip div {
.unipept-tooltip div {
font-weight: bold;
}
</style>
<div class="tooltip">
<div class="unipept-tooltip">
<div>
${this.getTooltipTitle(value, row, column)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/visualizations/sunburst/SunburstSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default class SunburstSettings extends Settings {
color: #fff;
}
.unipept-tooltip div,a {
.unipept-tooltip div, .unipept-tooltip a {
font-family: Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
Expand Down
2 changes: 1 addition & 1 deletion src/visualizations/treemap/TreemapSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default class TreemapSettings extends Settings {
color: #fff;
}
.unipept-tooltip div,a {
.unipept-tooltip div, .unipept-tooltip a {
font-family: Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
Expand Down
25 changes: 14 additions & 11 deletions src/visualizations/treeview/Treeview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,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 Expand Up @@ -225,7 +228,7 @@ export default class Treeview {
// Animate the fill and stroke of each circle (these circles make up the nodes that are rendered).
nodeUpdate.select("circle")
.attr("r", (d: HPN<TreeviewNode>) => this.computeNodeSize(d))
.style("fill-opacity", (d: HPN<TreeviewNode>) => d.data.isCollapsed() ? 1 : 0)
.style("fill-opacity", (d: HPN<TreeviewNode>) => d.children && d.children[0].data.isCollapsed() ? 1 : 0)
.style("stroke", (d: HPN<TreeviewNode>) => this.settings.nodeStrokeColor(d.data))
.style("fill", (d: HPN<TreeviewNode>) => this.settings.nodeFillColor(d.data));

Expand Down
2 changes: 1 addition & 1 deletion src/visualizations/treeview/TreeviewSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default class TreeviewSettings extends Settings {
color: #fff;
}
.unipept-tooltip div,a {
.unipept-tooltip div, .unipept-tooltip a {
font-family: Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
Expand Down

0 comments on commit 241f94d

Please sign in to comment.