     _.each @typeOrder.get('vehicle_type'), (vtype, idx) =>
       name = vtype.get('name')
 
-      @graph.append('svg:text').
+      graphEl.append('svg:text').
         attr('x', 100 + 50*idx).
         attr('y', 30).
         style('font-size', '14px').
         style('background-color', vehicleTypeColors[idx]).
         text(name)
 
-      @graph.append('svg:rect').
+      graphEl.append('svg:rect').
         attr('id', "legend-#{idx}").
         attr('x', 100 + 50*idx).
         attr('y', 10).

    windowContent = constSpan + table
    @$el.html @vizWindow(elemId: @link.id, content: windowContent)

  renderGraph: (sel) ->
    textSizeImprecisionOffset = 2
    labelFontSize = 10
    width = 450
    height = 400
    padding = 50

    @graph = d3.select(sel).append('svg:svg').
      attr('width', width + padding).
      attr('height', height + padding)

    @graph.append("svg:rect").
      attr("width", width + padding).
      attr("height", height + padding).
      attr("fill", 'white')

    @graph.append("svg:rect").
      attr('id', 'legend').
      attr('x', 5).
      attr('y', 5).
      attr('width', width + padding - 10).
      attr('height', padding - 12).
      attr('fill', 'white').
      attr('stroke', 'lightGray')

    @graph.append('svg:text').
      attr('x', 10).
      attr('y', 30).
      style('font-size', '20px').

            el.attr('enabled', true)
            d3.selectAll(".vehicle-graph-#{idx}").style('visibility','visible')

  renderGraph: (sel) ->
    textSizeImprecisionOffset = 2
    labelFontSize = 10
    width = 450
    height = 400
    padding = 50

    @graph = d3.select(sel).append('svg:svg').
      attr('width', width + padding).
      attr('height', height + padding)

    @graph.append("svg:rect").
      attr("width", width + padding).
      attr("height", height + padding).
      attr("fill", 'white')

    @graph.append("svg:rect").
      attr('id', 'legend').
      attr('x', 5).
      attr('y', 5).
      attr('width', width + padding - 10).
      attr('height', padding - 12).
      attr('fill', 'white').
      attr('stroke', 'lightGray')

    @renderLegend(@graph)

    vals = @demand.demands_by_vehicle_type()

    if vals.length > 0
