<s> import json <EOL> from mesa . visualization . ModularVisualization import VisualizationElement <EOL> class ChartModule ( VisualizationElement ) : <EOL> '''<STR_LIT>''' <EOL> package_includes = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> series = [ ] <EOL> canvas_width = <NUM_LIT> <EOL> canvas_height = <NUM_LIT:200> <EOL> data_collector_name = "<STR_LIT>" <EOL> def __init__ ( self , series , canvas_height = <NUM_LIT:200> , canvas_width = <NUM_LIT> , <EOL> data_collector_name = "<STR_LIT>" ) : <EOL> '''<STR_LIT>''' <EOL> self . series = series <EOL> self . canvas_height = canvas_height <EOL> self . canvas_width = canvas_width <EOL> self . data_collector_name = data_collector_name <EOL> series_json = json . dumps ( self . series ) <EOL> new_element = "<STR_LIT>" <EOL> new_element = new_element . format ( series_json , canvas_width , <EOL> canvas_height ) <EOL> self . js_code = "<STR_LIT>" + new_element + "<STR_LIT>" <EOL> def render ( self , model ) : <EOL> current_values = [ ] <EOL> data_collector = getattr ( model , self . data_collector_name ) <EOL> for s in self . series : <EOL> name = s [ "<STR_LIT>" ] <EOL> try : <EOL> val = data_collector . model_vars [ name ] [ - <NUM_LIT:1> ] <EOL> except : <EOL> val = <NUM_LIT:0> <EOL> current_values . append ( val ) <EOL> return current_values </s>
