@@ -78,9 +78,11 @@ function GraphD3(_selector: HTMLDivElement, _options: any) {
78
78
let svgTranslate : number [ ] ;
79
79
let node : any ;
80
80
let justLoaded = false ;
81
- var nominalTextSize = 10 ;
82
- var maxTextSize = 24 ;
81
+ let nominalTextSize = 10 ;
82
+ let maxTextSize = 24 ;
83
83
const VERSION = '2.0.0' ;
84
+ let coreSvg = null ;
85
+ let height = 585 ;
84
86
85
87
let zoomFuncs = { }
86
88
@@ -99,9 +101,9 @@ function GraphD3(_selector: HTMLDivElement, _options: any) {
99
101
}
100
102
101
103
function appendGraph ( container : d3 . Selection < any , unknown , null , undefined > ) {
102
- var mainSvg = container . append ( 'svg' )
104
+ let mainSvg = container . append ( 'svg' )
103
105
. attr ( 'width' , '100%' )
104
- . attr ( 'height' , '100%' )
106
+ . attr ( 'height' , height )
105
107
. attr ( 'class' , 'graphd3-graph' )
106
108
. call ( options . graphZoom . on ( 'zoom' , ( event ) => {
107
109
let scale = event . transform . k ;
@@ -113,8 +115,8 @@ function GraphD3(_selector: HTMLDivElement, _options: any) {
113
115
if ( svgScale ) {
114
116
scale *= svgScale ;
115
117
}
116
- var text = svg . selectAll ( '.node .text' ) ;
117
- var textSize = nominalTextSize ;
118
+ let text = svg . selectAll ( '.node .text' ) ;
119
+ let textSize = nominalTextSize ;
118
120
if ( nominalTextSize * scale > maxTextSize ) textSize = maxTextSize / scale ;
119
121
text . attr ( "font-size" , ( textSize - 3 ) + "px" ) ;
120
122
text . text ( ( d ) => {
@@ -146,6 +148,8 @@ function GraphD3(_selector: HTMLDivElement, _options: any) {
146
148
147
149
svgNodes = svg . append ( 'g' )
148
150
. attr ( 'class' , 'nodes' ) ;
151
+
152
+ coreSvg = mainSvg
149
153
}
150
154
151
155
function appendInfoPanel ( container ) {
@@ -465,10 +469,10 @@ function GraphD3(_selector: HTMLDivElement, _options: any) {
465
469
466
470
function updateNodesAndRelationships ( n , r ) {
467
471
468
- var nodeIds = nodes . map ( n => n . id )
472
+ let nodeIds = nodes . map ( n => n . id )
469
473
n = n . filter ( k => ! nodeIds . includes ( k . id ) )
470
474
471
- var edgeIds = relationships . map ( e => e . id )
475
+ let edgeIds = relationships . map ( e => e . id )
472
476
r = r . filter ( k => ! edgeIds . includes ( k . id ) )
473
477
474
478
updateRelationships ( r ) ;
@@ -789,6 +793,22 @@ function GraphD3(_selector: HTMLDivElement, _options: any) {
789
793
790
794
init ( ) ;
791
795
796
+ function resize ( ) {
797
+ const isFullScreen = parent . document . body . getElementsByClassName ( 'fullscreen' ) . length > 0
798
+ if ( isFullScreen ) {
799
+ coreSvg . attr ( "height" , parent . document . body . offsetHeight - 50 )
800
+ coreSvg . transition ( ) . call ( zoom . translateTo , ...ZOOM_PROPS . CAMERA_CENTER ( coreSvg . node ( ) . getBoundingClientRect ( ) . width , coreSvg . node ( ) . getBoundingClientRect ( ) . height - 300 ) )
801
+ } else {
802
+ coreSvg . attr ( "height" , height )
803
+ coreSvg . transition ( ) . call ( zoom . translateTo , ...ZOOM_PROPS . CAMERA_CENTER ( coreSvg . node ( ) . getBoundingClientRect ( ) . width , coreSvg . node ( ) . getBoundingClientRect ( ) . height ) )
804
+ }
805
+ simulation . restart ( )
806
+ }
807
+
808
+ d3 . select ( window ) . on ( "resize" , resize )
809
+
810
+ resize ( )
811
+
792
812
return {
793
813
graphDataToD3Data,
794
814
size,
0 commit comments