diff --git a/demo/moulinrouge/tests.py b/demo/moulinrouge/tests.py index aea539c..b9f6f09 100644 --- a/demo/moulinrouge/tests.py +++ b/demo/moulinrouge/tests.py @@ -453,21 +453,40 @@ def get_test_routes(app): 'value': ('mw', 40), 'label': 'Last' }]) - wmap.add('6th', [3, 5, 34, 12]) wmap.title = 'World Map !!' return wmap.render_response() @app.route('/test/supranational') def test_supranational(): wmap = world.SupranationalWorld(style=choice(list(styles.values()))) - - wmap.add('Asia', [('asia', 1)]) - wmap.add('Europe', [('europe', 1)]) - wmap.add('Africa', [('africa', 1)]) - wmap.add('North america', [('north_america', 1)]) - wmap.add('South america', [('south_america', 1)]) - wmap.add('Oceania', [('oceania', 1)]) - wmap.add('Antartica', [('antartica', 1)]) + v = [ + ('europe', 0), + ('oceania', 2), + ('antartica', 4), + ('south_america', 5), + ('africa', 6), + ('north_america', 7), + ('asia', 8) + ] + wmap.add('Serie with metadata', [ + v[0], + {'value': v[1]}, + {'value': v[2], 'label': 'Three'}, + {'value': v[3], 'xlink': 'http://4.example.com/'}, + {'value': v[4], 'xlink': 'http://5.example.com/', 'label': 'Five'}, + {'value': v[5], 'xlink': { + 'href': 'http://6.example.com/'}, 'label': 'Six'}, + {'value': v[6], 'xlink': { + 'href': 'http://7.example.com/', + 'target': '_blank'}, 'label': 'Seven'} + ]) + # wmap.add('Asia', [('asia', 1)]) + # wmap.add('Europe', [('europe', 1)]) + # wmap.add('Africa', [('africa', 1)]) + # wmap.add('North america', [('north_america', 1)]) + # wmap.add('South america', [('south_america', 1)]) + # wmap.add('Oceania', [('oceania', 1)]) + # wmap.add('Antartica', [('antartica', 1)]) wmap.title = 'Supra World Map !!' return wmap.render_response() diff --git a/pygal/graph/map.py b/pygal/graph/map.py index 6afc91a..a6edbf8 100644 --- a/pygal/graph/map.py +++ b/pygal/graph/map.py @@ -61,6 +61,7 @@ class BaseMap(Graph): ratio = 1 else: ratio = .3 + .7 * (value - min_) / (max_ - min_) + try: areae = map.findall( ".//*[@class='%s%s %s map-element']" % ( @@ -68,13 +69,7 @@ class BaseMap(Graph): self.kind)) except SyntaxError: # Python 2.6 (you'd better install lxml) - areae = [] - for g in map: - for e in g: - if '%s%s' % ( - self.area_prefix, area_code - ) in e.attrib.get('class', ''): - areae.append(e) + raise ImportError('lxml is required under python 2.6') if not areae: continue @@ -105,6 +100,7 @@ class BaseMap(Graph): else: title_node = self.svg.node(area, 'title') text = '' + title_node.text = text + '[%s] %s: %s' % ( serie.title, self.area_names[area_code], self._format(value)) diff --git a/pygal/test/conftest.py b/pygal/test/conftest.py index f551aee..6cf8643 100644 --- a/pygal/test/conftest.py +++ b/pygal/test/conftest.py @@ -20,6 +20,7 @@ import pytest import pygal from pygal.etree import etree +import sys from . import get_data @@ -32,9 +33,12 @@ def etreefx(request): def pytest_generate_tests(metafunc): - if etree._lxml_etree: + if etree._lxml_etree and sys.version_info[:2] != (2, 6): metafunc.fixturenames.append('etreefx') metafunc.parametrize('etreefx', ['lxml', 'etree'], indirect=True) + if sys.version_info[:2] != (2, 6): + if not etree._lxml_etree: + raise ImportError('lxml is required under python 2.6') if "Chart" in metafunc.funcargnames: metafunc.parametrize("Chart", pygal.CHARTS)