diff --git a/pygal/__init__.py b/pygal/__init__.py index b23431e..2a4fc92 100644 --- a/pygal/__init__.py +++ b/pygal/__init__.py @@ -27,6 +27,7 @@ from pygal.graph.bar import Bar from pygal.graph.box import Box from pygal.graph.dot import Dot from pygal.graph.frenchmap import FrenchMapDepartments, FrenchMapRegions +from pygal.graph.hungarianmap import HungarianCountyMap from pygal.graph.funnel import Funnel from pygal.graph.gauge import Gauge from pygal.graph.histogram import Histogram diff --git a/pygal/graph/hungarianmap.py b/pygal/graph/hungarianmap.py new file mode 100644 index 0000000..ab87161 --- /dev/null +++ b/pygal/graph/hungarianmap.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +# This file is part of pygal +# +# A python svg graph plotting library +# Copyright © 2012-2014 Kozea +# +# This library is free software: you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with pygal. If not, see . +""" +Hungarian maps + +""" + +from __future__ import division +from collections import defaultdict +from pygal.graph.map import BaseMap +from pygal._compat import u +from numbers import Number + +import os + + +# XXX: use http://hu.wikipedia.org/wiki/NUTS:HU hierarchical codes? +# Counties ~ NUTS-3: +COUNTIES = { + 'nograd': u('Nógrád'), + 'heves': u('Heves'), + 'jnsz': u('Jász-Nagykun-Szolnok'), + 'budapest': u('Budapest'), + 'pest': u('Pest'), + 'fejer': u('Fejér'), + 'veszprem': u('Veszprém'), + 'tolna': u('Tolna'), + 'ke': u('Komárom-Esztergom'), + 'gyms': u('Győr-Moson-Sopron'), + 'vas': u('Vas'), + 'zala': u('Zala'), + 'somogy': u('Somogy'), + 'baranya': u('Baranya'), + 'bk': u('Bács-Kiskun'), + 'csongrad': u('Csongrád'), + 'bekes': u('Békés'), + 'hb': u('Hajdú-Bihar'), + 'szszb': u('Szabolcs-Szatmár-Bereg'), + 'baz': u('Borsod-Abaúj-Zemplén'), +} + + +# TODO: NUTS-1 (country parts) and NUTS-2 (statistical regions) + + +with open(os.path.join( + os.path.dirname(__file__), 'maps', + 'HU_counties_blank.svg')) as file: + COUNTY_MAP = file.read() + + +class HungarianCountyMap(BaseMap): + """Hungarian county map""" + x_labels = list(COUNTIES.keys()) + area_names = COUNTIES + area_prefix = '' + # area_prefix = 'HU' + kind = 'megye' + svg_map = COUNTY_MAP diff --git a/pygal/graph/maps/HU_counties_blank.svg b/pygal/graph/maps/HU_counties_blank.svg index 5699a20..87033bc 100644 --- a/pygal/graph/maps/HU_counties_blank.svg +++ b/pygal/graph/maps/HU_counties_blank.svg @@ -6,7 +6,8 @@ version="1.0" width="841.88977pt" height="595.27557pt" - id="svg2"> + id="svg2" + viewBox="0 0 1050 700"> - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +