Sha256: 5fa4ddf667c60da094a5e39c5bd0d1b01c6a31524359f0decbb087e621c1fda3

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

# This is a test for D3, which we may actually use later.
# The pie is really a doughnut chart. Pie is shorter to type. Haha.
@DashboardApp.directive 'pie', ->
  link = (scope, el, attr) ->
    console.log('Pie data=' + scope.data +
      ' width=' + scope.width +
      ' height=' + scope.height)
    color = d3.scale.category10()
    data = scope.data
    width = scope.width || 300
    height = scope.height || 300
    min = Math.min(width, height)
    svg = d3.select(el[0]).append('svg')
    pie = d3.layout.pie().sort(null)
    arc = d3.svg.arc()
    .outerRadius(min / 2 * 0.9)
    .innerRadius(min / 2 * 0.5)
    svg.attr(
      width: width
      height: height
    )
    g = svg.append('g').attr('transform', "translate(#{width/2}, #{height/2})")
    arcs = g.selectAll('path').data(pie(data))
      .enter().append('path')
      .style('stroke', 'white')
      .attr('fill',
        (d,i) ->
          color(i)
        )
    scope.$watch('data',
    ->
      arcs.data(pie(data)).attr('d', arc)
    , true)
  link: link
  restrict: 'E'
  scope:
    data:   '='
    width:  '='
    height: '='

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubyneat_dashboard-0.4.1 app/js/dashboard/directives/pie.coffee
rubyneat_dashboard-0.4.0.alpha.6 app/js/dashboard/directives/pie.coffee
rubyneat_dashboard-0.4.0.alpha.4.pre.1 app/js/dashboard/directives/pie.coffee
rubyneat_dashboard-0.4.0.alpha.4 app/js/dashboard/directives/pie.coffee