Skip to content

Commit 9d950a8

Browse files
committed
test
1 parent 66e9336 commit 9d950a8

3 files changed

Lines changed: 38 additions & 95 deletions

File tree

docs/visualizer-data.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
* - Node and link relationship mapping
77
*/
88

9-
// Data structure variables
9+
// Data structure variables are now declared in visualizer-main.js
10+
/*
1011
let graph = { nodes: [], links: [] };
1112
let graphData = {};
1213
let nodeMap = new Map();
1314
let nodeUsageCounts = new Map();
1415
let nodeRelationships = new Map();
1516
let namespaces = new Set();
17+
*/
1618

1719
/**
1820
* Load the graph data from the data file

docs/visualizer-main.js

Lines changed: 32 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Main entry point for the C# Code Graph Visualizer
3-
* This file loads all the required modules in the correct order
3+
* This file loads all the required modules and contains all shared variables
44
*/
55

66
// Global graph data
@@ -25,100 +25,39 @@ let zoomBehavior;
2525
let simulation;
2626
let currentLayout = 'force';
2727

28-
// Load the visualization modules sequentially with dynamic imports
29-
document.addEventListener('DOMContentLoaded', async function() {
30-
// Add dynamic script loading function
31-
function loadScript(src) {
32-
return new Promise((resolve, reject) => {
33-
const script = document.createElement('script');
34-
script.src = src;
35-
script.onload = resolve;
36-
script.onerror = reject;
37-
document.body.appendChild(script);
38-
});
39-
}
28+
// State tracking
29+
let selectedNode = null;
30+
let highlightedNode = null;
4031

41-
try {
42-
console.log('C# Code Graph Visualizer starting...');
43-
44-
// Initialize UI references
45-
chartContainer = document.getElementById('chart');
46-
detailPanel = document.getElementById('detail-panel');
47-
loadingOverlay = document.getElementById('loading-overlay');
48-
tooltip = document.getElementById('tooltip');
49-
filterContainer = document.getElementById('filters-container');
50-
51-
// Show loading overlay
52-
if (loadingOverlay) {
53-
console.log('Showing loading overlay');
54-
loadingOverlay.style.display = 'flex';
55-
} else {
56-
console.error('Loading overlay element not found!');
57-
}
58-
59-
// Load modules in the required order
60-
console.log('Loading visualization modules...');
61-
await loadScript('visualizer-data.js');
62-
await loadScript('visualizer-styles.js');
63-
await loadScript('visualizer-filters.js');
64-
await loadScript('visualizer-ui.js');
65-
await loadScript('visualizer-core.js');
66-
67-
console.log('All visualization modules loaded successfully');
68-
69-
// Initialize the visualization manually since modules are loaded dynamically
70-
setTimeout(() => initVisualization(), 100);
71-
} catch (error) {
72-
console.error('Error loading visualization modules:', error);
73-
74-
// Hide loading overlay on error
75-
if (loadingOverlay) {
76-
loadingOverlay.style.display = 'none';
77-
}
78-
79-
// Show error to user
80-
alert('Failed to load visualization: ' + error.message);
32+
// Initialize when the document is loaded
33+
document.addEventListener('DOMContentLoaded', function() {
34+
console.log('C# Code Graph Visualizer starting...');
35+
36+
// Initialize UI references
37+
chartContainer = document.getElementById('chart');
38+
detailPanel = document.getElementById('detail-panel');
39+
loadingOverlay = document.getElementById('loading-overlay');
40+
tooltip = document.getElementById('tooltip');
41+
filterContainer = document.getElementById('filters-container');
42+
43+
// Show loading overlay
44+
if (loadingOverlay) {
45+
console.log('Showing loading overlay');
46+
loadingOverlay.style.display = 'flex';
8147
}
82-
});
83-
84-
/**
85-
* Initialize the visualization
86-
*/
87-
async function initVisualization() {
88-
try {
89-
console.log('Initializing visualization...');
90-
91-
// Load data
92-
await loadGraph();
93-
94-
// Setup visualization components
95-
setupVisualization();
96-
97-
// Initialize filters
98-
initializeFilters();
99-
100-
// Add custom styles
101-
addStyles();
102-
103-
// Setup event listeners for layout controls
104-
document.getElementById('force-layout').addEventListener('click', switchToForceDirectedLayout);
105-
document.getElementById('hierarchical-layout').addEventListener('click', switchToHierarchicalLayout);
106-
document.getElementById('reset-zoom').addEventListener('click', resetZoom);
107-
document.getElementById('reset-filters').addEventListener('click', resetAllFilters);
108-
109-
// Hide loading overlay when complete
48+
49+
// Load the original visualizer script
50+
const script = document.createElement('script');
51+
script.src = 'enhanced_visualizer.js';
52+
script.onload = function() {
53+
console.log('Visualization loaded successfully');
54+
};
55+
script.onerror = function(error) {
56+
console.error('Error loading visualization:', error);
11057
if (loadingOverlay) {
11158
loadingOverlay.style.display = 'none';
112-
console.log('Visualization initialized successfully!');
11359
}
114-
} catch (error) {
115-
console.error('Error initializing visualization:', error);
116-
117-
// Hide loading overlay on error
118-
if (loadingOverlay) {
119-
loadingOverlay.style.display = 'none';
120-
}
121-
122-
alert('Failed to initialize visualization: ' + error.message);
123-
}
124-
}
60+
alert('Failed to load visualization: ' + error);
61+
};
62+
document.body.appendChild(script);
63+
});

docs/visualizer-ui.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
* - Context menu
88
*/
99

10-
// UI element references
10+
// UI element references (now declared in visualizer-main.js)
11+
/*
1112
let chartContainer;
1213
let detailPanel;
1314
let tooltip;
1415
let filterContainer;
1516
let loadingOverlay;
17+
*/
1618

1719
// State tracking
1820
let selectedNode = null;

0 commit comments

Comments
 (0)