summaryrefslogtreecommitdiff
path: root/templates/project/widgets/graph/graph.coffee
blob: 3a149db85aca5c9c650bfbaf1a4a78001b00f0f6 (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
26
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) ->
    super
    if @graph
      @graph.series[0].data = data.points
      @graph.render()