chore: переделал коридор для большого графика

This commit is contained in:
Андрей Скирченко 2024-11-16 21:34:17 +03:00
parent 180b9f0a71
commit efbdb8ca19

View File

@ -41,6 +41,11 @@ class PlotWidget(BasePlotWidget):
legend.setParentItem(plot_widget.graphicsItem())
return plot_widget, legend
def _find_linear_stage(self, signal: pd.Series):
max_index = np.argmax(signal)
start = max_index + 10
return start
def get_stage_info(self,
stage: str,
dataframe: pd.DataFrame,
@ -105,15 +110,17 @@ class PlotWidget(BasePlotWidget):
plot_widget.setYRange(mean - 260, mean + 260)
plot_widget.setInteractive(False)
else:
max_value = min([max(dataframe[signal["name"]]) for signal in description["Signals"]])
region = pg.LinearRegionItem([max_value - max_value * 0.015,
max_value + max_value * 0.015],
i_list = [self._find_linear_stage(dataframe[signal["name"]]) for signal in description["Signals"]]
mean_i = np.mean(i_list)
x = time_axis[int(mean_i)]
y = np.mean([dataframe[signal["name"]][int(mean_i)] for signal in description["Signals"]])
region = pg.LinearRegionItem([y - y * 0.015,
y + y * 0.015],
movable=False,
orientation="horizontal")
region.setBrush(pg.mkBrush([0, 250, 0, 100]))
plot_widget.setYRange(max_value - 200, max_value + 200)
plot_widget.setXRange(3.5, 4.5)
plot_widget.setYRange(y - 200, y + 200)
plot_widget.setXRange(x, x + 0.5)
plot_widget.addItem(region)
plot_widget.setInteractive(False)