         ([@spec.rowHeaders[m]].concat row for row, m in @spec.data)
 
     toLocal: ->
-        eval("#{@spec.id} = $blab.sheet['#{@spec.id}'].spec.data")
+        eval("#{@spec.id} = $blab.component.sheet['#{@spec.id}'].spec.data")
 
     fromLocal: (u)->
-        $blab.sheet[@spec.id].spec.data = u
+        $blab.component.sheet[@spec.id].spec.data = u
 
 
 class PlotXY extends Widget
 
     constructor: (@spec) ->
-        @sheets = ($blab.sheet[id] for id in @spec.sheetIds)
+        @sheets = ($blab.component.sheet[id] for id in @spec.sheetIds)
         defaults = {}
         @chart = c3.generate(
             bindto: $("##{@spec.id}")[0]

    update: ->
        @sheet.spec.data[0][0] =  @slider.slider("value")


toolbox =
    sheet: Sheet    
    figure: PlotXY
    table: Table
    markdown: Markdown
   
## From GUI

# sheets

###
$blab.sheet = []
sh = (id, data) ->
    new Sheet {id:id, data:data, compute: true}

$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]]
    z: sh "z", [[50]]
    q: sh "q", [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]]
    u: sh "u"
    x1: sh "x1", [[30, 50, 100, 230, 300, 310]]
    y1: sh "y1", [[30, 200, 100, 400, 150, 250], [130, 300, 200, 300, 250, 450]]

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

$blab.sheet['q'].spec.rowHeaders = ['one','two']
$blab.sheet['q'].spec.colHeaders = ['i','ii','iii','iv','v','vi']
###

###
# slider

slid = (id) -> new Slider
    id:id
    value: 3

$blab.slider =
    z: slid "z"

# tables

tab = (id) -> new Table {id:id, compute:true}
$blab.table =
    A: tab "A"
    x: tab "x"
    b: tab "b"
    y: tab "y"

# figures

fig1 =  -> new PlotXY
    id: "fig1"
    sheetIds: ["q"]
    data:
        x: ""
        types: 
            one: 'area'
            two: 'area-spline'

fig2 =  -> new PlotXY
    id: "fig2"
    sheetIds: ["x1", "q"]
    data:
        x: "r0"
        types: 
            one: 'spline'
            two: 'line'

$blab.figure =
    fig1: fig1()
    fig2: fig2()

# markdown

md = """

## markdown

*emphasis*

**bold**

~~strike~~

[marked + mathjax](http://kerzol.github.io/markdown-mathjax/editor.html)

```javascript
var s = "JavaScript syntax highlighting";
alert(s);
```

| Tables        | Are           | Cool  |
| ------------- |:-------------:| -----:|
| col 3 is      | right-aligned | $1600 |
| col 2 is      | centered      |   $12 |
| zebra stripes | are neat      |    $1 |


"""

markdn = -> new Markdown
    id: "content"
    md: md 

$blab.markdown =
    md1: markdn()

###

# user code



    constructor: (@spec) ->

        @sheet = $blab.component.sheet[@spec.id]

        @container = $("##{@spec.id}")
        @container.append("<div class='slider'></div>")
