code: def integralByInterval(requestContext, seriesList, intervalUnit):
      
      intervalDuration = int(to_seconds(parseTimeOffset(intervalUnit)))
      startTime = int(epoch(requestContext['startTime']))
      results = []
      for series in seriesList:
          newValues = []
          # current time within series iteration
          currentTime = series.start
          # current accumulated value
          current = 0.0
          for val in series:
              # reset integral value if crossing an interval boundary
              if (
                  ((currentTime - startTime) // intervalDuration) !=
                  ((currentTime - startTime - series.step) // intervalDuration)
              ):
                  current = 0.0
              if val is None:
                  # keep previous value since val can be None when resetting
                  # current to 0.0
                  newValues.append(current)
              else:
                  current += val
                  newValues.append(current)
              currentTime += series.step
          newName = "integralByInterval(%s,'%s')" % (series.name, intervalUnit)
          newSeries = TimeSeries(newName, series.start, series.end, series.step,
                                 newValues)
          newSeries.pathExpression = newName
          results.append(newSeries)
      return results
docs: This will do the same as integral() funcion, except resetting the total
      to 0 at the given time in the parameter "from"
      Useful for finding totals per hour/day/week/..
  
      Example::
  
          &target=integralByInterval(company.sales.perMinute,
                                     "1d")&from=midnight-10days
  
      This would start at zero on the left side of the graph, adding the sales
      each minute, and show the evolution of sales per day during the last 10
      days.