summaryrefslogtreecommitdiff
path: root/templates/project/widgets/graph/graph.coffee
blob: 8b56a873aa53f146308b7fa4b530fce8f5caf081 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class Dashing.Graph extends Dashing.Widget

  @accessor 'current', ->
    points = @get('points')
    if points
      points[points.length - 1].y

  ready: ->
    @graph = new Rickshaw.Graph(
      element: @node
      width: $(@node).parent().width()
      series: [
        {
        color: "#fff",
        data: [{ x: 0, y: 0}]
        }
      ]
    )
    x_axis = new Rickshaw.Graph.Axis.Time(graph: @graph)
    @graph.render()

  onData: (data) ->
    if @graph
      @graph.series[0].data = data.points
      @graph.render()