|
|
@ -24,18 +24,21 @@ from pygal.graph.stackedbar import StackedBar |
|
|
|
class HorizontalGraph(Graph): |
|
|
|
class HorizontalGraph(Graph): |
|
|
|
"""Horizontal graph""" |
|
|
|
"""Horizontal graph""" |
|
|
|
def __init__(self, *args, **kwargs): |
|
|
|
def __init__(self, *args, **kwargs): |
|
|
|
|
|
|
|
self.first_pass = True |
|
|
|
kwargs['_horizontal'] = True |
|
|
|
kwargs['_horizontal'] = True |
|
|
|
super(HorizontalGraph, self).__init__(*args, **kwargs) |
|
|
|
super(HorizontalGraph, self).__init__(*args, **kwargs) |
|
|
|
|
|
|
|
|
|
|
|
def _compute(self): |
|
|
|
def _compute(self): |
|
|
|
if self.x_labels: |
|
|
|
self.first_pass = False |
|
|
|
self.x_labels = reversed(self.x_labels) |
|
|
|
if self.first_pass and self.x_labels: |
|
|
|
|
|
|
|
self.x_labels = list(reversed(self.x_labels)) |
|
|
|
super(HorizontalGraph, self)._compute() |
|
|
|
super(HorizontalGraph, self)._compute() |
|
|
|
self._x_labels, self._y_labels = self._y_labels, self._x_labels |
|
|
|
self._x_labels, self._y_labels = self._y_labels, self._x_labels |
|
|
|
self._box.swap() |
|
|
|
self._box.swap() |
|
|
|
# Y axis is inverted |
|
|
|
# Y axis is inverted |
|
|
|
for serie in self.series: |
|
|
|
if self.first_pass: |
|
|
|
serie.values = reversed(serie.values) |
|
|
|
for serie in self.series: |
|
|
|
|
|
|
|
serie.values = list(reversed(serie.values)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HorizontalBar(HorizontalGraph, Bar): |
|
|
|
class HorizontalBar(HorizontalGraph, Bar): |
|
|
|