mirror of https://github.com/Kozea/pygal.git
Florian Mounier
13 years ago
7 changed files with 84 additions and 94 deletions
@ -0,0 +1,30 @@
|
||||
class Style(object): |
||||
def __init__(self, |
||||
background='black', |
||||
plot_background='#111', |
||||
foreground='#999', |
||||
foreground_light='#eee', |
||||
foreground_dark='#555', |
||||
colors=( |
||||
'#ff5995', '#b6e354', '#feed6c', '#8cedff', '#9e6ffe', |
||||
'#899ca1', '#f8f8f2', '#808384', '#bf4646', '#516083', |
||||
'#f92672', '#82b414', '#fd971f', '#56c2d6', '#8c54fe', |
||||
'#465457')): |
||||
self.background = background |
||||
self.plot_background = plot_background |
||||
self.foreground = foreground |
||||
self.foreground_light = foreground_light |
||||
self.foreground_dark = foreground_dark |
||||
self._colors = colors |
||||
|
||||
@property |
||||
def colors(self): |
||||
def color(tupl): |
||||
return ( |
||||
'.color-{0} {{\n' |
||||
' stroke: {1};\n' |
||||
' fill: {1};\n' |
||||
'}}\n'.format(*tupl)) |
||||
return '\n'.join(map(color, enumerate(self._colors))) |
||||
|
||||
DefaultStyle = Style() |
@ -0,0 +1,26 @@
|
||||
from pygal.style import Style |
||||
|
||||
|
||||
def test_colors(): |
||||
style = Style(colors=['red', '#231A3b', '#ff0', 'rgb(12, 231, 3)']) |
||||
assert style.colors == '''\ |
||||
.color-0 { |
||||
stroke: red; |
||||
fill: red; |
||||
} |
||||
|
||||
.color-1 { |
||||
stroke: #231A3b; |
||||
fill: #231A3b; |
||||
} |
||||
|
||||
.color-2 { |
||||
stroke: #ff0; |
||||
fill: #ff0; |
||||
} |
||||
|
||||
.color-3 { |
||||
stroke: rgb(12, 231, 3); |
||||
fill: rgb(12, 231, 3); |
||||
} |
||||
''' |
Loading…
Reference in new issue