Example #1
0
    def setAxes(self):
        # [Are axes changing?, new min, new max]
        setXAxes = [False, None, None]
        setYAxes = [False, None, None]

        # dealing with the current time and the time that we have to
        #   go back for x-axis limits
        currTime = time.time()
        # measured in seconds
        timeBack = 0
        # x-axis maximum is current time
        setXAxes[2] = date_helpers.dateObj(currTime)

        # get and save input from all fields
        min_input = self.minutes.text()
        hour_input = self.hours.text()
        day_input = self.days.text()
        Ymin_input = self.Ymin.text()
        Ymax_input = self.Ymax.text()
        axes_input = [('min', min_input), ('hour', hour_input),
                      ('day', day_input), ('Ymin', Ymin_input),
                      ('Ymax', Ymax_input)]
        for axis_tuple in axes_input:
            try:
                value = float(axis_tuple[1])
                if axis_tuple[0] == 'Ymin':
                    setYAxes[0] = True
                    setYAxes[1] = value
                elif axis_tuple[0] == 'Ymax':
                    setYAxes[0] = True
                    setYAxes[2] = value
                elif axis_tuple[0] == 'min':
                    setXAxes[0] = True
                    timeBack += value*60
                elif axis_tuple[0] == 'hour':
                    setXAxes[0] = True
                    timeBack += value*60*60
                elif axis_tuple[0] == 'day':
                    setXAxes[0] = True
                    timeBack += value*60*60*24
            # if no input was given to field, ignore it
            except ValueError:
                pass

        # set x-axis minimum to current time minus specified time window
        setXAxes[1] = date_helpers.dateObj(currTime - timeBack)

        # if y-axis limits have been changed
        if setYAxes[0]:
            self.graph.setYlim(amin=setYAxes[1], amax=setYAxes[2])
        # if x-axis limits have been changed
        if setXAxes[0]:
            self.graph.auto = False
            self.graph.timeWindow = timeBack
            self.graph.setXlim(amin=setXAxes[1], amax=setXAxes[2])

        if self.graph.hasRightAxis:
            self.setRAxis()
 def timeFrame(self):
     if not self.auto:
         currTime = time.time()
         rightLim = date_helpers.dateObj(currTime)
         leftLim = date_helpers.dateObj(currTime - self.timeWindow)
         self.setXlim(amin=leftLim, amax=rightLim)
Example #3
0
 def timeFrame(self):
     if not self.auto:
         currTime = time.time()
         rightLim = date_helpers.dateObj(currTime)
         leftLim = date_helpers.dateObj(currTime - self.timeWindow)
         self.setXlim(amin=leftLim, amax=rightLim)