You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by as...@apache.org on 2021/06/22 13:46:11 UTC

[airflow] 21/38: Make task ID on legend have enough width and width of line chart to be 100%. (#15915)

This is an automated email from the ASF dual-hosted git repository.

ash pushed a commit to branch v2-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit fb628678e7dc223a5684c29ea538bd22d3541ed9
Author: PengMingHua905001 <84...@users.noreply.github.com>
AuthorDate: Thu Jun 10 23:38:03 2021 +0800

    Make task ID on legend have enough width and width of line chart to be 100%.  (#15915)
    
    * Make task ID on legend have enough width and width of line chart to be 100%.
    
    * Make task ID on legend have enough width and width of line chart to be 100%.
    
    * Fix pylint errors.
    
    (cherry picked from commit 6e9e56246b216a43eabb050c5b220f3665de6305)
---
 airflow/www/views.py | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/airflow/www/views.py b/airflow/www/views.py
index 6d8a90e..eadec6c 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -431,6 +431,10 @@ class AirflowBaseView(BaseView):  # noqa: D101
         'macros': macros,
     }
 
+    line_chart_attr = {
+        'legend.maxKeyLength': 200,
+    }
+
     def render_template(self, *args, **kwargs):
         return super().render_template(
             *args,
@@ -2270,8 +2274,18 @@ class Airflow(AirflowBaseView):  # noqa: D101  pylint: disable=too-many-public-m
         if root:
             dag = dag.sub_dag(task_ids_or_regex=root, include_upstream=True, include_downstream=False)
         chart_height = wwwutils.get_chart_height(dag)
-        chart = nvd3.lineChart(name="lineChart", x_is_date=True, height=chart_height, width="1200")
-        cum_chart = nvd3.lineChart(name="cumLineChart", x_is_date=True, height=chart_height, width="1200")
+        chart = nvd3.lineChart(
+            name="lineChart",
+            x_is_date=True,
+            height=chart_height,
+            chart_attr=self.line_chart_attr
+        )
+        cum_chart = nvd3.lineChart(
+            name="cumLineChart",
+            x_is_date=True,
+            height=chart_height,
+            chart_attr=self.line_chart_attr
+        )
 
         y_points = defaultdict(list)
         x_points = defaultdict(list)
@@ -2390,7 +2404,11 @@ class Airflow(AirflowBaseView):  # noqa: D101  pylint: disable=too-many-public-m
 
         chart_height = wwwutils.get_chart_height(dag)
         chart = nvd3.lineChart(
-            name="lineChart", x_is_date=True, y_axis_format='d', height=chart_height, width="1200"
+            name="lineChart",
+            x_is_date=True,
+            y_axis_format='d',
+            height=chart_height,
+            chart_attr=self.line_chart_attr
         )
 
         for task in dag.tasks:
@@ -2460,7 +2478,12 @@ class Airflow(AirflowBaseView):  # noqa: D101  pylint: disable=too-many-public-m
             dag = dag.sub_dag(task_ids_or_regex=root, include_upstream=True, include_downstream=False)
 
         chart_height = wwwutils.get_chart_height(dag)
-        chart = nvd3.lineChart(name="lineChart", x_is_date=True, height=chart_height, width="1200")
+        chart = nvd3.lineChart(
+            name="lineChart",
+            x_is_date=True,
+            height=chart_height,
+            chart_attr=self.line_chart_attr
+        )
         y_points = {}
         x_points = {}
         for task in dag.tasks: