summaryrefslogtreecommitdiff
path: root/components/Graph/drawLabels.ts
diff options
context:
space:
mode:
authorThomas F. K. Jorna <[email protected]>2022-09-27 15:09:17 +0200
committerThomas F. K. Jorna <[email protected]>2022-09-27 15:09:17 +0200
commita575d14b6621d5464d33d52ca642f2db70c3e370 (patch)
tree5a1d38227a93b1bf2b152ed4af5820a59c34cf91 /components/Graph/drawLabels.ts
parentfa84c052b221d157fa869cd4912acd538b5005a0 (diff)
fix: move a ton of functions to separate files
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)