<a id="Eunoia.place_labels"></a>

<a id="Eunoia.place_labels-Tuple{Eunoia.AbstractEulerFit, AbstractDict}"></a>

# Eunoia.place\_labels

Julia · 1.0.1

[Source](<https://github.com/jolars/Eunoia.jl/blob/db1275ffc768591b8c9271c56d8dfa2f3351bfcd/src/Eunoia.jl>)

```julia
place_labels(
    fit::AbstractEulerFit,
    sizes::AbstractDict;
    placement::Union{Nothing, AbstractString} = nothing,
    leader::Union{Nothing, AbstractString} = nothing,
    margin::Union{Nothing, Real} = nothing,
    iterations::Union{Nothing, Integer} = nothing,
    precision::Union{Nothing, Real} = nothing,
    tether::Union{Nothing, AbstractString} = nothing,
    leader_gap::Union{Nothing, Real} = nothing,
    min_gap::Union{Nothing, Real} = nothing
)
```

<a id="methods"></a>

## Methods

<a id="method-bf1f028cf24f5cea0a7e3103c066b159cd800d99dc581f9db47cfd621887a5e3"></a>

### `place_labels(
    fit::AbstractEulerFit,
    sizes::AbstractDict;
    placement::Union{Nothing, AbstractString} = nothing,
    leader::Union{Nothing, AbstractString} = nothing,
    margin::Union{Nothing, Real} = nothing,
    iterations::Union{Nothing, Integer} = nothing,
    precision::Union{Nothing, Real} = nothing,
    tether::Union{Nothing, AbstractString} = nothing,
    leader_gap::Union{Nothing, Real} = nothing,
    min_gap::Union{Nothing, Real} = nothing
)`

[Source](<https://github.com/jolars/Eunoia.jl/blob/db1275ffc768591b8c9271c56d8dfa2f3351bfcd/src/Eunoia.jl>)

```julia
place_labels(fit, sizes; placement=nothing, leader=nothing, margin=nothing,
             iterations=nothing, precision=nothing, tether=nothing,
             leader_gap=nothing, min_gap=nothing)
```

Resolve collision-aware label positions for the regions of a fitted [`EulerFit`](<4ed69989ba26556a9f6f1924004c8ef9d3a879be2533c31ba480a63a0d640b42>)/[`VennFit`](<aaeedc476b437f51a25680a2e40c9055c9ecd3ca856c0fe73f756ff578293692>), given the rendered label box sizes. 

The core can't place labels without their on-screen sizes (font metrics it never sees at fit time), so this is a separate call from [`euler`](<724ed6727eeae60915c72bfade1aba4de6ed59849fa7c8c0907cf91088d062d1>): measure each label, then ask for placements. `sizes` is a mapping from region/combination strings (`"A"`, `"A&B"`, …) to a `(width, height)` tuple in the same coordinate units as the fitted `shapes`. Only regions present in both `sizes` and the fit's geometry get a placement; degenerate inputs are silently skipped. 

Each placement tries to sit inside its region; one that can't fit is pushed outside with a leader line. Returns a `Dict{String,LabelPlacement}` (see [`LabelPlacement`](<b4506487ededf0a7c82aba939d73026bffbc453a51b1db85ce982e56778f36fc>)). 

Strategy knobs (all optional; `nothing` keeps the core default). Invalid string tokens are rejected by the native core and surface as an error: 

- `leader`: leader edge type, `"straight"` (default) or `"elbow"` (d3-pie style orthogonal leaders with column-based placement).
- `placement`: exterior solver for straight leaders, `"raycast"` (default), `"force_directed"` (spring/repulsion relaxation for crowded diagrams), or `"matched"` (noncrossing boundary labels); ignored for `"elbow"`.
- `margin`: gap between the diagram and exterior labels (both edge types); the per-region proportional default applies when omitted.
- `iterations`: iteration cap for `"force_directed"` (default `200`); ignored otherwise.
- `precision`: pole-of-inaccessibility search precision (default `0.01`).
- `tether`: where an exterior leader attaches to its region, `"poi"` (default, the pole of inaccessibility) or `"boundary"` (the region's outer ring).
- `leader_gap`: visible gap between the leader tip and the label box (default `0.0`).
- `min_gap`: minimum vertical spacing between stacked `"elbow"` labels; ignored otherwise.

```julia
fit = euler(Dict("A" => 5, "B" => 3, "A&B" => 1.5))
placements = place_labels(fit, Dict("A" => (0.6, 0.3), "B" => (0.6, 0.3));
                          placement="force_directed")
```
