@ -24,7 +24,9 @@ from pygal.util import cycle_fill
from pygal import colors
from pygal . colors import darken , lighten
import sys
import re
re_dasharray_delimiters = re . compile ( r ' [ \ .|,|x| \ || \ - ]+ ' , re . I )
class Style ( object ) :
""" Styling class containing colors for the css generation """
@ -38,6 +40,9 @@ class Style(object):
font_family = ' monospace ' , # Monospaced font is highly encouraged
opacity = ' .8 ' ,
opacity_hover = ' .9 ' ,
stroke_width = ' 1 ' ,
stroke_style = ' round ' ,
stroke_dasharray = ( 0 , 0 ) ,
transition = ' 250ms ' ,
colors = (
' #ff5995 ' , ' #b6e354 ' , ' #feed6c ' , ' #8cedff ' , ' #9e6ffe ' ,
@ -52,9 +57,34 @@ class Style(object):
self . font_family = font_family
self . opacity = opacity
self . opacity_hover = opacity_hover
self . stroke_width = stroke_width
self . stroke_style = stroke_style
self . stroke_dasharray = stroke_dasharray
self . transition = transition
self . colors = colors
self . validate_stroke_values ( )
def validate_stroke_values ( self ) :
# stroke_width
self . stroke_width = float ( self . stroke_width )
# stroke_style
self . stroke_style = self . stroke_style . lower ( ) . strip ( )
if not self . stroke_style in [ ' round ' , ' bevel ' , ' miter ' ] :
self . stroke_style = ' round '
# stroke_dasharray
if isinstance ( self . stroke_dasharray , ( list , tuple ) ) :
self . stroke_dasharray = ' %d , %d ' % self . stroke_dasharray
if isinstance ( self . stroke_dasharray , str ) :
self . stroke_dasharray = re . sub ( re_dasharray_delimiters , ' , ' , self . stroke_dasharray )
if not isinstance ( self . stroke_dasharray , str ) :
raise ValueError ( ' stroke_dasharray not in proper form: tuple(int,int) ' )
def get_colors ( self , prefix ) :
""" Get the css color list """