Spaces:
Running
Running
Commit
·
513a8f8
1
Parent(s):
8daace0
Updated footer credits in index.html, refined CSS styles for better layout and responsiveness, and modified JavaScript to ensure edge colors match target nodes. Enhanced search functionality to support Enter key input.
Browse files- css/style.css +66 -78
- daily-paper-atlas/js/main.js +20 -20
- index.html +6 -5
- js/main.js +53 -28
css/style.css
CHANGED
@@ -61,7 +61,8 @@ canvas#sigma_bg_1 {
|
|
61 |
transform: translateY(-50%);
|
62 |
right: 20px;
|
63 |
width: 270px;
|
64 |
-
background-color: #fff;
|
|
|
65 |
margin: 0;
|
66 |
z-index: 20;
|
67 |
border-radius: 4px;
|
@@ -224,28 +225,29 @@ canvas#sigma_bg_1 {
|
|
224 |
position: absolute;
|
225 |
top: 50%;
|
226 |
transform: translateY(-50%);
|
227 |
-
left:
|
228 |
width: 250px;
|
229 |
-
padding:
|
230 |
background: rgba(255, 255, 255, 0.9);
|
231 |
-
box-shadow: 0
|
232 |
z-index: 20;
|
233 |
max-height: 80vh;
|
234 |
overflow-y: auto;
|
|
|
235 |
}
|
236 |
|
237 |
#mainpanel .col {
|
238 |
-
margin-bottom:
|
239 |
}
|
240 |
|
241 |
#title {
|
242 |
font-size: 24px;
|
243 |
font-weight: bold;
|
244 |
-
margin-bottom:
|
245 |
}
|
246 |
|
247 |
#titletext {
|
248 |
-
margin-bottom:
|
249 |
line-height: 1.5;
|
250 |
}
|
251 |
|
@@ -263,15 +265,19 @@ canvas#sigma_bg_1 {
|
|
263 |
}
|
264 |
|
265 |
#legend {
|
266 |
-
margin-top:
|
267 |
-
margin-bottom:
|
268 |
-
|
|
|
|
|
|
|
269 |
}
|
270 |
|
271 |
.legend-item {
|
272 |
display: flex;
|
273 |
align-items: center;
|
274 |
-
margin-bottom:
|
|
|
275 |
}
|
276 |
|
277 |
.legend-color {
|
@@ -299,23 +305,32 @@ canvas#sigma_bg_1 {
|
|
299 |
margin-top: 10px;
|
300 |
}
|
301 |
|
302 |
-
#search
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
border: 1px solid #ccc;
|
304 |
-
|
305 |
-
|
306 |
box-sizing: border-box;
|
307 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
}
|
309 |
|
310 |
#search-button {
|
311 |
-
display:
|
312 |
-
align-items: center;
|
313 |
-
justify-content: center;
|
314 |
-
width: 30px;
|
315 |
-
background-color: #1f77b4;
|
316 |
-
color: white;
|
317 |
-
border-radius: 0 4px 4px 0;
|
318 |
-
cursor: pointer;
|
319 |
}
|
320 |
|
321 |
.state {
|
@@ -328,18 +343,20 @@ canvas#sigma_bg_1 {
|
|
328 |
}
|
329 |
|
330 |
.results {
|
331 |
-
margin-top:
|
332 |
}
|
333 |
|
334 |
.results a {
|
335 |
display: block;
|
336 |
-
padding:
|
337 |
color: #1f77b4;
|
338 |
text-decoration: none;
|
|
|
339 |
}
|
340 |
|
341 |
.results a:hover {
|
342 |
text-decoration: underline;
|
|
|
343 |
}
|
344 |
|
345 |
.select-wrapper {
|
@@ -458,13 +475,21 @@ canvas#sigma_bg_1 {
|
|
458 |
}
|
459 |
|
460 |
#key-features {
|
461 |
-
margin-bottom:
|
|
|
|
|
|
|
|
|
462 |
}
|
463 |
|
464 |
#key-features ul {
|
465 |
padding-left: 20px;
|
466 |
}
|
467 |
|
|
|
|
|
|
|
|
|
468 |
#node-info {
|
469 |
position: absolute;
|
470 |
background: rgba(255, 255, 255, 0.8);
|
@@ -477,32 +502,29 @@ canvas#sigma_bg_1 {
|
|
477 |
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
478 |
}
|
479 |
|
480 |
-
.
|
481 |
-
|
|
|
|
|
|
|
|
|
|
|
482 |
}
|
483 |
|
484 |
-
#
|
485 |
-
|
486 |
-
padding: 6px 10px;
|
487 |
-
border: 1px solid #ccc;
|
488 |
-
border-radius: 4px 0 0 4px;
|
489 |
}
|
490 |
|
491 |
-
#
|
492 |
-
|
493 |
-
|
494 |
-
justify-content: center;
|
495 |
-
width: 30px;
|
496 |
-
background-color: #1f77b4;
|
497 |
-
color: white;
|
498 |
-
border-radius: 0 4px 4px 0;
|
499 |
-
cursor: pointer;
|
500 |
}
|
501 |
|
502 |
-
.
|
503 |
-
|
504 |
}
|
505 |
|
|
|
506 |
#attributepane .text .nodeattributes {
|
507 |
display: block;
|
508 |
padding: 10px;
|
@@ -534,38 +556,4 @@ canvas#sigma_bg_1 {
|
|
534 |
margin-bottom: 12px;
|
535 |
font-size: 13px;
|
536 |
display: block;
|
537 |
-
}
|
538 |
-
|
539 |
-
#attributepane .text .nodeattributes .p {
|
540 |
-
font-weight: bold;
|
541 |
-
font-size: 14px;
|
542 |
-
margin: 15px 0 5px 0;
|
543 |
-
}
|
544 |
-
|
545 |
-
#attributepane .text .nodeattributes .link {
|
546 |
-
margin-bottom: 5px;
|
547 |
-
}
|
548 |
-
|
549 |
-
#attributepane .text .nodeattributes .link ul {
|
550 |
-
margin: 0;
|
551 |
-
padding: 0;
|
552 |
-
list-style: none;
|
553 |
-
}
|
554 |
-
|
555 |
-
#attributepane .text .nodeattributes .link ul li {
|
556 |
-
padding: 4px 0;
|
557 |
-
border-bottom: 1px solid #eee;
|
558 |
-
}
|
559 |
-
|
560 |
-
#attributepane .text .nodeattributes .link ul li a {
|
561 |
-
color: #007AFF;
|
562 |
-
text-decoration: none;
|
563 |
-
display: block;
|
564 |
-
padding: 2px 0;
|
565 |
-
font-size: 13px;
|
566 |
-
}
|
567 |
-
|
568 |
-
#attributepane .text .nodeattributes .link ul li a:hover {
|
569 |
-
color: #0056b3;
|
570 |
-
text-decoration: underline;
|
571 |
}
|
|
|
61 |
transform: translateY(-50%);
|
62 |
right: 20px;
|
63 |
width: 270px;
|
64 |
+
/* background-color: #fff; */
|
65 |
+
background: rgba(255, 255, 255, 0.5);
|
66 |
margin: 0;
|
67 |
z-index: 20;
|
68 |
border-radius: 4px;
|
|
|
225 |
position: absolute;
|
226 |
top: 50%;
|
227 |
transform: translateY(-50%);
|
228 |
+
left: 20px;
|
229 |
width: 250px;
|
230 |
+
padding: 15px;
|
231 |
background: rgba(255, 255, 255, 0.9);
|
232 |
+
box-shadow: 0 0 13px 3px rgba(0, 0, 0, 0.2);
|
233 |
z-index: 20;
|
234 |
max-height: 80vh;
|
235 |
overflow-y: auto;
|
236 |
+
border-radius: 4px;
|
237 |
}
|
238 |
|
239 |
#mainpanel .col {
|
240 |
+
margin-bottom: 25px;
|
241 |
}
|
242 |
|
243 |
#title {
|
244 |
font-size: 24px;
|
245 |
font-weight: bold;
|
246 |
+
margin-bottom: 10px;
|
247 |
}
|
248 |
|
249 |
#titletext {
|
250 |
+
margin-bottom: 20px;
|
251 |
line-height: 1.5;
|
252 |
}
|
253 |
|
|
|
265 |
}
|
266 |
|
267 |
#legend {
|
268 |
+
margin-top: 20px;
|
269 |
+
margin-bottom: 25px;
|
270 |
+
}
|
271 |
+
|
272 |
+
#legend h2 {
|
273 |
+
margin-bottom: 12px;
|
274 |
}
|
275 |
|
276 |
.legend-item {
|
277 |
display: flex;
|
278 |
align-items: center;
|
279 |
+
margin-bottom: 8px;
|
280 |
+
padding: 3px 0;
|
281 |
}
|
282 |
|
283 |
.legend-color {
|
|
|
305 |
margin-top: 10px;
|
306 |
}
|
307 |
|
308 |
+
#search h2 {
|
309 |
+
margin-bottom: 12px;
|
310 |
+
}
|
311 |
+
|
312 |
+
.search-wrapper {
|
313 |
+
margin-bottom: 12px;
|
314 |
+
}
|
315 |
+
|
316 |
+
#search-input {
|
317 |
+
width: 100%;
|
318 |
+
padding: 8px 12px;
|
319 |
border: 1px solid #ccc;
|
320 |
+
border-radius: 4px;
|
321 |
+
font-size: 13px;
|
322 |
box-sizing: border-box;
|
323 |
+
transition: border-color 0.2s;
|
324 |
+
}
|
325 |
+
|
326 |
+
#search-input:focus {
|
327 |
+
border-color: #007AFF;
|
328 |
+
outline: none;
|
329 |
+
box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.2);
|
330 |
}
|
331 |
|
332 |
#search-button {
|
333 |
+
display: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
}
|
335 |
|
336 |
.state {
|
|
|
343 |
}
|
344 |
|
345 |
.results {
|
346 |
+
margin-top: 15px;
|
347 |
}
|
348 |
|
349 |
.results a {
|
350 |
display: block;
|
351 |
+
padding: 8px 0;
|
352 |
color: #1f77b4;
|
353 |
text-decoration: none;
|
354 |
+
border-bottom: 1px solid #eee;
|
355 |
}
|
356 |
|
357 |
.results a:hover {
|
358 |
text-decoration: underline;
|
359 |
+
background-color: #f5f5f5;
|
360 |
}
|
361 |
|
362 |
.select-wrapper {
|
|
|
475 |
}
|
476 |
|
477 |
#key-features {
|
478 |
+
margin-bottom: 25px;
|
479 |
+
}
|
480 |
+
|
481 |
+
#key-features h2 {
|
482 |
+
margin-bottom: 12px;
|
483 |
}
|
484 |
|
485 |
#key-features ul {
|
486 |
padding-left: 20px;
|
487 |
}
|
488 |
|
489 |
+
#key-features li {
|
490 |
+
margin-bottom: 8px;
|
491 |
+
}
|
492 |
+
|
493 |
#node-info {
|
494 |
position: absolute;
|
495 |
background: rgba(255, 255, 255, 0.8);
|
|
|
502 |
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
503 |
}
|
504 |
|
505 |
+
#mainpanel .footer {
|
506 |
+
margin-top: 25px;
|
507 |
+
padding-top: 15px;
|
508 |
+
border-top: 1px solid #eee;
|
509 |
+
font-size: 12px;
|
510 |
+
color: #777;
|
511 |
+
text-align: center;
|
512 |
}
|
513 |
|
514 |
+
#mainpanel .footer .credits {
|
515 |
+
line-height: 1.4;
|
|
|
|
|
|
|
516 |
}
|
517 |
|
518 |
+
#mainpanel .footer .credits a {
|
519 |
+
color: #007AFF;
|
520 |
+
text-decoration: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
521 |
}
|
522 |
|
523 |
+
#mainpanel .footer .credits a:hover {
|
524 |
+
text-decoration: underline;
|
525 |
}
|
526 |
|
527 |
+
/* Ensure attributepane styles are present */
|
528 |
#attributepane .text .nodeattributes {
|
529 |
display: block;
|
530 |
padding: 10px;
|
|
|
556 |
margin-bottom: 12px;
|
557 |
font-size: 13px;
|
558 |
display: block;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
559 |
}
|
daily-paper-atlas/js/main.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
// Force edge colors to match their
|
2 |
function forceEdgeColors() {
|
3 |
-
console.log("Forcibly updating all edge colors to match their
|
4 |
|
5 |
// Create a map of node IDs to colors for faster lookup
|
6 |
let nodeColors = {};
|
@@ -8,14 +8,14 @@ function forceEdgeColors() {
|
|
8 |
nodeColors[node.id] = node.color || '#aaa';
|
9 |
});
|
10 |
|
11 |
-
// Update all edge colors based on their
|
12 |
sigmaInstance.iterEdges(function(edge) {
|
13 |
-
const
|
14 |
-
if (
|
15 |
-
edge.color =
|
16 |
-
console.log(`Updated edge ${edge.id} color to ${
|
17 |
} else {
|
18 |
-
console.log(`Could not find color for edge ${edge.id}'s
|
19 |
}
|
20 |
});
|
21 |
|
@@ -56,22 +56,22 @@ function initializeGraph(data) {
|
|
56 |
});
|
57 |
}
|
58 |
|
59 |
-
// First add all nodes, then add edges with colors matching their
|
60 |
for (let i = 0; i < graph.edges.length; i++) {
|
61 |
let edge = graph.edges[i];
|
62 |
|
63 |
-
// Find
|
64 |
-
let
|
65 |
sigmaInstance.iterNodes(function(node) {
|
66 |
-
if (node.id == edge.
|
67 |
-
|
68 |
-
console.log(`Setting edge ${edge.id} color to match
|
69 |
}
|
70 |
});
|
71 |
|
72 |
sigmaInstance.addEdge(edge.id, edge.source, edge.target, {
|
73 |
size: edge.size || 1,
|
74 |
-
color:
|
75 |
});
|
76 |
}
|
77 |
|
@@ -87,7 +87,7 @@ function initializeGraph(data) {
|
|
87 |
nodeBorderColor: '#fff',
|
88 |
defaultNodeBorderColor: '#fff',
|
89 |
defaultNodeHoverColor: '#fff',
|
90 |
-
edgeColor: '
|
91 |
defaultEdgeColor: '#f00' // Set a default that's noticeable so we can see if our explicit coloring fails
|
92 |
});
|
93 |
|
@@ -139,10 +139,10 @@ function applyNodeStyles() {
|
|
139 |
}
|
140 |
});
|
141 |
|
142 |
-
// Then update edge colors to match their
|
143 |
sigmaInstance.iterEdges(function(edge) {
|
144 |
sigmaInstance.iterNodes(function(node) {
|
145 |
-
if (node.id == edge.
|
146 |
edge.color = node.color;
|
147 |
}
|
148 |
});
|
@@ -188,10 +188,10 @@ function colorNodesByAttribute(attribute) {
|
|
188 |
n.color = valueColors[value];
|
189 |
});
|
190 |
|
191 |
-
// Update edge colors to match their
|
192 |
sigmaInstance.iterEdges(function(edge) {
|
193 |
sigmaInstance.iterNodes(function(node) {
|
194 |
-
if (node.id == edge.
|
195 |
edge.originalColor = node.color;
|
196 |
edge.color = node.color;
|
197 |
}
|
|
|
1 |
+
// Force edge colors to match their target nodes
|
2 |
function forceEdgeColors() {
|
3 |
+
console.log("Forcibly updating all edge colors to match their target nodes");
|
4 |
|
5 |
// Create a map of node IDs to colors for faster lookup
|
6 |
let nodeColors = {};
|
|
|
8 |
nodeColors[node.id] = node.color || '#aaa';
|
9 |
});
|
10 |
|
11 |
+
// Update all edge colors based on their target nodes
|
12 |
sigmaInstance.iterEdges(function(edge) {
|
13 |
+
const targetColor = nodeColors[edge.target];
|
14 |
+
if (targetColor) {
|
15 |
+
edge.color = targetColor;
|
16 |
+
console.log(`Updated edge ${edge.id} color to ${targetColor} from target ${edge.target}`);
|
17 |
} else {
|
18 |
+
console.log(`Could not find color for edge ${edge.id}'s target node ${edge.target}`);
|
19 |
}
|
20 |
});
|
21 |
|
|
|
56 |
});
|
57 |
}
|
58 |
|
59 |
+
// First add all nodes, then add edges with colors matching their target nodes
|
60 |
for (let i = 0; i < graph.edges.length; i++) {
|
61 |
let edge = graph.edges[i];
|
62 |
|
63 |
+
// Find target node to match its color
|
64 |
+
let targetNodeColor = '#aaa';
|
65 |
sigmaInstance.iterNodes(function(node) {
|
66 |
+
if (node.id == edge.target) {
|
67 |
+
targetNodeColor = node.color;
|
68 |
+
console.log(`Setting edge ${edge.id} color to match target node ${node.id}: ${targetNodeColor}`);
|
69 |
}
|
70 |
});
|
71 |
|
72 |
sigmaInstance.addEdge(edge.id, edge.source, edge.target, {
|
73 |
size: edge.size || 1,
|
74 |
+
color: targetNodeColor
|
75 |
});
|
76 |
}
|
77 |
|
|
|
87 |
nodeBorderColor: '#fff',
|
88 |
defaultNodeBorderColor: '#fff',
|
89 |
defaultNodeHoverColor: '#fff',
|
90 |
+
edgeColor: 'target', // This tells sigma to use target node color for edges
|
91 |
defaultEdgeColor: '#f00' // Set a default that's noticeable so we can see if our explicit coloring fails
|
92 |
});
|
93 |
|
|
|
139 |
}
|
140 |
});
|
141 |
|
142 |
+
// Then update edge colors to match their target nodes
|
143 |
sigmaInstance.iterEdges(function(edge) {
|
144 |
sigmaInstance.iterNodes(function(node) {
|
145 |
+
if (node.id == edge.target) {
|
146 |
edge.color = node.color;
|
147 |
}
|
148 |
});
|
|
|
188 |
n.color = valueColors[value];
|
189 |
});
|
190 |
|
191 |
+
// Update edge colors to match their target nodes
|
192 |
sigmaInstance.iterEdges(function(edge) {
|
193 |
sigmaInstance.iterNodes(function(node) {
|
194 |
+
if (node.id == edge.target) {
|
195 |
edge.originalColor = node.color;
|
196 |
edge.color = node.color;
|
197 |
}
|
index.html
CHANGED
@@ -63,11 +63,16 @@
|
|
63 |
<h2>Search:</h2>
|
64 |
<div class="search-wrapper">
|
65 |
<input type="text" id="search-input" placeholder="Search by name">
|
66 |
-
<div id="search-button">→</div>
|
67 |
</div>
|
68 |
<div class="results"></div>
|
69 |
</div>
|
70 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
</div>
|
72 |
|
73 |
<div id="attributepane">
|
@@ -90,9 +95,5 @@
|
|
90 |
<div class="z" rel="out"></div>
|
91 |
<div class="z" rel="center"></div>
|
92 |
</div>
|
93 |
-
|
94 |
-
<div id="developercontainer">
|
95 |
-
Web rendering powered by <a href="https://sigmajs.org/" target="_blank">SigmaJS</a>. Developed by Daily Paper Atlas Team.
|
96 |
-
</div>
|
97 |
</body>
|
98 |
</html>
|
|
|
63 |
<h2>Search:</h2>
|
64 |
<div class="search-wrapper">
|
65 |
<input type="text" id="search-input" placeholder="Search by name">
|
|
|
66 |
</div>
|
67 |
<div class="results"></div>
|
68 |
</div>
|
69 |
</div>
|
70 |
+
|
71 |
+
<div class="col footer">
|
72 |
+
<div class="credits">
|
73 |
+
Web rendering powered by <a href="https://sigmajs.org/" target="_blank">SigmaJS</a>. Developed by Daily Paper Atlas Team.
|
74 |
+
</div>
|
75 |
+
</div>
|
76 |
</div>
|
77 |
|
78 |
<div id="attributepane">
|
|
|
95 |
<div class="z" rel="out"></div>
|
96 |
<div class="z" rel="center"></div>
|
97 |
</div>
|
|
|
|
|
|
|
|
|
98 |
</body>
|
99 |
</html>
|
js/main.js
CHANGED
@@ -37,7 +37,7 @@ $(document).ready(function() {
|
|
37 |
});
|
38 |
|
39 |
// Set up search functionality
|
40 |
-
$('#search-input').
|
41 |
let searchTerm = $(this).val();
|
42 |
if (searchTerm.length > 2) {
|
43 |
searchNodes(searchTerm);
|
@@ -46,10 +46,13 @@ $(document).ready(function() {
|
|
46 |
}
|
47 |
});
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
if (
|
52 |
-
|
|
|
|
|
|
|
53 |
}
|
54 |
});
|
55 |
|
@@ -183,8 +186,8 @@ function initializeGraph(data) {
|
|
183 |
for (let i = 0; i < graph.edges.length; i++) {
|
184 |
let edge = graph.edges[i];
|
185 |
sigmaInstance.addEdge(edge.id, edge.source, edge.target, {
|
186 |
-
size: edge.size || 1
|
187 |
-
|
188 |
});
|
189 |
}
|
190 |
|
@@ -200,7 +203,7 @@ function initializeGraph(data) {
|
|
200 |
nodeBorderColor: '#fff',
|
201 |
defaultNodeBorderColor: '#fff',
|
202 |
defaultNodeHoverColor: '#fff',
|
203 |
-
edgeColor: 'target',
|
204 |
defaultEdgeColor: '#ccc'
|
205 |
});
|
206 |
|
@@ -237,6 +240,7 @@ function initializeGraph(data) {
|
|
237 |
function applyNodeStyles() {
|
238 |
if (!sigmaInstance) return;
|
239 |
try {
|
|
|
240 |
sigmaInstance.iterNodes(function(node) {
|
241 |
if (node.type && config.nodeTypes && config.nodeTypes[node.type]) {
|
242 |
node.color = config.nodeTypes[node.type].color;
|
@@ -246,6 +250,8 @@ function applyNodeStyles() {
|
|
246 |
node.size = nodeTypes[node.type].size;
|
247 |
}
|
248 |
});
|
|
|
|
|
249 |
sigmaInstance.refresh();
|
250 |
} catch (e) {
|
251 |
console.error("Error applying node styles:", e);
|
@@ -300,10 +306,20 @@ function bindEvents() {
|
|
300 |
|
301 |
// When a node is clicked, display its details
|
302 |
sigmaInstance.bind('upnodes', function(event) {
|
303 |
-
console.log("Node clicked:", event);
|
304 |
if (event.content && event.content.length > 0) {
|
305 |
var nodeId = event.content[0];
|
306 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
}
|
308 |
});
|
309 |
|
@@ -361,9 +377,16 @@ function bindEvents() {
|
|
361 |
|
362 |
// When stage is clicked, close the attribute pane
|
363 |
document.getElementById('sigma-canvas').addEventListener('click', function(evt) {
|
364 |
-
//
|
365 |
-
if (
|
366 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
}
|
368 |
});
|
369 |
}
|
@@ -497,12 +520,11 @@ function nodeActive(nodeId) {
|
|
497 |
|
498 |
// Apply different styles based on connection status
|
499 |
if (isConnected) {
|
500 |
-
//
|
501 |
-
const highlightColor = config.highlighting?.highlightedEdgeColor ?? '#000000';
|
502 |
const sizeFactor = config.highlighting?.highlightedEdgeSizeFactor ?? 2;
|
503 |
-
e.color = highlightColor;
|
504 |
e.size = (e.attr.originalSize) * sizeFactor;
|
505 |
-
|
|
|
506 |
} else {
|
507 |
// For non-connected edges, use a very light gray that's almost invisible
|
508 |
// RGBA doesn't seem to work consistently in Sigma.js v0.1
|
@@ -519,13 +541,13 @@ function nodeActive(nodeId) {
|
|
519 |
// Add debug check after redraw to verify edge colors
|
520 |
setTimeout(function() {
|
521 |
console.log("Verifying edge colors after redraw:");
|
522 |
-
let colorCount = {
|
523 |
|
524 |
sigmaInstance.iterEdges(function(e) {
|
525 |
-
if (e.color === '#
|
526 |
-
colorCount.
|
527 |
-
} else if (e.color.
|
528 |
-
colorCount.
|
529 |
} else {
|
530 |
colorCount.other++;
|
531 |
}
|
@@ -682,6 +704,15 @@ function nodeNormal() {
|
|
682 |
|
683 |
// Force redraw
|
684 |
sigmaInstance.draw(2, 2, 2, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
685 |
}
|
686 |
|
687 |
// Helper function to convert colors to RGB
|
@@ -769,12 +800,6 @@ function updateLegend() {
|
|
769 |
}
|
770 |
}
|
771 |
|
772 |
-
// Add legend for edges
|
773 |
-
legendHTML += `<div class="legend-item">
|
774 |
-
<div class="legend-line"></div>
|
775 |
-
<div class="legend-label">Connections</div>
|
776 |
-
</div>`;
|
777 |
-
|
778 |
// Set the HTML
|
779 |
$('#colorLegend').html(legendHTML);
|
780 |
}
|
|
|
37 |
});
|
38 |
|
39 |
// Set up search functionality
|
40 |
+
$('#search-input').on('input', function(e) {
|
41 |
let searchTerm = $(this).val();
|
42 |
if (searchTerm.length > 2) {
|
43 |
searchNodes(searchTerm);
|
|
|
46 |
}
|
47 |
});
|
48 |
|
49 |
+
// Add functionality for Enter key in search
|
50 |
+
$('#search-input').keypress(function(e) {
|
51 |
+
if (e.which === 13) { // Enter key
|
52 |
+
let searchTerm = $(this).val();
|
53 |
+
if (searchTerm.length > 0) {
|
54 |
+
searchNodes(searchTerm);
|
55 |
+
}
|
56 |
}
|
57 |
});
|
58 |
|
|
|
186 |
for (let i = 0; i < graph.edges.length; i++) {
|
187 |
let edge = graph.edges[i];
|
188 |
sigmaInstance.addEdge(edge.id, edge.source, edge.target, {
|
189 |
+
size: edge.size || 1
|
190 |
+
// Don't set edge color here - let the drawing properties handle it
|
191 |
});
|
192 |
}
|
193 |
|
|
|
203 |
nodeBorderColor: '#fff',
|
204 |
defaultNodeBorderColor: '#fff',
|
205 |
defaultNodeHoverColor: '#fff',
|
206 |
+
edgeColor: 'target', // Use target node color for edges
|
207 |
defaultEdgeColor: '#ccc'
|
208 |
});
|
209 |
|
|
|
240 |
function applyNodeStyles() {
|
241 |
if (!sigmaInstance) return;
|
242 |
try {
|
243 |
+
// First update node colors
|
244 |
sigmaInstance.iterNodes(function(node) {
|
245 |
if (node.type && config.nodeTypes && config.nodeTypes[node.type]) {
|
246 |
node.color = config.nodeTypes[node.type].color;
|
|
|
250 |
node.size = nodeTypes[node.type].size;
|
251 |
}
|
252 |
});
|
253 |
+
|
254 |
+
// Ensure edges match the target node colors by redrawing
|
255 |
sigmaInstance.refresh();
|
256 |
} catch (e) {
|
257 |
console.error("Error applying node styles:", e);
|
|
|
306 |
|
307 |
// When a node is clicked, display its details
|
308 |
sigmaInstance.bind('upnodes', function(event) {
|
309 |
+
console.log("Node clicked event fired:", event);
|
310 |
if (event.content && event.content.length > 0) {
|
311 |
var nodeId = event.content[0];
|
312 |
+
console.log("Processing node click for node:", nodeId);
|
313 |
+
// Set a flag to indicate we're processing a node click
|
314 |
+
sigmaInstance.isMouseDown = true;
|
315 |
+
// Call nodeActive with a slight delay to ensure event handling is complete
|
316 |
+
setTimeout(function() {
|
317 |
+
nodeActive(nodeId);
|
318 |
+
// Reset the flag after processing
|
319 |
+
setTimeout(function() {
|
320 |
+
sigmaInstance.isMouseDown = false;
|
321 |
+
}, 10);
|
322 |
+
}, 10);
|
323 |
}
|
324 |
});
|
325 |
|
|
|
377 |
|
378 |
// When stage is clicked, close the attribute pane
|
379 |
document.getElementById('sigma-canvas').addEventListener('click', function(evt) {
|
380 |
+
// If we're in detail view and didn't click on a node, return to full graph
|
381 |
+
if (sigmaInstance.detail && !sigmaInstance.isMouseDown) {
|
382 |
+
// Give priority to node click events by waiting
|
383 |
+
setTimeout(function() {
|
384 |
+
// Only proceed if isMouseDown is still false after the delay
|
385 |
+
if (!sigmaInstance.isMouseDown) {
|
386 |
+
console.log("Canvas clicked while in detail view - returning to full view");
|
387 |
+
nodeNormal();
|
388 |
+
}
|
389 |
+
}, 100);
|
390 |
}
|
391 |
});
|
392 |
}
|
|
|
520 |
|
521 |
// Apply different styles based on connection status
|
522 |
if (isConnected) {
|
523 |
+
// For connected edges, keep their original color and just increase size
|
|
|
524 |
const sizeFactor = config.highlighting?.highlightedEdgeSizeFactor ?? 2;
|
|
|
525 |
e.size = (e.attr.originalSize) * sizeFactor;
|
526 |
+
// Don't change the color property at all - preserve exactly as is
|
527 |
+
console.log("Edge connected to selected node:", e.id, "Source:", sourceId, "Target:", targetId, "Keeping original color");
|
528 |
} else {
|
529 |
// For non-connected edges, use a very light gray that's almost invisible
|
530 |
// RGBA doesn't seem to work consistently in Sigma.js v0.1
|
|
|
541 |
// Add debug check after redraw to verify edge colors
|
542 |
setTimeout(function() {
|
543 |
console.log("Verifying edge colors after redraw:");
|
544 |
+
let colorCount = { original: 0, greyed: 0, other: 0 };
|
545 |
|
546 |
sigmaInstance.iterEdges(function(e) {
|
547 |
+
if (e.color === '#ededed') {
|
548 |
+
colorCount.greyed++;
|
549 |
+
} else if (e.attr && e.attr.originalColor && e.color === e.attr.originalColor) {
|
550 |
+
colorCount.original++;
|
551 |
} else {
|
552 |
colorCount.other++;
|
553 |
}
|
|
|
704 |
|
705 |
// Force redraw
|
706 |
sigmaInstance.draw(2, 2, 2, 2);
|
707 |
+
|
708 |
+
// Ensure edge colors match target nodes after restoring
|
709 |
+
try {
|
710 |
+
if (typeof forceEdgeColors === 'function') {
|
711 |
+
forceEdgeColors();
|
712 |
+
}
|
713 |
+
} catch (e) {
|
714 |
+
console.error("Error refreshing edge colors:", e);
|
715 |
+
}
|
716 |
}
|
717 |
|
718 |
// Helper function to convert colors to RGB
|
|
|
800 |
}
|
801 |
}
|
802 |
|
|
|
|
|
|
|
|
|
|
|
|
|
803 |
// Set the HTML
|
804 |
$('#colorLegend').html(legendHTML);
|
805 |
}
|