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%. (apache#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 6e9e562)
(cherry picked from commit fb62867)
(cherry picked from commit 8b2a7b7)
  • Loading branch information
PengMingHua905001 authored and kaxil committed Jun 23, 2021
1 parent 19b303e commit 44ddad0
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions airflow/www/views.py
Expand Up @@ -407,6 +407,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 @@ -2154,8 +2158,18 @@ def duration(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")
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 @@ -2275,7 +2289,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 @@ -2346,7 +2364,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:
Expand Down

0 comments on commit 44ddad0

Please sign in to comment.