@@ -66,21 +66,33 @@ class StemmaRenderer {
66
66
Download . set_downloads ( stemma . dot ) ;
67
67
}
68
68
69
+ /**
70
+ * Resizes the current graph/stemma when the browser window gets
71
+ * resized. Also set the new corresponding with on the GraphViz
72
+ * renderer so that subsequent stemmas are depicted at the right
73
+ * size.
74
+ */
69
75
resizeSVG ( ) {
70
76
const margin = 14 ;
77
+ const stemmaButtonsRowHeight = document . querySelector ( '#stemma-buttons' ) . getBoundingClientRect ( ) [ 'height' ] ;
71
78
const bbrect = document . querySelector ( '#graph-area' ) . getBoundingClientRect ( ) ;
72
- const width = bbrect [ 'width' ] ;
73
- const height = bbrect [ 'height' ] ;
79
+ const width = bbrect [ 'width' ] - ( 2 * margin ) ;
80
+ const factor = bbrect [ 'height' ] / window . innerHeight ;
81
+ const height = bbrect [ 'height' ] - stemmaButtonsRowHeight ;
74
82
const graphArea = d3 . select ( '#graph-area' ) ;
75
83
const svg = graphArea . select ( "#graph" ) . selectWithoutDataPropagation ( "svg" ) ;
76
84
svg
77
85
. transition ( )
78
86
. duration ( 700 )
79
- . attr ( "width" , width - 2 * margin )
80
- . attr ( "height" , height - 2 * margin ) ;
81
- // var d = svg.datum();
82
- // d.attributes['width'] = width - margin;
83
- // d.attributes['height'] = height - margin;
87
+ . attr ( "width" , width )
88
+ . attr ( "height" , height ) ;
89
+ // This is a bit weird, but we need to reset the size of the original
90
+ // graphviz renderer that was set when the line
91
+ // `const stemmaRenderer = new StemmaRenderer();`
92
+ // was executed, and not on `this`. There's probably
93
+ // cleaner ways to do this.
94
+ stemmaRenderer . graphvizRoot . width ( width ) ;
95
+ stemmaRenderer . graphvizRoot . height ( height ) ;
84
96
}
85
97
86
98
}
0 commit comments