Spaces:
Running
Running
Commit
·
5b82be9
1
Parent(s):
0b2054b
edge colors as grey
Browse files- daily-paper-atlas/js/main.js +90 -169
- js/main.js +2 -2
daily-paper-atlas/js/main.js
CHANGED
@@ -1,114 +1,102 @@
|
|
1 |
// Force edge colors to match their target nodes
|
2 |
function forceEdgeColors() {
|
3 |
-
|
4 |
|
5 |
// Create a map of node IDs to node info for faster lookup
|
6 |
let nodeInfo = {};
|
7 |
-
let
|
8 |
|
9 |
sigmaInstance.iterNodes(function(node) {
|
10 |
-
//
|
11 |
-
|
12 |
-
|
|
|
|
|
13 |
|
14 |
nodeInfo[node.id] = {
|
15 |
color: node.color || '#aaa',
|
16 |
-
type:
|
17 |
};
|
18 |
});
|
19 |
|
20 |
-
console.log("Node type counts:",
|
21 |
|
22 |
-
|
23 |
-
let edgeStats = {
|
24 |
-
total: 0,
|
25 |
paperAuthor: 0,
|
26 |
paperOrg: 0,
|
27 |
other: 0
|
28 |
};
|
29 |
|
30 |
-
//
|
|
|
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(`
|
39 |
return;
|
40 |
}
|
41 |
|
42 |
-
|
43 |
-
|
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 |
-
|
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 |
-
|
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 |
-
|
84 |
-
// Default to
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
-
//
|
88 |
-
if (
|
89 |
-
|
|
|
90 |
}
|
91 |
}
|
92 |
});
|
93 |
|
94 |
-
|
95 |
-
sigmaInstance.refresh();
|
96 |
|
97 |
-
|
98 |
-
|
99 |
|
100 |
-
//
|
101 |
setTimeout(() => {
|
102 |
-
|
103 |
-
|
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
|
@@ -273,68 +261,48 @@ function initializeGraph(data) {
|
|
273 |
mouseInertia: 0.8
|
274 |
});
|
275 |
|
276 |
-
|
277 |
-
|
278 |
-
// Add nodes and edges to sigma
|
279 |
for (let i = 0; i < graph.nodes.length; i++) {
|
280 |
let node = graph.nodes[i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
sigmaInstance.addNode(node.id, {
|
282 |
label: node.label || node.id,
|
283 |
x: node.x || Math.random() * 100,
|
284 |
y: node.y || Math.random() * 100,
|
285 |
size: node.size || 1,
|
286 |
-
color:
|
287 |
-
config.nodeTypes[node.type].color : nodeTypes[node.type]?.color || '#666'),
|
288 |
type: node.type
|
289 |
});
|
290 |
}
|
291 |
|
292 |
-
// First add all nodes, then add edges
|
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,8 +318,10 @@ function initializeGraph(data) {
|
|
350 |
nodeBorderColor: '#fff',
|
351 |
defaultNodeBorderColor: '#fff',
|
352 |
defaultNodeHoverColor: '#fff',
|
353 |
-
edgeColor: '
|
354 |
-
defaultEdgeColor: '#ccc' //
|
|
|
|
|
355 |
});
|
356 |
|
357 |
// Configure graph properties
|
@@ -364,26 +334,15 @@ function initializeGraph(data) {
|
|
364 |
});
|
365 |
|
366 |
// Force redraw and refresh
|
367 |
-
sigmaInstance.draw(
|
368 |
|
369 |
// Force apply node colors from config to override any hardcoded colors in the data
|
370 |
forceNodeColorsFromConfig();
|
371 |
|
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
|
384 |
applyNodeStyles();
|
385 |
|
386 |
-
// Force edge colors
|
387 |
forceEdgeColors();
|
388 |
|
389 |
// Initialize filtering
|
@@ -414,42 +373,11 @@ function applyNodeStyles() {
|
|
414 |
}
|
415 |
});
|
416 |
|
417 |
-
//
|
418 |
-
|
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 |
-
|
|
|
453 |
} catch (e) {
|
454 |
console.error("Error applying node styles:", e);
|
455 |
}
|
@@ -534,8 +462,6 @@ function colorNodesByAttribute(attribute) {
|
|
534 |
|
535 |
// Display node details (used when a node is clicked)
|
536 |
function nodeActive(nodeId) {
|
537 |
-
console.log("nodeActive called with id:", nodeId);
|
538 |
-
|
539 |
// Find the node
|
540 |
var node = null;
|
541 |
sigmaInstance.iterNodes(function(n) {
|
@@ -549,7 +475,6 @@ function nodeActive(nodeId) {
|
|
549 |
return;
|
550 |
}
|
551 |
|
552 |
-
console.log("Node found:", node);
|
553 |
sigmaInstance.detail = true;
|
554 |
selectedNode = node;
|
555 |
|
@@ -576,8 +501,6 @@ function nodeActive(nodeId) {
|
|
576 |
}
|
577 |
});
|
578 |
|
579 |
-
console.log("Neighbors found:", Object.keys(neighbors).length);
|
580 |
-
|
581 |
// Update node appearance
|
582 |
sigmaInstance.iterNodes(function(n) {
|
583 |
if (n.id == nodeId) {
|
@@ -622,7 +545,6 @@ function nodeActive(nodeId) {
|
|
622 |
|
623 |
// Show node details panel
|
624 |
try {
|
625 |
-
console.log("Displaying attribute pane");
|
626 |
// Make absolutely sure the panel is visible with both CSS approaches
|
627 |
$('#attributepane').show().css('display', 'block');
|
628 |
|
@@ -652,8 +574,6 @@ function nodeActive(nodeId) {
|
|
652 |
var id = $(this).data('node-id');
|
653 |
nodeActive(id);
|
654 |
});
|
655 |
-
|
656 |
-
console.log("Attribute pane updated with node details");
|
657 |
} catch (e) {
|
658 |
console.error("Error updating attribute pane:", e);
|
659 |
}
|
@@ -661,7 +581,6 @@ function nodeActive(nodeId) {
|
|
661 |
|
662 |
// Reset display (used when clicking outside nodes or closing the panel)
|
663 |
function nodeNormal() {
|
664 |
-
console.log("nodeNormal called");
|
665 |
if (sigmaInstance) {
|
666 |
sigmaInstance.detail = false;
|
667 |
selectedNode = null;
|
@@ -684,7 +603,9 @@ function nodeNormal() {
|
|
684 |
|
685 |
// Hide panel and refresh display
|
686 |
$('#attributepane').css('display', 'none');
|
687 |
-
|
|
|
|
|
688 |
|
689 |
// Force edge colors to ensure they're correct after reset
|
690 |
forceEdgeColors();
|
|
|
1 |
// Force edge colors to match their target nodes
|
2 |
function forceEdgeColors() {
|
3 |
+
if (!sigmaInstance) return;
|
4 |
|
5 |
// Create a map of node IDs to node info for faster lookup
|
6 |
let nodeInfo = {};
|
7 |
+
let nodeTypeCount = { paper: 0, author: 0, organization: 0, unknown: 0 };
|
8 |
|
9 |
sigmaInstance.iterNodes(function(node) {
|
10 |
+
// Log a few nodes to verify their properties
|
11 |
+
if (nodeTypeCount[node.type || 'unknown'] < 3) {
|
12 |
+
console.log(`Node ${node.id}: type=${node.type}, color=${node.color}`);
|
13 |
+
}
|
14 |
+
nodeTypeCount[node.type || 'unknown']++;
|
15 |
|
16 |
nodeInfo[node.id] = {
|
17 |
color: node.color || '#aaa',
|
18 |
+
type: node.type || 'unknown'
|
19 |
};
|
20 |
});
|
21 |
|
22 |
+
console.log("Node type counts:", nodeTypeCount);
|
23 |
|
24 |
+
let edgeTypeCount = {
|
|
|
|
|
25 |
paperAuthor: 0,
|
26 |
paperOrg: 0,
|
27 |
other: 0
|
28 |
};
|
29 |
|
30 |
+
// First pass: determine colors
|
31 |
+
let edgeColors = {};
|
32 |
sigmaInstance.iterEdges(function(edge) {
|
|
|
|
|
33 |
const sourceNode = nodeInfo[edge.source];
|
34 |
const targetNode = nodeInfo[edge.target];
|
35 |
|
36 |
if (!sourceNode || !targetNode) {
|
37 |
+
console.log(`Missing node info for edge ${edge.id}: source=${edge.source}, target=${edge.target}`);
|
38 |
return;
|
39 |
}
|
40 |
|
41 |
+
let newColor;
|
42 |
+
let edgeType = '';
|
|
|
|
|
|
|
|
|
43 |
|
44 |
// Check if this is a paper-author connection
|
45 |
if ((sourceNode.type === 'paper' && targetNode.type === 'author') ||
|
46 |
(sourceNode.type === 'author' && targetNode.type === 'paper')) {
|
47 |
+
edgeTypeCount.paperAuthor++;
|
|
|
48 |
// Use author color for the edge
|
49 |
const authorNode = sourceNode.type === 'author' ? sourceNode : targetNode;
|
50 |
+
newColor = authorNode.color;
|
51 |
+
edgeType = 'paper-author';
|
|
|
|
|
|
|
|
|
52 |
}
|
53 |
// Check if this is a paper-organization connection
|
54 |
else if ((sourceNode.type === 'paper' && targetNode.type === 'organization') ||
|
55 |
(sourceNode.type === 'organization' && targetNode.type === 'paper')) {
|
56 |
+
edgeTypeCount.paperOrg++;
|
|
|
57 |
// Use paper color for the edge
|
58 |
const paperNode = sourceNode.type === 'paper' ? sourceNode : targetNode;
|
59 |
+
newColor = paperNode.color;
|
60 |
+
edgeType = 'paper-org';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
// For any other connection types
|
63 |
else {
|
64 |
+
edgeTypeCount.other++;
|
65 |
+
// Default to source color for all other connection types
|
66 |
+
newColor = sourceNode.color;
|
67 |
+
edgeType = 'other';
|
68 |
+
}
|
69 |
+
|
70 |
+
// Store the color to apply in the second pass
|
71 |
+
edgeColors[edge.id] = {
|
72 |
+
color: newColor,
|
73 |
+
type: edgeType
|
74 |
+
};
|
75 |
+
});
|
76 |
+
|
77 |
+
// Second pass: apply colors
|
78 |
+
sigmaInstance.iterEdges(function(edge) {
|
79 |
+
if (edgeColors[edge.id]) {
|
80 |
+
const colorInfo = edgeColors[edge.id];
|
81 |
+
edge.color = colorInfo.color;
|
82 |
|
83 |
+
// Log a few edges of each type to verify coloring
|
84 |
+
if (edgeTypeCount[colorInfo.type === 'paper-author' ? 'paperAuthor' :
|
85 |
+
colorInfo.type === 'paper-org' ? 'paperOrg' : 'other'] <= 3) {
|
86 |
+
console.log(`Edge ${edge.id} (${colorInfo.type}): color=${colorInfo.color}`);
|
87 |
}
|
88 |
}
|
89 |
});
|
90 |
|
91 |
+
console.log("Edge type counts:", edgeTypeCount);
|
|
|
92 |
|
93 |
+
// Force a complete redraw to ensure colors are applied
|
94 |
+
sigmaInstance.draw();
|
95 |
|
96 |
+
// Additional refresh to ensure changes are visible
|
97 |
setTimeout(() => {
|
98 |
+
sigmaInstance.refresh();
|
99 |
+
}, 50);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
}
|
101 |
|
102 |
// Log node colors for debugging
|
|
|
261 |
mouseInertia: 0.8
|
262 |
});
|
263 |
|
264 |
+
// Add nodes to sigma
|
|
|
|
|
265 |
for (let i = 0; i < graph.nodes.length; i++) {
|
266 |
let node = graph.nodes[i];
|
267 |
+
|
268 |
+
// Ensure node type is set
|
269 |
+
if (!node.type && node.id) {
|
270 |
+
const idParts = node.id.split('_');
|
271 |
+
if (idParts.length >= 2) {
|
272 |
+
node.type = idParts[0]; // Extract type from ID (e.g., "paper_123" -> "paper")
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
// Get color from config based on node type
|
277 |
+
let nodeColor;
|
278 |
+
if (node.type && config.nodeTypes && config.nodeTypes[node.type]) {
|
279 |
+
nodeColor = config.nodeTypes[node.type].color;
|
280 |
+
} else if (node.type && nodeTypes[node.type]) {
|
281 |
+
nodeColor = nodeTypes[node.type].color;
|
282 |
+
} else {
|
283 |
+
nodeColor = '#666';
|
284 |
+
}
|
285 |
+
|
286 |
+
// Log node info for debugging
|
287 |
+
if (i < 5) {
|
288 |
+
console.log(`Adding node: id=${node.id}, type=${node.type}, color=${nodeColor}`);
|
289 |
+
}
|
290 |
+
|
291 |
sigmaInstance.addNode(node.id, {
|
292 |
label: node.label || node.id,
|
293 |
x: node.x || Math.random() * 100,
|
294 |
y: node.y || Math.random() * 100,
|
295 |
size: node.size || 1,
|
296 |
+
color: nodeColor,
|
|
|
297 |
type: node.type
|
298 |
});
|
299 |
}
|
300 |
|
301 |
+
// First add all nodes, then add edges
|
302 |
for (let i = 0; i < graph.edges.length; i++) {
|
303 |
let edge = graph.edges[i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
sigmaInstance.addEdge(edge.id, edge.source, edge.target, {
|
305 |
+
size: edge.size || 1
|
|
|
306 |
});
|
307 |
}
|
308 |
|
|
|
318 |
nodeBorderColor: '#fff',
|
319 |
defaultNodeBorderColor: '#fff',
|
320 |
defaultNodeHoverColor: '#fff',
|
321 |
+
edgeColor: 'source', // Use source node colors by default, will be overridden by our custom colors
|
322 |
+
defaultEdgeColor: '#ccc', // Only used if no color is set
|
323 |
+
minEdgeSize: 0.5,
|
324 |
+
maxEdgeSize: 2
|
325 |
});
|
326 |
|
327 |
// Configure graph properties
|
|
|
334 |
});
|
335 |
|
336 |
// Force redraw and refresh
|
337 |
+
sigmaInstance.draw();
|
338 |
|
339 |
// Force apply node colors from config to override any hardcoded colors in the data
|
340 |
forceNodeColorsFromConfig();
|
341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
// Initialize node colors and sizes by type
|
343 |
applyNodeStyles();
|
344 |
|
345 |
+
// Force edge colors one final time to ensure proper coloring
|
346 |
forceEdgeColors();
|
347 |
|
348 |
// Initialize filtering
|
|
|
373 |
}
|
374 |
});
|
375 |
|
376 |
+
// Force a redraw to ensure node colors are applied
|
377 |
+
sigmaInstance.draw(2, 2, 2, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
|
379 |
+
// Now update edge colors using forceEdgeColors
|
380 |
+
forceEdgeColors();
|
381 |
} catch (e) {
|
382 |
console.error("Error applying node styles:", e);
|
383 |
}
|
|
|
462 |
|
463 |
// Display node details (used when a node is clicked)
|
464 |
function nodeActive(nodeId) {
|
|
|
|
|
465 |
// Find the node
|
466 |
var node = null;
|
467 |
sigmaInstance.iterNodes(function(n) {
|
|
|
475 |
return;
|
476 |
}
|
477 |
|
|
|
478 |
sigmaInstance.detail = true;
|
479 |
selectedNode = node;
|
480 |
|
|
|
501 |
}
|
502 |
});
|
503 |
|
|
|
|
|
504 |
// Update node appearance
|
505 |
sigmaInstance.iterNodes(function(n) {
|
506 |
if (n.id == nodeId) {
|
|
|
545 |
|
546 |
// Show node details panel
|
547 |
try {
|
|
|
548 |
// Make absolutely sure the panel is visible with both CSS approaches
|
549 |
$('#attributepane').show().css('display', 'block');
|
550 |
|
|
|
574 |
var id = $(this).data('node-id');
|
575 |
nodeActive(id);
|
576 |
});
|
|
|
|
|
577 |
} catch (e) {
|
578 |
console.error("Error updating attribute pane:", e);
|
579 |
}
|
|
|
581 |
|
582 |
// Reset display (used when clicking outside nodes or closing the panel)
|
583 |
function nodeNormal() {
|
|
|
584 |
if (sigmaInstance) {
|
585 |
sigmaInstance.detail = false;
|
586 |
selectedNode = null;
|
|
|
603 |
|
604 |
// Hide panel and refresh display
|
605 |
$('#attributepane').css('display', 'none');
|
606 |
+
|
607 |
+
// Force a complete redraw to ensure colors are properly applied
|
608 |
+
sigmaInstance.draw(2, 2, 2, 2).refresh();
|
609 |
|
610 |
// Force edge colors to ensure they're correct after reset
|
611 |
forceEdgeColors();
|
js/main.js
CHANGED
@@ -516,7 +516,7 @@ function nodeActive(nodeId) {
|
|
516 |
// First, ensure we store the original color (only once)
|
517 |
if (typeof e.attr.originalColor === 'undefined') {
|
518 |
e.attr.originalColor = e.color;
|
519 |
-
console.log("Storing original color for edge:", e.id, "Color:", e.color);
|
520 |
}
|
521 |
|
522 |
// Store original size for edges (only once)
|
@@ -560,7 +560,7 @@ function nodeActive(nodeId) {
|
|
560 |
const sizeFactor = config.highlighting?.highlightedEdgeSizeFactor ?? 2;
|
561 |
e.size = (e.attr.originalSize) * sizeFactor;
|
562 |
// Don't change the color property at all - preserve exactly as is
|
563 |
-
console.log("Edge connected to selected node:", e.id, "Source:", sourceId, "Target:", targetId, "Keeping original color");
|
564 |
} else {
|
565 |
// For non-connected edges, use a very light gray that's almost invisible
|
566 |
// RGBA doesn't seem to work consistently in Sigma.js v0.1
|
|
|
516 |
// First, ensure we store the original color (only once)
|
517 |
if (typeof e.attr.originalColor === 'undefined') {
|
518 |
e.attr.originalColor = e.color;
|
519 |
+
// console.log("Storing original color for edge:", e.id, "Color:", e.color);
|
520 |
}
|
521 |
|
522 |
// Store original size for edges (only once)
|
|
|
560 |
const sizeFactor = config.highlighting?.highlightedEdgeSizeFactor ?? 2;
|
561 |
e.size = (e.attr.originalSize) * sizeFactor;
|
562 |
// Don't change the color property at all - preserve exactly as is
|
563 |
+
// console.log("Edge connected to selected node:", e.id, "Source:", sourceId, "Target:", targetId, "Keeping original color");
|
564 |
} else {
|
565 |
// For non-connected edges, use a very light gray that's almost invisible
|
566 |
// RGBA doesn't seem to work consistently in Sigma.js v0.1
|