ashb commented on a change in pull request #7238: [AIRFLOW-6613] center dag on 
graph view load
URL: https://github.com/apache/airflow/pull/7238#discussion_r372961024
 
 

 ##########
 File path: airflow/www/templates/airflow/graph.html
 ##########
 @@ -169,10 +169,27 @@
                                         "scale(" + d3.event.scale + ")");
           });
       svg.call(zoom);
-    }
 
-    // Centering the DAG on load (Not implemented yet)
-    // https://github.com/dagrejs/dagre-d3/issues/245
+      // Centering the DAG on load
+      // Get Dagre Graph dimensions
+      var graphWidth = g.graph().width;
+      var graphHeight = g.graph().height;
+      // Get SVG dimensions
+      var padding = 20;
+      var svgBb = svg.node().getBoundingClientRect();
+      var width = svgBb.width - padding*2;
+      var height = svgBb.height - padding;  // we are not centering the dag 
vertically
 
 Review comment:
   Oh it will fit the dag in vertically, just not centre it vertically. Gotcha.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to