1+ // Maintaining a global variable storing the width of the svgContainer Element
2+ var maxX = 100 ;
3+
14// Draws a curve between two given [commit] points
25async function drawCurve ( container , startx , starty , endx , endy , color ) {
36 var firstLineEndY = starty + ( ( endy - starty - 40 ) / 2 ) ;
@@ -304,6 +307,9 @@ async function drawGraph(commits, commitDict) {
304307 var nextx = 30 + ( 14 * ( indexArray [ i + 1 ] . indexOf ( thisLineIndex ) ) ) ;
305308 var nexty = document . querySelectorAll ( '[circlesha="' + commits [ i + 1 ] . oid + '"]' ) [ 0 ] . cy . baseVal . value ;
306309 drawCurve ( commitsGraphContainer , thisx , thisy , nextx , nexty , lineColors [ thisLineIndex ] ) ;
310+ // Compairing the last container width to the new lines drawn's X coordinate
311+ // Using the larger of the two as the new width for the container
312+ maxX = Math . max ( thisx , maxX ) ;
307313 }
308314 }
309315 }
@@ -327,6 +333,15 @@ async function drawGraph(commits, commitDict) {
327333 }
328334 } ) ;
329335 } ) ;
336+ // Only updating width when it has crossed the min-width of 100
337+ if ( maxX > 100 ) {
338+ // Providing space for 13 lines at a time
339+ // Any more than that can hamper the UI of the screen
340+ maxX = Math . min ( maxX , 198 )
341+ // Updating the width of the svgContainer Element
342+ var svgContainer = document . querySelector ( '#graphSvg' ) ;
343+ svgContainer . style . width = maxX ;
344+ }
330345}
331346
332347// Get the vertical and horizontal position (center)
0 commit comments