@ -29,6 +29,7 @@ import sys
from pygal . config import Config
from pygal . config import Config
from pygal . _compat import u , is_list_like
from pygal . _compat import u , is_list_like
from pygal . graph import CHARTS_NAMES
from pygal . graph import CHARTS_NAMES
from pygal . i18n import SUPRANATIONAL
from pygal . util import prepare_values
from pygal . util import prepare_values
from uuid import uuid4
from uuid import uuid4
@ -65,11 +66,29 @@ class Ghost(object):
""" Add a serie to this graph """
""" Add a serie to this graph """
if not is_list_like ( values ) and not isinstance ( values , dict ) :
if not is_list_like ( values ) and not isinstance ( values , dict ) :
values = [ values ]
values = [ values ]
values = self . replace_supranationals ( values )
if secondary :
if secondary :
self . raw_series2 . append ( ( title , values ) )
self . raw_series2 . append ( ( title , values ) )
else :
else :
self . raw_series . append ( ( title , values ) )
self . raw_series . append ( ( title , values ) )
def replace_supranationals ( self , values ) :
""" Replaces the values if it contains a supranational code. """
from pygal import Worldmap
if not isinstance ( self , Worldmap ) :
return values
for suprakey in SUPRANATIONAL . keys ( ) :
if suprakey in values :
if not isinstance ( values , dict ) :
del values [ values . index ( suprakey ) ]
values . extend ( SUPRANATIONAL [ suprakey ] )
else :
values . update (
dict ( [ ( code , values [ suprakey ] )
for code in SUPRANATIONAL [ suprakey ] ] ) )
del values [ suprakey ]
return values
def make_series ( self , series ) :
def make_series ( self , series ) :
return prepare_values ( series , self . config , self . cls )
return prepare_values ( series , self . config , self . cls )