 
   fetchData : (start, end) ->
 
-    @minMaxHours = {}
     @fetchPromise = @model.fetch(
       data:
         start: start
         end: end
-    )
+    ).done( => @updateMinMaxHours() )
 
 
   getMinMaxHours : ->
 
-    # This function calculates the min/max working hours of the whole data set
+    # This function calculates the min/max working hours of the users of the selected team
     if _.isEmpty(@minMaxHours)
-      minTime = Math.min(_.pluck(@model.get("userInfos"), "workingTime")...)
-      maxTime = Math.max(_.pluck(@model.get("userInfos"), "workingTime")...)
+      selectedUsers = _.filter(@model.get("userInfos"), (userInfo) => @doDrawUser(userInfo.user))
+      workingTimes = _.pluck(selectedUsers, "workingTime")
+
+      if _.isEmpty(workingTimes) then workingTimes = [0]
+      minTime = Math.min(workingTimes...)
+      maxTime = Math.max(workingTimes...)
 
       # Convert ms to h
       @minMaxHours =



    if @doDrawProjects()
      svgProjectEdges = userInfos.map( (userInfo) =>
        { user, projects } = userInfo
        projects.map( (project) => @edge(user.name, project.name)) if @doDrawUser(user)
      ).join(";")

    return @minMaxHours


  updateMinMaxHours : ->

    @minMaxHours = {}
    @getMinMaxHours()


  updateSelectedTeam : ->

    @team = @ui.team.find("select")[0].value
    @updateMinMaxHours()
    @renderRangeSlider()


  onRender : ->
