 
     constructor: (@N=20, @lo=0, @hi=360) ->
         super "histo"
+
         chartArea = @obj
         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)
 
         @del = (@hi-@lo)/@N
         @data = ({count:1, val:i*@del} for i in  [0...@N])
-
-        @plotArea = chartArea.append("g")
-            .attr("transform", "translate(#{margin.left},#{margin.top})")
-            .attr("id", "plotArea")
-            .attr("width", width)
-            .attr("height", height)
 
         @bar = {domainDir:"y", domainAttr:"height", rangeDir:"x", rangeAttr:"width"}
 

            .remove()
        
    initAxes: ->
        @xScale = d3.scale.linear() # sim units -> screen units
            .domain([-1, 1])
            .range([0, width])

        @yScale = d3.scale.linear() # sim units -> screen units
            .domain([-1, 1])
            .range([height, 0])

        @xAxis = d3.svg.axis()
            .scale(@xScale)
            .orient("top")

        @yAxis = d3.svg.axis()
            .scale(@yScale)
            .orient("right")

        @lineFunction = d3.svg.line()
            .x( (d) => @xScale d.x )
            .y( (d) => @yScale d.y )
            .interpolate("linear");

    radialLine: (color) ->
        @plot.append('line')
            .attr("x1", @xScale 0)
            .attr("y1", @yScale 0)
            .style("stroke", color)
            .style("stroke-width","1")
        
    moveMarker: (marker, u, v) ->
        marker.attr("cx", u)
        marker.attr("cy", v)

        
class Histo extends d3Object

    margin = {top: 10, right: 30, bottom: 30, left: 30}

    snapshot: () ->
        Canvas.clear()
        @sun.emit()

    animate: () ->
        @timer = setInterval (=> @snapshot()), 50
