dataviz: truncate legend taking account the pie graph width (#68113)

This commit is contained in:
Frédéric Péters 2022-08-10 20:54:15 +02:00
parent 194d78e5be
commit 510a5c114e
1 changed files with 6 additions and 2 deletions

View File

@ -554,8 +554,12 @@ class ChartNgCell(CellBase):
chart.x_labels = [pygal.util.truncate(x, 15) for x in chart.x_labels]
else:
chart.show_legend = True
if width and width < 500:
chart.truncate_legend = 15
if width and height:
# pies are as tall as wide, reserve the appropriate space and distribute
# the rest for the legend.
chart.truncate_legend = (width - height) // 10
elif width:
chart.truncate_legend = width // 20
def process_one_dimensional_data(self, chart, data):
if self.hide_null_values: