CovidDashboard Class#

class CovidDashboard.Dashboard#

Bases: object

Used to create dashboards and tables from COVID data.

This class can be used to create dashboards from a list of images and to create tables from Lists that can be added to dashbaords or graphs. An example is included below.

create_PNG(width, height, file_name, fontsize)#

Creates a png file with specified dimensions and pink boarder.

Args:
width

Integer Value, width of the image in pixels.

height

Integer Value, height of the image in pixels.

file_name

String Value, the loaction where the file will be saved, do not include file extension or file path just the file_name.

fontsize

Integer Value, not used at this time.

create_dashboard(title, images, file_name)#

Takes a list of PNG images and creates a dashboard. Images will be displayed in order.

Args:
title

String Value, this is the title of the dashboard.

images

List, this will be a list of images to be used for the dashboard.

file_name

String Value, this is the name of the image file for the dashbaord, do not include the file extension.

Note

Do not include the file extension for the file_name argument.

Note

Only give 2 sizes of images to this function all portrait images should be the same size and all landscape images should be the same size.

Note

If you give portrait images they should be in an even number as these are laid side by side.

create_row(x_start, y_start, x_padding, y_padding, data, fill_colour, line_colour, label, to_total, image_path, fontsize)#

Creates a row of a table from a list of data.

Args,
x_start

Integer Value, start location on the x-axis.

y_start

Integer Value, start location on the y-axis.

x_padding

Integer Value, the amount of padding to have in the x-axis in pixels.

y_padding

Integer Value, the amount of padding to have in the y-axis in pixels.

data

List, data that will be used in the tables row.

fill_colour

String Value, background colour of the cells.

line_colour

String Value, Line colour of the table lines.

label

String Value, title for the row.

to_total

Boolean Value, this will be true if the values are to be added and a totals column inserted.

image_path

String Value, locaiton of the image that the table row will be inserted into, this must already exist.

fonstsize

Integer Value, size of the fonts to be used when generating the table.

create_table(x_start, y_start, x_padding, y_padding, data, fill_colour, line_colour, label, to_total, image_path, fontsize, title_row, table_title)#

Create a table and saves to PNG image, this method uses the create_row method in a loop to create tables.

Note

Data is a multidimenstional list data[row][column]

Args:
x_start

Integer Value, start location on the x-axis.

y_start

Integer Value, start location on the y-axis.

x_padding

Integer Value, the amount of padding to have in the x-axis in pixels.

y_padding

Integer Value, the amount of padding to have in the y-axis in pixels.

data

List[][], data that will be used in the tables row, this is multidimensional List[row][column].

fill_colour

String Value, background colour of the cells.

line_colour

String Value, Line colour of the table lines.

label

List, title for each column.

to_total

Boolean Value, this will be true if the values are to be added and a totals column inserted.

image_path

String Value, locaiton of the image that the table row will be inserted into, this must already exist.

fonstsize

Integer Value, size of the fonts to be used when generating the table.

title_row

List, title of each row, there must be a title for each row and a blank title for the top row if your using title_row.

table_title

String Value, title of the table.

Note

Please note that len(label) must be equal to the number of rows, this is the title for each row.

Note

If title_row is used then a blank label must be included in the label List i.e label = [‘’,’20 - 24’, ‘25 - 29’, ‘30 - 34’].

Note

If to_total is true then ensure that all data apart from the title header is numeric, for non numeric data set to_total to False.

Example:

from CovidDashboard import Dashboard as dash

dash = dash()
label = ['', 'Cases', 'Deaths', 'CFR']
title_row = ['0-4', '5-9', '10-14']
data = [title_row,[20156,22514,30145],[0,1,2],['0%','0%','0%']]

dash.create_table(500, 200, 15, 15, data, "white", "black", label, 
    False, "reports/images/test_Table.png", 30, True, "Just a test table")

This is what the table will look like:

0-4

5-9

10-14

Cases

20,156

22,514

30,145

Deaths

0

1

2

CFR

0%

0%

0%