       ngProgress.complete()
     , 1000
 
+
+  #    #############################################
+  #      Directive Literal
+  #    #############################################
 
   return {
     restrict: 'EA'

      renderLegend(scope, valFn)


  renderLegend = (scope, valFn) ->
    # reset current legend
    scope.legend.selectAll('li.key')

        .attr('height', 10)
        .attr('y', 10)
        .attr('x', (d, index) -> $(this).outerWidth() * index)
        .attr('class', (d) -> classFn(d) )


  filterDataForCategoricalLegend = (mapInstance, valFn) ->
    data = []
    dataUsed = mapInstance.usedDataValues
    for entry, index in valFn.range()
      category = valFn.domain()[index]
      if dataUsed.indexOf(category) != -1
        data.push
          key: entry
          value: category
    data


  # Stop progress bar with a timeout to prevent running conditions
