      valueLabels: { show: false }
      grid: { show: true }
      xaxis: { mode: 'time' }
+
+  numberOfDayes: ->
+    diff = (@till - @from) / 1000
+    days = diff / (3600 * 24)
+    days
 
   setTime: (element) ->
     time  = $(element).attr('time')

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

  plotGraph: (data) ->
    @data = data
    tKwh  = 0
    nDays = data.length
    tKwh += parseFloat(z[1]) for z in data
    @renderWeekView(data)  if @state == 'week'
    @renderMonthView(data) if @state == 'month'
    @renderYearView(data)  if @state == 'year'
    @botKwhdText = kWhText(tKwh, nDays, @price)

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


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