midrc_react.gui.common package
Submodules
midrc_react.gui.common.file_upload module
This module contains a function to process file uploads in a GUI application.
- midrc_react.gui.common.file_upload.process_file_upload(view, data_source_dict)
Process a file upload by printing debug information, opening the file via the view and updating the layout.
- Parameters:
view – An instance that implements open_excel_file and holds a data_selection_group_box attribute.
data_source_dict (dict) – Contains the uploaded file information.
midrc_react.gui.common.jsdview_base module
This module contains the JsdViewBase class, which serves as a base class for JSD views.
- class midrc_react.gui.common.jsdview_base.GroupBoxData
Bases:
object
This class represents a group box widget for data selection. It provides functionality for creating labels and combo boxes for data files and a category combo box. The class has methods for setting up the layout, updating the category combo box, and initializing the widget.
- Variables:
_file_infos (list) – A list of file information dictionaries.
_category_info (dict) – A dictionary containing information about the selected category.
- append_file_info(file_info: dict)
Appends a file information dictionary to the list of file information dictionaries.
- Parameters:
file_info (dict) – file information dictionary to append to the list
- property category_info
Get the category information dictionary.
- Returns:
A dictionary containing information about the selected category.
- Return type:
dict
- property file_infos
Get the file information dictionaries.
- Returns:
A list of file information dictionaries.
- Return type:
list
- get_category_info()
Get the category information dictionary.
- Returns:
A dictionary containing information about the selected category.
- Return type:
dict
- get_file_infos()
Get the file information dictionaries.
- Returns:
A list of file information dictionaries.
- Return type:
list
- update_category_index(categoryindex)
Updates the category information dictionary with the given category index.
- Parameters:
categoryindex (int) – Index to set the current category to
- Returns:
None
- update_category_list(categorylist, categoryindex)
Updates the category information dictionary with the given category list and index.
- Parameters:
categorylist (list(str)) – List of categories to add to the information dictionary
categoryindex (int) – Index to set the current index to (and item in the category list)
- Returns:
None
- update_category_text(categorytext)
Updates the category information dictionary with the given category text.
- Parameters:
categorytext (str) – The category to set the current category text (and current index) to
- Returns:
None
- class midrc_react.gui.common.jsdview_base.JsdViewBase
Bases:
QObject
This class represents a base class for JSD views. It provides functionality for creating a data selection group box, updating the category combo box, and initializing the widget.
- Variables:
_data_selection_group_box (GroupBoxData) – A data selection group box.
_controller (JSDController) – A JSDController object.
update_view_on_controller_initialization (bool) – A flag indicating whether the view should be updated on controller initialization.
- __init__()
Initialize the JsdViewBase.
- add_data_source
- property dataselectiongroupbox
Get the data selection group box.
- Returns:
The data selection group box.
- Return type:
- open_excel_file(data_source_dict)
Opens an Excel file and adds it to the data selection group box.
- Parameters:
data_source_dict (dict) – The data source dictionary.
- update_area_chart(category)
Updates the area chart with new data.
- Parameters:
category – The category to use for updating the area charts.
- update_jsd_timeline_plot(jsd_model: JSDTableModel)
Updates the JSD timeline plot with the specified JSD model.
- Parameters:
jsd_model – The JSDTableModel that contains the data for generating the timeline plot.
- update_pie_chart_dock(sheet_dict)
Updates the pie chart dock with the given sheet dict.
- Parameters:
sheet_dict (dict) – A dictionary of index keys and sheets.
- update_spider_chart(spider_plot_values_dict)
Updates the spider chart with new values.
- Parameters:
spider_plot_values_dict (dict) – A dictionary of dictionaries where each dictionary contains the values for one series on the spider chart.
- update_view_on_controller_initialization = True
midrc_react.gui.common.plot_utils module
This module contains a function to create a stacked area chart using Plotly.
- midrc_react.gui.common.plot_utils.create_stacked_area_figure(df, cols_to_use, cumulative_percents, individual_percents)
Create a stacked area chart by adding two traces per column: one for the filled area and one invisible trace for hover data.
- Parameters:
df (DataFrame) – Data frame containing a ‘date’ column.
cols_to_use (list) – List of column names to process.
cumulative_percents (dict) – Mapping of column names to cumulative percentage values.
individual_percents (dict) – Mapping of column names to actual percentage values.
- Returns:
The stacked area chart.
- Return type:
go.Figure
- midrc_react.gui.common.plot_utils.prepare_area_chart_data(df, cols_to_use, global_max_date)
Prepares data for an area chart.
If the maximum date in the dataframe is less than the global maximum date, appends a new row with the global maximum date.
Calculates cumulative percentages for the given columns.
- Parameters:
df (DataFrame) – Input data frame that must contain a ‘date’ column.
cols_to_use (list) – List of column names to use for calculations.
global_max_date – The global maximum date to compare with.
- Returns:
A tuple containing the updated DataFrame and the cumulative percentages.
- Return type:
tuple
midrc_react.gui.common.utils module
This module contains utility functions for file handling and data processing.
- midrc_react.gui.common.utils.create_data_source_dict(filename, file_content, data_type='content', content_type=None)
Create a data source dictionary.
- Parameters:
filename (str) – The file name.
file_content (BytesIO) – The file content.
data_type (str, optional) – The data type label. Defaults to ‘content’.
content_type (str, optional) – The content type. Defaults to None.
- Returns:
A dictionary with file details.
- Return type:
dict
- midrc_react.gui.common.utils.create_file_info(data_source, index)
Create a file info dictionary from a data source.
- Parameters:
data_source (dict) – Dictionary containing file info.
index (int) – The index to assign.
- Returns:
A dictionary with description, source_id, index and checked flag.
- Return type:
dict
- midrc_react.gui.common.utils.get_common_categories(file_infos, jsd_model)
Extract common categories from file information.
- Parameters:
file_infos (list) – List of file information dictionaries.
jsd_model – Model containing data_sources.
- Returns:
A list of common category keys.
- Return type:
list