Commit e077d9d6 authored by Valentin Valls's avatar Valentin Valls
Browse files

Added appendData

parent b7d428d8
......@@ -666,6 +666,15 @@ class TimeCurvePlot(BasePlot):
"""
self.submit("setData", **kwargs)
def append_data(self, **kwargs):
"""
Append the data displayed in this plot.
Arguments:
kwargs: Name of the data associated to the numpy array to append
"""
self.submit("appendData", **kwargs)
class ImageView(BasePlot):
......
......@@ -12,6 +12,7 @@ import numpy
from silx.gui import qt
from silx.gui.plot import Plot1D
from silx.gui.plot.items import axis as axis_mdl
_logger = logging.getLogger(__name__)
......@@ -34,6 +35,8 @@ class TimeCurvePlot(qt.QWidget):
layout = qt.QVBoxLayout(self)
layout.addWidget(self.__plot)
self.__maxPoints = 100
self.__plot.setGraphXLabel("Time")
xAxis = self.__plot.getXAxis()
xAxis.setTickMode(axis_mdl.TickMode.TIME_SERIES)
......@@ -73,6 +76,8 @@ class TimeCurvePlot(qt.QWidget):
data = numpy.concatenate((data, newData))
else:
data = newData
if len(data) > self.__maxPoints:
data = data[-self.__maxPoints :]
self.__data[name] = data
def selectCurve(self, yName, **kwargs):
......@@ -89,6 +94,12 @@ class TimeCurvePlot(qt.QWidget):
self.__data = dict(kwargs)
self.__safeUpdatePlot()
def appendData(self, **kwargs):
"""Update the current data with extra data"""
for name, data in kwargs.items():
self.__appendData(name, data)
self.__safeUpdatePlot()
def __safeUpdatePlot(self):
try:
self.__updatePlot()
......@@ -96,12 +107,10 @@ class TimeCurvePlot(qt.QWidget):
_logger.critical("Error while updating the plot", exc_info=True)
def __updatePlot(self):
self.__plot.clear()
xData = self.__data.get(self.__xAxisName)
if xData is None:
return
for name, style in self.__description.items():
yData = self.__data.get(name)
if yData is None:
......
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