Second round of code cleanup.
This commit is contained in:
@@ -2,12 +2,13 @@
|
||||
Contains all operations for creating charts, graphs and visual effects.
|
||||
'''
|
||||
from PyQt6.QtWidgets import QWidget
|
||||
import plotly
|
||||
import plotly, logging
|
||||
from plotly.graph_objects import Figure
|
||||
from plotly.graph_objs import FigureWidget
|
||||
import pandas as pd
|
||||
from frontend.widgets.functions import select_save_file
|
||||
|
||||
logger = logging.getLogger(f"submissions.{__name__}")
|
||||
|
||||
|
||||
class CustomFigure(Figure):
|
||||
|
||||
@@ -40,16 +41,12 @@ class CustomFigure(Figure):
|
||||
"""
|
||||
Creates final html code from plotly
|
||||
|
||||
Args:
|
||||
figure (Figure): input figure
|
||||
|
||||
Returns:
|
||||
str: html string
|
||||
"""
|
||||
html = '<html><body>'
|
||||
if self is not None:
|
||||
html += plotly.offline.plot(self, output_type='div',
|
||||
include_plotlyjs='cdn') #, image = 'png', auto_open=True, image_filename='plot_image')
|
||||
html += plotly.offline.plot(self, output_type='div', include_plotlyjs='cdn')
|
||||
else:
|
||||
html += "<h1>No data was retrieved for the given parameters.</h1>"
|
||||
html += '</body></html>'
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
Functions for constructing irida controls graphs using plotly.
|
||||
"""
|
||||
from pprint import pformat
|
||||
|
||||
from plotly.graph_objs import FigureWidget, Scatter
|
||||
|
||||
from . import CustomFigure
|
||||
import plotly.express as px
|
||||
import pandas as pd
|
||||
@@ -13,30 +10,23 @@ import logging
|
||||
|
||||
logger = logging.getLogger(f"submissions.{__name__}")
|
||||
|
||||
# NOTE: For click events try (haven't got working yet) ipywidgets >=7.0.0 required for figurewidgets:
|
||||
# https://plotly.com/python/click-events/
|
||||
|
||||
|
||||
class PCRFigure(CustomFigure):
|
||||
|
||||
def __init__(self, df: pd.DataFrame, modes: list, ytitle: str | None = None, parent: QWidget | None = None,
|
||||
months: int = 6):
|
||||
super().__init__(df=df, modes=modes)
|
||||
logger.debug(f"DF: {self.df}")
|
||||
# logger.debug(f"DF: {self.df}")
|
||||
self.construct_chart(df=df)
|
||||
|
||||
def hello(self):
|
||||
print("hello")
|
||||
|
||||
def construct_chart(self, df: pd.DataFrame):
|
||||
logger.debug(f"PCR df:\n {df}")
|
||||
# logger.debug(f"PCR df:\n {df}")
|
||||
try:
|
||||
express = px.scatter(data_frame=df, x='submitted_date', y="ct",
|
||||
scatter = px.scatter(data_frame=df, x='submitted_date', y="ct",
|
||||
hover_data=["name", "target", "ct", "reagent_lot"],
|
||||
color="target")
|
||||
except ValueError:
|
||||
express = px.scatter()
|
||||
scatter = FigureWidget([datum for datum in express.data])
|
||||
scatter = px.scatter()
|
||||
self.add_traces(scatter.data)
|
||||
self.update_traces(marker={'size': 15})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user