34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
|
|
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"]
|
||
|
|
|
||
|
|
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:
|
||
|
|
plot = plot_widget.plot(time_axis, dataframe[signal["name"]], pen=signal["pen"])
|
||
|
|
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)
|