def updateGraph(self): """Graph the pre-loaded data and add any desired features.""" # Step 1: Show only past X hours time_window = int(self.settings['past']) * 60 # Convert to minutes times = self.times[-time_window:] targets = self.targets[-time_window:] predictions = self.predictions[-time_window:] anomalies = self.anomalies[-time_window:] # Step 2: Smoothing if self.settings['smooth_check'] == 'True': smoothing_window = int(self.settings['smooth']) smoothing_window = min(smoothing_window, len(times)) targets = movingAverage(targets, smoothing_window) predictions = movingAverage(predictions, smoothing_window) self.canvas.graphData(times, targets, predictions) # Step 3: Anomalies if self.settings['anomaly_check'] == 'True': self.showAnomalies(times, anomalies) else: self.canvas.clearSpans()