import pandas as pd from PyQt5.QtWidgets import QWidget, QVBoxLayout import pyqtgraph as pg from base.base import BasePlotWidget class PlotWidget(BasePlotWidget): def _draw_stages(self, dataframe: pd.DataFrame) -> None: ... def _create_widget(self, dataframe: pd.DataFrame) -> QWidget: widget = QWidget() layout = QVBoxLayout() time_axis = dataframe["time"] dataframe_headers = dataframe.columns.tolist() for channel, description in self._plt_channels.items(): plot_widget = pg.PlotWidget(title=channel) plot_widget.showGrid(x=True, y=True) legend = pg.LegendItem((80, 60), offset=(70, 20)) legend.setParentItem(plot_widget.graphicsItem()) settings = description["Settings"] for signal in description["Signals"]: if signal["name"] in dataframe_headers: plot = plot_widget.plot(time_axis, dataframe[signal["name"]], pen=signal["pen"]) legend.addItem(plot, signal["name"]) if settings["zoom"] and max(time_axis) < 5.0: max_value = max(dataframe[signal["name"]]) plot_widget.setYRange(max_value - 200, max_value) plot_widget.setInteractive(False) layout.addWidget(plot_widget) widget.setLayout(layout) return widget def build(self, data: list[pd.DataFrame]) -> None: widgets = [self._create_widget(data_sample) for data_sample in data] self._mediator.notify(self, widgets)