From 20fec69159214e1d808dd7393786b060ea438777 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Fri, 10 Feb 2012 18:44:44 +0100 Subject: [PATCH] Styles --- out.py | 19 ++++++++++++------- pygal/css/graph.css | 14 ++++++++------ pygal/svg.py | 1 - 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/out.py b/out.py index fc2599b..b1ce739 100755 --- a/out.py +++ b/out.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from pygal import Line, Bar, XY, Pie, StackedBar, Config +from pygal.style import NeonStyle from math import cos, sin bar = Bar() @@ -11,19 +12,23 @@ bar.title = "Bar test" with open('out-bar.svg', 'w') as f: f.write(bar.render()) -stackedbar = StackedBar() + rng = [3, -32, 39, 12] -stackedbar.add('@@@@@@@', rng) rng2 = [24, -8, 18, 12] -stackedbar.add('++++++', rng2) rng3 = [6, 1, -10, 0] -stackedbar.add('--->', rng3) -stackedbar.x_label_rotation = 35 -stackedbar.x_labels = map(lambda x: '%s / %s / %s' % x, +config = Config() +config.x_label_rotation = 35 +config.x_labels = map(lambda x: '%s / %s / %s' % x, zip(map(str, rng), map(str, rng2), map(str, rng3))) -stackedbar.title = "Stackedbar test" +config.title = "Config test" +config.style = NeonStyle + +stackedbar = StackedBar(config) +stackedbar.add('@@@@@@@', rng) +stackedbar.add('++++++', rng2) +stackedbar.add('--->', rng3) with open('out-stackedbar.svg', 'w') as f: f.write(stackedbar.render()) diff --git a/pygal/css/graph.css b/pygal/css/graph.css index 77c4f66..c6e6006 100644 --- a/pygal/css/graph.css +++ b/pygal/css/graph.css @@ -93,6 +93,10 @@ svg * { stroke-width: 5px; } +.series .rect, .series .slice { + fill-opacity: {{ style.opacity }}; +} + .series text { opacity: 0; font-size: {{ font_sizes.values }}; @@ -106,6 +110,10 @@ svg * { opacity: 1; } +.series .bar:hover .rect, .series .slice:hover path{ + fill-opacity: 1; +} + .series .line { fill: none; stroke-width: 1px; @@ -116,13 +124,7 @@ svg * { stroke-width: 2px; } -.series .rect, .series .slice { - fill-opacity: {{ style.opacity }}; -} -.series .rect:hover, .series .slice:hover { - fill-opacity: 1; -} {{ style.colors }} diff --git a/pygal/svg.py b/pygal/svg.py index 966c6f8..651a030 100644 --- a/pygal/svg.py +++ b/pygal/svg.py @@ -1,7 +1,6 @@ import os from lxml import etree from pygal.view import View -from pygal.style import DefaultStyle from math import cos, sin, pi