A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
fix(app/graph): entity + link labels as settings
dextmorgn9808af70d086
diff --git a/flowsint-app/src/components/graphs/graph-viewer.tsx b/flowsint-app/src/components/graphs/graph-viewer.tsxindex ef2083ab..4eb35b5e 100644--- a/flowsint-app/src/components/graphs/graph-viewer.tsx+++ b/flowsint-app/src/components/graphs/graph-viewer.tsx@@ -668,10 +668,12 @@ const GraphViewer: React.FC<GraphViewerProps> = ({if (!shouldShowLabel && !isHighlighted) {return}- const fontSize = Math.max(+ const baseFontSize = Math.max(CONSTANTS.MIN_FONT_SIZE,(CONSTANTS.NODE_FONT_SIZE * (size / 2)) / globalScale + 2)+ const nodeLabelSetting = forceSettings.nodeLabelFontSize.value ?? 50+ const fontSize = baseFontSize * (nodeLabelSetting / 100)ctx.font = `${fontSize}px Sans-Serif`// Measure text for background sizing@@ -855,12 +857,14 @@ const GraphViewer: React.FC<GraphViewerProps> = ({if (textAngle > CONSTANTS.HALF_PI || textAngle < -CONSTANTS.HALF_PI) {textAngle += textAngle > 0 ? -CONSTANTS.PI : CONSTANTS.PI}- // Measure and draw label- ctx.font = LABEL_FONT_STRING+ const linkLabelSetting = forceSettings.linkLabelFontSize.value ?? 50+ // Measure and draw label with dynamic font size+ const linkFontSize = CONSTANTS.LABEL_FONT_SIZE * (linkLabelSetting / 100)+ ctx.font = `${linkFontSize}px Sans-Serif`const textWidth = ctx.measureText(link.label).width- const padding = CONSTANTS.LABEL_FONT_SIZE * CONSTANTS.PADDING_RATIO+ const padding = linkFontSize * CONSTANTS.PADDING_RATIOtempDimensions[0] = textWidth + padding- tempDimensions[1] = CONSTANTS.LABEL_FONT_SIZE + padding+ tempDimensions[1] = linkFontSize + paddingconst halfWidth = tempDimensions[0] * 0.5const halfHeight = tempDimensions[1] * 0.5// Batch canvas operations@@ -868,7 +872,7 @@ const GraphViewer: React.FC<GraphViewerProps> = ({ctx.translate(tempPos.x, tempPos.y)ctx.rotate(textAngle)// Draw rounded rectangle background- const borderRadius = CONSTANTS.LABEL_FONT_SIZE * 0.3+ const borderRadius = linkFontSize * 0.3ctx.beginPath()ctx.roundRect(-halfWidth, -halfHeight, tempDimensions[0], tempDimensions[1], borderRadius)// Background with semi-transparency@@ -894,7 +898,7 @@ const GraphViewer: React.FC<GraphViewerProps> = ({ctx.restore()}},- [forceSettings, theme, highlightLinks, highlightNodes]+ [forceSettings, theme, highlightLinks, highlightNodes, nodes.length])// Restart simulation when settings change (debounced)diff --git a/flowsint-app/src/stores/graph-settings-store.ts b/flowsint-app/src/stores/graph-settings-store.tsindex 6708aa7e..9a623454 100644--- a/flowsint-app/src/stores/graph-settings-store.ts+++ b/flowsint-app/src/stores/graph-settings-store.ts@@ -28,6 +28,22 @@ const DEFAULT_SETTINGS = {step: 0.1,description: 'Defines the width of the link between two nodes.'},+ nodeLabelFontSize: {+ type: 'number',+ value: 100,+ min: 50,+ max: 200,+ step: 5,+ description: 'Adjusts the font size of node labels (percentage of base size, scales with zoom)'+ },+ linkLabelFontSize: {+ type: 'number',+ value: 100,+ min: 50,+ max: 200,+ step: 5,+ description: 'Adjusts the font size of link labels (percentage of base size, scales with zoom)'+ },dagLevelDistance: {type: 'number',value: 50,