         .attr('class', 'crosshair-value')
 
     svg.style 'background-color', params.bgcolor
+
+clearExtent = (v) -> _.extend {}, v, {extent: null}
+setBrushing = (v) -> _.extend {}, v, {brushing: true}
+setNotBrushing = (v) -> _.extend {}, v, {brushing: false}
+
+expandIsolatedValuesToLineSegments = (values) ->
+  result = []
+  segment_length = 0
+  previous = null
+  _.each values, (v, i) ->
+    if v.value?
+      segment_length++
+      previous = v
+    else
+      if segment_length is 1
+        result.push previous
+      segment_length = 0
+
+    result.push v
+
+  if segment_length is 1
+    result.push previous
+  result

    externalBrushChanges.onValue ({extent}) ->
      if extent?
        domain = x.domain()
        []
        brush.extent [Math.min(Math.max(domain[0], extent[0]), domain[1]), Math.max(Math.min(domain[1], extent[1]), domain[0])]
      else
        brush.clear()

          d.y0 = y0
          d.value = y)

    if params.drawNullAsZero
      transform_value = (v) -> v ? 0
      filter_scatter_values = _.identity
      expand_line_values = _.identity
    else
      # TODO this won't work well with stack
      transform_value = (v) -> v
      filter_scatter_values = (values) ->
        _.filter values, (d) -> d.value?
      expand_line_values = expandIsolatedValuesToLineSegments

    time_min = null
    time_max = null
    value_min = null
    value_max = null
    targets = for s, targetIndex in data
      values = for datapoint, i in s.datapoints
        value = get_value datapoint, i
        timestamp = get_timestamp datapoint, i
