From e3f28caaf9f003b8c91df833b4e3daf88e42b8ad Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Thu, 12 Sep 2013 18:42:49 +0300 Subject: [PATCH] after cosiderations and tests it is better to change the orders of the bars instead of the legend. This is probably more of what a user would expect. fixes #55 all tests are passing --- pygal/graph/horizontalbar.py | 15 ++++----------- pygal/test/test_graph.py | 5 ++++- setup.py | 18 +++++++++++++++++- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/pygal/graph/horizontalbar.py b/pygal/graph/horizontalbar.py index 04dde92..5d7ea3b 100644 --- a/pygal/graph/horizontalbar.py +++ b/pygal/graph/horizontalbar.py @@ -27,17 +27,10 @@ from pygal.util import cached_property class HorizontalBar(HorizontalGraph, Bar): """Horizontal Bar graph""" - @cached_property - def _legends(self): - """Getter for series title""" - return [serie.title for serie in self.series][::-1] - - def _plot(self): - for index, serie in enumerate(self.series): + for index, serie in enumerate(self.series[::-1]): num = len(self.series) - index - 1 self.bar(self._serie(num), serie, index) - for index, serie in enumerate(self.secondary_series, len(self.series)): - #XXX - self.bar(self._serie(index), serie, index, True) - + for index, serie in enumerate(self.secondary_series[::-1]): + num = len(self.secondary_series) + len(self.series) - index -1 + self.bar(self._serie(num), serie, index + len(self.series), True) diff --git a/pygal/test/test_graph.py b/pygal/test/test_graph.py index 0ae11b9..4367f2d 100644 --- a/pygal/test/test_graph.py +++ b/pygal/test/test_graph.py @@ -43,7 +43,10 @@ def test_render_to_file(Chart, datas): chart.render_to_file(file_name) with open(file_name) as f: assert 'pygal' in f.read() - os.remove(file_name) + if Chart == pygal.HorizontalBar: + pass + else: + os.remove(file_name) def test_render_to_png(Chart, datas): diff --git a/setup.py b/setup.py index c4bced5..273b73b 100644 --- a/setup.py +++ b/setup.py @@ -17,9 +17,24 @@ # # You should have received a copy of the GNU Lesser General Public License # along with pygal. If not, see . -import os +import os, sys import re + from setuptools import setup, find_packages +from setuptools.command.test import test as TestCommand + + +class PyTest(TestCommand): + def finalize_options(self): + TestCommand.finalize_options(self) + self.test_args = [] + self.test_suite = True + def run_tests(self): + #import here, cause outside the eggs aren't loaded + import pytest + errno = pytest.main(self.test_args) + sys.exit(errno) + ROOT = os.path.dirname(__file__) with open(os.path.join(ROOT, 'pygal', '__init__.py')) as fd: @@ -40,6 +55,7 @@ setup( keywords=[ "svg", "chart", "graph", "diagram", "plot", "histogram", "kiviat"], tests_require=["pytest", "pyquery", "flask", "cairosvg"], + cmdclass = {'test': PyTest}, package_data={'pygal': ['css/*', 'graph/worldmap.svg']}, install_requires=['lxml'], classifiers=[