From b1f21bb03e419684a89e22bccd7186dc7cd2a97c Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Tue, 27 Sep 2011 09:43:18 +0200 Subject: [PATCH] Use real classes for bar styling --- pygal/bar.css | 63 +++++++++++++++----------------------------------- pygal/bar.py | 2 +- pygal/graph.py | 23 ++++++++---------- pygal/pie.css | 28 ++++++++++------------ 4 files changed, 42 insertions(+), 74 deletions(-) diff --git a/pygal/bar.css b/pygal/bar.css index 321b9a2..a2dcde2 100644 --- a/pygal/bar.css +++ b/pygal/bar.css @@ -1,83 +1,58 @@ -/* -$Id$ - -default fill styles for multiple datasets (probably only use a single -dataset on this graph though) -*/ -.key1,.fill1{ - fill: #ff0000; +.key, .fill { fill-opacity: 0.5; stroke: none; - stroke-width: 0.5; - + stroke-width: 1px; } -.key1,.fill1:hover{ + +.fill:hover{ fill-opacity: 0.25; -webkit-transition: 250ms; } + +.key1,.fill1{ + fill: #ff0000; +} + .key2,.fill2{ fill: #0000ff; - fill-opacity: 0.5; - stroke: none; - stroke-width: 1px; } + .key3,.fill3{ fill: #00ff00; - fill-opacity: 0.5; - stroke: none; - stroke-width: 1px; } + .key4,.fill4{ fill: #ffcc00; - fill-opacity: 0.5; - stroke: none; - stroke-width: 1px; } + .key5,.fill5{ fill: #00ccff; - fill-opacity: 0.5; - stroke: none; - stroke-width: 1px; } + .key6,.fill6{ fill: #ff00ff; - fill-opacity: 0.5; - stroke: none; - stroke-width: 1px; } + .key7,.fill7{ fill: #00ffff; - fill-opacity: 0.5; - stroke: none; - stroke-width: 1px; } + .key8,.fill8{ fill: #ffff00; - fill-opacity: 0.5; - stroke: none; - stroke-width: 1px; } + .key9,.fill9{ fill: #cc6666; - fill-opacity: 0.5; - stroke: none; - stroke-width: 1px; } + .key10,.fill10{ fill: #663399; - fill-opacity: 0.5; - stroke: none; - stroke-width: 1px; } + .key11,.fill11{ fill: #339900; - fill-opacity: 0.5; - stroke: none; - stroke-width: 1px; } + .key12,.fill12{ fill: #9966FF; - fill-opacity: 0.5; - stroke: none; - stroke-width: 1px; } diff --git a/pygal/bar.py b/pygal/bar.py index 8ea1d2a..75b0b7e 100644 --- a/pygal/bar.py +++ b/pygal/bar.py @@ -190,7 +190,7 @@ class VerticalBar(Bar): 'y': str(top), 'width': str(bar_width), 'height': str(length), - 'class': 'fill%s' % (dataset_count + 1), + 'class': 'fill fill%s' % (dataset_count + 1), }) self.make_datapoint_text( diff --git a/pygal/graph.py b/pygal/graph.py index f4867a3..dd4d51c 100644 --- a/pygal/graph.py +++ b/pygal/graph.py @@ -51,8 +51,8 @@ class Graph(object): * pygal.time_series """ - width = 500 - height = 300 + width = 1000 + height = 500 show_x_guidelines = False show_y_guidelines = True show_data_values = True @@ -575,7 +575,7 @@ class Graph(object): 'y': str(y_offset), 'width': str(self.KEY_BOX_SIZE), 'height': str(self.KEY_BOX_SIZE), - 'class': 'key%s' % (key_count + 1), + 'class': 'key key%s' % (key_count + 1), }) text = etree.SubElement(group, 'text', { 'x': str(self.KEY_BOX_SIZE + 5), @@ -644,14 +644,14 @@ class Graph(object): NSMAP = { None: SVG_NAMESPACE, 'xlink': 'http://www.w3.org/1999/xlink', - 'a3': 'http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/', + # 'a3': 'http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/', } self.root = etree.Element(SVG + "svg", attrib={ 'width': str(self.width), 'height': str(self.height), - 'viewBox': '0 0 %s %s' % (self.width, self.height), - '{http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/}' - 'scriptImplementation': 'Adobe', + 'viewBox': '0 0 100% 100%', + # '{http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/}' + # 'scriptImplementation': 'Adobe', }, nsmap=NSMAP) if hasattr(self, 'style_sheet_href'): pi = etree.ProcessingInstruction( @@ -661,12 +661,9 @@ class Graph(object): self.root.addprevious(pi) comment_strings = ( - ' Created with SVG.Graph ', - ' SVG.Graph by Jason R. Coombs ', - ' Based on SVG::Graph by Sean E. Russel ', - ' Based on Perl SVG:TT:Graph by Leo Lapworth & Stephan Morgan ', - ' ' + '/' * 66, - ) + u'Generatel with pygal ©Kozea 2011', + ' Based upon SVG.Graph by Jason R. Coombs ', + ) map(self.root.append, map(etree.Comment, comment_strings)) defs = etree.SubElement(self.root, 'defs') diff --git a/pygal/pie.css b/pygal/pie.css index 26ed4ed..8f72a72 100644 --- a/pygal/pie.css +++ b/pygal/pie.css @@ -1,7 +1,3 @@ -/* -$Id$ -*/ - .dataPointLabel{ fill: #000000; text-anchor:middle; @@ -15,71 +11,71 @@ $Id$ fill: #ff0000; fill-opacity: 0.7; stroke: none; - stroke-width: 1px; + stroke-width: 1px; } .key2,.fill2{ fill: #0000ff; fill-opacity: 0.7; stroke: none; - stroke-width: 1px; + stroke-width: 1px; } .key3,.fill3{ fill-opacity: 0.7; fill: #00ff00; stroke: none; - stroke-width: 1px; + stroke-width: 1px; } .key4,.fill4{ fill-opacity: 0.7; fill: #ffcc00; stroke: none; - stroke-width: 1px; + stroke-width: 1px; } .key5,.fill5{ fill-opacity: 0.7; fill: #00ccff; stroke: none; - stroke-width: 1px; + stroke-width: 1px; } .key6,.fill6{ fill-opacity: 0.7; fill: #ff00ff; stroke: none; - stroke-width: 1px; + stroke-width: 1px; } .key7,.fill7{ fill-opacity: 0.7; fill: #00ff99; stroke: none; - stroke-width: 1px; + stroke-width: 1px; } .key8,.fill8{ fill-opacity: 0.7; fill: #ffff00; stroke: none; - stroke-width: 1px; + stroke-width: 1px; } .key9,.fill9{ fill-opacity: 0.7; fill: #cc6666; stroke: none; - stroke-width: 1px; + stroke-width: 1px; } .key10,.fill10{ fill-opacity: 0.7; fill: #663399; stroke: none; - stroke-width: 1px; + stroke-width: 1px; } .key11,.fill11{ fill-opacity: 0.7; fill: #339900; stroke: none; - stroke-width: 1px; + stroke-width: 1px; } .key12,.fill12{ fill-opacity: 0.7; fill: #9966FF; stroke: none; - stroke-width: 1px; + stroke-width: 1px; }