     
 compute = ->
     b = fn(A, x)
-    tab['b'].setData b
-
-# Auto-compute after changing A and x
-tab['A'].afterChange (-> compute())
-tab['x'].afterChange (-> compute())
+    table['b'].setData b
 
 compute()
 
-
-
-
-
+# table updates
+table['A'].afterChange (-> compute())
+table['x'].afterChange (-> compute())
+table['y'].afterChange (-> figure['y'].load())


class BlabSymbol
    
    constructor: (@spec) ->


    afterChange: (@callback) ->
        @table.addHook 'afterChange', => @callback()

      
## From GUI

# sheets

sh = (id, data) -> new BlabSheet {id:id, data:data}
$blab.sheet =
    A: sh "A", [[1,2],[3,4]]
    x: sh "x", [[5],[6]]
    b: sh "b", [[0],[0]]
    y: sh "y", [[30, 200, 100, 400, 150, 250],[50,  20,  10,  40,  15,  25]]

$blab.sheet['y'].rowHeaders = ['dA','dB']
$blab.sheet['y'].colHeaders = ['i','ii','iii','iv','v','vi']

# tables

tab = (id) -> new BlabHandsontable {sheet:$blab.sheet[id], id:id}
$blab.table =
    A: tab "A"
    x: tab "x"
    b: tab "b"
    y: tab "y"

# figures

$blab.figure = []  
$blab.figure['y'] = new BlabC3 $blab.sheet['y'] 
    
## user coffeescript

# For convenience

sheet = $blab.sheet
table = $blab.table
figure = $blab.figure
for s, d of sheet
    eval(s + " = sheet['" + s + "'].data") # !!! local vars !!!

# User code
fn = (A, x) ->
