Commit 31c9b0a3 authored by Valentin Valls's avatar Valentin Valls
Browse files

Normalize time curve with curve plot

parent 5caf3c50
...@@ -1985,13 +1985,13 @@ class RegPlot: ...@@ -1985,13 +1985,13 @@ class RegPlot:
self.fig.submit("setGraphGrid", which=True) self.fig.submit("setGraphGrid", which=True)
# Define the plot content # Define the plot content
self.fig.select_time_curve("setpoint", color="blue", linestyle="-", z=2) self.fig.add_time_curve_item("setpoint", color="blue", linestyle="-", z=2)
self.fig.select_time_curve("input", color="red", linestyle="-", z=2) self.fig.add_time_curve_item("input", color="red", linestyle="-", z=2)
self.fig.select_time_curve( self.fig.add_time_curve_item(
"output", color="green", linestyle="-", yaxis="right", z=2 "output", color="green", linestyle="-", yaxis="right", z=2
) )
self.fig.select_time_curve("deadband_high", color="blue", linestyle="--", z=2) self.fig.add_time_curve_item("deadband_high", color="blue", linestyle="--", z=2)
self.fig.select_time_curve("deadband_low", color="blue", linestyle="--", z=2) self.fig.add_time_curve_item("deadband_low", color="blue", linestyle="--", z=2)
def is_plot_active(self): def is_plot_active(self):
if self.fig is None: if self.fig is None:
......
...@@ -517,7 +517,7 @@ class TimeCurvePlot(BasePlot): ...@@ -517,7 +517,7 @@ class TimeCurvePlot(BasePlot):
""" """
self.submit("setXDuration", second) self.submit("setXDuration", second)
def select_time_curve(self, yname, **kwargs): def add_time_curve_item(self, yname, **kwargs):
""" """
Select a dedicated data to be displayed against the time. Select a dedicated data to be displayed against the time.
...@@ -525,7 +525,7 @@ class TimeCurvePlot(BasePlot): ...@@ -525,7 +525,7 @@ class TimeCurvePlot(BasePlot):
name: Name of the data to use as y-axis name: Name of the data to use as y-axis
kwargs: Associated style (see `addCurve` from silx plot) kwargs: Associated style (see `addCurve` from silx plot)
""" """
self.submit("selectCurve", yname, **kwargs) self.submit("addTimeCurveItem", yname, **kwargs)
def set_data(self, **kwargs): def set_data(self, **kwargs):
""" """
......
...@@ -211,7 +211,7 @@ class TimeCurvePlot(qt.QWidget): ...@@ -211,7 +211,7 @@ class TimeCurvePlot(qt.QWidget):
data = newData data = newData
self.__data[name] = data self.__data[name] = data
def selectCurve(self, yName, **kwargs): def addTimeCurveItem(self, yName, **kwargs):
"""Update the plot description""" """Update the plot description"""
self.__description[yName] = kwargs self.__description[yName] = kwargs
self.__safeUpdatePlot() self.__safeUpdatePlot()
......
...@@ -260,9 +260,9 @@ p = f.get_plot(plot_class="timecurveplot", name="My plot") ...@@ -260,9 +260,9 @@ p = f.get_plot(plot_class="timecurveplot", name="My plot")
# Setup the plot to display a dedicated data name # Setup the plot to display a dedicated data name
# The data will be provided later # The data will be provided later
# the `time` data name is used as x-axis # the `time` data name is used as x-axis
p.select_time_curve("diode1") p.add_time_curve_item("diode1")
# The curve style can be specified # The curve style can be specified
p.select_time_curve("diode2", color="red") p.add_time_curve_item("diode2", color="red")
# The data can be set # The data can be set
# The time have to be provided in epoch second UTC (see python API `time.time()`) # The time have to be provided in epoch second UTC (see python API `time.time()`)
......
...@@ -508,8 +508,8 @@ def test_time_curve_plot(flint_session): ...@@ -508,8 +508,8 @@ def test_time_curve_plot(flint_session):
p = f.get_plot(plot_class="timecurveplot", name="timecurveplot") p = f.get_plot(plot_class="timecurveplot", name="timecurveplot")
p.select_time_curve("diode1") p.add_time_curve_item("diode1")
p.select_time_curve("diode2") p.add_time_curve_item("diode2")
# set_data update the curves # set_data update the curves
p.set_data(time=[0, 1, 2], diode1=[0, 1, 1], diode2=[1, 5, 1]) p.set_data(time=[0, 1, 2], diode1=[0, 1, 1], diode2=[1, 5, 1])
......
...@@ -27,8 +27,8 @@ def test_time_curve_plot__set_data(time_curve_plot_widget): ...@@ -27,8 +27,8 @@ def test_time_curve_plot__set_data(time_curve_plot_widget):
We expect curves to be displayed We expect curves to be displayed
""" """
w = time_curve_plot_widget w = time_curve_plot_widget
w.selectCurve("value1") w.addTimeCurveItem("value1")
w.selectCurve("value2") w.addTimeCurveItem("value2")
w.setData( w.setData(
time=[0, 1, 2, 3, 4, 5], value1=[0, 1, 2, 3, 4, 5], value2=[0, 1, 2, 3, 4, 5] time=[0, 1, 2, 3, 4, 5], value1=[0, 1, 2, 3, 4, 5], value2=[0, 1, 2, 3, 4, 5]
) )
...@@ -42,8 +42,8 @@ def test_time_curve_plot__clear(time_curve_plot_widget): ...@@ -42,8 +42,8 @@ def test_time_curve_plot__clear(time_curve_plot_widget):
We expect no curves to be displayed We expect no curves to be displayed
""" """
w = time_curve_plot_widget w = time_curve_plot_widget
w.selectCurve("value1") w.addTimeCurveItem("value1")
w.selectCurve("value2") w.addTimeCurveItem("value2")
w.setData( w.setData(
time=[0, 1, 2, 3, 4, 5], value1=[0, 1, 2, 3, 4, 5], value2=[0, 1, 2, 3, 4, 5] time=[0, 1, 2, 3, 4, 5], value1=[0, 1, 2, 3, 4, 5], value2=[0, 1, 2, 3, 4, 5]
) )
...@@ -58,8 +58,8 @@ def test_time_curve_plot__append_data(time_curve_plot_widget): ...@@ -58,8 +58,8 @@ def test_time_curve_plot__append_data(time_curve_plot_widget):
We expect the plot to contains curves witch grow up. We expect the plot to contains curves witch grow up.
""" """
w = time_curve_plot_widget w = time_curve_plot_widget
w.selectCurve("value1") w.addTimeCurveItem("value1")
w.selectCurve("value2") w.addTimeCurveItem("value2")
w.appendData(time=[0, 1, 2], value1=[0, 1, 2], value2=[0, 1, 2]) w.appendData(time=[0, 1, 2], value1=[0, 1, 2], value2=[0, 1, 2])
plot = w.getPlotWidget() plot = w.getPlotWidget()
curve = plot.getAllCurves()[0] curve = plot.getAllCurves()[0]
...@@ -77,8 +77,8 @@ def test_time_curve_plot__drop_data(time_curve_plot_widget): ...@@ -77,8 +77,8 @@ def test_time_curve_plot__drop_data(time_curve_plot_widget):
""" """
w = time_curve_plot_widget w = time_curve_plot_widget
w.setXDuration(5) w.setXDuration(5)
w.selectCurve("value1") w.addTimeCurveItem("value1")
w.selectCurve("value2") w.addTimeCurveItem("value2")
w.appendData(time=[0, 1, 2], value1=[0, 1, 2], value2=[0, 1, 2]) w.appendData(time=[0, 1, 2], value1=[0, 1, 2], value2=[0, 1, 2])
w.appendData(time=[3, 4, 5], value1=[0, 1, 2], value2=[0, 1, 2]) w.appendData(time=[3, 4, 5], value1=[0, 1, 2], value2=[0, 1, 2])
w.appendData(time=[6, 7, 8], value1=[0, 1, 2], value2=[0, 1, 2]) w.appendData(time=[6, 7, 8], value1=[0, 1, 2], value2=[0, 1, 2])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment