             
             # Adjust the range based on the current band index.
             y0 = (j - m + 1) * height
-            yscale.range [m * height + y0, y0]
-            y0 = yscale(0)
+            ys.range [m * height + y0, y0]
+            y0 = ys(0)
             i = i0
             n = width
             y1 = undefined

      if showLegend then do ->
        n = if showNegativeLegend then 2*m else m

        unless update
          parent.select("div.legend")
            .append("svg")
              .attr("width", 100)
              .attr("height", n * 15 + 15)
            .append("g")
              .attr("class", "content")
              .attr("transform", "translate(0, 10)")

        legend = parent.select("div.legend").select("g.content")


          selected = []
          parent.selectAll("input")
            .each (d) -> 
              that = d3.select(this)
              if that.property("checked")
                selected.push d.key
                that.property("checked", false)

          if selected.length > 0
            fire "applyFilter", selected


      filterBtns.append("button")
        .attr("class", "btn btn-mini")
        .html("&times;")
        .on "click", -> 
          parent.selectAll("input").property("checked", false)
          fire "applyFilter", null



    extents = (d.values.extent for d in data)
    extent = [ d3.min(extents, (d) -> d[0]), d3.max(extents, (d) -> d[1]) ]
    max = Math.max(-extent[0], extent[1])
    yscale.domain [0, max]


    unless update
      timeExtents = (d.values.timeExtent for d in data)
      timeExtent = [ d3.min(timeExtents, (d) -> d[0]), d3.max(timeExtents, (d) -> d[1]) ]
      tscale.domain(timeExtent)

      numSteps = Math.max(1, interval.range.apply(this, timeExtent).length)
      stepWidth = Math.ceil(width / numSteps)


    unless update
