Browse Source

Minor fixes in maps

pull/98/head
Florian Mounier 11 years ago
parent
commit
83729669e8
  1. 2
      pygal/__init__.py
  2. 7
      pygal/graph/frenchmap.py
  3. 4
      pygal/graph/worldmap.py
  4. 8
      pygal/util.py

2
pygal/__init__.py

@ -21,7 +21,7 @@ Pygal - A python svg graph plotting library
"""
__version__ = '1.4.0'
__version__ = '1.4.1'
import sys
from pygal.config import Config
from pygal.ghost import Ghost, REAL_CHARTS

7
pygal/graph/frenchmap.py

@ -225,6 +225,7 @@ class FrenchMapDepartments(Graph):
areae = map.xpath(
"//*[contains(concat(' ', normalize-space(@class), ' '),"
" ' %s%s ')]" % (self.area_prefix, area_code))
if not areae:
continue
for area in areae:
@ -251,9 +252,9 @@ class FrenchMapDepartments(Graph):
else:
title_node = self.svg.node(area, 'title')
text = ''
title_node.text = text + '[%s] %s: %d' % (
title_node.text = text + '[%s] %s: %s' % (
serie.title,
self.area_names[area_code], value)
self.area_names[area_code], self._format(value))
self.nodes['plot'].append(map)
@ -378,6 +379,8 @@ DEPARTMENTS_REGIONS = {
def aggregate_regions(values):
if isinstance(values, dict):
values = values.items()
regions = defaultdict(int)
for department, value in values:
regions[DEPARTMENTS_REGIONS[department]] += value

4
pygal/graph/worldmap.py

@ -102,8 +102,8 @@ class Worldmap(Graph):
else:
title_node = self.svg.node(country, 'title')
text = ''
title_node.text = text + '[%s] %s: %d' % (
title_node.text = text + '[%s] %s: %s' % (
serie.title,
self.country_names[country_code], value)
self.country_names[country_code], self._format(value))
self.nodes['plot'].append(map)

8
pygal/util.py

@ -326,9 +326,10 @@ def prepare_values(raw, config, cls):
from pygal.graph.datey import DateY
from pygal.graph.histogram import Histogram
from pygal.graph.worldmap import Worldmap
from pygal.graph.frenchmap import FrenchMapDepartments
if config.x_labels is None and hasattr(cls, 'x_labels'):
config.x_labels = cls.x_labels
if config.zero == 0 and issubclass(cls, Worldmap):
if config.zero == 0 and issubclass(cls, (Worldmap, FrenchMapDepartments)):
config.zero = 1
for key in ('x_labels', 'y_labels'):
@ -358,7 +359,7 @@ def prepare_values(raw, config, cls):
metadata = {}
values = []
if isinstance(raw_values, dict):
if issubclass(cls, Worldmap):
if issubclass(cls, (Worldmap, FrenchMapDepartments)):
raw_values = list(raw_values.items())
else:
value_list = [None] * width
@ -390,7 +391,8 @@ def prepare_values(raw, config, cls):
value = (None, None)
elif not is_list_like(value):
value = (value, config.zero)
if issubclass(cls, DateY) or issubclass(cls, Worldmap):
if issubclass(cls, DateY) or issubclass(
cls, (Worldmap, FrenchMapDepartments)):
value = (adapter(value[0]), value[1])
else:
value = list(map(adapter, value))

Loading…
Cancel
Save