Skip to content

Commit 054e286

Browse files
committed
save
1 parent dec9ba8 commit 054e286

10 files changed

Lines changed: 3631 additions & 436 deletions

docs/enhanced_index.html

Lines changed: 2 additions & 422 deletions
Large diffs are not rendered by default.

docs/enhanced_styles.css

Lines changed: 513 additions & 0 deletions
Large diffs are not rendered by default.

docs/enhanced_visualizer.js

Lines changed: 97 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
// Enhanced C# Code Graph Visualizer
2+
// -----------------------------------------------------
3+
// This script creates an interactive visualization of C# code relationships
4+
// using D3.js for graph rendering and manipulation.
5+
26
document.addEventListener('DOMContentLoaded', function() {
7+
// ============================================================
8+
// GLOBAL VARIABLES AND INITIALIZATION
9+
// ============================================================
10+
311
// Global variables
412
let graph;
513
let svg;
@@ -22,6 +30,10 @@ document.addEventListener('DOMContentLoaded', function() {
2230
// Track current visualization state
2331
let unusedElements = new Set();
2432

33+
// ============================================================
34+
// INITIALIZATION FUNCTIONS
35+
// ============================================================
36+
2537
// Load and initialize visualization
2638
async function initVisualization() {
2739
try {
@@ -275,11 +287,7 @@ document.addEventListener('DOMContentLoaded', function() {
275287
.data(graph.links)
276288
.enter()
277289
.append('line')
278-
.attr('class', 'link')
279-
.attr('data-id', (d, i) => `link-${i}`)
280-
.attr('data-source', d => typeof d.source === 'object' ? d.source.id : d.source)
281-
.attr('data-target', d => typeof d.target === 'object' ? d.target.id : d.target)
282-
.attr('data-type', d => d.type || 'default')
290+
.attr('class', d => `link ${d.type}`)
283291
.style('stroke', d => getLinkColor(d))
284292
.style('stroke-width', 1.5);
285293

@@ -316,8 +324,10 @@ document.addEventListener('DOMContentLoaded', function() {
316324
.style('font-size', '10px')
317325
.style('fill', 'black')
318326
.style('stroke', 'white')
319-
.style('stroke-width', '0.5px')
327+
.style('stroke-width', '0.7px')
320328
.style('paint-order', 'stroke')
329+
.style('font-weight', 'bold')
330+
.style('text-shadow', 'none') // Explicitly remove any text shadow
321331
.style('pointer-events', 'none');
322332

323333
console.log("Graph drawing complete");
@@ -326,6 +336,10 @@ document.addEventListener('DOMContentLoaded', function() {
326336
setTimeout(applyFilters, 100);
327337
}
328338

339+
// ============================================================
340+
// VISUAL STYLING AND APPEARANCE
341+
// ============================================================
342+
329343
// Get node color based on its type and status
330344
function getNodeColor(d) {
331345
// If node is not used, return unused color
@@ -361,15 +375,17 @@ document.addEventListener('DOMContentLoaded', function() {
361375
function getLinkColor(d) {
362376
switch (d.type) {
363377
case 'containment':
364-
return getComputedStyle(document.documentElement).getPropertyValue('--link-color');
365-
case 'call':
366-
return '#555';
367-
case 'reference':
368-
return 'blue';
369-
case 'external':
370-
return getComputedStyle(document.documentElement).getPropertyValue('--external-color');
378+
return '#666';
379+
case 'inheritance':
380+
return '#3498db';
381+
case 'implementation':
382+
return '#2ecc71';
383+
case 'usage':
384+
return '#e74c3c';
385+
case 'calls':
386+
return '#f39c12';
371387
default:
372-
return '#ccc';
388+
return '#aaa';
373389
}
374390
}
375391

@@ -1435,3 +1451,70 @@ function resetAllFilters() {
14351451

14361452
console.log("All filters have been reset");
14371453
}
1454+
1455+
// Get link color based on its type
1456+
function getLinkColor(d) {
1457+
switch (d.type) {
1458+
case 'containment':
1459+
return '#666';
1460+
case 'inheritance':
1461+
return '#3498db';
1462+
case 'implementation':
1463+
return '#2ecc71';
1464+
case 'usage':
1465+
return '#e74c3c';
1466+
case 'calls':
1467+
return '#f39c12';
1468+
default:
1469+
return '#aaa';
1470+
}
1471+
}
1472+
1473+
// ============================================================
1474+
// GRAPH MANIPULATION AND LAYOUT
1475+
// ============================================================
1476+
1477+
// Zoom behavior functions
1478+
function zoomed(event) {
1479+
gContainer.attr('transform', event.transform);
1480+
}
1481+
1482+
// Zoom to a specific node
1483+
function zoomToNode(node) {
1484+
// Get the current transform
1485+
const currentTransform = d3.zoomTransform(svg.node());
1486+
1487+
// Create a new transform centered on the node
1488+
const targetX = width / 2 - node.x * currentTransform.k;
1489+
const targetY = height / 2 - node.y * currentTransform.k;
1490+
1491+
// Smoothly transition to the new transform
1492+
svg.transition()
1493+
.duration(750)
1494+
.call(
1495+
zoomBehavior.transform,
1496+
d3.zoomIdentity
1497+
.translate(targetX, targetY)
1498+
.scale(currentTransform.k)
1499+
);
1500+
}
1501+
1502+
// Fixed unterminated template literal syntax error
1503+
function zoomToNode(node) {
1504+
// Get the current transform
1505+
const currentTransform = d3.zoomTransform(svg.node());
1506+
1507+
// Create a new transform centered on the node
1508+
const targetX = width / 2 - node.x * currentTransform.k;
1509+
const targetY = height / 2 - node.y * currentTransform.k;
1510+
1511+
// Smoothly transition to the new transform
1512+
svg.transition()
1513+
.duration(750)
1514+
.call(
1515+
zoomBehavior.transform,
1516+
d3.zoomIdentity
1517+
.translate(targetX, targetY)
1518+
.scale(currentTransform.k)
1519+
);
1520+
}

0 commit comments

Comments
 (0)