@@ -35,7 +35,7 @@ function adjustLinkPath(d: any) {
3535 const dy = d . target . y - d . source . y ;
3636 const distance = Math . sqrt ( dx * dx + dy * dy ) ;
3737
38- // 各ノードが持つ半径を取得(存在しない場合はデフォルト値を設定)
38+ // Get node radius (default to 5 if not specified)
3939 const sourceRadius = d . source . radius || 5 ;
4040 const targetRadius = d . target . radius || 5 ;
4141
@@ -82,15 +82,15 @@ function Graph(svg: any, { nodes, links }: { nodes: Node[]; links: Link[] }) {
8282 . append ( 'marker' )
8383 . attr ( 'id' , markerId )
8484 . attr ( 'viewBox' , '0 0 10 10' )
85- . attr ( 'refX' , 10 ) // 矢印の位置調整(重要)
85+ . attr ( 'refX' , 10 ) // Arrow position adjustment (important)
8686 . attr ( 'refY' , 5 )
8787 . attr ( 'markerWidth' , 10 )
8888 . attr ( 'markerHeight' , 10 )
89- . attr ( 'orient' , 'auto' ) ; // 通常の 'auto' でもOK
89+ . attr ( 'orient' , 'auto' ) ; // Standard 'auto' works fine
9090 marker
9191 . append ( 'path' )
92- . attr ( 'd' , 'M 0 0 L 10 5 L 0 10 z' ) // 矢印の形
93- . attr ( 'fill' , 'black' ) ; // 見やすく
92+ . attr ( 'd' , 'M 0 0 L 10 5 L 0 10 z' ) // Arrow shape
93+ . attr ( 'fill' , 'black' ) ; // For visibility
9494
9595 const link = g
9696 . selectAll ( 'path' )
@@ -100,14 +100,14 @@ function Graph(svg: any, { nodes, links }: { nodes: Node[]; links: Link[] }) {
100100 . attr ( 'stroke' , 'black' )
101101 . attr ( 'stroke-width' , 1 )
102102 . attr ( 'fill' , 'none' )
103- . attr ( 'marker-end' , `url(#${ markerId } )` ) // 矢印のIDを指定
103+ . attr ( 'marker-end' , `url(#${ markerId } )` ) // Reference arrow marker
104104 . attr ( 'd' , adjustLinkPath ) ;
105105
106106 const node = g
107107 . selectAll ( 'g' )
108108 . data ( nodes )
109109 . enter ( )
110- . append ( 'g' ) // グループ要素を追加
110+ . append ( 'g' ) // Add group element
111111 . classed ( 'node-group' , true ) ;
112112
113113 node
@@ -131,16 +131,16 @@ function Graph(svg: any, { nodes, links }: { nodes: Node[]; links: Link[] }) {
131131 )
132132 . classed ( 'circle' , true ) ;
133133
134- // テキスト(最初は非表示)を追加
134+ // Add text labels (initially hidden)
135135 node
136136 . append ( 'text' )
137137 . text ( ( d : any ) => ( d . name ? d . name : d . id ) )
138- . attr ( 'y' , - 20 ) // ノードの上に表示
138+ . attr ( 'y' , - 20 ) // Display above the node
139139 . attr ( 'text-anchor' , 'middle' )
140140 . style ( 'font-size' , '12px' )
141141 . style ( 'display' , 'none' ) ;
142142
143- // ノードのクリックイベントを統合
143+ // Node click event handling
144144 node
145145 . on ( 'mouseover' , function ( this : SVGGElement , event : any , d : any ) {
146146 console . log ( 'mouseover' , d ) ;
@@ -153,15 +153,15 @@ function Graph(svg: any, { nodes, links }: { nodes: Node[]; links: Link[] }) {
153153 }
154154 } )
155155 . on ( 'click' , function ( this : SVGGElement , event : any , d : any ) {
156- console . log ( 'click' , this , d ) ; // thisが正しい要素を指しているか確認
156+ console . log ( 'click' , this , d ) ; // Verify this points to the correct element
157157 const isClicked = d3 . select ( this ) . classed ( 'clicked' ) ;
158- console . log ( 'isClicked:' , isClicked ) ; // 現在の状態を確認
159- d3 . select ( this ) . classed ( 'clicked' , ! isClicked ) ; // クラスのトグル
158+ console . log ( 'isClicked:' , isClicked ) ; // Check current state
159+ d3 . select ( this ) . classed ( 'clicked' , ! isClicked ) ; // Toggle class
160160 d3 . select ( this )
161161 . select ( 'text' )
162- . style ( 'display' , isClicked ? 'none' : 'block' ) ; // 表示状態をトグル
162+ . style ( 'display' , isClicked ? 'none' : 'block' ) ; // Toggle visibility
163163
164- // ドラッグ解除の処理
164+ // Release drag fixing
165165 if ( isClicked ) {
166166 delete d . fx ;
167167 delete d . fy ;
@@ -172,7 +172,7 @@ function Graph(svg: any, { nodes, links }: { nodes: Node[]; links: Link[] }) {
172172 simulation . on ( 'tick' , ( ) => {
173173 link . attr ( 'd' , adjustLinkPath ) ;
174174 // node.attr('cx', (d: any) => d.x).attr('cy', (d: any) => d.y);
175- node . attr ( 'transform' , ( d : any ) => `translate(${ d . x } ,${ d . y } )` ) ; // グループ全体を移動
175+ node . attr ( 'transform' , ( d : any ) => `translate(${ d . x } ,${ d . y } )` ) ; // Move entire group
176176 } ) ;
177177
178178 const width = 800 ;
@@ -199,7 +199,7 @@ function Graph(svg: any, { nodes, links }: { nodes: Node[]; links: Link[] }) {
199199 node . call ( drag ) ;
200200
201201 function dragstart ( ) {
202- // ドラッグ開始時の処理(必要に応じて追加)
202+ // Drag start handler (add logic as needed)
203203 }
204204
205205 function dragged ( event : any , d : any ) {
0 commit comments