From 8b2a7b75c71726078e32044d1fee5d11a26dbb5a Mon Sep 17 00:00:00 2001 From: PengMingHua905001 <84373510+PengMingHua905001@users.noreply.github.com> Date: Thu, 10 Jun 2021 23:38:03 +0800 Subject: [PATCH] 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) (cherry picked from commit fb628678e7dc223a5684c29ea538bd22d3541ed9) --- 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 6d8a90e314bcd..eadec6cb5c3ac 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 @@ def duration(self, session=None): 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 @@ def tries(self, session=None): 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 @@ def landing_times(self, session=None): 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: