<s> from . option import Base <EOL> from . option import Axis , Legend , Tooltip , Series <EOL> from . datastructure import * <EOL> __version__ = '<STR_LIT>' <EOL> __author__ = '<STR_LIT>' <EOL> class Echart ( Base ) : <EOL> def __init__ ( self , title , description = None , ** kwargs ) : <EOL> self . title = { <EOL> '<STR_LIT:text>' : title , <EOL> '<STR_LIT>' : description , <EOL> } <EOL> self . x_axis = [ ] <EOL> self . y_axis = [ ] <EOL> self . series = [ ] <EOL> def use ( self , obj ) : <EOL> if isinstance ( obj , Axis ) : <EOL> if obj . position in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> self . x_axis . append ( obj ) <EOL> else : <EOL> self . y_axis . append ( obj ) <EOL> return self <EOL> if isinstance ( obj , Legend ) : <EOL> self . legend = obj <EOL> elif isinstance ( obj , Tooltip ) : <EOL> self . tooltip = obj <EOL> elif isinstance ( obj , Series ) : <EOL> self . series . append ( obj ) <EOL> return self <EOL> @ property <EOL> def data ( self ) : <EOL> return self . series <EOL> @ property <EOL> def json ( self ) : <EOL> """<STR_LIT>""" <EOL> json = { <EOL> '<STR_LIT:title>' : self . title , <EOL> '<STR_LIT>' : list ( map ( dict , self . x_axis ) ) , <EOL> '<STR_LIT>' : list ( map ( dict , self . y_axis ) ) , <EOL> '<STR_LIT>' : list ( map ( dict , self . series ) ) , <EOL> } <EOL> if not hasattr ( self , '<STR_LIT>' ) : <EOL> self . legend = Legend ( list ( map ( lambda o : o . name , self . data ) ) ) <EOL> json [ '<STR_LIT>' ] = self . legend . json <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> json [ '<STR_LIT>' ] = self . tooltip . json <EOL> return json </s>
