         else
           'none'
 
-    bars = vis.selectAll('rect.bar')
+    @bars = vis.selectAll('rect.bar')
       .data(data)
     .enter().append('rect')
       .attr('x', (d, i) => @x i)

    @div class: 'editor-stats-wrapper', tabindex: -1, =>
      @div class: 'editor-stats', outlet: 'editorStats'

  initialize: (@rootView) ->
    super

    @subscribe $(window), 'resize', _.debounce((=> @draw()), 300)

  draw: ->
    @editorStats.empty()

      .attr('width', @x.rangeBand())
      .attr('class', 'bar')

    @updateInterval = setInterval((=> @update()), 5000)

  update: ->
    newdata = d3.entries @stats.eventLog
    max  = d3.max newdata, (d) -> d.value
    @y.domain [0, max]
    h = @height()
    @bars.data(newdata).transition()
      .attr('height', (d, i) =>  h - @y(d.value) - @pt - @pb)
      .attr('y', (d, i) => @y(d.value))
    @bars.classed('max', (d, i) -> d.value == max)

  toggle: (@stats) ->
    if @hasParent()
