 class LabelView extends Renderer.View
   initialize: (options) ->
     super(options)
+
+    @set_visuals(@mget('source'))
     @set_data(@mget('source'))
-    @label_div = (null for i in @text)
 
   bind_bokeh_events: () ->
     if @mget('render_mode') == 'css'

    else
      @listenTo(@model, 'data_update', @plot_view.request_render)

  render: () ->
    @map_data() ##unclear why calling this in init returns NaNs

    if @mget('render_mode') == 'canvas'


  _canvas_text: () ->
    ctx = @plot_view.canvas_view.ctx
    for i in [0...@text.length]
      ctx.save()
      ctx.translate(@sx[i], @sy[i])
      ctx.rotate(@mget('angle'))

      @visuals.text.set_vectorize(ctx, i)
      ctx.fillText(@text[i], 0, 0)
      ctx.restore()

  _css_text: () ->
    ctx = @plot_view.canvas_view.ctx

    for i in [0...@text.length]

      if @label_div[i].html() == ""
        @label_div[i].appendTo(@plot_view.$el.find('div.bk-canvas-events'))

      debugger;
      @label_div[i]
        .html(@text[i])
        .css({
          'position': 'absolute'
          'top': "#{@sy[i] + @mget('y_offset') + @y_shift[i]}px"
          'left': "#{@sx[i] + @mget('x_offset') + @x_shift[i]}px"
          # 'background-color': 'rgba(255, 255, 255, 0)'
          'font-size': "#{@text_font_size[i]}"
          'font-family': "#{@mget('text_font')}"
          })
        .show()

class Label extends Annotation.Model
  default_view: LabelView
