From c57f4ae695631f95b5dfd0f1b0bc0b6e499b2fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fekete=20Kriszti=C3=A1n?= Date: Fri, 5 Jun 2015 21:42:00 +0200 Subject: [PATCH 1/3] Public domain Hungary county map http://commons.wikimedia.org/wiki/File:HU_counties_blank.svg http://upload.wikimedia.org/wikipedia/commons/b/b3/HU_counties_blank.svg --- pygal/graph/maps/HU_counties_blank.svg | 111 +++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 pygal/graph/maps/HU_counties_blank.svg diff --git a/pygal/graph/maps/HU_counties_blank.svg b/pygal/graph/maps/HU_counties_blank.svg new file mode 100644 index 00000000..5699a204 --- /dev/null +++ b/pygal/graph/maps/HU_counties_blank.svg @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 1750bac66f816af3c95d091274400ced37e201ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fekete=20Kriszti=C3=A1n?= Date: Sat, 6 Jun 2015 00:15:10 +0200 Subject: [PATCH 2/3] HungarianCountyMap - svg edited: - added around -s - moved class attribute from to - formatted class attribute so that BaseMap could find & color parts - added viewBox - copied frenchmap.py to hungarianmap.py and edited - exported the new class from pygal/__init__.py --- pygal/__init__.py | 1 + pygal/graph/hungarianmap.py | 75 +++++++++ pygal/graph/maps/HU_counties_blank.svg | 203 +++++++++++++++---------- 3 files changed, 198 insertions(+), 81 deletions(-) create mode 100644 pygal/graph/hungarianmap.py diff --git a/pygal/__init__.py b/pygal/__init__.py index b23431ef..2a4fc922 100644 --- a/pygal/__init__.py +++ b/pygal/__init__.py @@ -27,6 +27,7 @@ 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 00000000..ab87161f --- /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 5699a204..87033bc0 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"> - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From ac45c30123a645a63e8a3839841150697e64f7e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fekete=20Kriszti=C3=A1n?= Date: Thu, 11 Jun 2015 17:38:43 +0200 Subject: [PATCH 3/3] cleanup --- pygal/graph/hungarianmap.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pygal/graph/hungarianmap.py b/pygal/graph/hungarianmap.py index ab87161f..5265715a 100644 --- a/pygal/graph/hungarianmap.py +++ b/pygal/graph/hungarianmap.py @@ -22,10 +22,8 @@ """ 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 @@ -56,7 +54,7 @@ } -# TODO: NUTS-1 (country parts) and NUTS-2 (statistical regions) +# XXX: NUTS-1 (country parts) and NUTS-2 (statistical regions)? with open(os.path.join(