You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ma...@apache.org on 2017/06/08 15:36:47 UTC
[04/18] incubator-airflow git commit: [AIRFLOW-1263] Dynamic height
for charts
[AIRFLOW-1263] Dynamic height for charts
Dynamic heights for webserver charts so that
longer task
names fit
Closes #2344 from aoen/ddavydov--
dynamic_chart_heights
Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/fc5fe5cc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/fc5fe5cc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/fc5fe5cc
Branch: refs/heads/v1-8-test
Commit: fc5fe5cc4e3b27058c777ff6036f5ea86f30adbd
Parents: 6600faf
Author: Dan Davydov <da...@airbnb.com>
Authored: Mon Jun 5 16:32:42 2017 -0700
Committer: Maxime Beauchemin <ma...@gmail.com>
Committed: Thu Jun 8 08:36:20 2017 -0700
----------------------------------------------------------------------
airflow/www/views.py | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/fc5fe5cc/airflow/www/views.py
----------------------------------------------------------------------
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 29f3e91..46cbbb9 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -279,6 +279,16 @@ def should_hide_value_for_key(key_name):
and conf.getboolean('admin', 'hide_sensitive_variable_fields')
+
+def get_chart_height(dag):
+ """
+ TODO(aoen): See [AIRFLOW-1263] We use the number of tasks in the DAG as a heuristic to
+ approximate the size of generated chart (otherwise the charts are tiny and unreadable
+ when DAGs have a large number of tasks). Ideally nvd3 should allow for dynamic-height
+ charts, that is charts that take up space based on the size of the components within.
+ """
+ return 600 + len(dag.tasks) * 10
+
class Airflow(BaseView):
def is_visible(self):
@@ -1389,10 +1399,12 @@ class Airflow(BaseView):
include_upstream=True,
include_downstream=False)
+
+ chart_height = get_chart_height(dag)
chart = nvd3.lineChart(
- name="lineChart", x_is_date=True, height=600, width="1200")
+ name="lineChart", x_is_date=True, height=chart_height, width="1200")
cum_chart = nvd3.lineChart(
- name="cumLineChart", x_is_date=True, height=600, width="1200")
+ name="cumLineChart", x_is_date=True, height=chart_height, width="1200")
y = {}
x = {}
@@ -1483,8 +1495,10 @@ class Airflow(BaseView):
include_upstream=True,
include_downstream=False)
+ chart_height = get_chart_height(dag)
chart = nvd3.lineChart(
- name="lineChart", x_is_date=True, y_axis_format='d', height=600, width="1200")
+ name="lineChart", x_is_date=True, y_axis_format='d', height=chart_height,
+ width="1200")
for task in dag.tasks:
y = []
@@ -1545,8 +1559,9 @@ class Airflow(BaseView):
include_upstream=True,
include_downstream=False)
+ chart_height = get_chart_height(dag)
chart = nvd3.lineChart(
- name="lineChart", x_is_date=True, height=600, width="1200")
+ name="lineChart", x_is_date=True, height=chart_height, width="1200")
y = {}
x = {}
for task in dag.tasks:
@@ -1589,7 +1604,7 @@ class Airflow(BaseView):
'airflow/chart.html',
dag=dag,
chart=chart.htmlcontent,
- height="700px",
+ height=str(chart_height + 100) + "px",
demo_mode=conf.getboolean('webserver', 'demo_mode'),
root=root,
form=form,