From eb9066991fb1803665596fa56be3835b5e1b5101 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Wed, 24 Jun 2015 18:00:59 +0200 Subject: [PATCH] Externalized swiss map to pygal_map_ch --- demo/moulinrouge/tests.py | 12 +++-- pygal/__init__.py | 1 - pygal/graph/maps/ch.cantons.svg | 91 --------------------------------- pygal/graph/swissmap.py | 72 -------------------------- pygal/test/test_config.py | 2 +- 5 files changed, 9 insertions(+), 169 deletions(-) delete mode 100644 pygal/graph/maps/ch.cantons.svg delete mode 100644 pygal/graph/swissmap.py diff --git a/demo/moulinrouge/tests.py b/demo/moulinrouge/tests.py index 7796ec9..458ba95 100644 --- a/demo/moulinrouge/tests.py +++ b/demo/moulinrouge/tests.py @@ -2,7 +2,7 @@ # This file is part of pygal from pygal import ( Bar, Gauge, Pyramid, Funnel, Dot, StackedBar, StackedLine, XY, - CHARTS_BY_NAME, Config, Line, Worldmap, Histogram, Box, SwissMapCantons, + CHARTS_BY_NAME, Config, Line, Worldmap, Histogram, Box, Pie, Treemap, TimeLine, DateLine, DateTimeLine, SupranationalWorldmap) @@ -11,11 +11,15 @@ try: except ImportError: fr = None +try: + from pygal.maps import ch +except ImportError: + ch = None + from flask import abort from pygal.style import styles, Style, RotateStyle from pygal.colors import rotate from pygal.graph.horizontal import HorizontalGraph -from pygal.graph.swissmap import CANTONS from random import randint, choice from datetime import datetime @@ -470,10 +474,10 @@ def get_test_routes(app): @app.route('/test/swissmap') def test_swissmap(): - smap = SwissMapCantons(style=choice(list(styles.values()))) + smap = ch.Cantons(style=choice(list(styles.values()))) for i in range(10): smap.add('s%d' % i, [ - (choice(list(CANTONS.keys())), randint(0, 100)) + (choice(list(ch.CANTONS.keys())), randint(0, 100)) for _ in range(randint(1, 5))]) smap.add('links', [{ diff --git a/pygal/__init__.py b/pygal/__init__.py index 86f0977..779c0a2 100644 --- a/pygal/__init__.py +++ b/pygal/__init__.py @@ -37,7 +37,6 @@ from pygal.graph.pyramid import Pyramid from pygal.graph.radar import Radar from pygal.graph.stackedbar import StackedBar from pygal.graph.stackedline import StackedLine -from pygal.graph.swissmap import SwissMapCantons from pygal.graph.time import DateLine, DateTimeLine, TimeLine, TimeDeltaLine from pygal.graph.treemap import Treemap from pygal.graph.verticalpyramid import VerticalPyramid diff --git a/pygal/graph/maps/ch.cantons.svg b/pygal/graph/maps/ch.cantons.svg deleted file mode 100644 index 7f016ad..0000000 --- a/pygal/graph/maps/ch.cantons.svg +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pygal/graph/swissmap.py b/pygal/graph/swissmap.py deleted file mode 100644 index bbacd0f..0000000 --- a/pygal/graph/swissmap.py +++ /dev/null @@ -1,72 +0,0 @@ -# -*- 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 . -""" -Worldmap chart - -""" - -from __future__ import division -from pygal.graph.map import BaseMap -from pygal._compat import u -import os - - -CANTONS = { - 'kt-zh': u("ZH"), - 'kt-be': u("BE"), - 'kt-lu': u("LU"), - 'kt-ju': u("JH"), - 'kt-ur': u("UR"), - 'kt-sz': u("SZ"), - 'kt-ow': u("OW"), - 'kt-nw': u("NW"), - 'kt-gl': u("GL"), - 'kt-zg': u("ZG"), - 'kt-fr': u("FR"), - 'kt-so': u("SO"), - 'kt-bl': u("BS"), - 'kt-bs': u("BL"), - 'kt-sh': u("SH"), - 'kt-ar': u("AR"), - 'kt-ai': u("AI"), - 'kt-sg': u("SG"), - 'kt-gr': u("GR"), - 'kt-ag': u("AG"), - 'kt-tg': u("TG"), - 'kt-ti': u("TI"), - 'kt-vd': u("VD"), - 'kt-vs': u("VS"), - 'kt-ne': u("NE"), - 'kt-ge': u("GE"), -} - - -with open(os.path.join( - os.path.dirname(__file__), 'maps', - 'ch.cantons.svg')) as file: - CNT_MAP = file.read() - - -class SwissMapCantons(BaseMap): - """Swiss Cantons map""" - x_labels = list(CANTONS.keys()) - area_names = CANTONS - area_prefix = 'z' - kind = 'canton' - svg_map = CNT_MAP diff --git a/pygal/test/test_config.py b/pygal/test/test_config.py index 373c279..38fbcd5 100644 --- a/pygal/test/test_config.py +++ b/pygal/test/test_config.py @@ -20,7 +20,7 @@ from pygal import ( Line, Dot, Pie, Treemap, Radar, Config, Bar, Funnel, Worldmap, SupranationalWorldmap, Histogram, Gauge, Box, XY, - Pyramid, HorizontalBar, HorizontalStackedBar, SwissMapCantons, + Pyramid, HorizontalBar, HorizontalStackedBar, DateTimeLine, TimeLine, DateLine, TimeDeltaLine) from pygal.graph.map import BaseMap from pygal._compat import u