Spaces:
Running
Running
Commit
·
0b2054b
1
Parent(s):
934d8c3
edges are grey
Browse files- css/style.css +20 -0
- daily-paper-atlas/js/main.js +286 -35
- index.html +1 -1
- js/main.js +12 -1
css/style.css
CHANGED
@@ -590,4 +590,24 @@ canvas#sigma_bg_1 {
|
|
590 |
#debug-controls,
|
591 |
#config-debug {
|
592 |
display: none !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
593 |
}
|
|
|
590 |
#debug-controls,
|
591 |
#config-debug {
|
592 |
display: none !important;
|
593 |
+
}
|
594 |
+
|
595 |
+
/* Edge color toggle styles */
|
596 |
+
.toggle-wrapper {
|
597 |
+
margin-top: 8px;
|
598 |
+
}
|
599 |
+
|
600 |
+
.toggle-label {
|
601 |
+
display: flex;
|
602 |
+
align-items: center;
|
603 |
+
cursor: pointer;
|
604 |
+
}
|
605 |
+
|
606 |
+
.toggle-label input[type="checkbox"] {
|
607 |
+
margin-right: 8px;
|
608 |
+
cursor: pointer;
|
609 |
+
}
|
610 |
+
|
611 |
+
#edge-settings h2 {
|
612 |
+
margin-bottom: 10px;
|
613 |
}
|
daily-paper-atlas/js/main.js
CHANGED
@@ -1,26 +1,114 @@
|
|
1 |
// Force edge colors to match their target nodes
|
2 |
function forceEdgeColors() {
|
3 |
-
console.log("Forcibly updating
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
// Create a map of node IDs to colors for faster lookup
|
6 |
-
let nodeColors = {};
|
7 |
sigmaInstance.iterNodes(function(node) {
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
});
|
10 |
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
sigmaInstance.iterEdges(function(edge) {
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
});
|
21 |
|
|
|
22 |
sigmaInstance.refresh();
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
// Log node colors for debugging
|
@@ -104,6 +192,70 @@ function forceNodeColorsFromConfig() {
|
|
104 |
console.log("Node colors have been forcibly applied from config");
|
105 |
}
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
// Initialize the graph with the loaded data
|
108 |
function initializeGraph(data) {
|
109 |
graph = data;
|
@@ -141,18 +293,48 @@ function initializeGraph(data) {
|
|
141 |
for (let i = 0; i < graph.edges.length; i++) {
|
142 |
let edge = graph.edges[i];
|
143 |
|
144 |
-
//
|
145 |
-
let
|
|
|
|
|
|
|
146 |
sigmaInstance.iterNodes(function(node) {
|
147 |
-
if (node.id
|
148 |
-
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
}
|
151 |
});
|
152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
sigmaInstance.addEdge(edge.id, edge.source, edge.target, {
|
154 |
size: edge.size || 1,
|
155 |
-
color:
|
156 |
});
|
157 |
}
|
158 |
|
@@ -168,8 +350,8 @@ function initializeGraph(data) {
|
|
168 |
nodeBorderColor: '#fff',
|
169 |
defaultNodeBorderColor: '#fff',
|
170 |
defaultNodeHoverColor: '#fff',
|
171 |
-
edgeColor: '
|
172 |
-
defaultEdgeColor: '#
|
173 |
});
|
174 |
|
175 |
// Configure graph properties
|
@@ -190,6 +372,12 @@ function initializeGraph(data) {
|
|
190 |
// Force edge colors again after applying node colors
|
191 |
forceEdgeColors();
|
192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
console.log("Sigma instance created and configured:", sigmaInstance);
|
194 |
|
195 |
// Initialize node colors and sizes by type
|
@@ -226,13 +414,39 @@ function applyNodeStyles() {
|
|
226 |
}
|
227 |
});
|
228 |
|
229 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
sigmaInstance.iterEdges(function(edge) {
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
});
|
237 |
|
238 |
sigmaInstance.refresh();
|
@@ -275,14 +489,41 @@ function colorNodesByAttribute(attribute) {
|
|
275 |
n.color = valueColors[value];
|
276 |
});
|
277 |
|
278 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
sigmaInstance.iterEdges(function(edge) {
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
});
|
287 |
|
288 |
sigmaInstance.refresh();
|
@@ -312,15 +553,25 @@ function nodeActive(nodeId) {
|
|
312 |
sigmaInstance.detail = true;
|
313 |
selectedNode = node;
|
314 |
|
315 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
var neighbors = {};
|
317 |
sigmaInstance.iterEdges(function(e) {
|
318 |
if (e.source == nodeId || e.target == nodeId) {
|
319 |
neighbors[e.source == nodeId ? e.target : e.source] = {
|
320 |
name: e.label || "",
|
|
|
321 |
color: e.color
|
322 |
};
|
323 |
-
// Keep
|
324 |
e.originalColor = e.color;
|
325 |
}
|
326 |
});
|
|
|
1 |
// Force edge colors to match their target nodes
|
2 |
function forceEdgeColors() {
|
3 |
+
console.log("Forcibly updating edge colors based on connection type");
|
4 |
+
|
5 |
+
// Create a map of node IDs to node info for faster lookup
|
6 |
+
let nodeInfo = {};
|
7 |
+
let typeCounts = { paper: 0, author: 0, organization: 0, unknown: 0 };
|
8 |
|
|
|
|
|
9 |
sigmaInstance.iterNodes(function(node) {
|
10 |
+
// Make sure node type is properly set
|
11 |
+
let nodeType = node.type || 'unknown';
|
12 |
+
typeCounts[nodeType] = (typeCounts[nodeType] || 0) + 1;
|
13 |
+
|
14 |
+
nodeInfo[node.id] = {
|
15 |
+
color: node.color || '#aaa',
|
16 |
+
type: nodeType
|
17 |
+
};
|
18 |
});
|
19 |
|
20 |
+
console.log("Node type counts:", typeCounts);
|
21 |
+
|
22 |
+
// Track edge coloring statistics
|
23 |
+
let edgeStats = {
|
24 |
+
total: 0,
|
25 |
+
paperAuthor: 0,
|
26 |
+
paperOrg: 0,
|
27 |
+
other: 0
|
28 |
+
};
|
29 |
+
|
30 |
+
// Update all edge colors based on connection type
|
31 |
sigmaInstance.iterEdges(function(edge) {
|
32 |
+
edgeStats.total++;
|
33 |
+
|
34 |
+
const sourceNode = nodeInfo[edge.source];
|
35 |
+
const targetNode = nodeInfo[edge.target];
|
36 |
+
|
37 |
+
if (!sourceNode || !targetNode) {
|
38 |
+
console.log(`Could not find node info for edge ${edge.id}`);
|
39 |
+
return;
|
40 |
+
}
|
41 |
+
|
42 |
+
// Add debugging output for specific paper-organization edges (limit to first few)
|
43 |
+
if (edgeStats.total < 10 &&
|
44 |
+
((sourceNode.type === 'paper' && targetNode.type === 'organization') ||
|
45 |
+
(sourceNode.type === 'organization' && targetNode.type === 'paper'))) {
|
46 |
+
console.log(`DEBUG Edge ${edge.id}: ${sourceNode.type}(${edge.source}) -> ${targetNode.type}(${edge.target})`);
|
47 |
+
}
|
48 |
+
|
49 |
+
// Check if this is a paper-author connection
|
50 |
+
if ((sourceNode.type === 'paper' && targetNode.type === 'author') ||
|
51 |
+
(sourceNode.type === 'author' && targetNode.type === 'paper')) {
|
52 |
+
|
53 |
+
edgeStats.paperAuthor++;
|
54 |
+
// Use author color for the edge
|
55 |
+
const authorNode = sourceNode.type === 'author' ? sourceNode : targetNode;
|
56 |
+
edge.color = authorNode.color;
|
57 |
+
|
58 |
+
// Debug for a few edges
|
59 |
+
if (edgeStats.paperAuthor < 5) {
|
60 |
+
console.log(`Paper-Author edge ${edge.id}: Using author color ${edge.color}`);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
// Check if this is a paper-organization connection
|
64 |
+
else if ((sourceNode.type === 'paper' && targetNode.type === 'organization') ||
|
65 |
+
(sourceNode.type === 'organization' && targetNode.type === 'paper')) {
|
66 |
+
|
67 |
+
edgeStats.paperOrg++;
|
68 |
+
// Use paper color for the edge
|
69 |
+
const paperNode = sourceNode.type === 'paper' ? sourceNode : targetNode;
|
70 |
+
const orgNode = sourceNode.type === 'organization' ? sourceNode : targetNode;
|
71 |
+
|
72 |
+
// Debug every paper-org edge to verify correct mapping
|
73 |
+
console.log(`Paper-Org edge ${edge.id}: Paper=${paperNode.type}(${edge.source === paperNode.id ? 'source' : 'target'}) color=${paperNode.color}, Org=${orgNode.type}(${edge.source === orgNode.id ? 'source' : 'target'}) color=${orgNode.color}`);
|
74 |
+
|
75 |
+
// EXPLICITLY SET COLOR - Make very clear what we're setting
|
76 |
+
const oldColor = edge.color;
|
77 |
+
edge.color = paperNode.color;
|
78 |
+
|
79 |
+
console.log(` Set edge ${edge.id} color: ${oldColor} -> ${edge.color}`);
|
80 |
+
}
|
81 |
+
// For any other connection types
|
82 |
+
else {
|
83 |
+
edgeStats.other++;
|
84 |
+
// Default to target color for all other connection types
|
85 |
+
edge.color = targetNode.color;
|
86 |
+
|
87 |
+
// Debug for a few "other" edges
|
88 |
+
if (edgeStats.other < 5) {
|
89 |
+
console.log(`Other edge ${edge.id}: Using target color ${edge.color}`);
|
90 |
+
}
|
91 |
}
|
92 |
});
|
93 |
|
94 |
+
// Force the refresh to apply changes
|
95 |
sigmaInstance.refresh();
|
96 |
+
|
97 |
+
console.log("Edge coloring stats:", edgeStats);
|
98 |
+
console.log("Edge colors have been updated based on connection types");
|
99 |
+
|
100 |
+
// Add debug check after redraw to verify edge colors
|
101 |
+
setTimeout(() => {
|
102 |
+
console.log("Verifying edge colors after redraw:");
|
103 |
+
let colorCount = {};
|
104 |
+
sigmaInstance.iterEdges(function(edge) {
|
105 |
+
if (!colorCount[edge.color]) {
|
106 |
+
colorCount[edge.color] = 0;
|
107 |
+
}
|
108 |
+
colorCount[edge.color]++;
|
109 |
+
});
|
110 |
+
console.log("Edge color counts:", colorCount);
|
111 |
+
}, 100);
|
112 |
}
|
113 |
|
114 |
// Log node colors for debugging
|
|
|
192 |
console.log("Node colors have been forcibly applied from config");
|
193 |
}
|
194 |
|
195 |
+
// Debug function to check paper-organization edge coloring
|
196 |
+
function debugPaperOrgEdges() {
|
197 |
+
console.log("Debugging paper-organization edge coloring");
|
198 |
+
|
199 |
+
// Create a map of node IDs to node info for faster lookup
|
200 |
+
let nodeInfo = {};
|
201 |
+
sigmaInstance.iterNodes(function(node) {
|
202 |
+
nodeInfo[node.id] = {
|
203 |
+
color: node.color || '#aaa',
|
204 |
+
type: node.type || 'unknown',
|
205 |
+
label: node.label || node.id
|
206 |
+
};
|
207 |
+
});
|
208 |
+
|
209 |
+
// Find and log all paper-organization edges
|
210 |
+
let paperOrgEdges = [];
|
211 |
+
sigmaInstance.iterEdges(function(edge) {
|
212 |
+
const sourceNode = nodeInfo[edge.source];
|
213 |
+
const targetNode = nodeInfo[edge.target];
|
214 |
+
|
215 |
+
if (!sourceNode || !targetNode) return;
|
216 |
+
|
217 |
+
// Check if this is a paper-organization connection
|
218 |
+
if ((sourceNode.type === 'paper' && targetNode.type === 'organization') ||
|
219 |
+
(sourceNode.type === 'organization' && targetNode.type === 'paper')) {
|
220 |
+
|
221 |
+
const paperNode = sourceNode.type === 'paper' ? sourceNode : targetNode;
|
222 |
+
const orgNode = sourceNode.type === 'organization' ? sourceNode : targetNode;
|
223 |
+
|
224 |
+
paperOrgEdges.push({
|
225 |
+
edgeId: edge.id,
|
226 |
+
edgeColor: edge.color,
|
227 |
+
paperNodeId: paperNode.id,
|
228 |
+
paperNodeLabel: paperNode.label,
|
229 |
+
paperNodeColor: paperNode.color,
|
230 |
+
orgNodeId: orgNode.id,
|
231 |
+
orgNodeLabel: orgNode.label,
|
232 |
+
orgNodeColor: orgNode.color,
|
233 |
+
edgeSourceIsOrg: sourceNode.type === 'organization'
|
234 |
+
});
|
235 |
+
}
|
236 |
+
});
|
237 |
+
|
238 |
+
console.log(`Found ${paperOrgEdges.length} paper-organization edges`);
|
239 |
+
console.log("Sample of paper-organization edges:", paperOrgEdges.slice(0, 5));
|
240 |
+
|
241 |
+
// Check if edges are colored correctly (should match paper color)
|
242 |
+
let correctlyColored = 0;
|
243 |
+
let incorrectlyColored = 0;
|
244 |
+
|
245 |
+
for (const edge of paperOrgEdges) {
|
246 |
+
if (edge.edgeColor === edge.paperNodeColor) {
|
247 |
+
correctlyColored++;
|
248 |
+
} else {
|
249 |
+
incorrectlyColored++;
|
250 |
+
console.log(`Incorrectly colored edge: ${edge.edgeId} (color: ${edge.edgeColor}, should be: ${edge.paperNodeColor})`);
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
console.log(`Edge coloring stats: ${correctlyColored} correct, ${incorrectlyColored} incorrect`);
|
255 |
+
|
256 |
+
return paperOrgEdges;
|
257 |
+
}
|
258 |
+
|
259 |
// Initialize the graph with the loaded data
|
260 |
function initializeGraph(data) {
|
261 |
graph = data;
|
|
|
293 |
for (let i = 0; i < graph.edges.length; i++) {
|
294 |
let edge = graph.edges[i];
|
295 |
|
296 |
+
// Get source and target node info to determine edge color
|
297 |
+
let sourceNode = null;
|
298 |
+
let targetNode = null;
|
299 |
+
let edgeColor = '#aaa';
|
300 |
+
|
301 |
sigmaInstance.iterNodes(function(node) {
|
302 |
+
if (node.id === edge.source) {
|
303 |
+
sourceNode = {
|
304 |
+
type: node.type || 'unknown',
|
305 |
+
color: node.color || '#aaa'
|
306 |
+
};
|
307 |
+
}
|
308 |
+
if (node.id === edge.target) {
|
309 |
+
targetNode = {
|
310 |
+
type: node.type || 'unknown',
|
311 |
+
color: node.color || '#aaa'
|
312 |
+
};
|
313 |
}
|
314 |
});
|
315 |
|
316 |
+
if (sourceNode && targetNode) {
|
317 |
+
// Paper-Author connection: use author color
|
318 |
+
if ((sourceNode.type === 'paper' && targetNode.type === 'author') ||
|
319 |
+
(sourceNode.type === 'author' && targetNode.type === 'paper')) {
|
320 |
+
const authorNode = sourceNode.type === 'author' ? sourceNode : targetNode;
|
321 |
+
edgeColor = authorNode.color;
|
322 |
+
}
|
323 |
+
// Paper-Organization connection: use paper color
|
324 |
+
else if ((sourceNode.type === 'paper' && targetNode.type === 'organization') ||
|
325 |
+
(sourceNode.type === 'organization' && targetNode.type === 'paper')) {
|
326 |
+
const paperNode = sourceNode.type === 'paper' ? sourceNode : targetNode;
|
327 |
+
edgeColor = paperNode.color;
|
328 |
+
}
|
329 |
+
// Default to target color for all other connections
|
330 |
+
else {
|
331 |
+
edgeColor = targetNode.color;
|
332 |
+
}
|
333 |
+
}
|
334 |
+
|
335 |
sigmaInstance.addEdge(edge.id, edge.source, edge.target, {
|
336 |
size: edge.size || 1,
|
337 |
+
color: edgeColor
|
338 |
});
|
339 |
}
|
340 |
|
|
|
350 |
nodeBorderColor: '#fff',
|
351 |
defaultNodeBorderColor: '#fff',
|
352 |
defaultNodeHoverColor: '#fff',
|
353 |
+
edgeColor: 'default', // Use our custom edge colors instead of target node colors
|
354 |
+
defaultEdgeColor: '#ccc' // Default color for edges without explicit colors
|
355 |
});
|
356 |
|
357 |
// Configure graph properties
|
|
|
372 |
// Force edge colors again after applying node colors
|
373 |
forceEdgeColors();
|
374 |
|
375 |
+
// Add debug call to check paper-organization edges
|
376 |
+
setTimeout(() => {
|
377 |
+
console.log("Running edge coloring debug check");
|
378 |
+
debugPaperOrgEdges();
|
379 |
+
}, 2000);
|
380 |
+
|
381 |
console.log("Sigma instance created and configured:", sigmaInstance);
|
382 |
|
383 |
// Initialize node colors and sizes by type
|
|
|
414 |
}
|
415 |
});
|
416 |
|
417 |
+
// Update edge colors following the custom logic
|
418 |
+
// Create a map of node IDs to node info for faster lookup
|
419 |
+
let nodeInfo = {};
|
420 |
+
sigmaInstance.iterNodes(function(node) {
|
421 |
+
nodeInfo[node.id] = {
|
422 |
+
color: node.color || '#aaa',
|
423 |
+
type: node.type || 'unknown'
|
424 |
+
};
|
425 |
+
});
|
426 |
+
|
427 |
+
// Apply the custom edge coloring rules
|
428 |
sigmaInstance.iterEdges(function(edge) {
|
429 |
+
const sourceNode = nodeInfo[edge.source];
|
430 |
+
const targetNode = nodeInfo[edge.target];
|
431 |
+
|
432 |
+
if (!sourceNode || !targetNode) return;
|
433 |
+
|
434 |
+
// Paper-Author connection: use author color
|
435 |
+
if ((sourceNode.type === 'paper' && targetNode.type === 'author') ||
|
436 |
+
(sourceNode.type === 'author' && targetNode.type === 'paper')) {
|
437 |
+
const authorNode = sourceNode.type === 'author' ? sourceNode : targetNode;
|
438 |
+
edge.color = authorNode.color;
|
439 |
+
}
|
440 |
+
// Paper-Organization connection: use paper color
|
441 |
+
else if ((sourceNode.type === 'paper' && targetNode.type === 'organization') ||
|
442 |
+
(sourceNode.type === 'organization' && targetNode.type === 'paper')) {
|
443 |
+
const paperNode = sourceNode.type === 'paper' ? sourceNode : targetNode;
|
444 |
+
edge.color = paperNode.color;
|
445 |
+
}
|
446 |
+
// Default to target color for all other connection types
|
447 |
+
else {
|
448 |
+
edge.color = targetNode.color;
|
449 |
+
}
|
450 |
});
|
451 |
|
452 |
sigmaInstance.refresh();
|
|
|
489 |
n.color = valueColors[value];
|
490 |
});
|
491 |
|
492 |
+
// Create a map of node IDs to node info for faster lookup
|
493 |
+
let nodeInfo = {};
|
494 |
+
sigmaInstance.iterNodes(function(node) {
|
495 |
+
nodeInfo[node.id] = {
|
496 |
+
color: node.color || '#aaa',
|
497 |
+
type: node.type || 'unknown'
|
498 |
+
};
|
499 |
+
});
|
500 |
+
|
501 |
+
// Apply the custom edge coloring rules
|
502 |
sigmaInstance.iterEdges(function(edge) {
|
503 |
+
const sourceNode = nodeInfo[edge.source];
|
504 |
+
const targetNode = nodeInfo[edge.target];
|
505 |
+
|
506 |
+
if (!sourceNode || !targetNode) return;
|
507 |
+
|
508 |
+
// Paper-Author connection: use author color
|
509 |
+
if ((sourceNode.type === 'paper' && targetNode.type === 'author') ||
|
510 |
+
(sourceNode.type === 'author' && targetNode.type === 'paper')) {
|
511 |
+
const authorNode = sourceNode.type === 'author' ? sourceNode : targetNode;
|
512 |
+
edge.originalColor = authorNode.color;
|
513 |
+
edge.color = authorNode.color;
|
514 |
+
}
|
515 |
+
// Paper-Organization connection: use paper color
|
516 |
+
else if ((sourceNode.type === 'paper' && targetNode.type === 'organization') ||
|
517 |
+
(sourceNode.type === 'organization' && targetNode.type === 'paper')) {
|
518 |
+
const paperNode = sourceNode.type === 'paper' ? sourceNode : targetNode;
|
519 |
+
edge.originalColor = paperNode.color;
|
520 |
+
edge.color = paperNode.color;
|
521 |
+
}
|
522 |
+
// Default to target color for all other connection types
|
523 |
+
else {
|
524 |
+
edge.originalColor = targetNode.color;
|
525 |
+
edge.color = targetNode.color;
|
526 |
+
}
|
527 |
});
|
528 |
|
529 |
sigmaInstance.refresh();
|
|
|
553 |
sigmaInstance.detail = true;
|
554 |
selectedNode = node;
|
555 |
|
556 |
+
// Create a map of node IDs to node info for faster lookup
|
557 |
+
let nodeInfo = {};
|
558 |
+
sigmaInstance.iterNodes(function(n) {
|
559 |
+
nodeInfo[n.id] = {
|
560 |
+
color: n.color || '#aaa',
|
561 |
+
type: n.type || 'unknown'
|
562 |
+
};
|
563 |
+
});
|
564 |
+
|
565 |
+
// Find neighbors and store original edge colors
|
566 |
var neighbors = {};
|
567 |
sigmaInstance.iterEdges(function(e) {
|
568 |
if (e.source == nodeId || e.target == nodeId) {
|
569 |
neighbors[e.source == nodeId ? e.target : e.source] = {
|
570 |
name: e.label || "",
|
571 |
+
type: e.source == nodeId ? nodeInfo[e.target].type : nodeInfo[e.source].type,
|
572 |
color: e.color
|
573 |
};
|
574 |
+
// Keep track of original edge color
|
575 |
e.originalColor = e.color;
|
576 |
}
|
577 |
});
|
index.html
CHANGED
@@ -70,7 +70,7 @@
|
|
70 |
|
71 |
<div class="col footer">
|
72 |
<div class="credits">
|
73 |
-
Graph visualization by <a href="https://gephi.org/" target="_blank">Gephi</a> and rendered for web by <a href="https://sigmajs.org/" target="_blank">SigmaJS</a
|
74 |
</div>
|
75 |
</div>
|
76 |
</div>
|
|
|
70 |
|
71 |
<div class="col footer">
|
72 |
<div class="credits">
|
73 |
+
Graph visualization by <a href="https://gephi.org/" target="_blank">Gephi</a> and rendered for web by <a href="https://sigmajs.org/" target="_blank">SigmaJS</a>.
|
74 |
</div>
|
75 |
</div>
|
76 |
</div>
|
js/main.js
CHANGED
@@ -38,6 +38,9 @@ $(document).ready(function() {
|
|
38 |
config.data = 'data/' + config.data;
|
39 |
}
|
40 |
|
|
|
|
|
|
|
41 |
loadGraph();
|
42 |
}).fail(function(jqXHR, textStatus, errorThrown) {
|
43 |
console.error("Failed to load config:", textStatus, errorThrown);
|
@@ -220,10 +223,12 @@ function initializeGraph(data) {
|
|
220 |
nodeBorderColor: '#fff',
|
221 |
defaultNodeBorderColor: '#fff',
|
222 |
defaultNodeHoverColor: '#fff',
|
223 |
-
edgeColor: '
|
224 |
defaultEdgeColor: '#ccc'
|
225 |
});
|
226 |
|
|
|
|
|
227 |
// Configure graph properties
|
228 |
sigmaInstance.graphProperties({
|
229 |
minNodeSize: config.sigma?.graphProperties?.minNodeSize || 1,
|
@@ -926,6 +931,12 @@ function updateLegend() {
|
|
926 |
}
|
927 |
}
|
928 |
|
|
|
|
|
|
|
|
|
|
|
|
|
929 |
// Set the HTML
|
930 |
$('#colorLegend').html(legendHTML);
|
931 |
}
|
|
|
38 |
config.data = 'data/' + config.data;
|
39 |
}
|
40 |
|
41 |
+
// Initialize the edge color toggle after config is loaded
|
42 |
+
$('#grey-edges-toggle').prop('checked', config.features?.useGreyEdges || false);
|
43 |
+
|
44 |
loadGraph();
|
45 |
}).fail(function(jqXHR, textStatus, errorThrown) {
|
46 |
console.error("Failed to load config:", textStatus, errorThrown);
|
|
|
223 |
nodeBorderColor: '#fff',
|
224 |
defaultNodeBorderColor: '#fff',
|
225 |
defaultNodeHoverColor: '#fff',
|
226 |
+
edgeColor: 'default', // Always use solid grey edges
|
227 |
defaultEdgeColor: '#ccc'
|
228 |
});
|
229 |
|
230 |
+
console.log("Edge color mode: solid grey");
|
231 |
+
|
232 |
// Configure graph properties
|
233 |
sigmaInstance.graphProperties({
|
234 |
minNodeSize: config.sigma?.graphProperties?.minNodeSize || 1,
|
|
|
931 |
}
|
932 |
}
|
933 |
|
934 |
+
// Add edge color information - always grey
|
935 |
+
legendHTML += `<div class="legend-item">
|
936 |
+
<div class="legend-line" style="background-color: #ccc;"></div>
|
937 |
+
<div class="legend-label">Edge (Solid Grey)</div>
|
938 |
+
</div>`;
|
939 |
+
|
940 |
// Set the HTML
|
941 |
$('#colorLegend').html(legendHTML);
|
942 |
}
|