                #{ Highcharts.dateFormat('%A, %b %e, %Y', @x) }
              </span>"
         points = _.sortBy(@points, (point) -> point.y)
-        for point, index in points.reverse()
-          strIndex = zfill(index + 1, 2)
+        for point, index in points[-numberOfPositions..]
+          strIndex = zfill(numberOfPositions - index, 2)
           if point.y > 0
             s += "<br/>#{ strIndex }
                   <span style=\"color: #{ point.series.color };\"> ● </span>"

    for item, count of topitems
      items[item][timestamp] = count

  chart = prepareChart()
  # Limit timeframe to last half.
  if timeframe != 'overall'
    timestamps = timestamps[-timestamps.length // 2 .. -1]

  for item, weeks of items
    series =
      name: item

  return s


prepareChart = (numberOfPositions) ->
  $chart = $('#chart')
  $chart.highcharts 'StockChart',
    chart:
