Skip to content

Commit 66e9336

Browse files
committed
test
1 parent d8b45c4 commit 66e9336

2 files changed

Lines changed: 99 additions & 34 deletions

File tree

docs/visualizer-core.js

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,14 @@
77
* - Zoom and pan behavior
88
*/
99

10-
// Global variables for visualization
10+
// These variables are now defined in visualizer-main.js and shared across modules
11+
/*
1112
let svg;
1213
let gContainer;
1314
let zoomBehavior;
1415
let simulation;
1516
let currentLayout = 'force';
16-
17-
/**
18-
* Initialize the visualization
19-
*/
20-
async function initVisualization() {
21-
try {
22-
console.log('Initializing visualization...');
23-
24-
// Show loading overlay during initialization
25-
showLoading();
26-
27-
// Load data
28-
await loadGraph();
29-
30-
// Setup visualization components
31-
setupVisualization();
32-
33-
// Initialize filters
34-
initializeFilters();
35-
36-
// Add custom styles
37-
addStyles();
38-
39-
// Hide loading overlay when complete
40-
hideLoading();
41-
} catch (error) {
42-
console.error('Error initializing visualization:', error);
43-
alert('Failed to initialize visualization: ' + error.message);
44-
}
45-
}
17+
*/
4618

4719
/**
4820
* Set up the visualization after data is loaded
@@ -83,6 +55,9 @@ function setupVisualization() {
8355
// Initialize force layout
8456
initializeForceLayout();
8557

58+
// Set up background click to clear selection
59+
setupBackgroundClick();
60+
8661
console.log("Visualization setup complete");
8762
}
8863

@@ -443,9 +418,6 @@ document.addEventListener('DOMContentLoaded', function() {
443418
tooltip = document.getElementById('tooltip');
444419
filterContainer = document.getElementById('filters');
445420

446-
// Initialize visualization
447-
initVisualization();
448-
449421
// Layout control buttons
450422
document.getElementById('force-layout').addEventListener('click', switchToForceDirectedLayout);
451423
document.getElementById('hierarchical-layout').addEventListener('click', switchToHierarchicalLayout);

docs/visualizer-main.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,28 @@
33
* This file loads all the required modules in the correct order
44
*/
55

6+
// Global graph data
7+
let graph = { nodes: [], links: [] };
8+
let graphData = {};
9+
let nodeMap = new Map();
10+
let nodeUsageCounts = new Map();
11+
let nodeRelationships = new Map();
12+
let namespaces = new Set();
13+
14+
// Module references
15+
let chartContainer;
16+
let detailPanel;
17+
let loadingOverlay;
18+
let tooltip;
19+
let filterContainer;
20+
21+
// Global variables for visualization
22+
let svg;
23+
let gContainer;
24+
let zoomBehavior;
25+
let simulation;
26+
let currentLayout = 'force';
27+
628
// Load the visualization modules sequentially with dynamic imports
729
document.addEventListener('DOMContentLoaded', async function() {
830
// Add dynamic script loading function
@@ -17,15 +39,86 @@ document.addEventListener('DOMContentLoaded', async function() {
1739
}
1840

1941
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+
2059
// Load modules in the required order
60+
console.log('Loading visualization modules...');
2161
await loadScript('visualizer-data.js');
2262
await loadScript('visualizer-styles.js');
2363
await loadScript('visualizer-filters.js');
2464
await loadScript('visualizer-ui.js');
2565
await loadScript('visualizer-core.js');
2666

2767
console.log('All visualization modules loaded successfully');
68+
69+
// Initialize the visualization manually since modules are loaded dynamically
70+
setTimeout(() => initVisualization(), 100);
2871
} catch (error) {
2972
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);
3081
}
3182
});
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
110+
if (loadingOverlay) {
111+
loadingOverlay.style.display = 'none';
112+
console.log('Visualization initialized successfully!');
113+
}
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+
}

0 commit comments

Comments
 (0)