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_r372231747
##########
File path: airflow/www/templates/airflow/graph.html
##########
@@ -169,10 +169,26 @@
"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 width = parseInt(svg.style("width").replace(/px/, "")) - padding*2;
Review comment:
Does this work if the width is defined in units other than px in the css?
----------------------------------------------------------------
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