code: function determineUnitForAutoTicks(minUnit, min, max, capacity) {
  	var ilen = UNITS.length;
  	var i, interval, factor;
  
  	for (i = UNITS.indexOf(minUnit); i < ilen - 1; ++i) {
  		interval = INTERVALS[UNITS[i]];
  		factor = interval.steps ? interval.steps[interval.steps.length - 1] : MAX_INTEGER;
  
  		if (interval.common && Math.ceil((max - min) / (factor * interval.size)) <= capacity) {
  			return UNITS[i];
  		}
  	}
  
  	return UNITS[ilen - 1];
  }
docs: Figures out what unit results in an appropriate number of auto-generated ticks