0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 11:41:49 +02:00

fix: removed DI references, fixed set when adding plot by fig

This commit is contained in:
wyzula-jan
2024-02-14 19:34:36 +01:00
parent b676877242
commit 7c15d75011
2 changed files with 11 additions and 9 deletions

View File

@ -76,10 +76,11 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
# Crete widget instance and its config # Crete widget instance and its config
widget_config = WidgetConfig( widget_config = WidgetConfig(
parent_figure_id=self.gui_id, widget_class="BECPlotBase", gui_id=widget_id, **kwargs parent_figure_id=self.gui_id, widget_class="BECPlotBase", gui_id=widget_id
) )
widget = BECPlotBase(config=widget_config) widget = BECPlotBase(config=widget_config)
widget.set(**kwargs) # TODO can be done througt config somehow
# Check if position is occupied # Check if position is occupied
if row is not None and col is not None: if row is not None and col is not None:

View File

@ -98,7 +98,7 @@ class BECPlotBase(BECConnector, pg.PlotItem):
Args: Args:
title(str): Title of the plot widget. title(str): Title of the plot widget.
""" """
self.plt.setTitle(title) self.setTitle(title)
self.config.axis.title = title self.config.axis.title = title
@rpc_public @rpc_public
@ -108,7 +108,7 @@ class BECPlotBase(BECConnector, pg.PlotItem):
Args: Args:
label(str): Label of the x-axis. label(str): Label of the x-axis.
""" """
self.plt.setLabel("bottom", label) self.setLabel("bottom", label)
self.config.axis.x_label = label self.config.axis.x_label = label
@rpc_public @rpc_public
@ -118,7 +118,7 @@ class BECPlotBase(BECConnector, pg.PlotItem):
Args: Args:
label(str): Label of the y-axis. label(str): Label of the y-axis.
""" """
self.plt.setLabel("left", label) self.setLabel("left", label)
self.config.axis.y_label = label self.config.axis.y_label = label
@rpc_public @rpc_public
@ -128,7 +128,7 @@ class BECPlotBase(BECConnector, pg.PlotItem):
Args: Args:
scale(Literal["linear", "log"]): Scale of the x-axis. scale(Literal["linear", "log"]): Scale of the x-axis.
""" """
self.plt.setLogMode(x=(scale == "log")) self.setLogMode(x=(scale == "log"))
self.config.axis.x_scale = scale self.config.axis.x_scale = scale
@rpc_public @rpc_public
@ -138,7 +138,7 @@ class BECPlotBase(BECConnector, pg.PlotItem):
Args: Args:
scale(Literal["linear", "log"]): Scale of the y-axis. scale(Literal["linear", "log"]): Scale of the y-axis.
""" """
self.plt.setLogMode(y=(scale == "log")) self.setLogMode(y=(scale == "log"))
self.config.axis.y_scale = scale self.config.axis.y_scale = scale
@rpc_public @rpc_public
@ -148,7 +148,7 @@ class BECPlotBase(BECConnector, pg.PlotItem):
Args: Args:
x_lim(tuple): Limits of the x-axis. x_lim(tuple): Limits of the x-axis.
""" """
self.plt.setXRange(x_lim[0], x_lim[1]) self.setXRange(x_lim[0], x_lim[1])
self.config.axis.x_lim = x_lim self.config.axis.x_lim = x_lim
@rpc_public @rpc_public
@ -158,7 +158,7 @@ class BECPlotBase(BECConnector, pg.PlotItem):
Args: Args:
y_lim(tuple): Limits of the y-axis. y_lim(tuple): Limits of the y-axis.
""" """
self.plt.setYRange(y_lim[0], y_lim[1]) self.setYRange(y_lim[0], y_lim[1])
self.config.axis.y_lim = y_lim self.config.axis.y_lim = y_lim
@rpc_public @rpc_public
@ -169,7 +169,7 @@ class BECPlotBase(BECConnector, pg.PlotItem):
x(bool): Show grid on the x-axis. x(bool): Show grid on the x-axis.
y(bool): Show grid on the y-axis. y(bool): Show grid on the y-axis.
""" """
self.plt.showGrid(x, y) self.showGrid(x, y)
self.config.axis.x_grid = x self.config.axis.x_grid = x
self.config.axis.y_grid = y self.config.axis.y_grid = y
@ -182,4 +182,5 @@ class BECPlotBase(BECConnector, pg.PlotItem):
data_y(list|np.ndarray): y-axis data data_y(list|np.ndarray): y-axis data
label(str): label of the plot label(str): label of the plot
""" """
# TODO very basic so far, add more options
self.plot(data_x, data_y, name=label) self.plot(data_x, data_y, name=label)