From 30e9d95c89f6fc528703b7f0467e19aa7dc58bcc Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Tue, 4 Oct 2011 16:07:09 +0200 Subject: [PATCH] Strugling with size --- pygal/css/graph.css | 3 ++- pygal/graph.py | 10 +++++++--- setup.py | 12 +----------- test/moulinrouge/__init__.py | 6 ------ 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/pygal/css/graph.css b/pygal/css/graph.css index c35e040..8e26911 100644 --- a/pygal/css/graph.css +++ b/pygal/css/graph.css @@ -4,10 +4,11 @@ font-family: helvetica; } .svgBackground{ - fill:#ffffff; + fill: transparent; } .graphBackground{ fill: #e8eef6; + fill-opacity: 0.7; } /* graphs titles */ diff --git a/pygal/graph.py b/pygal/graph.py index eed0441..1f4f091 100644 --- a/pygal/graph.py +++ b/pygal/graph.py @@ -45,8 +45,8 @@ class Graph(object): * pygal.time_series """ - width = 1000 - height = 500 + ratio = .7 + width = 600 show_x_guidelines = False show_y_guidelines = True show_data_values = True @@ -99,6 +99,10 @@ class Graph(object): self.load_config(config) self.clear_data() + @property + def height(self): + return int(self.width * self.ratio) + def load_config(self, config): self.__dict__.update(config) @@ -515,7 +519,7 @@ class Graph(object): 'xlink': 'http://www.w3.org/1999/xlink', } self.root = etree.Element("{%s}svg" % svg_ns, attrib={ - 'viewBox': '0 0 100% 100%', + 'viewBox': '0 0 %d %d' % (self.width, self.height) }, nsmap=nsmap) if hasattr(self, 'style_sheet_href'): diff --git a/setup.py b/setup.py index 20ec60f..6fa651a 100644 --- a/setup.py +++ b/setup.py @@ -15,19 +15,10 @@ class DisabledTestCommand(Command): "test command not supported on pygal." " Use setup.py nosetests instead") -_this_dir = os.path.dirname(__file__) -_readme = os.path.join(_this_dir, 'readme.txt') -_long_description = open(_readme).read().strip() - -# it seems that dateutil 2.0 only works under Python 3 -dateutil_req = ( - ['python-dateutil>=1.4,<2.0dev'] if sys.version_info < (3, 0) - else ['python-dateutil>=2.0']) setup_params = dict( name="pygal", description="Python svg graph abstract layer", - long_description=_long_description, author="Jason R. Coombs, Kozea", author_email="jaraco@jaraco.com, gayoub@kozea.fr", url="https://github.com/Kozea/pygal", @@ -35,9 +26,8 @@ setup_params = dict( zip_safe=True, include_package_data=True, install_requires=[ - 'cssutils>=0.9.8a3', 'lxml>=2.0', - ] + dateutil_req, + ], license="MIT", classifiers=[ "Development Status :: 5 - Production/Stable", diff --git a/test/moulinrouge/__init__.py b/test/moulinrouge/__init__.py index fe5aa25..60c87cf 100644 --- a/test/moulinrouge/__init__.py +++ b/test/moulinrouge/__init__.py @@ -22,9 +22,6 @@ def random_value(): def generate_vbar(**opts): - opts.setdefault('width', 375) - opts.setdefault('height', 245) - g = VerticalBar(labels, opts) for serie, values in series.items(): g.add_data({'data': values, 'title': serie}) @@ -48,7 +45,6 @@ def create_app(): @app.route("/all-.svg") def all_svg(type): - width, height = 800, 600 series = random.randrange(1, 10) data = random.randrange(1, 10) @@ -62,8 +58,6 @@ def create_app(): series = 1 g = Pie({'fields': labels}) - g.width, g.height = width, height - for i in range(series): values = [random_value() for i in range(data)] g.add_data({'data': values, 'title': random_label()})