function offset(type, position, _ref3, labelPaddingSize, external) {
  var margin = _ref3.margin,
      border = _ref3.border,
      padding = _ref3.padding;

  var shift = function shift(dir) {
    return 0;
  };

  var offsetX = 0;
  var offsetY = 0; // If external labels then push them to the edge of the band
  // else keep them centred

  var locationMultiplier = external ? 1 : 0.5; // Account for padding within the label

  var labelPaddingShift = external ? labelPaddingSize * 2 : 0;

  if (type === 'padding') {
    shift = function shift(dir) {
      return padding[dir] * locationMultiplier + labelPaddingShift;
    };
  } else if (type === 'border') {
    shift = function shift(dir) {
      return padding[dir] + border[dir] * locationMultiplier + labelPaddingShift;
    };
  } else if (type === 'margin') {
    shift = function shift(dir) {
      return padding[dir] + border[dir] + margin[dir] * locationMultiplier + labelPaddingShift;
    };
  }

  if (position === 'top') {
    offsetY = -shift('top');
  } else if (position === 'right') {
    offsetX = shift('right');
  } else if (position === 'bottom') {
    offsetY = shift('bottom');
  } else if (position === 'left') {
    offsetX = -shift('left');
  }

  return {
    offsetX: offsetX,
    offsetY: offsetY
  };
}
Offset the label based on how many layers appear before it
For example:
margin labels will shift further outwards if there are
padding labels