Sha256: 6ab6758dfa6947d32899e8169698a5627b7f44b42325dae3510d634132a4e2dd
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
@DashboardApp.directive 'populationBrigade', -> link: (scope, el, attr) -> # link code begin margin = top: 5 right: 10 bottom: 5 left: 10 box = height: h = scope.height || 160 width: w = scope.width || 900 inner_height: h - margin.top - margin.bottom inner_width: w - margin.right - margin.left config = numOfPops: scope.numberOfPops || 10 icon = uri: "/images/population_sprite.050.png" width: 50 height: 148 bottom: 10 range = x: d3.scale.linear().range([ box.width, 0]).domain([0, config.numOfPops]) y: d3.scale.linear().range([ box.height, 0 ]) svg = d3.select(el[0]).append('svg') .attr('width', box.width).attr('height', box.height) .append('g') .attr("transform", "translate(" + margin.left + "," + margin.top + ")") popboxes = [] update_brigade = (tick) -> console.log tick new_popbox = (i, name) -> g = svg.append("g") .attr("transform", "translate(#{range.x(i)}, #{0})") g.append("image") .attr("xlink:href", icon.uri) .attr("width", icon.width) .attr("height", icon.height) g.append("text").text(name) .attr("transform", "translate(#{icon.width / 2}, #{icon.height - icon.bottom}) rotate(-90)") g popboxes.push new_popbox(0, "many") popboxes.push new_popbox(1, "moe") popboxes.push new_popbox(2, "jack") scope.$watch 'tickSource', (tick) -> update_brigade tick # link code end restrict: "E" scope: width: '=' height: '=' tickSource: '=' numberOfPops: '='
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubyneat_dashboard-0.4.0.alpha.6 | app/js/dashboard/directives/population_brigade.coffee |