Skip to content

Commit

Permalink
adding a max size
Browse files Browse the repository at this point in the history
  • Loading branch information
trashhalo committed Jun 28, 2022
1 parent d2b4100 commit 3be9666
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logseq-graph-analysis",
"version": "0.0.5",
"version": "0.0.8",
"type": "module",
"main": "./dist/index.html",
"license": "GPL",
Expand Down
14 changes: 11 additions & 3 deletions src/Sigma.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,20 @@
dispatch("nodeclick", node);
};
const maxSize = (size: number, max: number) => {
if (size > max) {
return max;
} else {
return size;
}
};
const nodeReducer = (node: string, data: Attributes) => {
const res: Partial<NodeDisplayData> = { ...data };
if ($settings.size === "in") {
res.size = Math.max(1, graph.neighbors(node).length / 2);
res.size = maxSize(Math.max(1, graph.neighbors(node).length / 2), 16);
} else if ($settings.size === "out") {
res.size = graph.inDegree(node);
res.size = maxSize(graph.inDegree(node), 16);
}
if ($settings.search && res.label && res.label.includes($settings.search)) {
Expand Down Expand Up @@ -112,7 +120,7 @@
res.color = orange;
} else if (adamicAdarResults[node]) {
res.color = red;
res.size = 5 * adamicAdarResults[node].measure;
res.size = maxSize(5 * adamicAdarResults[node].measure, 16);
res.label = `${adamicAdarResults[node].measure} ${data.label}`;
} else {
res.zIndex = -1;
Expand Down

0 comments on commit 3be9666

Please sign in to comment.