houqp 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_r372795902
##########
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:
i believe s3 always sets the style in px. but i found a better method to get
the real dimension of the svg element, so i have switched to that, which
returns px as integer.
----------------------------------------------------------------
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