diff --git a/combo/apps/dataviz/models.py b/combo/apps/dataviz/models.py index 88a81e2d..756cafe2 100644 --- a/combo/apps/dataviz/models.py +++ b/combo/apps/dataviz/models.py @@ -26,6 +26,7 @@ from django.conf import settings from jsonfield import JSONField from requests.exceptions import HTTPError import pygal +import pygal.util from combo.data.models import CellBase from combo.data.library import register_cell_class @@ -272,6 +273,9 @@ class ChartNgCell(CellBase): chart.add(serie_label, values) if width and width < 500: chart.legend_at_bottom = True + if self.chart_type == 'horizontal-bar': + # truncate labels + chart.x_labels = [pygal.util.truncate(x, 15) for x in chart.x_labels] else: # pie, create a serie by data, to get different colours values = data