function handleTouch(){
// Observe the "mousedown" (click + hold) event on all of our category color-bars
  $(document).on('mousedown', '.stat', function(evt){
    var self = this;
    // var globaloffset = $(this).position().left;
    
    // var globaloffset = 192.21875;
    var posArray = [];
    $('.statsblock').each(function(){
    	var blockoffset = $(this).children('[data-index="'+$(self).attr('data-index')+'"]').position().left;
    	posArray.push(blockoffset);
    });
    var globaloffset = _.min(posArray);
    $('.statsblock').each(function(){
      $(this).css({'height': '100%'});
      var blockoffset = $(this).children('[data-index="'+$(self).attr('data-index')+'"]').position().left;
      console.log(blockoffset);
      $(this).animate({'left': globaloffset-blockoffset}, 200);
      $(this).parents('.bar').children('span').children('strong').text(commafy($(this).children('[data-index="'+$(self).attr('data-index')+'"]').attr('data-value')));
    }); //each

// Fade out all bars not of the category you clicked
    $('.stat:not("[data-index='+$(self).attr('data-index')+']")').css({'opacity':0.2});
    $('.stat[data-index='+$(self).attr('data-index')+']').addClass('active');
    $('.bar').css({'background-color':'transparent'});

////// OPTIONAL: Sort bars based on order
    var barHeight = $('.bar').height() + 11;
    var sorted = _.sortBy($('.stat[data-index="'+$(self).attr('data-index')+'"]'), function(obj,iter){
      return $(obj).width();
    }); //sorted
    _.map(sorted, function(obj,iter){
      var startHeight = barHeight * (iter) - $(obj).parents('.bar').position().top + 20;
      $(obj).parents('.bar').css({'top':startHeight}).attr('which', iter);
    })

// Reset the position of everything wehn you release your mouse
    $(document).on('mouseup', function(){
      $('.statsblock').animate({'left':'0px', 'height': $('.cat_full_height_on').is('.active') ? '100%' : '3px'}, 200);
      $('.stat').css({'opacity':'1'}).removeClass('active');
      $('.bar').css({'top':'0px', 'background-color': 'rgba(0,0,0,0.1)'});
      $('.bar').each(function(){
        $(this).children('span').children('strong').text("");
        // $(this).children('span').children('strong').text(commafy($(this).attr('data-value')));
      })
      $(document).off('mouseup');
    }); //documnet on mouseup
    return false;
  }) //click

}
/*=======================================================
STEP 3: HANDLE ADVANCED INTERACTION
=======================================================*/
STEP 3: HANDLE ADVANCED INTERACTION
STEP 3 : HANDLE ADVANCED INTERACTION
function handleTouch(){
  $(document).on('mousedown', '.stat', function(evt){
    var self = this;
    var posArray = [];
    $('.statsblock').each(function(){
    	var blockoffset = $(this).children('[data-index="'+$(self).attr('data-index')+'"]').position().left;
    	posArray.push(blockoffset);
    });
    var globaloffset = _.min(posArray);
    $('.statsblock').each(function(){
      $(this).css({'height': '100%'});
      var blockoffset = $(this).children('[data-index="'+$(self).attr('data-index')+'"]').position().left;
      console.log(blockoffset);
      $(this).animate({'left': globaloffset-blockoffset}, 200);
      $(this).parents('.bar').children('span').children('strong').text(commafy($(this).children('[data-index="'+$(self).attr('data-index')+'"]').attr('data-value')));
    }); 
    $('.stat:not("[data-index='+$(self).attr('data-index')+']")').css({'opacity':0.2});
    $('.stat[data-index='+$(self).attr('data-index')+']').addClass('active');
    $('.bar').css({'background-color':'transparent'});
    var barHeight = $('.bar').height() + 11;
    var sorted = _.sortBy($('.stat[data-index="'+$(self).attr('data-index')+'"]'), function(obj,iter){
      return $(obj).width();
    }); 
    _.map(sorted, function(obj,iter){
      var startHeight = barHeight * (iter) - $(obj).parents('.bar').position().top + 20;
      $(obj).parents('.bar').css({'top':startHeight}).attr('which', iter);
    })
    $(document).on('mouseup', function(){
      $('.statsblock').animate({'left':'0px', 'height': $('.cat_full_height_on').is('.active') ? '100%' : '3px'}, 200);
      $('.stat').css({'opacity':'1'}).removeClass('active');
      $('.bar').css({'top':'0px', 'background-color': 'rgba(0,0,0,0.1)'});
      $('.bar').each(function(){
        $(this).children('span').children('strong').text("");
      })
      $(document).off('mouseup');
    }); 
    return false;
  }) 
}
function handleTouch ( ) { $ ( document ) . on ( 'mousedown' , '.stat' , function ( evt ) { var self = this ; var posArray = [ ] ; $ ( '.statsblock' ) . each ( function ( ) { var blockoffset = $ ( this ) . children ( '[data-index="' + $ ( self ) . attr ( 'data-index' ) + '"]' ) . position ( ) . left ; posArray . push ( blockoffset ) ; } ) ; var globaloffset = _ . min ( posArray ) ; $ ( '.statsblock' ) . each ( function ( ) { $ ( this ) . css ( { 'height' : '100%' } ) ; var blockoffset = $ ( this ) . children ( '[data-index="' + $ ( self ) . attr ( 'data-index' ) + '"]' ) . position ( ) . left ; console . log ( blockoffset ) ; $ ( this ) . animate ( { 'left' : globaloffset - blockoffset } , 200 ) ; $ ( this ) . parents ( '.bar' ) . children ( 'span' ) . children ( 'strong' ) . text ( commafy ( $ ( this ) . children ( '[data-index="' + $ ( self ) . attr ( 'data-index' ) + '"]' ) . attr ( 'data-value' ) ) ) ; } ) ; $ ( '.stat:not("[data-index=' + $ ( self ) . attr ( 'data-index' ) + ']")' ) . css ( { 'opacity' : 0.2 } ) ; $ ( '.stat[data-index=' + $ ( self ) . attr ( 'data-index' ) + ']' ) . addClass ( 'active' ) ; $ ( '.bar' ) . css ( { 'background-color' : 'transparent' } ) ; var barHeight = $ ( '.bar' ) . height ( ) + 11 ; var sorted = _ . sortBy ( $ ( '.stat[data-index="' + $ ( self ) . attr ( 'data-index' ) + '"]' ) , function ( obj , iter ) { return $ ( obj ) . width ( ) ; } ) ; _ . map ( sorted , function ( obj , iter ) { var startHeight = barHeight * ( iter ) - $ ( obj ) . parents ( '.bar' ) . position ( ) . top + 20 ; $ ( obj ) . parents ( '.bar' ) . css ( { 'top' : startHeight } ) . attr ( 'which' , iter ) ; } ) $ ( document ) . on ( 'mouseup' , function ( ) { $ ( '.statsblock' ) . animate ( { 'left' : '0px' , 'height' : $ ( '.cat_full_height_on' ) . is ( '.active' ) ? '100%' : '3px' } , 200 ) ; $ ( '.stat' ) . css ( { 'opacity' : '1' } ) . removeClass ( 'active' ) ; $ ( '.bar' ) . css ( { 'top' : '0px' , 'background-color' : 'rgba(0,0,0,0.1)' } ) ; $ ( '.bar' ) . each ( function ( ) { $ ( this ) . children ( 'span' ) . children ( 'strong' ) . text ( "" ) ; } ) $ ( document ) . off ( 'mouseup' ) ; } ) ; return false ; } ) }
STEP 3: HANDLE ADVANCED INTERACTION
STEP 3 : HANDLE ADVANCED INTERACTION
// Observe the "mousedown" (click + hold) event on all of our category color-bars // var globaloffset = $(this).position().left; // var globaloffset = 192.21875; //each // Fade out all bars not of the category you clicked ////// OPTIONAL: Sort bars based on order //sorted // Reset the position of everything wehn you release your mouse // $(this).children('span').children('strong').text(commafy($(this).attr('data-value'))); //documnet on mouseup //click