import pandas as pd from PyQt5.QtWidgets import QWidget, QVBoxLayout import pyqtgraph as pg from base.base import BasePlotWidget class PlotWidget(BasePlotWidget): def _create_widget(self, dataframe: pd.DataFrame) -> QWidget: widget = QWidget() layout = QVBoxLayout() time_axis = dataframe["time"] print(max(time_axis)) for channel, signals in self._plot_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()) for signal in signals: if signal["name"] in dataframe.columns.tolist(): plot = plot_widget.plot(time_axis, dataframe[signal["name"]], pen=signal["pen"]) if signal["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) legend.addItem(plot, signal["name"]) 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)