summaryrefslogtreecommitdiff
path: root/components/Graph/drawLabels.ts
diff options
context:
space:
mode:
authorThomas F. K. Jorna <[email protected]>2022-09-27 16:32:13 +0200
committerGitHub <[email protected]>2022-09-27 16:32:13 +0200
commit6f783297f37e95d083b32a7160afcb55e309e883 (patch)
treeaf9fdc3db50ecbc61036d88c81eeea3703ff17cc /components/Graph/drawLabels.ts
parent16a8da9e5107833032893bc4c0680b368ac423ac (diff)
parent1936250b99b8747d841edd83002ed20ec12aa793 (diff)
feat: add ability to add/remove nodes to/from the local graph from emacs
Adds the commands `org-roam-ui-add-to-local-graph` and `org-roam-ui-remove-from-local-graph`
Diffstat (limited to 'components/Graph/drawLabels.ts')
-rw-r--r--components/Graph/drawLabels.ts17
1 files changed, 13 insertions, 4 deletions
diff --git a/components/Graph/drawLabels.ts b/components/Graph/drawLabels.ts
index fa19270..46790e6 100644
--- a/components/Graph/drawLabels.ts
+++ b/components/Graph/drawLabels.ts
@@ -1,8 +1,10 @@
import { OrgRoamNode } from '../../api'
import { NodeObject } from 'force-graph'
import { initialVisuals } from '../config'
-import { hexToRGBA, LinksByNodeId } from '../../pages'
+import { LinksByNodeId } from '../../pages'
import wrap from 'word-wrap'
+import { nodeSize } from '../../util/nodeSize'
+import { hexToRGBA } from '../../util/hexToRGBA'
export interface drawLabelsProps {
labelBackgroundColor: string
@@ -14,7 +16,6 @@ export interface drawLabelsProps {
previouslyHighlightedNodes: { [id: string]: {} }
visuals: typeof initialVisuals
opacity: number
- nodeSize: (node: NodeObject) => number
filteredLinksByNodeId: LinksByNodeId
nodeRel: number
hoverNode: NodeObject | null
@@ -44,7 +45,6 @@ export function drawLabels(props: drawLabelsProps) {
previouslyHighlightedNodes,
visuals,
opacity,
- nodeSize,
filteredLinksByNodeId,
nodeRel,
hoverNode,
@@ -78,7 +78,16 @@ export function drawLabels(props: drawLabelsProps) {
const label = nodeTitle.substring(0, visuals.labelLength)
const nodeS = Math.cbrt(
- (visuals.nodeRel * nodeSize(node)) / Math.pow(globalScale, visuals.nodeZoomSize),
+ (visuals.nodeRel *
+ nodeSize({
+ node,
+ highlightedNodes,
+ linksByNodeId: filteredLinksByNodeId,
+ opacity,
+ previouslyHighlightedNodes,
+ visuals,
+ })) /
+ Math.pow(globalScale, visuals.nodeZoomSize),
)
const fontSize = visuals.labelFontSize / Math.cbrt(Math.pow(globalScale, visuals.nodeZoomSize))
// ? Math.max((visuals.labelFontSize * nodeS) / 2, (visuals.labelFontSize * nodeS) / 3)