Skip to content

Commit

Permalink
Make task ID on legend have enough width and width of line chart to b…
Browse files Browse the repository at this point in the history
…e 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.
  • Loading branch information
PengMingHua905001 committed Jun 10, 2021
1 parent 408bd26 commit 6e9e562
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions airflow/www/views.py
Expand Up @@ -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,
Expand Down Expand Up @@ -2305,8 +2309,18 @@ def duration(self, session=None):
if root:
dag = dag.partial_subset(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)
Expand Down Expand Up @@ -2425,7 +2439,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:
Expand Down Expand Up @@ -2495,7 +2513,12 @@ def landing_times(self, session=None):
dag = dag.partial_subset(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:
Expand Down

0 comments on commit 6e9e562

Please sign in to comment.