% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/middleware.R
\name{.directlabel_points}
\alias{.directlabel_points}
\title{Choose direct-label anchor points for grouped point data}
\usage{
.directlabel_points(data, x, y, group, placement, adj_fact, facet_vars)
}
\arguments{
\item{data}{A data frame containing the variables to be plotted and labelled.}

\item{x, y}{Unquoted column names giving the x- and y-variables.}

\item{group}{Unquoted column name giving the grouping variable from which to
construct labels.}

\item{placement}{Character string giving the preferred label placement
relative to each group's cloud of points. One of "top", "right", "bottom",
or "left".}

\item{adj_fact}{A single numeric value giving the proportional adjustment
applied to the group-specific target location. For point data, this changes
the target used to choose the labelled point, but does not move the final
label anchor away from the selected observed point.}

\item{facet_vars}{Optional character vector of facet variable names. When
supplied, label anchor points are calculated separately within each
group-by-facet combination.}
}
\value{
A tibble with one row per group or group-by-facet combination. The
returned data include standardized x and y columns, .label_plus, and
any grouping or faceting variables needed by ggplot2 to assign labels to
panels correctly.
}
\description{
directlabel_points() is an internal helper used by
\code{\link[=direct_labels_plus]{direct_labels_plus()}} when geometry = "point". It chooses one observed
point per group, or per group-by-facet combination, to use as the anchor
location for a direct label. How the label is then drawn with respect to that
chosen point is determined by \code{\link[ggrepel:geom_text_repel]{ggrepel::geom_label_repel()}}.
}
\details{
The helper works by calculating a target location for each group and then
selecting the observed point closest to that target. For "top" and
"bottom" placements, the target is centered at the group's median x-value
and then shifted toward the group's maximum or minimum y-value. For "left"
and "right" placements, the same logic is applied with x and y reversed.

This helper assumes that label locations should be tied to observed points.
It therefore never invents a new x/y coordinate for point labels. Empty or
all-missing groups should be screened before this helper is called.
}
\keyword{internal}
