 
   shift: (direction) ->
     timeWindow = @till - @from
-    shiftsize  = timeWindow * 0.2
+    shiftsize  = timeWindow
     if direction == 'right'
        @from += shiftsize
        @till += shiftsize

      @till -= shiftsize
    @fetchData()

  calculateAverage = (data) ->
    if data.length > 0
      pAverage  = 0
      nPoints   = data.length
      pAverage += parseFloat(z[1]) for z in data

      timeB = Number(data[0][0])/1000.0
      timeA = Number(data[data.length-1][0])/1000.0

      timeWindow = (timeB - timeA)
      timeWidth  = timeWindow / nPoints
      kwhWindow  = (timeWidth * pAverage) / 3600000

      pAverage = (pAverage / nPoints)
      ($ '#stat').html((pAverage).toFixed(1)+' W | '+(kwhWindow).toFixed(1)+' kWh')
    else
      ($ '#stat').html('No data')


    super
    @pAverage  = 0
    @kwhWindow = 0
    @price     = 0.24
    @botKwhdText = ''
    $('#loading').hide()
    @fetchData()

  plotGraph: (data) ->
    @calculateAverage(data); #assign @kwhWindow
    @renderWeekView(data)  if @state == 'week'
    @renderMonthView(data) if @state == 'month'
    @renderYearView(data)  if @state == 'year'
    @botKwhdText = kWhText(@kwhWindow, @numberOfDayes(), @price)
    $("#bot_out").html(@botKwhdText)

  kWhText= (tKwh, nDays, price) ->
    text  = 'Total: ' + (tKwh).toFixed(0)
