 
-class BlabSymbol
+# A BlabSheet is an array of data augmented with row and column names
+# (i.e., how spreadsheets look. Better name?). If row/col names aren't
+# given, defaults are applied. Data can be extracted by various
+# methods: for instance, JSON data with the row headings as keys
+# (rowJson). The data provided by the methods is suitable for
+# digestion by other table/plotting classes.
+
+class BlabSheet
     
     constructor: (@spec) ->
 

    
compute = ->
    b = fn(A, x)
    tab['b'].setData b

# Auto-compute after changing A and x
tab['A'].afterChange (-> compute())
tab['x'].afterChange (-> compute())

compute()






        else
            @rowHeaders = ('r'+k for k in [0...@data.length])

    rowJson: ->
        x = {}
        x[rh] = @data[k] for rh, k in @rowHeaders
        return x

# BlabC3 is a convenience wrapper for c3.js; it takes a BlabSheet as
# its argument. There are various other charting libraries (nvd3 for
# d3.js) and these can be simularly wrapped.

class BlabC3

    constructor: (@sheet) ->

        @chart = c3.generate(
          bindto: '#chart'
          data: json: @sheet.rowJson()
          )

    load: ->
        @chart.load(json: @sheet.rowJson())

# BlabHandsontable = wrapper for handsontable.js

class BlabHandsontable
    
    constructor: (@spec) ->

        @sheet = @spec.sheet
        @data = @sheet.data

        @table = new Handsontable $("#"+@spec.id)[0],
            data: @data
            startRows: @data.length
            startCols: @data[0].length
            rowHeaders: @sheet.rowHeaders
            colHeaders: @sheet.colHeaders 
            contextMenu: true
            columns: ({type: 'numeric'} for k in [1..@data[0].length])

