Skip to content

graphmodules

Pragmatismo edited this page Mar 8, 2023 · 5 revisions

Graph Modules

These take lists of data and create a .png image of a graph or some visual display of the information which is saved to the requested output destination.

Internal workings of Graph Modules

Graph modules must have two functions; one that lists settings and one that creates the graph.

Read Graph Options

read_graph_options() - this simply returns a list of all the options which can be used with this graph and their default values.

def read_graph_options():
    graph_module_settings_dict = {
         "title_text":"",
         "color_cycle":"false",
         "line_style":"-",
         "marker":"o",
         "show_grid":"true",
         "major_ticks":"",
         "minor_ticks":""
         }
    return graph_module_settings_dict

These settings are used in the gui and graph presets used to make datawalls, the settings dictionary is handed to the make_graph function as extra=graph_module_settings_dict

Make Graph

make_graph(list_of_datasets, graph_path, ymax="", ymin="", size_h="", size_v="",
extra={})

This will be imported by either the gui or the make graph script on the pi, must be handed a list_of_datasets including a list of datetimes and values for each dataset to be graphed, currently they also require keys but this will be altered - for example [ [dates, temp_values, keys], [dates, humid_values, keys] ]

graph_path is also required and is the output path of the finished graph.

extra= an optional dictionary of settings to be changed, e.g. to mark each point on a line graph with a small circle extra['marker'] = "o"

to disable markers. extra['marker'] = ""

Clone this wiki locally