           downsample: "1m-avg"
         })
         Backbone.multi_fetch [ new_met ], (err, results) ->
+          metric.set({query: new_met.get("query")})
           g.updateOptions({ file: new_met.tuples() })
 
   }

    else
      Dygraph.startZoom(event, g, context)

  opts.interactionModel.mouseup = (event, g, context) ->
    if context.isZooming
      Dygraph.endZoom(event, g, context)
    else if context.isPanning
      Dygraph.endPan(event, g, context)

      # check if we need more data
      [minX, maxX] = g.xAxisRange()
      start_diff = g.xAxisExtremes()[0] - minX
      end_diff = maxX - g.xAxisExtremes()[1]

      if start_diff > 100000 || end_diff > 100000
        # sufficiently panned, fetch more data
        new_met = new Bixby.model.Metric({
          id: metric.id
          host_id: metric.get("metadata").host_id
          start: parseInt(minX / 1000)
          end: parseInt(maxX / 1000)
          downsample: "1m-avg"
        })
        Backbone.multi_fetch [ new_met ], (err, results) ->
          # don't replace data... add on to existing data
          g.updateOptions({ file: new_met.tuples() })


  # draw

    # set range if known
    opts.valueRange = [ 0, 100 ]

  opts.interactionModel = _.clone(Dygraph.Interaction.defaultModel)

  # override mousedown to allow toggling pan mode
  opts.interactionModel.mousedown = (event, g, context) ->
    # Right-click should not initiate a zoom.
    if event.button && event.button == 2
      return

