 
   return _.extend continuousBucket, buckets
 
-maxValuesFromBuckets = (buckets, sampleKey) ->
+maxValuesFromBucketsExtended = (buckets, sampleKey) ->
   maxValues = []
   
   lastInsertedValue = 0
+
   _.each buckets, (samples) ->
     values = _.pluck(samples, sampleKey)
 

  title: "Team Score Progression",
  legend: {
    position: "none"
  },
  pointSize: 3
}


  return maxValues

progressionDataToPoints = (data, bucketWindow, dataPoints) ->
      buckets = timestampsToBuckets data, "time", bucketWindow
      steps = maxValuesFromBucketsExtended buckets, "score"

      if steps.length < dataPoints
        return steps

      return _.rest(steps, steps.length - dataPoints)

@drawTeamProgressionGraph = (selector, points) ->
  div = divFromSelector selector
  apiCall "GET", "/api/stats/team/score_progression", {}
  .done (data) ->
    if data.data.length > 0

      graphData = [
        ["Time", "Score", {role: "tooltip"}]
      ]
      
      steps = progressionDataToPoints data.data, 600, 30
      
      (graphData.push(["", score, score]) for score in steps)

      console.log graphData

      packagedData = google.visualization.arrayToDataTable graphData

      chart = new google.visualization.SteppedAreaChart(div)
      chart.draw(packagedData, teamGraphOptions)

