                 ranges: []
             }
 
-            updateDataset(dataset)
-
-        updateDataset = (dataset) =>
-            el = @root.select("g.datasets #dataset-#{dataset.id}")
-            d = @data[dataset.id]
+            @updateDataset(dataset.id)
+
+        @updateDataset = (dataset) =>
+            console.log "Updating dataset #{dataset}"
+
+            el = @root.select("g.datasets #dataset-#{dataset}")
+            d = @data[dataset]
 
             # update data
+            d.ranges = []
+            d.points = []
             for data in d.callback()
                 if(data.length > 1)
-                    @data[dataset.id].ranges.push data
+                    d.ranges.push data
                 else
-                    @data[dataset.id].points.push data[0]
+                    d.points.push data[0]
 
             lineFunction = d3.svg.line()
                 .x( (d) => @scales.x(d) )
-                .y( 5 * index )
+                .y( 5 * d.index )
                 .interpolate('linear')
 
             # ranges
+            el.selectAll('path').remove()
             r = el.selectAll('path')
                 .data(d.ranges)
 

            r.exit().remove()

            # points
            p = el.selectAll('circle')
                .data(d.points)

            p.enter().append('circle')
                    .attr('cx', (d) => @scales.x(d))

        @axis =
            x: d3.svg.axis()
                .scale(@scales.x)
                .tickSubdivide(3)
                .tickSize(@options.height - 13)

        @root.append('g')
            .attr('class', 'axis')
            .call(@axis.x)

        # translate the main x axis
        d3.select(@element).select('g.axis .domain')
            .attr('transform', "translate(0, #{options.height - 14})")

        # datasets
        @root.append('g')
