Debugged reports.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Construct turnaround time charts
|
||||
Construct BC control concentration charts
|
||||
"""
|
||||
from pprint import pformat
|
||||
from . import CustomFigure
|
||||
@@ -21,17 +21,15 @@ class ConcentrationsChart(CustomFigure):
|
||||
super().__init__(df=df, modes=modes, settings=settings)
|
||||
self.df = df
|
||||
self.construct_chart()
|
||||
# if threshold:
|
||||
# self.add_hline(y=threshold)
|
||||
self.update_layout(showlegend=False)
|
||||
|
||||
def construct_chart(self, df: pd.DataFrame | None = None):
|
||||
if df:
|
||||
self.df = df
|
||||
# logger.debug(f"Constructing concentration chart with df:\n{self.df}")
|
||||
try:
|
||||
self.df = self.df[self.df.concentration.notnull()]
|
||||
self.df = self.df.sort_values(['submitted_date', 'submission'], ascending=[True, True]).reset_index(drop=True)
|
||||
self.df = self.df.sort_values(['submitted_date', 'submission'], ascending=[True, True]).reset_index(
|
||||
drop=True)
|
||||
self.df = self.df.reset_index().rename(columns={"index": "idx"})
|
||||
# logger.debug(f"DF after changes:\n{self.df}")
|
||||
scatter = px.scatter(data_frame=self.df, x='submission', y="concentration",
|
||||
@@ -41,8 +39,6 @@ class ConcentrationsChart(CustomFigure):
|
||||
except (ValueError, AttributeError) as e:
|
||||
logger.error(f"Error constructing chart: {e}")
|
||||
scatter = px.scatter()
|
||||
# logger.debug(f"Scatter data: {scatter.data}")
|
||||
# self.add_traces(scatter.data)
|
||||
# NOTE: For some reason if data is allowed to sort itself it leads to wrong ordering of x axis.
|
||||
traces = sorted(scatter.data, key=itemgetter("name"))
|
||||
for trace in traces:
|
||||
@@ -60,6 +56,9 @@ class ConcentrationsChart(CustomFigure):
|
||||
tickmode='array',
|
||||
tickvals=tickvals,
|
||||
ticktext=ticklabels,
|
||||
),
|
||||
yaxis=dict(
|
||||
rangemode="nonnegative"
|
||||
)
|
||||
)
|
||||
self.update_traces(marker={'size': 15})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
Pane showing turnaround time summary.
|
||||
Pane showing BC control concentrations summary.
|
||||
"""
|
||||
from PyQt6.QtWidgets import QWidget, QPushButton, QComboBox, QLabel
|
||||
from PyQt6.QtWidgets import QWidget, QPushButton
|
||||
from .info_tab import InfoPane
|
||||
from backend.excel.reports import ConcentrationMaker
|
||||
from frontend.visualizations.concentrations_chart import ConcentrationsChart
|
||||
@@ -22,12 +22,6 @@ class Concentrations(InfoPane):
|
||||
self.layout.addWidget(self.export_button, 0, 3, 1, 1)
|
||||
self.fig = None
|
||||
self.report_object = None
|
||||
# self.submission_typer = QComboBox(self)
|
||||
# subs = ["All"] + [item.name for item in SubmissionType.query()]
|
||||
# self.submission_typer.addItems(subs)
|
||||
# self.layout.addWidget(QLabel("Submission Type"), 1, 0, 1, 1)
|
||||
# self.layout.addWidget(self.submission_typer, 1, 1, 1, 3)
|
||||
# self.submission_typer.currentTextChanged.connect(self.update_data)
|
||||
self.update_data()
|
||||
|
||||
def update_data(self) -> None:
|
||||
@@ -40,17 +34,6 @@ class Concentrations(InfoPane):
|
||||
super().update_data()
|
||||
months = self.diff_month(self.start_date, self.end_date)
|
||||
chart_settings = dict(start_date=self.start_date, end_date=self.end_date)
|
||||
# if self.submission_typer.currentText() == "All":
|
||||
# submission_type = None
|
||||
# subtype_obj = None
|
||||
# else:
|
||||
# submission_type = self.submission_typer.currentText()
|
||||
# subtype_obj = SubmissionType.query(name = submission_type)
|
||||
# self.report_obj = ConcentrationMaker(start_date=self.start_date, end_date=self.end_date)#, submission_type=submission_type)
|
||||
self.report_obj = ConcentrationMaker(**chart_settings)
|
||||
# if subtype_obj:
|
||||
# threshold = subtype_obj.defaults['turnaround_time'] + 0.5
|
||||
# else:
|
||||
# threshold = None
|
||||
self.fig = ConcentrationsChart(df=self.report_obj.df, settings=chart_settings, modes=[], months=months)
|
||||
self.webview.setHtml(self.fig.html)
|
||||
|
||||
Reference in New Issue
Block a user