         @timer = null
 
 
+###
 count = (0 for [0..19])
 sim = new Simulation
 $("#params4b").on "click", =>
     sim.stop()
 setTimeout (-> sim.start()), 2000
-
-
-new Histo
+###
+
+h = new Histo
+h.update((20-i for i in  [0...20]))

    constructor: (@N=20, @lo=0, @hi=100) ->
        super "histo"
        chartArea = @obj

        @dx = (@hi-@lo)/@N
        @x = (@dx*n for n in [0...@N])
        console.log "???", @x


        @count = (i for i in  [0...@N])
        @data = ({count:i, x:i*@dx} for i in  [0...@N])

        console.log "data", @data
        console.log "count", @count


        @values = d3.range(100).map(d3.random.bates(10))

        @xScale = d3.scale.linear()
            .domain([0, 1])
            .range([0, width])

        #@data = d3.layout.histogram().frequency(false)
        #    .bins(@xScale.ticks(20)) @values

        ##console.log "data", @data

        @yScale = d3.scale.linear()
            .domain([0, 1])
            .range([0, height]);

        chartArea.attr("width", width + margin.left + margin.right)
        chartArea.attr("height", height + margin.top + margin.bottom)
        chartArea.attr("class","chart")
        chartArea.attr("id", "chartArea")

        @plotArea = chartArea.append("g")
            .attr("transform", "translate(#{margin.left},#{margin.top})")

            .attr("width", width)
            .attr("height", height)

        @bar = {domainDir:"y", domainAttr:"height", rangeDir:"x", rangeAttr:"width"}
        #@bar = {domainDir:"x", domainAttr:"width", rangeDir:"y", rangeAttr:"height"}        

        @plotArea.selectAll("rect")
           .data(@data)
           .enter()
           .append("rect")
           .attr(@bar.domainDir, (d) -> d.val )
           .attr(@bar.domainAttr, @del)

    update: (c) ->
        @data[i].count = c[i] for i in [0...@N]
        cmax = d3.max(c)
        @plotArea.selectAll("rect")
            .data(@data)
            .attr(@bar.rangeDir, (d,i) => (1-d.count/cmax)*width)
            .attr(@bar.rangeAttr, (d, i) => d.count/cmax*width)

        
class Canvas
