function createLegend(comparable) {
  var colorRange = d3.scale.category10().domain(d3.range(1).reverse());
  $('.bar-chart').after('<div class="legend"></div>');
  var categories = _.pluck(comparable[0].stats, 'name');
  $.each(categories, function(key,value){
    var span = $('<span>'+value+'</span>');
    span.css({'border-color': d3.rgb(colorRange(key)).brighter(1)});
    span.css({'background-color': d3.rgb(colorRange(key)).darker(1)});
    $('.legend').append(span);
  })
}
/*=======================================================
STEP 1B: SPEND-BY-CATEGORY LEVEL OF DATA
=======================================================*/
STEP 1B: SPEND-BY-CATEGORY LEVEL OF DATA
STEP 1B : SPEND - BY - CATEGORY LEVEL OF DATA
function createLegend(comparable) {
  var colorRange = d3.scale.category10().domain(d3.range(1).reverse());
  $('.bar-chart').after('<div class="legend"></div>');
  var categories = _.pluck(comparable[0].stats, 'name');
  $.each(categories, function(key,value){
    var span = $('<span>'+value+'</span>');
    span.css({'border-color': d3.rgb(colorRange(key)).brighter(1)});
    span.css({'background-color': d3.rgb(colorRange(key)).darker(1)});
    $('.legend').append(span);
  })
}
function createLegend ( comparable ) { var colorRange = d3 . scale . category10 ( ) . domain ( d3 . range ( 1 ) . reverse ( ) ) ; $ ( '.bar-chart' ) . after ( '<div class="legend"></div>' ) ; var categories = _ . pluck ( comparable [ 0 ] . stats , 'name' ) ; $ . each ( categories , function ( key , value ) { var span = $ ( '<span>' + value + '</span>' ) ; span . css ( { 'border-color' : d3 . rgb ( colorRange ( key ) ) . brighter ( 1 ) } ) ; span . css ( { 'background-color' : d3 . rgb ( colorRange ( key ) ) . darker ( 1 ) } ) ; $ ( '.legend' ) . append ( span ) ; } ) }
STEP 1B: SPEND-BY-CATEGORY LEVEL OF DATA
STEP 1B : SPEND - BY - CATEGORY LEVEL OF DATA