   help:         () -> new models.HelpTool()
 }
 
+_with_default = (value, default_value) ->
+  if value == undefined then default_value else value
+
 class Figure extends models.Plot
 
   constructor: (attrs={}) ->
     attrs = _.clone(attrs)
 
-    tools = attrs.tools ? _default_tools
+    tools = _with_default(attrs.tools, _default_tools)
     delete attrs.tools
 
     attrs.x_range = @_get_range(attrs.x_range)


      return result

  _fixup_values: (cls, source, attrs) ->
    for name, value of attrs
      [prop, ...] = cls.prototype.props[name]

      if prop.prototype.dataspec
        if value?
          if _.isArray(value)
            source.data[name] = value
            attrs[name] = { field: name }
          else if _.isNumber(value) or _.isString(value) # or Date?
            attrs[name] = { value: value }

  _glyph: (cls, params, args) ->
    params = params.split(",")

      [args..., opts] = args
      attrs = _.clone(opts)
      for param, i in params
        do (param, i) ->
          attrs[param] = args[i]

    has_sglyph = _.any(_.keys(attrs), (key) -> key.startsWith("selection_"))
    has_hglyph = _.any(_.keys(attrs), (key) -> key.startsWith("hover_"))

    glyph_ca   = @_pop_colors_and_alpha(cls, attrs)
    nsglyph_ca = @_pop_colors_and_alpha(cls, attrs, "nonselection_")
    sglyph_ca  = if has_sglyph then @_pop_colors_and_alpha(cls, attrs, "selection_") else {}
    hglyph_ca  = if has_hglyph then @_pop_colors_and_alpha(cls, attrs, "hover_") else {}

    data = {}

    @_fixup_values(cls, data,   glyph_ca)
    @_fixup_values(cls, data, nsglyph_ca)
    @_fixup_values(cls, data,  sglyph_ca)
    @_fixup_values(cls, data,  hglyph_ca)

    @_fixup_values(cls, data, attrs)

    _make_glyph = (cls, attrs, extra_attrs) =>
      new cls(_.extend({}, attrs, extra_attrs))

    glyph   = _make_glyph(cls, attrs,   glyph_ca)
    nsglyph = _make_glyph(cls, attrs, nsglyph_ca)
    sglyph  = if has_sglyph then _make_glyph(cls, attrs,  sglyph_ca) else null
    hglyph  = if has_hglyph then _make_glyph(cls, attrs,  hglyph_ca) else null

    source = attrs.source ? new models.ColumnDataSource()
    source.data = _.extend({}, source.data, data)
    delete attrs.source

    glyph_renderer = new models.GlyphRenderer({
      data_source:        source
