function filterOverlappingLabels(
  { orientation, targetNodes, labels, container },
  findLeft = binaryLeftSearch
) {
  const renderLabels = [];
  const coord = orientation === 'v' ? 'x' : 'y';
  const side = orientation === 'v' ? 'width' : 'height';
  const getTextBounds = (item) => item.textBounds;
  const getNodeBounds = (item) => item.node.localBounds;

  return (doNotUse, labelIndex) => {
    const { textBounds: labelBounds, node: labelNode } = labels[labelIndex];

    // ### Test if label is not fully inside container based on the orientation ###
    if (
      labelBounds[coord] < container[coord] ||
      labelBounds[coord] + labelBounds[side] > container[coord] + container[side]
    ) {
      return false;
    }

    // ### Test label to label collision ###
    const leftStartLabel = findLeft(labelBounds, renderLabels, coord, side, getTextBounds);
    for (let i = leftStartLabel; i < renderLabels.length; i++) {
      if (testRectRect(labelBounds, renderLabels[i].textBounds)) {
        return false;
      }
    }

    // ### Test label to node collision ###
    const leftStartNode = findLeft(labelBounds, targetNodes, coord, side, getNodeBounds);
    const labelRightBoundary = labelBounds[coord] + labelBounds[side];
    for (let i = leftStartNode; i < targetNodes.length; i++) {
      const node = targetNodes[i].node;
      // Do not test beyond this node, as they are assumed to not collide with the label
      if (labelRightBoundary < node.localBounds[coord]) {
        break;
      }

      if (testRectRect(labelBounds, node.localBounds) && labelNode !== node) {
        return false;
      }
    }

    // No collision occured, allow the label to be rendered
    renderLabels.push(labels[labelIndex]);
    return true;
  };
}
/**
 * The purpose of this module is to act as a filtering function to remove any labels
 * that meets one of the following criterias:
 * -- The label is not fully inside the container, such that it would be fully or partially clipped if rendered
 * -- The label overlaps another label
 * -- The label overlaps another bar which is not the bar the label is originating from
 *
 * Assumes that the nodes are sorted from left/top to right/down, as that allows
 * some optimizations to be performed.
 * @private
 * @returns {function} Filter function, returns false if label be removed and true otherwise
 */
The purpose of this module is to act as a filtering function to remove any labels
that meets one of the following criterias:
The label is not fully inside the container, such that it would be fully or partially clipped if rendered
The label overlaps another label
The label overlaps another bar which is not the bar the label is originating from

Assumes that the nodes are sorted from left/top to right/down, as that allows
some optimizations to be performed.
@private
@returns {function} Filter function, returns false if label be removed and true otherwise
The purpose of this module is to act as a filtering function to remove any labels that meets one of the following criterias : The label is not fully inside the container such that it would be fully or partially clipped if rendered The label overlaps another label The label overlaps another bar which is not the bar the label is originating from Assumes that the nodes are sorted from left / top to right / down as that allows some optimizations to be performed . @private @returns { function } Filter function returns false if label be removed and true otherwise
function filterOverlappingLabels(
  { orientation, targetNodes, labels, container },
  findLeft = binaryLeftSearch
) {
  const renderLabels = [];
  const coord = orientation === 'v' ? 'x' : 'y';
  const side = orientation === 'v' ? 'width' : 'height';
  const getTextBounds = (item) => item.textBounds;
  const getNodeBounds = (item) => item.node.localBounds;
  return (doNotUse, labelIndex) => {
    const { textBounds: labelBounds, node: labelNode } = labels[labelIndex];
    if (
      labelBounds[coord] < container[coord] ||
      labelBounds[coord] + labelBounds[side] > container[coord] + container[side]
    ) {
      return false;
    }
    const leftStartLabel = findLeft(labelBounds, renderLabels, coord, side, getTextBounds);
    for (let i = leftStartLabel; i < renderLabels.length; i++) {
      if (testRectRect(labelBounds, renderLabels[i].textBounds)) {
        return false;
      }
    }
    const leftStartNode = findLeft(labelBounds, targetNodes, coord, side, getNodeBounds);
    const labelRightBoundary = labelBounds[coord] + labelBounds[side];
    for (let i = leftStartNode; i < targetNodes.length; i++) {
      const node = targetNodes[i].node;
      if (labelRightBoundary < node.localBounds[coord]) {
        break;
      }
      if (testRectRect(labelBounds, node.localBounds) && labelNode !== node) {
        return false;
      }
    }
    renderLabels.push(labels[labelIndex]);
    return true;
  };
}
function filterOverlappingLabels ( { orientation , targetNodes , labels , container } , findLeft = binaryLeftSearch ) { const renderLabels = [ ] ; const coord = orientation === 'v' ? 'x' : 'y' ; const side = orientation === 'v' ? 'width' : 'height' ; const getTextBounds = ( item ) => item . textBounds ; const getNodeBounds = ( item ) => item . node . localBounds ; return ( doNotUse , labelIndex ) => { const { textBounds : labelBounds , node : labelNode } = labels [ labelIndex ] ; if ( labelBounds [ coord ] < container [ coord ] || labelBounds [ coord ] + labelBounds [ side ] > container [ coord ] + container [ side ] ) { return false ; } const leftStartLabel = findLeft ( labelBounds , renderLabels , coord , side , getTextBounds ) ; for ( let i = leftStartLabel ; i < renderLabels . length ; i ++ ) { if ( testRectRect ( labelBounds , renderLabels [ i ] . textBounds ) ) { return false ; } } const leftStartNode = findLeft ( labelBounds , targetNodes , coord , side , getNodeBounds ) ; const labelRightBoundary = labelBounds [ coord ] + labelBounds [ side ] ; for ( let i = leftStartNode ; i < targetNodes . length ; i ++ ) { const node = targetNodes [ i ] . node ; if ( labelRightBoundary < node . localBounds [ coord ] ) { break ; } if ( testRectRect ( labelBounds , node . localBounds ) && labelNode !== node ) { return false ; } } renderLabels . push ( labels [ labelIndex ] ) ; return true ; } ; }
The purpose of this module is to act as a filtering function to remove any labels
 that meets one of the following criterias:
 -- The label is not fully inside the container, such that it would be fully or partially clipped if rendered
 -- The label overlaps another label
 -- The label overlaps another bar which is not the bar the label is originating from
The purpose of this module is to act as a filtering function to remove any labels that meets one of the following criterias : -- The label is not fully inside the container such that it would be fully or partially clipped if rendered -- The label overlaps another label -- The label overlaps another bar which is not the bar the label is originating from
// ### Test if label is not fully inside container based on the orientation ### // ### Test label to label collision ### // ### Test label to node collision ### // Do not test beyond this node, as they are assumed to not collide with the label // No collision occured, allow the label to be rendered