basic_report.report module¶
- class basic_report.report.Report(report_dir, report_title=None, report_date=None, config_file=None, color_mode='light', text_color=None)[source]¶
Bases:
objectMain report object
- Parameters:
report_dir (str | Path)
report_title (str | None)
report_date (str | int | date | datetime | None)
config_file (str | Path | None)
color_mode (str)
text_color (str | None)
- add_accordion_item(name)[source]¶
Add another accordion item to the current accordion layout
- Parameters:
name (str) – The text shown on the accordion
- add_calendar_heatmap(*, misc=None, domain=None, label=None, subdomain=None, date=None, color=None, x=None, y=None, custom_config=None)[source]¶
Add a calendar heatmap to the report
- Parameters:
misc (CalendarMisc | None) – The miscellaneous configuration for the calendar heatmap
domain (CalendarDomain | None) – The domain configuration for the calendar heatmap
label (CalendarLabel | None) – The label configuration for the calendar heatmap
subdomain (CalendarSubDomain | None) – (CalendarSubDomain | None): The subdomain configuration for the calendar heatmap
date (CalendarDate | None) – The date configuration for the calendar heatmap
color (CalendarColor | None) – The color configuration for the calendar heatmap
x (list[str] | None) – The time data array, e.g., dates
y (list[float | int] | None) – The corresponding value array
custom_config (dict[str, Any] | None) – A custom config dict to easily override any defaults set in the report. See the documentation for the calendar heatmap for an in depth discussion of the available parameters
- add_card(*, background_color=None, border_color=None, image=None, header_text=None, header_text_color=None, header_background_color=None, header_border_color=None, footer_text=None, footer_text_color=None, footer_background_color=None, footer_border_color=None, max_width='18rem')[source]¶
Add a section title to the page
- Parameters:
background_color (str | None) – The name of the background color for the whole card
border_color (str | None) – The name of the border color for the whole card
image (str | None) – A header image for the card. The source image will not be deleted!
header_text (str | None) – Text to be shown as header of the card
header_text_color (str | None) – The name of the header text color
header_background_color (str | None) – The name of the background color for the header section
header_border_color (str | None) – The name of the border color for the header section, only really
footer_text (str | None) – Text to be shown as footer of the card
footer_text_color (str | None) – The name of the footer text color
footer_background_color (str | None) – The name of the background color for the footer section
footer_border_color (str | None) – The name of the border color for the footer section, only really affects the line between the footer and the body
max_width (str) – The maximum width of the card
- add_custom_html_code(html)[source]¶
Add custom / generic html code
- Parameters:
html (str) – The HTML string.
- add_dictionary(dictionary, key_color=None, key_width=None, value_color=None)[source]¶
Add a dictionary as key value list to the report
- Parameters:
dictionary (dict[str, str] | list[list[str]]) – The dictionary that should be added to the report. The key will be right aligned in one column, whereas the values will be left aligned in the next column
key_color (str | None) – The text color for the keys
key_width (str | None) – The width of the key column. Use any of the html specifications, e.g. 150px etc.
value_color (str | None) – The color of the value text
- add_error_warning_info_section(**kwargs)[source]¶
Add a section detailing errors, warnings, and info
- add_global_link_to_page(page_name, link_name)[source]¶
Add a link to another page to the navbar
- Parameters:
page_name (str) – The key/name of the page to link to
link_name (str) – The text that will be displayed
- add_header(header_text, color=None)[source]¶
Add a header to the current page
- Parameters:
header_text (str) – Header text. You can use any valid HTML code inside the text, e.g., links and such.
color (Optional[str]) – Color of the header box
- add_image(image_source, remove_source=None, responsive=None, center=None)[source]¶
Add an image to the current page
- Parameters:
image_source (Union[str, Path]) – The path to the image to add
remove_source (Optional[bool]) – If true the source will be deleted and only acopy in the report dir is kept
responsive (Optional[bool]) – If true the image will automatically be resized to match the outer container
center (Optional[bool]) – If true the image will be centered
- add_list(list_items)[source]¶
Add a list to the current page
- Parameters:
list_items (list[str]) – A list to be added to the page
- add_local_link_to_page(page_name, link_name)[source]¶
Add a link to another page to the current page
- Parameters:
page_name (str) – The key/name of the page to link to
link_name (str) – The text that will be displayed
Add another navbar item to the current navbar layout
- Parameters:
name (str) – The text shown on the navbar pill
- add_page(name, subpage=True, color_mode=None)[source]¶
Add a new page to the report
- Parameters:
name (str) – The name of the report page
subpage (bool) – Indicates this is a subpage of the report
color_mode (Optional[str]) – Color mode of the page, either light or dark
- add_report_header(include_date=True, include_created_at=True, color=None)[source]¶
Add a report header to the current page
- Parameters:
include_date (bool) – Add the current date to the report
include_created_at (bool) – Include a subheader with the exact creation time of the report
color (Optional[str]) – The backgroound color for the header
- add_section_title(title_text, text_color=None, bar_color=None, alignment=None)[source]¶
Add a section title to the page
- Parameters:
title_text (str) – Title text
text_color (Optional[str]) – Color of the title text
bar_color (Optional[str]) – Color of the bars
alignment (Optional[str]) – Alignment of the title. If left or right is chosen the bar will be omitted on the chosen side
- add_sub_header(header_text, color=None, sub_level=None)[source]¶
Add a sub header to the current page
- Parameters:
header_text (str) – Header text. You can use any valid HTML code inside the text, e.g., links and such.
color (Optional[str]) – Color of the header box
sub_level (Optional[int]) – Shrinks the width of the header box. Levels can be 1 to 5. The higher the level the smaller the box
- add_tab(name)[source]¶
Add another tab to the current tab layout
- Parameters:
name (str) – The text shown on the tab
- add_table(table_data, formatters=None, options=None, size=None, align=None, caption=None, footers=None, order=None, color=None)[source]¶
Add a table to the page.
table_datacan either be a pandasDataFrameor a list of lists. For the former we assume indices and column labels are already properly formatted. For the latter we assume the first item contains the headers.- Parameters:
table_data (Union[DataFrame, list[list[Any]]]) – Data to tabelize.
formatters (Optional[Union[str, Callable, list[str], list[Callable]]]) – Formatters applied to each table element. If a list is provided it must match the number of columns. A single formatter is applied to all columns. The default formatter is
str().options (Optional[list[str]]) –
Turn optional elements of the DataTable on. Supported options:
page- Split long tables into pages of 10 (configurable)info- Show number of rowssearch- Add a search fieldno_sort- Disable initial sortingcolor_negative_values- Highlight values < 0 in redcolor_positive_values- Highlight values > 0 in greenfull_width- Table spans full window width
size (Optional[int]) – Sets the width of the table (1-12).
12uses full container width.align (Optional[str]) – Alignment of cell content.
caption (Optional[str]) – Text shown below the table.
footers (Optional[list[list[Any]]]) – Rows always shown at the bottom of the table.
order (Optional[list[list[Any]]]) – Default table order in the form
[[col_idx, 'asc' | 'desc'], ...].color (Optional[str]) – Text color. Automatically determined if omitted.
- add_text(text, color=None, align=None)[source]¶
Add (colored) text to the page
This will create a new paragraph. So if you want to mix colors within one paragraph you’ll have to do this yourself for now
- Parameters:
text (str) – Your text
color (Optional[str]) – One of the supported colors
align (Optional[Literal['left', 'center', 'right']]) – Alignment of text
Close the current navbar layout
- dump(*, overwrite=False)[source]¶
Save the report to file and add the CSS files
- Parameters:
overwrite (bool) – If true an existing report dir will be deleted first. Use with caution, there are no additional checks and balances implemented. If you rm your root its on you.
- get_local_link_to_page(page_name, link_name)[source]¶
Get a link to another page to the current page
- Parameters:
page_name (str) – The key/name of the page to link to
link_name (str) – The text that will be displayed
- open_cards(cards_type)[source]¶
Open a navbar layout
- Parameters:
cards_type (Literal['group', 'deck', 'columns'])
Open a navbar layout
- Parameters:
loc (Literal['left', 'right', 'top'] | None)
color (Literal['gray', 'red', 'blue', 'green'] | None)