Skip to content

A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.

feat(app): separate concerns for layouts

dextmorgn2f84a87febec
diff --git a/flowsint-app/public/icons/social_account.svg b/flowsint-app/public/icons/social_account.svg
new file mode 100644
index 00000000..0cec8645
--- /dev/null
+++ b/flowsint-app/public/icons/social_account.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-user-check-icon lucide-user-check"><path d="m16 11 2 2 4-4"/><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/></svg>
\ No newline at end of file
diff --git a/flowsint-app/public/icons/social_profile.svg b/flowsint-app/public/icons/social_profile.svg
deleted file mode 100644
index e45ee0dc..00000000
--- a/flowsint-app/public/icons/social_profile.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="#B8AFE6" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-user-check-icon lucide-user-check"><path d="m16 11 2 2 4-4"/><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/></svg>
\ No newline at end of file
diff --git a/flowsint-app/public/icons/username.svg b/flowsint-app/public/icons/username.svg
new file mode 100644
index 00000000..0cec8645
--- /dev/null
+++ b/flowsint-app/public/icons/username.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-user-check-icon lucide-user-check"><path d="m16 11 2 2 4-4"/><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/></svg>
\ No newline at end of file
diff --git a/flowsint-app/src/components/graphs/graph-viewer.tsx b/flowsint-app/src/components/graphs/graph-viewer.tsx
index c27a7b15..9ec617ec 100644
--- a/flowsint-app/src/components/graphs/graph-viewer.tsx
+++ b/flowsint-app/src/components/graphs/graph-viewer.tsx
@@ -1,4 +1,3 @@
-import { getDagreLayoutedElements } from '@/lib/utils'
import { useGraphControls } from '@/stores/graph-controls-store'
import { useGraphSettingsStore } from '@/stores/graph-settings-store'
import { useGraphStore } from '@/stores/graph-store'
@@ -11,6 +10,7 @@ import { Info, Plus, Share2, Type, Upload } from 'lucide-react'
import Lasso from './lasso'
import { GraphNode, GraphEdge } from '@/types'
import { useSaveNodePositions } from '@/hooks/use-save-node-positions'
+import { useLayout } from '@/hooks/use-layout'
function truncateText(text: string, limit: number = 16) {
if (text.length <= limit) return text
@@ -162,7 +162,17 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
const hoverFrameRef = useRef<number | null>(null)
// Use the dedicated hook for saving node positions
- const { saveAllNodePositions, markAsStabilized, markAsStabilizing } = useSaveNodePositions(sketchId)
+ const { saveAllNodePositions } = useSaveNodePositions(sketchId)
+
+ // Store selectors (needed before useLayout)
+ const forceSettings = useGraphSettingsStore((s) => s.forceSettings)
+
+ // Use the dedicated hook for layout logic
+ const { applyLayout } = useLayout({
+ forceSettings,
+ containerSize,
+ saveAllNodePositions,
+ })
// The ref for the node weighlist.
const labelRenderingCompound = useRef<LabelRenderingCompound>({
@@ -179,9 +189,6 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
// Store selectors
const nodeColors = useNodesDisplaySettings((s) => s.colors)
const getSize = useNodesDisplaySettings((s) => s.getSize)
-
- // Get settings by categories to avoid re-renders
- const forceSettings = useGraphSettingsStore((s) => s.forceSettings)
const setActions = useGraphControls((s) => s.setActions)
const currentNode = useGraphStore((s) => s.currentNode)
const selectedNodes = useGraphStore((s) => s.selectedNodes)
@@ -405,61 +412,20 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
throw new Error('No nodes available in graph')
}
- // Remove fx and fy from all nodes to allow repositioning
- graphData.nodes.forEach((node: any) => {
- delete node.fx
- delete node.fy
+ // Apply layout using dedicated hook
+ applyLayout({
+ layoutType,
+ nodes: graphData.nodes,
+ edges: graphData.links,
})
- if (layoutType === 'hierarchy') {
- // Apply dagre layout for hierarchical positioning
- const { nodes: layoutedNodes } = getDagreLayoutedElements(
- graphData.nodes,
- graphData.links
- )
-
- // Apply the calculated positions to the graph nodes
- layoutedNodes.forEach((layoutedNode: any) => {
- const graphNode = graphData.nodes.find((n: any) => n.id === layoutedNode.id) as any
- if (graphNode && layoutedNode.x !== undefined && layoutedNode.y !== undefined) {
- graphNode.x = layoutedNode.x
- graphNode.y = layoutedNode.y
- graphNode.fx = layoutedNode.x
- graphNode.fy = layoutedNode.y
- }
- })
-
- // Save all node positions immediately after hierarchy layout (force save)
- saveAllNodePositions(graphData.nodes, true)
- } else {
- // Force layout: reheat the simulation to recalculate positions
- if (typeof graphRef.current.d3ReheatSimulation !== 'function') {
- console.error('[Graph] d3ReheatSimulation method not available')
- throw new Error('d3ReheatSimulation method is not available')
- }
-
- // Mark as stabilizing to prevent saving during force simulation
- markAsStabilizing()
- graphRef.current.d3ReheatSimulation()
-
- // For force layout, save positions after simulation stabilizes
- const warmupTicks = forceSettings?.warmupTicks?.value ?? 0
- const stabilizationTime = warmupTicks * 10 + 1500 // Wait for simulation to stabilize
-
- setTimeout(() => {
- markAsStabilized()
- // Force save all positions after stabilization
- saveAllNodePositions(graphData.nodes, true)
- }, stabilizationTime)
- }
-
// Zoom to fit after a delay to see the new layout
setTimeout(() => {
if (graphRef.current && typeof graphRef.current.zoomToFit === 'function') {
graphRef.current.zoomToFit(400)
}
}, 500)
- }, [graphData, sketchId, forceSettings, saveAllNodePositions, markAsStabilized, markAsStabilizing])
+ }, [graphData, applyLayout])
// Optimized graph initialization callback
const initializeGraph = useCallback(
@@ -964,24 +930,6 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
[forceSettings, theme, highlightLinks, highlightNodes, nodes.length]
)
- // Restart simulation when settings change (debounced)
- useEffect(() => {
- let settingsTimeout: number | undefined
- const restartSimulation = () => {
- if (graphRef.current && isGraphReadyRef.current) {
- if (settingsTimeout) clearTimeout(settingsTimeout)
- settingsTimeout = setTimeout(() => {
- graphRef.current?.d3ReheatSimulation()
- }, 100) as any // Debounce settings changes
- }
- }
- // Restart simulation when force settings change
- restartSimulation()
- return () => {
- if (settingsTimeout) clearTimeout(settingsTimeout)
- }
- }, [forceSettings])
-
// Clear highlights when graph data changes
useEffect(() => {
setHighlightNodes(new Set())
@@ -998,23 +946,6 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
}
}, [])
- // Mark graph as stabilizing on initial load
- useEffect(() => {
- const warmupTicks = forceSettings?.warmupTicks?.value ?? 0
- if (warmupTicks > 0) {
- markAsStabilizing()
- // Wait for warmup + a small buffer to ensure graph has stabilized
- const timeout = setTimeout(() => {
- markAsStabilized()
- }, warmupTicks * 10 + 500) // Approximate time for warmup ticks
-
- return () => clearTimeout(timeout)
- } else {
- // No warmup, mark as stabilized immediately
- markAsStabilized()
- }
- }, [forceSettings?.warmupTicks?.value, nodes.length, edges.length, markAsStabilized, markAsStabilizing])
-
// Empty state
if (!nodes.length) {
return (
diff --git a/flowsint-app/src/components/graphs/settings.tsx b/flowsint-app/src/components/graphs/settings.tsx
index 997c86eb..6651f162 100644
--- a/flowsint-app/src/components/graphs/settings.tsx
+++ b/flowsint-app/src/components/graphs/settings.tsx
@@ -378,7 +378,10 @@ function DynamicSection({ categoryId, category, title, description }: DynamicSec
key={presetName}
variant="outline"
size="sm"
- onClick={() => applyPreset(presetName)}
+ onClick={() => {
+ applyPreset(presetName)
+ toast.success('Settings saved')
+ }}
className="justify-start"
>
{presetName}
diff --git a/flowsint-app/src/components/graphs/webgl/hooks/use-force-simulation.ts b/flowsint-app/src/components/graphs/webgl/hooks/use-force-simulation.ts
index a6a72f5b..e9d69a44 100644
--- a/flowsint-app/src/components/graphs/webgl/hooks/use-force-simulation.ts
+++ b/flowsint-app/src/components/graphs/webgl/hooks/use-force-simulation.ts
@@ -13,6 +13,10 @@ interface UseForceSimulationProps {
height: number
nodeColors: Record<ItemType, string>
layoutMode: LayoutMode
+ dagLevelDistance?: number
+ forceLinkDistance?: number
+ forceLinkStrength?: number
+ forceChargeStrength?: number
}
/**
@@ -33,6 +37,10 @@ export function useForceSimulation({
height,
nodeColors,
layoutMode,
+ dagLevelDistance = 50,
+ forceLinkDistance = GRAPH_CONSTANTS.FORCE_LINK_DISTANCE,
+ forceLinkStrength,
+ forceChargeStrength = GRAPH_CONSTANTS.FORCE_CHARGE_STRENGTH,
}: UseForceSimulationProps) {
const [simulationNodes, setSimulationNodes] = useState<SimulationNode[]>([])
const [simulationLinks, setSimulationLinks] = useState<SimulationLink[]>([])
@@ -64,6 +72,7 @@ export function useForceSimulation({
// Use Dagre hierarchical layout
const { nodes: layoutedNodes } = getDagreLayoutedElements(nodes, edges, {
direction: 'TB',
+ dagLevelDistance: dagLevelDistance,
})
simNodes = layoutedNodes.map((node) => prepareNode(node, node.x || 0, node.y || 0))
} else if (layoutMode === 'none') {
@@ -116,14 +125,18 @@ export function useForceSimulation({
// Create D3 force simulation only for force layout
if (layoutMode === 'force') {
+ const linkForce = forceLink(simLinks)
+ .id((d: any) => d.id)
+ .distance(forceLinkDistance)
+
+ // Apply link strength if provided (for fixed distance links)
+ if (forceLinkStrength !== undefined) {
+ linkForce.strength(forceLinkStrength)
+ }
+
const simulation = forceSimulation(simNodes)
- .force(
- 'link',
- forceLink(simLinks)
- .id((d: any) => d.id)
- .distance(GRAPH_CONSTANTS.FORCE_LINK_DISTANCE)
- )
- .force('charge', forceManyBody().strength(GRAPH_CONSTANTS.FORCE_CHARGE_STRENGTH))
+ .force('link', linkForce)
+ .force('charge', forceManyBody().strength(forceChargeStrength))
.force('center', forceCenter(width / 2, height / 2))
simulationRef.current = simulation
@@ -139,7 +152,18 @@ export function useForceSimulation({
simulationRef.current = null
}
}
- }, [nodes, edges, width, height, nodeColors, layoutMode])
+ }, [
+ nodes,
+ edges,
+ width,
+ height,
+ nodeColors,
+ layoutMode,
+ dagLevelDistance,
+ forceLinkDistance,
+ forceLinkStrength,
+ forceChargeStrength,
+ ])
return {
simulationNodes,
diff --git a/flowsint-app/src/components/graphs/webgl/index.tsx b/flowsint-app/src/components/graphs/webgl/index.tsx
index 7d69d746..d0ac7f64 100644
--- a/flowsint-app/src/components/graphs/webgl/index.tsx
+++ b/flowsint-app/src/components/graphs/webgl/index.tsx
@@ -73,6 +73,10 @@ const WebGLGraphViewer: React.FC<WebGLGraphViewerProps> = ({
height: dimensions.height,
nodeColors,
layoutMode,
+ dagLevelDistance: forceSettings.dagLevelDistance?.value,
+ forceLinkDistance: forceSettings.d3ForceLinkDistance?.value,
+ forceLinkStrength: forceSettings.d3ForceLinkStrength?.value,
+ forceChargeStrength: forceSettings.d3ForceChargeStrength?.value,
})
// Graph interactions (hover, click, drag)
diff --git a/flowsint-app/src/hooks/use-layout.ts b/flowsint-app/src/hooks/use-layout.ts
new file mode 100644
index 00000000..1305771a
--- /dev/null
+++ b/flowsint-app/src/hooks/use-layout.ts
@@ -0,0 +1,84 @@
+import { useCallback } from 'react'
+import { getDagreLayoutedElements, getForceLayoutedElements } from '@/lib/utils'
+import { GraphNode, GraphEdge } from '@/types'
+
+interface UseLayoutProps {
+ forceSettings: any
+ containerSize: { width: number; height: number }
+ saveAllNodePositions: (nodes: any[], force?: boolean) => void
+}
+
+interface LayoutOptions {
+ layoutType: 'force' | 'hierarchy'
+ nodes: GraphNode[]
+ edges: GraphEdge[]
+}
+
+export function useLayout({
+ forceSettings,
+ containerSize,
+ saveAllNodePositions,
+}: UseLayoutProps) {
+ const applyLayout = useCallback(
+ ({ layoutType, nodes, edges }: LayoutOptions) => {
+ // Remove fx and fy from all nodes to allow repositioning
+ nodes.forEach((node: any) => {
+ delete node.fx
+ delete node.fy
+ })
+
+ if (layoutType === 'hierarchy') {
+ // Apply dagre layout for hierarchical positioning
+ const { nodes: layoutedNodes } = getDagreLayoutedElements(nodes, edges, {
+ dagLevelDistance: forceSettings.dagLevelDistance?.value ?? 50,
+ })
+
+ // Apply the calculated positions to the graph nodes
+ layoutedNodes.forEach((layoutedNode: any) => {
+ const graphNode = nodes.find((n: any) => n.id === layoutedNode.id) as any
+ if (graphNode && layoutedNode.x !== undefined && layoutedNode.y !== undefined) {
+ graphNode.x = layoutedNode.x
+ graphNode.y = layoutedNode.y
+ graphNode.fx = layoutedNode.x
+ graphNode.fy = layoutedNode.y
+ }
+ })
+
+ // Save all node positions immediately after hierarchy layout
+ saveAllNodePositions(nodes, true)
+ } else {
+ // Force layout: calculate positions using D3-force
+ const { nodes: layoutedNodes } = getForceLayoutedElements(nodes, edges, {
+ width: containerSize.width || 800,
+ height: containerSize.height || 600,
+ chargeStrength: forceSettings.d3ForceChargeStrength?.value ?? -30,
+ linkDistance: forceSettings.d3ForceLinkDistance?.value ?? 30,
+ linkStrength: forceSettings.d3ForceLinkStrength?.value ?? 2,
+ alphaDecay: forceSettings.d3AlphaDecay?.value ?? 0.045,
+ alphaMin: forceSettings.d3AlphaMin?.value ?? 0,
+ velocityDecay: forceSettings.d3VelocityDecay?.value ?? 0.41,
+ iterations: forceSettings.cooldownTicks?.value ?? 300,
+ })
+
+ // Apply the calculated positions to the graph nodes
+ layoutedNodes.forEach((layoutedNode: any) => {
+ const graphNode = nodes.find((n: any) => n.id === layoutedNode.id) as any
+ if (graphNode && layoutedNode.x !== undefined && layoutedNode.y !== undefined) {
+ graphNode.x = layoutedNode.x
+ graphNode.y = layoutedNode.y
+ graphNode.fx = layoutedNode.x
+ graphNode.fy = layoutedNode.y
+ }
+ })
+
+ // Save all node positions immediately after force layout
+ saveAllNodePositions(nodes, true)
+ }
+
+ return nodes
+ },
+ [forceSettings, containerSize, saveAllNodePositions]
+ )
+
+ return { applyLayout }
+}
diff --git a/flowsint-app/src/lib/utils.ts b/flowsint-app/src/lib/utils.ts
index 4f51ae23..e62cb3e4 100644
--- a/flowsint-app/src/lib/utils.ts
+++ b/flowsint-app/src/lib/utils.ts
@@ -3,6 +3,7 @@ import { twMerge } from "tailwind-merge"
import Dagre from '@dagrejs/dagre';
import { GraphEdge, GraphNode } from '@/types';
import { FlowEdge, FlowNode } from "@/stores/flow-store";
+import { forceSimulation, forceLink, forceManyBody, forceCenter } from 'd3-force';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
@@ -13,6 +14,19 @@ interface LayoutOptions {
strength?: number;
distance?: number;
iterations?: number;
+ dagLevelDistance?: number;
+}
+
+interface ForceLayoutOptions {
+ width?: number;
+ height?: number;
+ chargeStrength?: number;
+ linkDistance?: number;
+ linkStrength?: number;
+ alphaDecay?: number;
+ alphaMin?: number;
+ velocityDecay?: number;
+ iterations?: number;
}
// dagre layout function for the main graph component.
@@ -23,15 +37,19 @@ export const getDagreLayoutedElements = (nodes: GraphNode[],
strength: -300,
distance: 10,
iterations: 300,
+ dagLevelDistance: 50,
},) => {
const g = new Dagre.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
+ // Use dagLevelDistance for both node and rank separation
+ const levelDistance = options.dagLevelDistance ?? 50;
+
// Configure dagre with proper spacing
g.setGraph({
rankdir: options.direction,
- nodesep: 10, // Horizontal spacing between nodes
- ranksep: 20, // Vertical spacing between ranks
+ nodesep: levelDistance, // Horizontal spacing between nodes (fixed distance)
+ ranksep: levelDistance, // Vertical spacing between ranks (fixed distance)
marginx: 10,
marginy: 10
});
@@ -69,6 +87,79 @@ export const getDagreLayoutedElements = (nodes: GraphNode[],
};
};
+// force layout function for the main graph component
+export const getForceLayoutedElements = (
+ nodes: GraphNode[],
+ edges: GraphEdge[],
+ options: ForceLayoutOptions = {
+ width: 800,
+ height: 600,
+ chargeStrength: -30,
+ linkDistance: 30,
+ linkStrength: 2,
+ alphaDecay: 0.045,
+ alphaMin: 0,
+ velocityDecay: 0.41,
+ iterations: 300,
+ }
+) => {
+ const {
+ width = 800,
+ height = 600,
+ chargeStrength = -30,
+ linkDistance = 30,
+ linkStrength = 2,
+ alphaDecay = 0.045,
+ alphaMin = 0,
+ velocityDecay = 0.41,
+ iterations = 300,
+ } = options;
+
+ // Create simulation nodes with initial random positions
+ const simNodes = nodes.map((node) => ({
+ ...node,
+ x: node.x ?? Math.random() * width,
+ y: node.y ?? Math.random() * height,
+ }));
+
+ // Create simulation links
+ const simLinks = edges.map((edge) => ({
+ source: typeof edge.source === 'object' ? edge.source.id : edge.source,
+ target: typeof edge.target === 'object' ? edge.target.id : edge.target,
+ }));
+
+ // Create D3 force simulation
+ const simulation = forceSimulation(simNodes as any)
+ .force(
+ 'link',
+ forceLink(simLinks)
+ .id((d: any) => d.id)
+ .distance(linkDistance)
+ .strength(linkStrength)
+ )
+ .force('charge', forceManyBody().strength(chargeStrength))
+ .force('center', forceCenter(width / 2, height / 2))
+ .alphaDecay(alphaDecay)
+ .alphaMin(alphaMin)
+ .velocityDecay(velocityDecay);
+
+ // Run simulation synchronously for specified iterations
+ for (let i = 0; i < iterations; i++) {
+ simulation.tick();
+ }
+
+ simulation.stop();
+
+ return {
+ nodes: simNodes.map((node) => ({
+ ...node,
+ x: node.x,
+ y: node.y,
+ })),
+ edges,
+ };
+};
+
// dagre layout function for the flow component.
export const getFlowDagreLayoutedElements = (nodes: FlowNode[],
edges: FlowEdge[],
diff --git a/flowsint-app/src/stores/graph-settings-store.ts b/flowsint-app/src/stores/graph-settings-store.ts
index 6b2343cb..9c470103 100644
--- a/flowsint-app/src/stores/graph-settings-store.ts
+++ b/flowsint-app/src/stores/graph-settings-store.ts
@@ -53,6 +53,33 @@ const DEFAULT_SETTINGS = {
description:
'Distance between different graph depths when using DAG (directed acyclic graph) layout mode'
},
+ d3ForceChargeStrength: {
+ type: 'number',
+ value: -120,
+ min: -500,
+ max: 0,
+ step: 5,
+ description:
+ 'Strength of repulsion between nodes (negative = repel, more negative = stronger repulsion, nodes further apart)'
+ },
+ d3ForceLinkDistance: {
+ type: 'number',
+ value: 50,
+ min: 10,
+ max: 2000,
+ step: 50,
+ description:
+ 'Target distance between connected nodes (higher = nodes further apart)'
+ },
+ d3ForceLinkStrength: {
+ type: 'number',
+ value: 2,
+ min: 0,
+ max: 2,
+ step: 0.1,
+ description:
+ 'Strength of links to maintain their target distance (higher = more rigid links, nodes stay closer to target distance, 2 = fixed distance)'
+ },
linkDirectionalArrowRelPos: {
type: 'number',
value: 1,
@@ -97,7 +124,7 @@ const DEFAULT_SETTINGS = {
},
d3AlphaDecay: {
type: 'number',
- value: 0.045,
+ value: 0.06,
min: 0,
max: 0.3,
step: 0.005,
@@ -115,7 +142,7 @@ const DEFAULT_SETTINGS = {
},
d3VelocityDecay: {
type: 'number',
- value: 0.41,
+ value: 0.6,
min: 0,
max: 1,
step: 0.01,
@@ -134,35 +161,55 @@ const DEFAULT_SETTINGS = {
}
}
-// Force Presets
+// Force Presets - Include all relevant force simulation parameters
const FORCE_PRESETS = {
'Tight Clusters': {
d3AlphaDecay: 0.1,
+ d3AlphaMin: 0.001,
d3VelocityDecay: 0.8,
+ d3ForceChargeStrength: -50,
+ d3ForceLinkDistance: 20,
+ d3ForceLinkStrength: 2,
cooldownTicks: 300,
cooldownTime: 20000
},
'Compact Network': {
d3AlphaDecay: 0.08,
+ d3AlphaMin: 0.001,
d3VelocityDecay: 0.7,
+ d3ForceChargeStrength: -80,
+ d3ForceLinkDistance: 30,
+ d3ForceLinkStrength: 2,
cooldownTicks: 250,
cooldownTime: 18000
},
'Balanced Layout': {
d3AlphaDecay: 0.06,
+ d3AlphaMin: 0,
d3VelocityDecay: 0.6,
+ d3ForceChargeStrength: -120,
+ d3ForceLinkDistance: 50,
+ d3ForceLinkStrength: 2,
cooldownTicks: 200,
cooldownTime: 15000
},
'Loose Organic': {
d3AlphaDecay: 0.04,
+ d3AlphaMin: 0,
d3VelocityDecay: 0.4,
+ d3ForceChargeStrength: -200,
+ d3ForceLinkDistance: 80,
+ d3ForceLinkStrength: 2,
cooldownTicks: 150,
cooldownTime: 12000
},
'High Energy': {
d3AlphaDecay: 0.02,
+ d3AlphaMin: 0,
d3VelocityDecay: 0.3,
+ d3ForceChargeStrength: -300,
+ d3ForceLinkDistance: 120,
+ d3ForceLinkStrength: 2,
cooldownTicks: 100,
cooldownTime: 10000
}
@@ -209,7 +256,7 @@ export const useGraphSettingsStore = create<GraphGeneralSettingsStore>()(
(set, get) => ({
// Settings state
settings: DEFAULT_SETTINGS,
- currentPreset: null,
+ currentPreset: 'Balanced Layout',
forceSettings: DEFAULT_SETTINGS.graph,
// UI State
settingsModalOpen: false,
@@ -251,7 +298,7 @@ export const useGraphSettingsStore = create<GraphGeneralSettingsStore>()(
set({
settings: DEFAULT_SETTINGS,
forceSettings: DEFAULT_SETTINGS.graph,
- currentPreset: null
+ currentPreset: 'Balanced Layout'
}),
getSettings: () => {
@@ -284,13 +331,15 @@ export const useGraphSettingsStore = create<GraphGeneralSettingsStore>()(
if (!preset) return
set((state) => {
- const newSettings = { ...state.settings } as any
+ // Create completely new objects with new references
+ const newGraphSettings = { ...state.settings.graph } as any
const newForceSettings = { ...state.forceSettings } as any
+ // Update each preset value, creating new objects for each setting
Object.entries(preset).forEach(([key, value]) => {
- if (newSettings.graph[key]) {
- newSettings.graph[key] = {
- ...newSettings.graph[key],
+ if (newGraphSettings[key]) {
+ newGraphSettings[key] = {
+ ...newGraphSettings[key],
value: value
}
}
@@ -302,6 +351,12 @@ export const useGraphSettingsStore = create<GraphGeneralSettingsStore>()(
}
})
+ // Create new settings object with new graph reference
+ const newSettings = {
+ ...state.settings,
+ graph: newGraphSettings
+ }
+
return {
settings: newSettings,
forceSettings: newForceSettings,
diff --git a/flowsint-app/src/stores/node-display-settings.ts b/flowsint-app/src/stores/node-display-settings.ts
index 2760fb9a..46dd5b73 100644
--- a/flowsint-app/src/stores/node-display-settings.ts
+++ b/flowsint-app/src/stores/node-display-settings.ts
@@ -7,7 +7,7 @@ export type ItemType =
| 'location'
| 'email'
| 'ip'
- | 'social_profile'
+ | 'social_account'
| 'organization'
| 'vehicle'
| 'car'
@@ -63,7 +63,7 @@ export const ITEM_TYPES: ItemType[] = [
'location',
'email',
'ip',
- 'social_profile',
+ 'social_account',
'organization',
'vehicle',
'car',
@@ -119,7 +119,7 @@ const DEFAULT_COLORS: Record<ItemType, string> = {
location: '#E57373', // rouge rosé
email: '#8E7CC3', // violet pastel
ip: '#5AA1C8', // orange chaud
- social_profile: '#A76DAA', // mauve
+ social_account: '#A76DAA', // mauve
organization: '#BCA18A', // taupe clair
vehicle: '#E1B84D', // jaune doux
car: '#BFAF7A', // olive beige
@@ -176,7 +176,7 @@ const DEFAULT_ICONS: Record<ItemType, string> = {
location: '🏠',
email: '✉️',
ip: '🌐',
- social_profile: '📱',
+ social_account: '📱',
organization: '🏢',
vehicle: '🚗',
car: '🚗',
@@ -232,7 +232,7 @@ const DEFAULT_SIZES: Record<ItemType, number> = {
location: 14, // Medium
email: 14, // Medium
ip: 16, // Medium-large
- social_profile: 14, // Medium
+ social_account: 14, // Medium
organization: 28, // Very large - important entities
vehicle: 12, // Small-medium
car: 12, // Small-medium