Browse Source

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

pull/54/head
Christian Ledermann 11 years ago
parent
commit
e3f28caaf9
  1. 15
      pygal/graph/horizontalbar.py
  2. 5
      pygal/test/test_graph.py
  3. 18
      setup.py

15
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)

5
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):

18
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 <http://www.gnu.org/licenses/>.
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=[

Loading…
Cancel
Save