         name: alert.label
         color: alert.color
         renderer: "line"
-        data: @createSeriesData(alert.name)
+        data: seriesData[alert.name]
         type: "alert"
 
     for topKey in @topKeys
       series.push
         name: @keyLegendName(topKey)
         color: palette.color()
-        data: @createSeriesData(topKey)
+        data: seriesData[topKey]
         type: "topkey"
         key: topKey
         renderer: "line"

        key: subKey
        name: @keyLegendName(subKey)
        color: palette.color()
        data: @createSeriesData(subKey)
        type: "subkey"
        renderer: "stack"


    tplArr.push("</table>")
    tplArr.join("")

  prepareSeriesData: (keys) ->
    ans = {}
    for key in keys
      ans[key] = []

    @store.each (record) =>
      total = record.get(@topKeys[0])
      for key in keys
        value = record.get(key)
        percent = 100 * value / total
        ans[key].push
          x: record.get("timestamp")
          y: value
          percent: percent
    ans

  createSeries: ->
    palette = new Rickshaw.Color.Palette
      scheme: new Muleview.view.Theme().colors

    keys = Ext.Array.pluck(@alerts || [], "name")
    keys = keys.concat(@topKeys || [])
    keys = keys.concat(@subKeys || [])
    seriesData = @prepareSeriesData(keys)

    series = []

