File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 body {
99 font-family : sans-serif;
1010 }
11+ html , body {
12+ margin : 0 ;
13+ padding : 0 ;
14+ width : 100% ;
15+ height : 100% ;
16+ overflow : hidden; /* no scrollbars */
17+ }
18+ svg {
19+ width : 100% ;
20+ height : 100% ;
21+ display : block; /* remove default spacing */
22+ }
1123 .link {
1224 stroke : # 999 ;
1325 stroke-opacity : 0.6 ;
@@ -34,9 +46,7 @@ <h1>Code Graph Visualization</h1>
3446 . catch ( err => console . error ( "Fetch error:" , err ) ) ;
3547
3648 function drawGraph ( graph ) {
37- const width = 960 ,
38- height = 600 ;
39-
49+ const width = window . innerWidth , height = window . innerHeight ;
4050 // Create an SVG
4151 const svg = d3 . select ( "#chart" )
4252 . append ( "svg" )
@@ -50,6 +60,16 @@ <h1>Code Graph Visualization</h1>
5060 method : "#2ca02c"
5161 } ;
5262
63+ const zoomBehavior = d3 . zoom ( )
64+ . scaleExtent ( [ 0.1 , 10 ] ) // optional limit: from 10% to 1000% zoom
65+ . on ( "zoom" , ( event ) => {
66+ // 2) The "zoom" handler updates the transform
67+ gContainer . attr ( "transform" , event . transform ) ;
68+ } ) ;
69+
70+ // 3) Attach the zoom to the SVG
71+ svg . call ( zoomBehavior ) ;
72+
5373 // Force simulation
5474 const simulation = d3 . forceSimulation ( graph . nodes )
5575 . force ( "link" , d3 . forceLink ( graph . links )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments