Skip to content

Commit b669f6c

Browse files
committed
fix: Improve node and edge color distinction in community visualization
- Change edge color to darker gray (slate-500) for better visibility - Add white borders to nodes to distinguish from edges - Increase edge width from 1 to 2 pixels - Increase node size from 16 to 18 pixels - Add thicker node borders (2px) with white color - Improve edge label visibility with dark background - Add hover and selection states for better interactivity
1 parent bec7f02 commit b669f6c

1 file changed

Lines changed: 46 additions & 24 deletions

File tree

frontend/src/components/CommunityVisualization.tsx

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,12 @@ export function CommunityVisualization({
128128
title: node.title || `${node.label} (${node.type})`,
129129
color: {
130130
background: color,
131-
border: color,
131+
border: '#ffffff', // White border to make nodes stand out from edges
132132
highlight: {
133+
background: color,
134+
border: '#fbbf24' // Yellow border when highlighted
135+
},
136+
hover: {
133137
background: color,
134138
border: '#ffffff'
135139
}
@@ -139,28 +143,41 @@ export function CommunityVisualization({
139143
size: 12
140144
},
141145
shape: 'dot',
142-
size: 16,
146+
size: 18, // Slightly larger for better visibility
147+
borderWidth: 2, // Thicker border to distinguish from edges
143148
community_id: communityId,
144149
type: node.type
145150
};
146151
});
147152

148-
// Format edges
149-
const edges = data.edges.map((edge: any) => ({
150-
from: edge.from,
151-
to: edge.to,
152-
label: edge.label || edge.type || '',
153-
arrows: 'to',
154-
color: {
155-
color: 'rgba(148, 163, 184, 0.5)',
156-
highlight: 'rgba(59, 130, 246, 0.8)'
157-
},
158-
width: 1,
159-
smooth: {
160-
type: 'continuous',
161-
roundness: 0.5
162-
}
163-
}));
153+
// Format edges with distinct colors from nodes
154+
const edges = data.edges.map((edge: any) => {
155+
// Get the colors of the connected nodes to determine edge color
156+
const fromNode = nodes.find((n: any) => n.id === edge.from);
157+
const toNode = nodes.find((n: any) => n.id === edge.to);
158+
159+
// Use a neutral gray color that's distinct from node colors
160+
// Make it darker and more visible
161+
const edgeColor = 'rgba(100, 116, 139, 0.7)'; // slate-500 with more opacity
162+
const edgeHighlight = 'rgba(148, 163, 184, 1.0)'; // lighter gray when highlighted
163+
164+
return {
165+
from: edge.from,
166+
to: edge.to,
167+
label: edge.label || edge.type || '',
168+
arrows: 'to',
169+
color: {
170+
color: edgeColor,
171+
highlight: edgeHighlight,
172+
hover: edgeHighlight
173+
},
174+
width: 2, // Make edges slightly thicker for better visibility
175+
smooth: {
176+
type: 'continuous',
177+
roundness: 0.5
178+
}
179+
};
180+
});
164181

165182
const networkData = { nodes, edges };
166183

@@ -181,21 +198,26 @@ export function CommunityVisualization({
181198
}
182199
},
183200
edges: {
184-
width: 1.5,
201+
width: 2, // Thicker edges for better visibility
185202
shadow: {
186203
enabled: true,
187-
color: 'rgba(0,0,0,0.2)',
188-
size: 3
204+
color: 'rgba(0,0,0,0.3)',
205+
size: 4
189206
},
190207
font: {
191208
size: 10,
192-
color: '#94a3b8',
193-
align: 'middle'
209+
color: '#cbd5e1', // Lighter color for edge labels
210+
align: 'middle',
211+
background: 'rgba(15, 23, 42, 0.8)', // Dark background for label readability
212+
strokeWidth: 2,
213+
strokeColor: 'rgba(15, 23, 42, 0.8)'
194214
},
195215
smooth: {
196216
type: 'continuous',
197217
roundness: 0.5
198-
}
218+
},
219+
selectionWidth: 3, // Thicker when selected
220+
hoverWidth: 2.5 // Slightly thicker on hover
199221
},
200222
physics: {
201223
enabled: true,

0 commit comments

Comments
 (0)