You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by da...@apache.org on 2017/06/05 23:32:59 UTC
incubator-airflow git commit: [AIRFLOW-1263] Dynamic height for charts
Repository: incubator-airflow
Updated Branches:
refs/heads/master 53ad99106 -> e3e6aa719
[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/e3e6aa71
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/e3e6aa71
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/e3e6aa71
Branch: refs/heads/master
Commit: e3e6aa71984f5fe2e9c36d1f177054b4457f5b34
Parents: 53ad991
Author: Dan Davydov <da...@airbnb.com>
Authored: Mon Jun 5 16:32:42 2017 -0700
Committer: Dan Davydov <da...@airbnb.com>
Committed: Mon Jun 5 16:32:46 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/e3e6aa71/airflow/www/views.py
----------------------------------------------------------------------
diff --git a/airflow/www/views.py b/airflow/www/views.py
index e250111..4fd52fe 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -284,6 +284,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):
@@ -1411,10 +1421,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 = defaultdict(list)
x = defaultdict(list)
@@ -1516,8 +1528,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 = []
@@ -1578,8 +1592,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:
@@ -1622,7 +1637,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,